Package org.naviqore.utils.spatial.index
Class KDTree<T extends Location<?>>
java.lang.Object
org.naviqore.utils.spatial.index.KDTree<T>
- Type Parameters:
T- The type of location stored in the tree.
A k-dimensional tree (k-d tree) for fast, efficient proximity searches. This implementation only supports
2-dimensional spatial data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnearestNeighbour(double firstComponent, double secondComponent) Finds the nearest neighbour to a coordinate specified by its components.nearestNeighbour(Coordinate coordinate) Finds the nearest neighbour to a given coordinate.nearestNeighbour(T location) Finds the nearest neighbour to a given location.rangeSearch(double firstComponent, double secondComponent, double radius) Performs a range search to find all locations within a certain radius of a coordinate specified by its components.rangeSearch(Coordinate center, double radius) Performs a range search to find all locations within a certain radius of a center coordinate.rangeSearch(T center, double radius) Performs a range search to find all locations within a certain radius of a center location.
-
Constructor Details
-
KDTree
public KDTree()
-
-
Method Details
-
nearestNeighbour
Finds the nearest neighbour to a given location.- Parameters:
location- The location to find the nearest neighbour for.- Returns:
- The nearest neighbour to the given location.
-
nearestNeighbour
Finds the nearest neighbour to a coordinate specified by its components.- Parameters:
firstComponent- The first component of the coordinate.secondComponent- The second component of the coordinate.- Returns:
- The nearest neighbour to the coordinate specified by firstComponent and secondComponent.
-
rangeSearch
Performs a range search to find all locations within a certain radius of a center location.- Parameters:
center- The center location for the range search.radius- The radius within which to search.- Returns:
- A list of all locations within the radius of the center.
-
rangeSearch
Performs a range search to find all locations within a certain radius of a coordinate specified by its components.- Parameters:
firstComponent- The first component of the center coordinate.secondComponent- The second component of the center coordinate.radius- The radius within which to search.- Returns:
- A list of all locations within the radius of the specified center coordinate.
-