public class RTree<T> extends java.lang.Object implements SpatialIndex<T>, java.lang.Iterable<T>
| Modifier and Type | Class and Description |
|---|---|
static class |
RTree.Iterator<T> |
SpatialIndex.SearchCb<T>| Modifier and Type | Field and Description |
|---|---|
protected org.oscim.utils.RTree.Node |
mRoot
Root of tree
|
int |
nodesAlloc |
int |
nodesFree |
| Constructor and Description |
|---|
RTree() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Remove all entries from tree.
|
void |
insert(Box box,
T item) |
void |
insert(double[] min,
double[] max,
T item)
Insert item.
|
boolean |
insertRect(org.oscim.utils.RTree.Rect rect,
T item,
int level)
Insert a data rectangle into an index structure.
|
java.util.Iterator<T> |
iterator() |
void |
printStats() |
boolean |
remove(Box box,
T item) |
boolean |
remove(double[] min,
double[] max,
T item)
Remove item.
|
boolean |
removeRect(org.oscim.utils.RTree.Rect rect,
T item)
Delete a data rectangle from an index structure.
|
java.util.List<T> |
search(Box bbox,
java.util.List<T> results) |
boolean |
search(Box bbox,
SpatialIndex.SearchCb<T> cb,
java.lang.Object context) |
boolean |
search(double[] min,
double[] max,
SpatialIndex.SearchCb<T> cb,
java.lang.Object context)
Find all items within search rectangle.
|
java.util.List<T> |
searchKNearestNeighbors(Point center,
int k,
double maxDistance,
java.util.List<T> results)
See https://github.com/mourner/rbush-knn/blob/master/index.js
|
void |
searchKNearestNeighbors(Point center,
int k,
double maxDistance,
SpatialIndex.SearchCb<T> cb,
java.lang.Object context) |
boolean |
searchStack(org.oscim.utils.RTree.Rect rect,
java.util.List<T> results) |
void |
searchStack(org.oscim.utils.RTree.Rect rect,
SpatialIndex.SearchCb<T> cb,
java.lang.Object context) |
int |
size()
Count the data elements in this container.
|
protected org.oscim.utils.RTree.Node mRoot
public int nodesAlloc
public int nodesFree
public void insert(double[] min,
double[] max,
T item)
min - Min of bounding rectmax - Max of bounding rectitem - data.public void insert(Box box, T item)
insert in interface SpatialIndex<T>public boolean remove(double[] min,
double[] max,
T item)
min - Min of bounding rectmax - Max of bounding rectitem - data.public boolean remove(Box box, T item)
remove in interface SpatialIndex<T>public boolean search(double[] min,
double[] max,
SpatialIndex.SearchCb<T> cb,
java.lang.Object context)
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_resultCallbackpublic boolean search(Box bbox, SpatialIndex.SearchCb<T> cb, java.lang.Object context)
search in interface SpatialIndex<T>public java.util.List<T> search(Box bbox, java.util.List<T> results)
search in interface SpatialIndex<T>public java.util.List<T> searchKNearestNeighbors(Point center, int k, double maxDistance, java.util.List<T> results)
searchKNearestNeighbors in interface SpatialIndex<T>public void searchKNearestNeighbors(Point center, int k, double maxDistance, SpatialIndex.SearchCb<T> cb, java.lang.Object context)
searchKNearestNeighbors in interface SpatialIndex<T>public int size()
size in interface SpatialIndex<T>public void clear()
clear in interface SpatialIndex<T>public void printStats()
public boolean insertRect(org.oscim.utils.RTree.Rect rect,
T item,
int level)
public boolean removeRect(org.oscim.utils.RTree.Rect rect,
T item)
false if record not found, true if
success.
RemoveRect provides for eliminating the root.public void searchStack(org.oscim.utils.RTree.Rect rect,
SpatialIndex.SearchCb<T> cb,
java.lang.Object context)
public boolean searchStack(org.oscim.utils.RTree.Rect rect,
java.util.List<T> results)