T
- the type of Coordinate.public class CoordinateKDTree<T extends Coordinate> extends Object implements CoordinateIndex<T>
Constructor and Description |
---|
CoordinateKDTree()
Create an empty KDTree object
|
CoordinateKDTree(Collection<T> coords)
Create a KDTree object and populate it with the given data.
|
Modifier and Type | Method and Description |
---|---|
protected static float |
distance(Coordinate a,
Coordinate b) |
void |
fastKNN(Collection<T> result,
Coordinate query,
int k)
Faster implementation of K-nearest-neighbours.
|
void |
insert(T point)
Inserts a point into the tree, preserving the spatial ordering.
|
void |
insertAll(Collection<T> coords)
Insert all the points from the given collection into the index.
|
void |
kNearestNeighbour(Collection<T> result,
Coordinate query,
int k)
Find the k nearest neighbour points in the index to
the query coordinate.
|
T |
nearestNeighbour(Coordinate query)
Find the nearest neighbour.
|
void |
rangeSearch(Collection<T> results,
Coordinate lowerExtreme,
Coordinate upperExtreme)
Searches the tree for all points contained within a given k-dimensional
bounding box and stores them in a Collection.
|
public CoordinateKDTree()
public CoordinateKDTree(Collection<T> coords)
coords
- the data to populate the index with.public void insertAll(Collection<T> coords)
coords
- The points to add.public void insert(T point)
insert
in interface CoordinateIndex<T extends Coordinate>
point
- Point to insert.public void rangeSearch(Collection<T> results, Coordinate lowerExtreme, Coordinate upperExtreme)
rangeSearch
in interface CoordinateIndex<T extends Coordinate>
results
- lowerExtreme
- upperExtreme
- protected static final float distance(Coordinate a, Coordinate b)
public T nearestNeighbour(Coordinate query)
nearestNeighbour
in interface CoordinateIndex<T extends Coordinate>
query
- query coordinatepublic void kNearestNeighbour(Collection<T> result, Coordinate query, int k)
CoordinateIndex
kNearestNeighbour
in interface CoordinateIndex<T extends Coordinate>
result
- Collection to hold the found coordinates.query
- The query coordinate.k
- The number of neighbours to find.public void fastKNN(Collection<T> result, Coordinate query, int k)
result
- Collection to hold the found coordinates.query
- The query coordinate.k
- The number of neighbours to find.