Package org.oscim.utils
Class RTree<T>
java.lang.Object
org.oscim.utils.RTree<T>
- All Implemented Interfaces:
Iterable<T>,SpatialIndex<T>
Implementation of RTree, a multidimensional bounding rectangle tree.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.oscim.utils.SpatialIndex
SpatialIndex.SearchCb<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.oscim.utils.RTree.NodeRoot of treeintint -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove all entries from tree.voidInsert item.voidbooleaninsertRect(org.oscim.utils.RTree.Rect rect, T item, int level) Insert a data rectangle into an index structure.iterator()voidbooleanRemove item.booleanbooleanremoveRect(org.oscim.utils.RTree.Rect rect, T item) Delete a data rectangle from an index structure.booleansearch(double[] min, double[] max, SpatialIndex.SearchCb<T> cb, Object context) Find all items within search rectangle.booleansearch(Box bbox, SpatialIndex.SearchCb<T> cb, Object context) searchKNearestNeighbors(Point center, int k, double maxDistance, List<T> results) See https://github.com/mourner/rbush-knn/blob/master/index.jsvoidsearchKNearestNeighbors(Point center, int k, double maxDistance, SpatialIndex.SearchCb<T> cb, Object context) booleansearchStack(org.oscim.utils.RTree.Rect rect, List<T> results) voidsearchStack(org.oscim.utils.RTree.Rect rect, SpatialIndex.SearchCb<T> cb, Object context) intsize()Count the data elements in this container.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
mRoot
protected org.oscim.utils.RTree.Node mRootRoot of tree -
nodesAlloc
public int nodesAlloc -
nodesFree
public int nodesFree
-
-
Constructor Details
-
RTree
public RTree()
-
-
Method Details
-
insert
Insert item.- Parameters:
min- Min of bounding rectmax- Max of bounding rectitem- data.
-
insert
- Specified by:
insertin interfaceSpatialIndex<T>
-
remove
Remove item.- Parameters:
min- Min of bounding rectmax- Max of bounding rectitem- data.
-
remove
- Specified by:
removein interfaceSpatialIndex<T>
-
search
Find all items within search rectangle.- Parameters:
a_min- Min of search bounding recta_max- Max of search bounding recta_searchResult- Search result array. Caller should set grow size. Function will reset, not append to array.a_resultCallback- Callback function to return result. Callback should return 'true' to continue searchinga_context- User context to pass as parameter to a_resultCallback- Returns:
- Returns the number of entries found
-
search
- Specified by:
searchin interfaceSpatialIndex<T>
-
search
- Specified by:
searchin interfaceSpatialIndex<T>
-
searchKNearestNeighbors
See https://github.com/mourner/rbush-knn/blob/master/index.js- Specified by:
searchKNearestNeighborsin interfaceSpatialIndex<T>
-
searchKNearestNeighbors
public void searchKNearestNeighbors(Point center, int k, double maxDistance, SpatialIndex.SearchCb<T> cb, Object context) - Specified by:
searchKNearestNeighborsin interfaceSpatialIndex<T>
-
size
public int size()Count the data elements in this container. This is slow as no internal counter is maintained.- Specified by:
sizein interfaceSpatialIndex<T>
-
clear
public void clear()Remove all entries from tree.- Specified by:
clearin interfaceSpatialIndex<T>
-
printStats
public void printStats() -
insertRect
Insert a data rectangle into an index structure. InsertRect provides for splitting the root; returns 1 if root was split, 0 if it was not. The level argument specifies the number of steps up from the leaf level to insert; e.g. a data rectangle goes in at level = 0. InsertRect2 does the recursion. -
removeRect
Delete a data rectangle from an index structure. Pass in a pointer to a Rect, the tid of the record, ptr to ptr to root node.- Returns:
falseif record not found,trueif success. RemoveRect provides for eliminating the root.
-
searchStack
public void searchStack(org.oscim.utils.RTree.Rect rect, SpatialIndex.SearchCb<T> cb, Object context) -
searchStack
-
iterator
-