Package org.stianloader.stianknn
Class SpatialBufferedQueryArray<E>
java.lang.Object
org.stianloader.stianknn.SpatialBufferedQueryArray<E>
- Type Parameters:
E- The type of elements this container may store. Note that the elements have to be wrapped in aPointObjectPair, see the constructor's signature for more.
- All Implemented Interfaces:
SpatialIndex1NN<E>,SpatialIndexIterable<E>,SpatialIndexKNN<E>,SpatialRingIndex1NN<E>
public class SpatialBufferedQueryArray<E>
extends Object
implements SpatialRingIndex1NN<E>, SpatialIndexIterable<E>
An improved variant of the original variant of KNN spatial queries implemented by this library.
In specific, this class makes use of buffering to avoid cases where object with equal distance
get absorbed. At a technical level, this variant retains the core design idea wherein the points
are stored in an array sorted by their horizontal position. This allows objects with similar coordinates to be
grouped together closer in memory. It also avoid the use of nests or otherwise multiple arrays,
which is a property that is commonly used across traditional spatial queries, but which can
be inefficient at times.
-
Constructor Summary
ConstructorsConstructorDescriptionSpatialBufferedQueryArray(@NotNull Collection<@NotNull PointObjectPair<E>> points) -
Method Summary
Modifier and TypeMethodDescriptioncreateIterator(float x, float y) Create an iterator that fetches the element close to the point defined by the parametersxandy.query1nn(float x, float y, float minDistSq, float maxDistSq) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.stianloader.stianknn.SpatialRingIndex1NN
query1nn
-
Constructor Details
-
SpatialBufferedQueryArray
-
-
Method Details
-
createIterator
Description copied from interface:SpatialIndexIterableCreate an iterator that fetches the element close to the point defined by the parametersxandy. The iterator will return the elements closest to the point first, then return the elements further away from the point.Note that the iterator may be inefficient when fetching large amounts of points, though it concretely depends on the implementation.
- Specified by:
createIteratorin interfaceSpatialIndexIterable<E>- Parameters:
x- The x component of the position of the point which will be the origin for the proximity evaluations.y- The y component of the position of the point which will be the origin for the proximity evaluations.- Returns:
- An iterator that iterates over the elements based on the proximity from the given point.
-
query1nn
- Specified by:
query1nnin interfaceSpatialRingIndex1NN<E>
-
queryKnn
public void queryKnn(float x, float y, int neighbourCount, @NotNull @NotNull Consumer<@NotNull E> out) - Specified by:
queryKnnin interfaceSpatialIndexKNN<E>
-