/** * Locate nearest neighbours for a given point in space. * @param nMin number of entries to be returned. More entries may or may not be returned if * several points have the same distance. * @param distanceFunction A distance function for rectangle data. This parameter is optional, * passing a {@code null} will use the default distance function. * @param center the center point * @return The query iterator. */ public PhKnnQuerySF<T> nearestNeighbour(int nMin, PhDistanceSF distanceFunction, double ... center) { long[] lCenter = new long[2*dims]; pre.pre(center, center, lCenter); PhDistanceSF df = distanceFunction == null ? dist : distanceFunction; return new PhKnnQuerySF<>(pht.nearestNeighbour(nMin, df, null, lCenter), dims, pre); }
/** * Locate nearest neighbours for a given point in space. * @param nMin number of entries to be returned. More entries may or may not be returned if * several points have the same distance. * @param key the center point * @return List of neighbours. */ public PhKnnQueryF<T> nearestNeighbour(int nMin, double... key) { long[] lKey = new long[key.length]; pre.pre(key, lKey); PhKnnQuery<T> iter = pht.nearestNeighbour(nMin, PhDistanceF.THIS, null, lKey); return new PhKnnQueryF<>(iter, pht.getDim(), pre); }
/** * Locate nearest neighbours for a given point in space. * @param nMin number of entries to be returned. More entries may or may not be returned if * several points have the same distance. * @param dist Distance function. Note that the distance function should be compatible * with the preprocessor of the tree. * @param key the center point * @return KNN query iterator. */ public PhKnnQueryF<T> nearestNeighbour(int nMin, PhDistance dist, double... key) { long[] lKey = new long[key.length]; pre.pre(key, lKey); PhKnnQuery<T> iter = pht.nearestNeighbour(nMin, dist, null, lKey); return new PhKnnQueryF<>(iter, pht.getDim(), pre); }