public List<AnnotationTile> generateTiles( List<AnnotationData<?>> annotations, AnnotationIndexer indexer, TilePyramid pyramid ) { Map<TileIndex, AnnotationTile> tiles = new HashMap<>(); for ( AnnotationData<?> annotation : annotations ) { List<TileAndBinIndices> indices = indexer.getIndices( annotation, pyramid ); for ( TileAndBinIndices index : indices ) { TileIndex tileIndex = index.getTile(); BinIndex binIndex = index.getBin(); if ( tiles.containsKey( tileIndex ) ) { tiles.get( tileIndex ).addDataToBin(binIndex, annotation); } else { AnnotationTile tile = new AnnotationTile( tileIndex ); tile.addDataToBin(binIndex, annotation); tiles.put( tileIndex, tile ); } } } return new ArrayList<>( tiles.values() ); }
@Override public boolean equals (Object obj) { if (this == obj) return true; if (null == obj) return false; if (!(obj instanceof TileAndBinIndices)) return false; TileAndBinIndices tb = (TileAndBinIndices) obj; if (!_tile.equals(tb.getTile())) return false; if (!_bin.equals(tb.getBin())) return false; return true; } }
private void removeDataCertificateFromTiles( List< AnnotationTile > tilesToWrite, List< TileIndex > tilesToRemove, List< AnnotationTile > tiles, AnnotationData<?> data, TilePyramid pyramid ) { // clear supplied lists tilesToWrite.clear(); tilesToRemove.clear(); // for each tile, remove data from bins for ( AnnotationTile tile : tiles ) { // get bin index for the annotation in this tile BinIndex binIndex = _indexer.getIndicesByLevel( data, tile.getDefinition().getLevel(), pyramid ).get(0).getBin(); // remove data from tile tile.removeDataFromBin(binIndex, data); } // determine which tiles need to be re-written and which need to be removed for ( AnnotationTile tile : tiles ) { if ( tile.isEmpty() ) { // if no data left, flag tile for removal tilesToRemove.add( tile.getDefinition() ); } else { // flag tile to be written tilesToWrite.add( tile ); } } }
private void addDataCertificateToTiles( List<AnnotationTile> tiles, List<TileAndBinIndices> indices, AnnotationData<?> data ) { for ( TileAndBinIndices index : indices ) { // check all existing tiles for matching index boolean found = false; for ( AnnotationTile tile : tiles ) { if ( tile.getDefinition().equals( index.getTile() ) ) { // tile exists already, add data to bin tile.addDataToBin( index.getBin(), data ); found = true; break; } } if ( !found ) { // no tile exists, add tile AnnotationTile tile = new AnnotationTile( index.getTile() ); tile.addDataToBin(index.getBin(), data); tiles.add( tile ); } } }
BinIndex binIndex = _indexer.getIndicesByLevel( annotation, tileIndex.getLevel(), pyramid ).get(0).getBin(); int index = binIndex.getX() + ( binIndex.getY() * tileIndex.getXBins() );