/** * 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); }
private Point getTileCoordinates (double x, double y) { Point2D point = new Point2D.Double(x, y); TileIndex tile = _pyramid.rootToTile(point, _level); return new Point(tile.getX(), tile.getY()); }
TileIndex index = _pyramid.rootToTile(rawX, rawY, _comparisonLevel); long x = index.getX(); long y = index.getY();
private Point getBinCoordinates (double x, double y) { Point2D point = new Point2D.Double(x, y); TileIndex tile = _pyramid.rootToTile(point, _level); if (tile.getXBins() != _numXBins && tile.getYBins() != _numYBins) { tile = new TileIndex(tile.getLevel(), tile.getX(), tile.getY(), _numXBins, _numYBins); } BinIndex bin = _pyramid.rootToBin(point, tile); return new Point(tile.getX()*tile.getXBins()+bin.getX(), tile.getY()*tile.getYBins()+(tile.getYBins()-1-bin.getY())); }
@Override public List<TileAndBinIndices> getIndicesByLevel( AnnotationData<?> data, int level, TilePyramid pyramid ) { List<TileAndBinIndices> tileAndBins = new LinkedList<>(); if ( !data.isRangeBased() ) { // point annotation Double x = ( data.getX() == null ) ? 0 : data.getX(); Double y = ( data.getY() == null ) ? 0 : data.getY(); // map from x and y to tile and bin TileIndex tile = pyramid.rootToTile( x, y, level, NUM_BINS, NUM_BINS ); BinIndex bin = pyramid.rootToBin( x, y, tile ); tileAndBins.add( new TileAndBinIndices( tile, bin ) ); return tileAndBins; } else { // range annotations Double x0 = ( data.getX0() == null ) ? 0 : data.getX0(); Double y0 = ( data.getY0() == null ) ? 0 : data.getY0(); Double x1 = ( data.getX1() == null ) ? 0 : data.getX1(); Double y1 = ( data.getY1() == null ) ? 0 : data.getY1(); // bottom left TileIndex tileBL = pyramid.rootToTile(x0, y0, level, NUM_BINS, NUM_BINS); // top right TileIndex tileTR = pyramid.rootToTile( x1, y1, level, NUM_BINS, NUM_BINS ); for (int i=tileBL.getX(); i<=tileTR.getX(); i++) { for (int j=tileBL.getY(); j <= tileTR.getY(); j++) { tileAndBins.add( new TileAndBinIndices( new TileIndex(level, i, j, NUM_BINS, NUM_BINS ), RANGE_BIN ) ); } } } return tileAndBins; }
int order1 = _order.get(y1).get(x1); Point2D point1 = _points.get(y1).get(x1); TileIndex index1 = _pyramid.rootToTile(point1, L1); int order2 = _order.get(y2).get(x2); Point2D point2 = _points.get(y2).get(x2); TileIndex index2 = _pyramid.rootToTile(point2, L2); TileIndex index1AtLevel2 = _pyramid.rootToTile(point1, L2); TileIndex index2AtLevel1 = _pyramid.rootToTile(point2, L1);