private IIORasterDataReader( RasterIOOptions options, boolean resetableStream, int imageIndex ) { this.imageIndex = imageIndex; this.format = options.get( RasterIOOptions.OPT_FORMAT ); this.options = options; this.resetableStream = resetableStream; }
public synchronized void setRasterDataReader( RasterDataReader reader ) { this.rasterLoaded = false; this.raster = null; reader.close(); this.reader = reader; }
/** * Reads RasterData from RasterReader and wraps it in a RasterDataContainer. RasterData stays in memory. * * @param reader * RasterReader for RasterData */ public MemoryRasterDataContainer( RasterDataReader reader ) { this.raster = reader.read(); }
/** * Return a RasterIOOption object with the format set according to the given file with an optional * {@link RasterGeoReference}. * * @param file * @param envelope * @return RasterIOOption proper format. */ public static RasterIOOptions forFile( File file, RasterGeoReference envelope ) { RasterIOOptions result = new RasterIOOptions( envelope ); String ext = FileUtils.getFileExtension( file ); result.add( OPT_FORMAT, ext ); result.add( READ_WLD_FILE, null ); return result; }
/** * loads the raster * * @param tileBaseDir * @return the loaded simpleraster * @throws IOException */ public AbstractRaster loadRaster( String tileBaseDir ) throws IOException { File file = new File( getFullFileName( tileBaseDir ) ); RasterReader reader = new IIORasterReader(); RasterIOOptions options = RasterIOOptions.forFile( file, getEnvelope() ); return reader.load( file, options ); }
private static RasterWriter getRasterWriter( AbstractRaster raster, RasterIOOptions options ) { for ( RasterIOProvider writer : getRasterIOLoader() ) { String format = options.get( RasterIOOptions.OPT_FORMAT ); RasterWriter possibleWriter = writer.getRasterWriter( format ); // TODO if ( possibleWriter != null && possibleWriter.canWrite( raster, options ) ) { return possibleWriter; } } return null; }
@Override public String getDataLocationId() { return ( cachedReader != null ) ? cachedReader.getDataLocationId() : super.getDataLocationId(); }
private static RasterReader getRasterReader( File filename, RasterIOOptions options ) { for ( RasterIOProvider reader : getRasterIOLoader() ) { String format = options.get( RasterIOOptions.OPT_FORMAT ); if ( format == null ) { String nm = filename.getName(); format = nm.substring( nm.lastIndexOf( '.' ) + 1 ); } RasterReader possibleReader = reader.getRasterReader( format ); if ( possibleReader != null && possibleReader.canLoad( filename ) ) { return possibleReader; } } return null; }
/** * Save a raster to a file. * * @param raster * @param filename * @throws IOException */ public static void saveRasterToFile( AbstractRaster raster, File filename ) throws IOException { saveRasterToFile( raster, filename, new RasterIOOptions() ); }
private static RasterReader getRasterReader( RasterIOOptions options ) { for ( RasterIOProvider reader : getRasterIOLoader() ) { String format = options.get( RasterIOOptions.OPT_FORMAT ); RasterReader possibleReader = reader.getRasterReader( format ); if ( possibleReader != null ) { return possibleReader; } } return null; }
/** * Set the default loading policy to one configured in the {@link RasterDataContainerFactory} * * @param ref * @param format * of the raster to read, e.g. png, jpg, tiff..., may be <code>null</code> */ public RasterIOOptions( RasterGeoReference ref, String format ) { this( ref ); if ( format != null && !"".equals( format ) ) { add( OPT_FORMAT, format ); } }
/** * Load a raster from a file. * * @param filename * the filename of the raster * @return the loaded raster as an AbstractRaster * @throws IOException */ public static AbstractRaster loadRasterFromFile( File filename ) throws IOException { RasterIOOptions options = RasterIOOptions.forFile( filename ); return loadRasterFromFile( filename, options, null ); }
/** * Set the memory buffer to null and call dispose on the reader as well. */ public void dispose() { synchronized ( LOCK ) { if ( data != null ) { data = null; } if ( reader != null ) { reader.dispose(); } } }
/** * writes a RasterReference into a world file (with .wld extension). * * @param renv * the envelope * @param file * the raster file * @throws IOException */ public static void writeWorldFile( RasterGeoReference renv, File file ) throws IOException { writeWorldFile( renv, file, "wld" ); }
@Override public void dispose() { this.dispose( cachedReader != null && !cachedReader.shouldCreateCacheFile() ); }
/** * Return a RasterIOOption object with the format set according to the given file. * * @param file * @return RasterIOOption proper format. */ public static RasterIOOptions forFile( File file ) { RasterIOOptions result = new RasterIOOptions(); String ext = FileUtils.getFileExtension( file ); result.add( OPT_FORMAT, ext ); return result; }
private void setID( RasterIOOptions options ) { this.dataLocationId = options != null ? options.get( RasterIOOptions.ORIGIN_OF_RASTER ) : null; if ( dataLocationId == null ) { if ( this.file != null ) { this.dataLocationId = FileUtils.getFilename( this.file ); } } }
public synchronized RasterData getRasterData() { if ( !rasterLoaded ) { if ( log.isDebugEnabled() ) { log.debug( "reading: " + this.toString() ); } raster = reader.read(); rasterLoaded = true; } return raster; }
private void setID( RasterIOOptions options ) { this.dataLocationId = options != null ? options.get( RasterIOOptions.ORIGIN_OF_RASTER ) : null; if ( dataLocationId == null ) { if ( this.file != null ) { this.dataLocationId = FileUtils.getFilename( this.file ); } } }
private void setID( RasterIOOptions options ) { this.dataLocationId = options != null ? options.get( RasterIOOptions.ORIGIN_OF_RASTER ) : null; if ( dataLocationId == null ) { if ( this.file != null ) { this.dataLocationId = FileUtils.getFilename( this.file ); } } }