public GeoPackageTile getTile ( BoundingBox requestBoundingBox ) { GeoPackageTile tile = null ; // Transform to the projection of the tiles ProjectionTransform transformRequestToTiles = requestProjection . getTransformation ( tilesProjection ) ; BoundingBox tilesBoundingBox = requestBoundingBox . transform ( transformRequestToTiles ) ; List < TileMatrix > tileMatrices = getTileMatrices ( tilesBoundingBox ) ; for ( int i = 0 ; tile == null && i < tileMatrices . size ( ) ; i ++ ) { TileMatrix tileMatrix = tileMatrices . get ( i ) ; TileResultSet tileResults = retrieveTileResults ( tilesBoundingBox , tileMatrix ) ; if ( tileResults != null ) { try { if ( tileResults . getCount ( ) > 0 ) { BoundingBox requestProjectedBoundingBox = requestBoundingBox . transform ( transformRequestToTiles ) ; // Determine the requested tile dimensions, or use the // dimensions of a single tile matrix tile int requestedTileWidth = width != null ? width : ( int ) tileMatrix . getTileWidth ( ) ; int requestedTileHeight = height != null ? height : ( int ) tileMatrix . getTileHeight ( ) ; // Determine the size of the tile to initially draw int tileWidth = requestedTileWidth ; int tileHeight = requestedTileHeight ; if ( ! sameProjection ) { tileWidth = ( int ) Math . round ( ( requestProjectedBoundingBox . getMaxLongitude ( ) - requestProjectedBoundingBox . getMinLongitude ( ) ) / tileMatrix . getPixelXSize ( ) ) ; tileHeight = ( int ) Math . round ( ( requestProjectedBoundingBox . getMaxLatitude ( ) - requestProjectedBoundingBox . getMinLatitude ( ) ) / tileMatrix . getPixelYSize ( ) ) ; } // Draw the resulting bitmap with the matching tiles GeoPackageTile geoPackageTile = drawTile ( tileMatrix , tileResults , requestProjectedBoundingBox , tileWidth , tileHeight ) ; // Create the tile if ( geoPackageTile != null ) { // Project the tile if needed if ( ! sameProjection && geoPackageTile . getImage ( ) != null ) { BufferedImage reprojectTile = reprojectTile ( geoPackageTile . getImage ( ) , requestedTileWidth , requestedTileHeight , requestBoundingBox , transformRequestToTiles , tilesBoundingBox ) ; geoPackageTile = new GeoPackageTile ( requestedTileWidth , requestedTileHeight , reprojectTile ) ; } tile = geoPackageTile ; } } } finally { tileResults . close ( ) ; } } } return tile ; }
Get the tile from the request bounding box in the request projection