@Override public TileAndBinIndices next () { int tileX = (int) Math.floor(_curBinX/_numXBins); int tileY = (int) Math.floor(_curBinY/_numYBins); TileIndex tile = new TileIndex(_level, tileX, tileY, _numXBins, _numYBins); int binX = _curBinX-_numXBins*tileX; int binY = _curBinY-_numYBins*tileY; BinIndex bin = new BinIndex(binX, _numYBins-1-binY); ++_curBinX; if (_curBinX > _maxBinX) { _curBinX = _minBinX; ++_curBinY; } return new TileAndBinIndices(tile, bin); }
TileIndex tile = new TileIndex(level, tileX, tileY, xBins, yBins); return new TileAndBinIndices(tile, tileBin);
for (int x=250; x<256; ++x) { for (int y=5; y>=0; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=0; x<=5; ++x) { for (int y=5; y>=0; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=250; x<256; ++x) { for (int y=255; y>=250; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=0; x<=5; ++x) { for (int y=255; y>=250; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y)));
@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; }
for (int x=250; x<256; ++x) { for (int y=5; y>=0; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=0; x<256; ++x) { for (int y=5; y>=0; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=0; x<=5; ++x) { for (int y=5; y>=0; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=250; x<256; ++x) { for (int y=255; y>=0; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=0; x<256; ++x) { for (int y=255; y>=0; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=0; x<=5; ++x) { for (int y=255; y>=0; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=250; x<256; ++x) { for (int y=255; y>=250; --y) { expectedResults.add(new TileAndBinIndices(tile, new BinIndex(x, y))); for (int x=0; x<256; ++x) {
private void testTile (TileIndex tile, int binX, int binY, int univX, int univY) { BinIndex tileBin = new BinIndex(binX, binY); BinIndex universalBin = new BinIndex(univX, univY); Assert.assertEquals(universalBin, TileIndex.tileBinIndexToUniversalBinIndex(tile, tileBin)); Assert.assertEquals(new TileAndBinIndices(tile, tileBin), TileIndex.universalBinIndexToTileBinIndex(tile, universalBin)); } @Test
TileIndex tile = new TileIndex(level, tileX, tileY, xBins, yBins); return new TileAndBinIndices(tile, tileBin);