Class QuadTree
- 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
close(Iterator<Data> iter)
Closes this QuadTree after use...IndexFile
getIndexfile()
int
getMaxDepth()
int
getNumShapes()
Node
getRoot()
void
insert(int recno, Envelope bounds)
Inserts a shape record id in the quadtreevoid
insert(Node node, int recno, Envelope recBounds, int maxDepth)
Inserts a shape record id in the quadtreevoid
registerIterator(Iterator<Data> object)
CloseableIterator<Data>
search(Envelope bounds)
void
setMaxDepth(int maxDepth)
void
setNumShapes(int numShapes)
void
setRoot(Node root)
boolean
trim()
-
-
-
Constructor Detail
-
QuadTree
public QuadTree(int numShapes, Envelope maxBounds, IndexFile file)
Constructor. The maxDepth will be calculated.- Parameters:
numShapes
- The total number of shapes to indexmaxBounds
- 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 indexmaxDepth
- The max depth of the index, must be <= 65535maxBounds
- 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 indexmaxDepth
- The max depth of the index, must be <= 65535
-
-
Method Detail
-
insert
public void insert(int recno, Envelope bounds) throws StoreException
Inserts a shape record id in the quadtree- Parameters:
recno
- The record numberbounds
- 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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
StoreException
-
getIndexfile
public IndexFile getIndexfile()
-
-