org.geotools.index.quadtree
Class QuadTree

Object
  extended by QuadTree

public class QuadTree
extends Object

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
Module:
modules/plugin/shapefile (gt-shapefile.jar)

Constructor Summary
QuadTree(int numShapes, Envelope maxBounds, IndexFile file)
          Constructor.
QuadTree(int numShapes, int maxDepth, Envelope maxBounds, IndexFile file)
          Constructor.
QuadTree(int numShapes, int maxDepth, IndexFile file)
          Constructor.
 
Method Summary
 void close()
           
 void close(Iterator 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 quadtree
 void registerIterator(Iterator object)
           
 CloseableCollection<Data> search(Envelope bounds)
           
 void setMaxDepth(int maxDepth)
           
 void setNumShapes(int numShapes)
           
 void setRoot(Node root)
           
 boolean trim()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 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 Detail

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

search

public CloseableCollection<Data> search(Envelope bounds)
                                 throws StoreException
Parameters:
bounds -
Returns:
A List of Integer
Throws:
StoreException

close

public void close(Iterator iter)
           throws StoreException
Closes this QuadTree after use...

Throws:
StoreException

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
Throws:
StoreException

registerIterator

public void registerIterator(Iterator object)

getIndexfile

public IndexFile getIndexfile()


Copyright © 1996-2010 Geotools. All Rights Reserved.