public class HPRtree extends Object implements SpatialIndex
The tree is constructed by sorting the items by the Hilbert code of the midpoint of their envelope. Then, a set of internal layers is created recursively as follows:
nodeCapacity
NOTE: Based on performance testing, the HPRtree is somewhat faster than the STRtree. It should also be more memory-efficent, due to fewer object allocations. However, it is not clear whether this will produce a significant improvement for use in JTS operations.
STRtree
Constructor and Description |
---|
HPRtree()
Creates a new index with the default node capacity.
|
HPRtree(int nodeCapacity)
Creates a new index with the given node capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
build()
Builds the index, if not already built.
|
Envelope[] |
getBounds()
Gets the extents of the internal index nodes
|
void |
insert(Envelope itemEnv,
Object item)
Adds a spatial item with an extent specified by the given
Envelope to the index |
List |
query(Envelope searchEnv)
Queries the index for all items whose extents intersect the given search
Envelope
Note that some kinds of indexes may also return objects which do not in fact
intersect the query envelope. |
void |
query(Envelope searchEnv,
ItemVisitor visitor)
Queries the index for all items whose extents intersect the given search
Envelope ,
and applies an ItemVisitor to them. |
boolean |
remove(Envelope itemEnv,
Object item)
Removes a single item from the tree.
|
int |
size()
Gets the number of items in the index.
|
public HPRtree()
public HPRtree(int nodeCapacity)
nodeCapacity
- the node capacity to usepublic int size()
public void insert(Envelope itemEnv, Object item)
SpatialIndex
Envelope
to the indexinsert
in interface SpatialIndex
public List query(Envelope searchEnv)
SpatialIndex
Envelope
Note that some kinds of indexes may also return objects which do not in fact
intersect the query envelope.query
in interface SpatialIndex
searchEnv
- the envelope to query forpublic void query(Envelope searchEnv, ItemVisitor visitor)
SpatialIndex
Envelope
,
and applies an ItemVisitor
to them.
Note that some kinds of indexes may also return objects which do not in fact
intersect the query envelope.query
in interface SpatialIndex
searchEnv
- the envelope to query forvisitor
- a visitor object to apply to the items foundpublic boolean remove(Envelope itemEnv, Object item)
SpatialIndex
remove
in interface SpatialIndex
itemEnv
- the Envelope of the item to removeitem
- the item to removetrue
if the item was foundpublic void build()
public Envelope[] getBounds()
Copyright © 2020. All rights reserved.