Class STRtreeJGT
- java.lang.Object
-
- org.locationtech.jts.index.strtree.AbstractSTRtree
-
- org.hortonmachine.gears.io.las.index.strtree.STRtreeJGT
-
- All Implemented Interfaces:
Serializable,org.locationtech.jts.index.SpatialIndex
public class STRtreeJGT extends org.locationtech.jts.index.strtree.AbstractSTRtree implements org.locationtech.jts.index.SpatialIndex, Serializable
A query-only R-tree created using the Sort-Tile-Recursive (STR) algorithm. For two-dimensional spatial data.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.
- Version:
- 1.7
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description STRtreeJGT()Constructs an STRtree with the default node capacity.STRtreeJGT(int nodeCapacity)Constructs an STRtree with the given maximum number of child nodes that a node may have.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.locationtech.jts.index.strtree.AbstractNodecreateNode(int level)protected ListcreateParentBoundables(List childBoundables, int newLevel)Creates the parent level for the given child level.protected ListcreateParentBoundablesFromVerticalSlice(List childBoundables, int newLevel)intdepth()Returns the number of items in the tree.protected ComparatorgetComparator()protected org.locationtech.jts.index.strtree.AbstractSTRtree.IntersectsOpgetIntersectsOp()voidinsert(org.locationtech.jts.geom.Envelope itemEnv, Object item)Inserts an item having the given bounds into the tree.Object[]nearestNeighbour(STRtreeJGT tree, org.locationtech.jts.index.strtree.ItemDistance itemDist)Finds the two nearest items from this tree and another tree, usingItemDistanceas the distance metric.ObjectnearestNeighbour(org.locationtech.jts.geom.Envelope env, Object item, org.locationtech.jts.index.strtree.ItemDistance itemDist)Finds the item in this tree which is nearest to the givenObject, usingItemDistanceas the distance metric.Object[]nearestNeighbour(org.locationtech.jts.index.strtree.ItemDistance itemDist)Finds the two nearest items in the tree, usingItemDistanceas the distance metric.Listquery(org.locationtech.jts.geom.Envelope searchEnv)Returns items whose bounds intersect the given envelope.voidquery(org.locationtech.jts.geom.Envelope searchEnv, org.locationtech.jts.index.ItemVisitor visitor)Returns items whose bounds intersect the given envelope.ListqueryBoundables(Object searchBounds)Queries the tree and returnsItemBoundables instead of only the values.booleanremove(org.locationtech.jts.geom.Envelope itemEnv, Object item)Removes a single item from the tree.intsize()Returns the number of items in the tree.protected List[]verticalSlices(List childBoundables, int sliceCount)
-
-
-
Method Detail
-
createParentBoundables
protected List createParentBoundables(List childBoundables, int newLevel)
Creates the parent level for the given child level. First, orders the items by the x-values of the midpoints, and groups them into vertical slices. For each slice, orders the items by the y-values of the midpoints, and group them into runs of size M (the node capacity). For each run, creates a new (parent) node.- Overrides:
createParentBoundablesin classorg.locationtech.jts.index.strtree.AbstractSTRtree
-
createParentBoundablesFromVerticalSlice
protected List createParentBoundablesFromVerticalSlice(List childBoundables, int newLevel)
-
verticalSlices
protected List[] verticalSlices(List childBoundables, int sliceCount)
- Parameters:
childBoundables- Must be sorted by the x-value of the envelope midpoints
-
createNode
protected org.locationtech.jts.index.strtree.AbstractNode createNode(int level)
- Specified by:
createNodein classorg.locationtech.jts.index.strtree.AbstractSTRtree
-
getIntersectsOp
protected org.locationtech.jts.index.strtree.AbstractSTRtree.IntersectsOp getIntersectsOp()
- Specified by:
getIntersectsOpin classorg.locationtech.jts.index.strtree.AbstractSTRtree
-
insert
public void insert(org.locationtech.jts.geom.Envelope itemEnv, Object item)Inserts an item having the given bounds into the tree.- Specified by:
insertin interfaceorg.locationtech.jts.index.SpatialIndex
-
query
public List query(org.locationtech.jts.geom.Envelope searchEnv)
Returns items whose bounds intersect the given envelope.- Specified by:
queryin interfaceorg.locationtech.jts.index.SpatialIndex
-
query
public void query(org.locationtech.jts.geom.Envelope searchEnv, org.locationtech.jts.index.ItemVisitor visitor)Returns items whose bounds intersect the given envelope.- Specified by:
queryin interfaceorg.locationtech.jts.index.SpatialIndex
-
remove
public boolean remove(org.locationtech.jts.geom.Envelope itemEnv, Object item)Removes a single item from the tree.- Specified by:
removein interfaceorg.locationtech.jts.index.SpatialIndex- Parameters:
itemEnv- the Envelope of the item to removeitem- the item to remove- Returns:
trueif the item was found
-
queryBoundables
public List queryBoundables(Object searchBounds)
Queries the tree and returnsItemBoundables instead of only the values.Also builds the tree, if necessary.
- Parameters:
searchBounds- the bounds to search for.- Returns:
- the list of
ItemBoundables.
-
size
public int size()
Returns the number of items in the tree.- Overrides:
sizein classorg.locationtech.jts.index.strtree.AbstractSTRtree- Returns:
- the number of items in the tree
-
depth
public int depth()
Returns the number of items in the tree.- Overrides:
depthin classorg.locationtech.jts.index.strtree.AbstractSTRtree- Returns:
- the number of items in the tree
-
getComparator
protected Comparator getComparator()
- Specified by:
getComparatorin classorg.locationtech.jts.index.strtree.AbstractSTRtree
-
nearestNeighbour
public Object[] nearestNeighbour(org.locationtech.jts.index.strtree.ItemDistance itemDist)
Finds the two nearest items in the tree, usingItemDistanceas the distance metric. A Branch-and-Bound tree traversal algorithm is used to provide an efficient search.- Parameters:
itemDist- a distance metric applicable to the items in this tree- Returns:
- the pair of the nearest items
-
nearestNeighbour
public Object nearestNeighbour(org.locationtech.jts.geom.Envelope env, Object item, org.locationtech.jts.index.strtree.ItemDistance itemDist)
Finds the item in this tree which is nearest to the givenObject, usingItemDistanceas 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.
- Parameters:
env- the envelope of the query itemitem- the item to find the nearest neighbour ofitemDist- a distance metric applicable to the items in this tree and the query item- Returns:
- the nearest item in this tree
-
nearestNeighbour
public Object[] nearestNeighbour(STRtreeJGT tree, org.locationtech.jts.index.strtree.ItemDistance itemDist)
Finds the two nearest items from this tree and another tree, usingItemDistanceas 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.- Parameters:
tree- another treeitemDist- a distance metric applicable to the items in the trees- Returns:
- the pair of the nearest items, one from each tree
-
-