@Override public void dispose() { this.dispose( cachedReader != null && !cachedReader.shouldCreateCacheFile() ); }
/** * Adds a raster reader to this cache, all cache files will be written to this cache directory. * * @param reader * to add to the cache. * @return a new CachedReader which was added to the cache. */ public RasterReader addReader( RasterReader reader ) { CacheRasterReader result = null; if ( reader != null ) { if ( reader instanceof CacheRasterReader ) { result = (CacheRasterReader) reader; } else { boolean createCache = reader.shouldCreateCacheFile(); File cacheFile = null; if ( createCache ) { cacheFile = createCacheFile( reader.getDataLocationId() ); } result = new CacheRasterReader( reader, cacheFile, this ); } addReader( result ); } else { LOG.debug( "Not adding reader to cache, because it is was null." ); } if ( LOG.isDebugEnabled() && result != null && reader != null ) { LOG.debug( "Adding reader to cache {} with id: {}.", reader, reader.getDataLocationId() ); } return result; }
/** * @param cachedReader * @param cacheFile * @param cache * */ public CacheRasterReader( RasterReader cachedReader, File cacheFile, RasterCache cache ) { this( cachedReader.getWidth(), cachedReader.getHeight(), cacheFile, cachedReader.shouldCreateCacheFile(), cachedReader.getRasterDataInfo(), cachedReader.getGeoReference(), cache ); this.cachedReader = cachedReader; // rb: instantiate on load may not be the wanted thing. // if ( this.cachedReader != null && !this.cachedReader.canReadTiles() ) { // BufferResult result = null; // try { // result = this.cachedReader.read( new RasterRect( 0, 0, this.cachedReader.getWidth(), // this.cachedReader.getHeight() ), null ); // } catch ( IOException e ) { // LOG.warn( "Could not create tiles from the reader because; {}", e.getLocalizedMessage(), e ); // // e.printStackTrace(); // } // if ( result != null ) { // createTilesFromFilledBuffer( result.getResult(), result.getRect().width, result.getRect().height ); // } // result = null; // } }