private TextureTileProvider getMatchingProvider( double unitsPerPixel ) { TextureTileProvider provider = providers[0]; for ( int i = 0; i < providers.length; i++ ) { // double provRes = providers[i].getNativeResolution(); if ( !providers[i].hasTextureForResolution( unitsPerPixel ) ) { break; } provider = providers[i]; } LOG.debug( "Using povider with native resolution: " + provider.getNativeResolution() ); return provider; }
/** * @param request */ private TextureTile getMatchingTileWithLogging( TextureTileRequest request ) { TextureTile tile = null; // System.out.println( "Cached tiles: " + cachedTiles.size() ); LOG.debug( "testing: " + request.toString() ); for ( TextureTile candidate : cachedTiles ) { LOG.debug( "against: " + candidate ); if ( request.isFullfilled( candidate ) ) { LOG.debug( "-- a match " ); tile = candidate; // System.out.println( "using from cache tile: " + tile.hashCode() ); cachedTiles.remove( candidate ); cachedTiles.add( candidate ); break; } } if ( tile == null ) { LOG.debug( "-- no match " ); tile = getMatchingProvider( request.getUnitsPerPixel() ).getTextureTile( request ); if ( tile != null && tile.enableCaching() ) { addToCache( tile ); } } return tile; }
/** * @param request */ private TextureTile getMatchingTileWithout( TextureTileRequest request ) { TextureTile tile = null; for ( TextureTile candidate : cachedTiles ) { if ( request.isFullfilled( candidate ) ) { tile = candidate; cachedTiles.remove( candidate ); cachedTiles.add( candidate ); break; } } if ( tile == null ) { tile = getMatchingProvider( request.getUnitsPerPixel() ).getTextureTile( request ); if ( tile != null && tile.enableCaching() ) { addToCache( tile ); } } return tile; }
/** * * @param unitsPerPixel * @return the native resolution of the configured TextureProvider, based on the meters per pixel. */ public double getMatchingResolution( double unitsPerPixel ) { TextureTileProvider match = getMatchingProvider( unitsPerPixel ); if ( match != null ) { // System.out.println( "The match: " + match + " requested upp: " + unitsPerPixel ); if ( Double.isNaN( match.getNativeResolution() ) && match.hasTextureForResolution( unitsPerPixel ) ) { // we have a texture but it is not limited to a minimal units per pixel. return unitsPerPixel; } return match.getNativeResolution(); } // match was null or the provider does not supply a texture for the given resolution. return Double.NaN; }