public PhRangeQuery(PhQuery<T> iter, PhTree<T> tree, PhDistance dist, PhFilterDistance filter) { this.dims = tree.getDim(); this.q = iter; this.dist = dist; this.filter = filter; this.min = new long[dims]; this.max = new long[dims]; }
@Override public int getDIM() { return tree.getDim(); }
public int getDim() { return pht.getDim(); }
/** * Create a new range tree backed by the the specified tree. * Note that the backing tree's dimensionality must be a multiple of 2. * * @param tree the backing tree */ public PhTreeSolid(PhTree<T> tree) { this.dims = tree.getDim()/2; if (dims*2 != tree.getDim()) { throw new IllegalArgumentException("The backing tree's DIM must be a multiple of 2"); } pht = tree; pre = new PreProcessorRange.Simple(); qMIN = new long[dims]; Arrays.fill(qMIN, Long.MIN_VALUE); qMAX = new long[dims]; Arrays.fill(qMAX, Long.MAX_VALUE); }
/** * Create a new {@code double} tree backed by the the specified tree. * Note that the backing tree's dimensionality must be a multiple of 2. * * @param tree the backing tree */ public PhTreeSolidF(PhTree<T> tree) { this(tree, new PreProcessorRangeF.IEEE(tree.getDim())); }
/** * Create a new {@code double} tree backed by the the specified tree. * Note that the backing tree's dimensionality must be a multiple of 2. * * @param tree the backing tree * @param pre a preprocessor instance */ public PhTreeSolidF(PhTree<T> tree, PreProcessorRangeF pre) { this.dims = tree.getDim()/2; if (dims*2 != tree.getDim()) { throw new IllegalArgumentException("The backing tree's DIM must be a multiple of 2"); } this.pht = tree; this.pre = pre; this.dist = new PhDistanceSFEdgeDist(pre, dims); //this.dist = new PhDistanceSFCenterDist(pre, dims); qMIN = new double[dims]; Arrays.fill(qMIN, Double.NEGATIVE_INFINITY); qMAX = new double[dims]; Arrays.fill(qMAX, Double.POSITIVE_INFINITY); }
/** * @return an iterator over all elements in the tree */ public PhExtentF<T> queryExtent() { return new PhExtentF<>(pht.queryExtent(), 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 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); }
/** * Performs a rectangular window query. The parameters are the min and max keys which * contain the minimum respectively the maximum keys in every dimension. * @param min Minimum values * @param max Maximum values * @return Result iterator. */ public PhQueryF<T> query(double[] min, double[] max) { long[] lMin = new long[min.length]; long[] lMax = new long[max.length]; pre.pre(min, lMin); pre.pre(max, lMax); return new PhQueryF<>(pht.query(lMin, lMax), pht.getDim(), pre); }