public class STRtree extends AbstractSTRtreeimplements SpatialIndex , Serializable
The STR packed R-tree is simple to implement and maximizes space utilization; that is, as many leaves as possible are filled to capacity. Overlap between nodes is far less than in a basic R-tree. However, once the tree has been built (explicitly or on the first call to #query), items may not be added or removed.
Described in: P. Rigaux, Michel Scholl and Agnes Voisard. Spatial Databases With Application To GIS. Morgan Kaufmann, San Francisco, 2002.
AbstractSTRtree.IntersectsOp root| Constructor and Description |
|---|
STRtree()
Constructs an STRtree with the default node capacity.
|
STRtree(int nodeCapacity)
Constructs an STRtree with the given maximum number of child nodes that a node may have.
|
| Modifier and Type | Method and Description |
|---|---|
protected AbstractNode |
createNode(int level)
|
protected List |
createParentBoundables(List
Creates the parent level for the given child level.
|
protected List |
createParentBoundablesFromVerticalSlice(List
|
int |
depth()
Returns the number of items in the tree.
|
protected Comparator |
getComparator()
|
protected AbstractSTRtree |
getIntersectsOp()
|
void |
insert(Envelope
Inserts an item having the given bounds into the tree.
|
Object |
nearestNeighbour(Envelope
Finds the item in this tree which is nearest to the given
Object, using
ItemDistance as the distance metric.
|
Object |
nearestNeighbour(ItemDistance
Finds the two nearest items in the tree, using
ItemDistance as the distance metric.
|
Object |
nearestNeighbour(STRtree
Finds the two nearest items from this tree and another tree, using
ItemDistance as the distance metric.
|
List |
query(Envelope
Returns items whose bounds intersect the given envelope.
|
void |
query(Envelope
Returns items whose bounds intersect the given envelope.
|
boolean |
remove(Envelope
Removes a single item from the tree.
|
int |
size()
Returns the number of items in the tree.
|
protected List |
verticalSlices(List
|
boundablesAtLevel, build, compareDoubles, depth, getNodeCapacity, getRoot, insert, isEmpty, itemsTree, lastNode, query, query, remove, sizepublic STRtree()
public STRtree(int nodeCapacity)
The minimum recommended capacity setting is 4.
protected ListcreateParentBoundables(List childBoundables, int newLevel)
protected ListcreateParentBoundablesFromVerticalSlice(List childBoundables, int newLevel)
protected List[] verticalSlices(List childBoundables, int sliceCount)
childBoundables - Must be sorted by the x-value of the envelope midpoints
protected AbstractNodecreateNode(int level)
protected AbstractSTRtree.IntersectsOp getIntersectsOp()
getIntersectsOp in class
AbstractSTRtree
AbstractSTRtree.IntersectsOp
public void insert(EnvelopeitemEnv, Object item)
public Listquery(Envelope searchEnv)
query in interface
SpatialIndex
searchEnv - the envelope to query for
public void query(EnvelopesearchEnv, ItemVisitor visitor)
query in interface
SpatialIndex
searchEnv - the envelope to query for
visitor - a visitor object to apply to the items found
public boolean remove(EnvelopeitemEnv, Object item)
remove in interface
SpatialIndex
itemEnv - the Envelope of the item to remove
item - the item to remove
true if the item was found
public int size()
size in class
AbstractSTRtree
public int depth()
depth in class
AbstractSTRtree
protected ComparatorgetComparator()
public Object[] nearestNeighbour(ItemDistance itemDist)
ItemDistance as the distance metric. A Branch-and-Bound tree traversal algorithm is used to provide an efficient search.
itemDist - a distance metric applicable to the items in this tree
public ObjectnearestNeighbour(Envelope env, Object item, ItemDistance itemDist)
Object, using
ItemDistance as the distance metric. A Branch-and-Bound tree traversal algorithm is used to provide an efficient search.
The query object does not have to be contained in the tree, but it does have to be compatible with the itemDist distance metric.
env - the envelope of the query item
item - the item to find the nearest neighbour of
itemDist - a distance metric applicable to the items in this tree and the query item
public Object[] nearestNeighbour(STRtree tree, ItemDistance itemDist)
ItemDistance as the distance metric. A Branch-and-Bound tree traversal algorithm is used to provide an efficient search. The result value is a pair of items, the first from this tree and the second from the argument tree.
tree - another tree
itemDist - a distance metric applicable to the items in the trees