Object
QuadTree
All Implemented Interfaces:
Closeable, AutoCloseable

public class QuadTree extends Object implements Closeable
Java porting of mapserver quadtree implementation.

Note that this implementation is not thread safe, so don't share the same instance across two or more threads.

TODO: example of typical use...

Author:
Tommaso Nolli
  • Constructor Details

    • QuadTree

      public QuadTree(int numShapes, Envelope maxBounds, IndexFile file)
      Constructor. The maxDepth will be calculated.
      Parameters:
      numShapes - The total number of shapes to index
      maxBounds - The bounds of all geometries to be indexed
    • QuadTree

      public QuadTree(int numShapes, int maxDepth, Envelope maxBounds, IndexFile file)
      Constructor.
      Parameters:
      numShapes - The total number of shapes to index
      maxDepth - The max depth of the index, must be <= 65535
      maxBounds - The bounds of all geometries to be indexed
    • QuadTree

      public QuadTree(int numShapes, int maxDepth, IndexFile file)
      Constructor. WARNING: using this constructor, you have to manually set the root
      Parameters:
      numShapes - The total number of shapes to index
      maxDepth - The max depth of the index, must be <= 65535
  • Method Details

    • insert

      public void insert(int recno, Envelope bounds) throws StoreException
      Inserts a shape record id in the quadtree
      Parameters:
      recno - The record number
      bounds - The bounding box
      Throws:
      StoreException
    • insert

      public void insert(Node node, int recno, Envelope recBounds, int maxDepth) throws StoreException
      Inserts a shape record id in the quadtree
      Throws:
      StoreException
    • search

      public CloseableIterator<Data> search(Envelope bounds) throws StoreException
      Returns:
      A List of Integer
      Throws:
      StoreException
    • close

      public void close(Iterator<Data> iter) throws IOException
      Closes this QuadTree after use...
      Throws:
      IOException
    • trim

      public boolean trim() throws StoreException
      Throws:
      StoreException
    • getMaxDepth

      public int getMaxDepth()
      Returns:
      Returns the maxDepth.
    • setMaxDepth

      public void setMaxDepth(int maxDepth)
      Parameters:
      maxDepth - The maxDepth to set.
    • getNumShapes

      public int getNumShapes()
      Returns:
      Returns the numShapes.
    • setNumShapes

      public void setNumShapes(int numShapes)
      Parameters:
      numShapes - The numShapes to set.
    • getRoot

      public Node getRoot()
      Returns:
      Returns the root.
    • setRoot

      public void setRoot(Node root)
      Parameters:
      root - The root to set.
    • close

      public void close() throws StoreException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      StoreException
    • registerIterator

      public void registerIterator(Iterator<Data> object)
    • getIndexfile

      public IndexFile getIndexfile()