/** * Compare two raw input values according to our pyramid scheme * * @return Standard comparison values, as per {@link Comparator} */ public int compareRaw (double x1, double y1, double x2, double y2) { TileIndex tile1 = _pyramid.rootToTile(x1, y1, _comparisonLevel); TileIndex tile2 = _pyramid.rootToTile(x2, y2, _comparisonLevel); return compareIndexAtLevel(tile1, tile2); }
/** * Compare two raw input values according to our pyramid scheme * * @return Standard comparison values, as per {@link Comparator} */ public int compareRaw (Point2D pt1, Point2D pt2) { // Mostly taken from http://en.wikipedia.org/wiki/Z-order_curve, but // this is a very simple 2-dimensional case, so the results are rather // simplified. TileIndex tile1 = _pyramid.rootToTile(pt1, _comparisonLevel); TileIndex tile2 = _pyramid.rootToTile(pt2, _comparisonLevel); return compareIndexAtLevel(tile1, tile2); }
/** * Compare two tile indices. The indices are compared at the level of the * least zoomed-in of the two tiles. * * @return Standard comparison values, as per {@link Comparator} */ public int compareIndex (TileIndex t1, TileIndex t2) { int l1 = t1.getLevel(); int l2 = t2.getLevel(); if (l1 < l2) { // Bring t2 up to the level of t1 int p2 = 1 << (l2 - l1); t2 = new TileIndex(l1, t2.getX() / p2, t2.getY() / p2, t2.getXBins(), t2.getYBins()); } else if (l1 > l2) { // Bring t1 up to the level of t2 int p2 = 1 << (l1 - l2); t1 = new TileIndex(l2, t1.getX() / p2, t1.getY() / p2, t1.getXBins(), t1.getYBins()); } return compareIndexAtLevel(t1, t2); }