Package org.esa.snap.core.dataio.dimap
Class DimapProductWriter
- java.lang.Object
-
- org.esa.snap.core.dataio.AbstractProductWriter
-
- org.esa.snap.core.dataio.dimap.DimapProductWriter
-
- All Implemented Interfaces:
ProductWriter
public class DimapProductWriter extends AbstractProductWriter
The product writer for the BEAM-DIMAP format.The BEAM-DIMAP version history is provided in the API doc of the
DimapProductWriterPlugIn.- Version:
- $Revision$ $Date$
- See Also:
DimapProductWriterPlugIn,DimapProductReaderPlugIn
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDimapProductWriter.WriterExtender
-
Constructor Summary
Constructors Constructor Description DimapProductWriter(ProductWriterPlugIn writerPlugIn)Construct a new instance of a product writer for the given BEAM-DIMAP product writer plug-in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExtender(DimapProductWriter.WriterExtender writerExtender)voidclose()Closes all output streams currently open.voiddeleteOutput()Deletes the physically representation of the product from the hard disk.voidflush()Writes all data in memory to disk.Map<Band,ImageOutputStream>getBandOutputStreams()Returns all band output streams opened so far.FilegetOutputDir()Returns the output directory of the product beeing written.voidinitDirs(File outputFile)Initializes all the internal file and directory elements from the given output file.booleanisIncrementalMode()Returns whether this product writer writes only modified product nodes.voidremoveBand(Band band)Overwrite this method to physicaly delete aBandfrom the writer's output file.voidsetIncrementalMode(boolean enabled)Enables resp.voidsetUseCache(boolean useCache)booleanshouldWrite(ProductNode node)Returns wether the given product node is to be written.voidwriteBandRasterData(Band sourceBand, int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight, ProductData sourceBuffer, ProgressMonitor pm)Writes raster data from the given in-memory source buffer into the data sink specified by the given source band and region.protected voidwriteProductNodesImpl()Writes the in-memory representation of a data product.-
Methods inherited from class org.esa.snap.core.dataio.AbstractProductWriter
checkOutput, getOutput, getSourceProduct, getWriterPlugIn, isInstanceOfValidOutputType, setFormatName, writeProductNodes
-
-
-
-
Constructor Detail
-
DimapProductWriter
public DimapProductWriter(ProductWriterPlugIn writerPlugIn)
Construct a new instance of a product writer for the given BEAM-DIMAP product writer plug-in.- Parameters:
writerPlugIn- the given BEAM-DIMAP product writer plug-in, must not benull
-
-
Method Detail
-
setUseCache
public void setUseCache(boolean useCache)
-
getOutputDir
public File getOutputDir()
Returns the output directory of the product beeing written.
-
getBandOutputStreams
public Map<Band,ImageOutputStream> getBandOutputStreams()
Returns all band output streams opened so far.
-
writeProductNodesImpl
protected void writeProductNodesImpl() throws IOExceptionWrites the in-memory representation of a data product. This method was called bywriteProductNodes(product, output)of the AbstractProductWriter.- Specified by:
writeProductNodesImplin classAbstractProductWriter- Throws:
IllegalArgumentException- ifoutputtype is not one of the supported output sources.IOException- if an I/O error occurs
-
initDirs
public void initDirs(File outputFile) throws IOException
Initializes all the internal file and directory elements from the given output file. This method only must be called if the product writer should write the given data to raw data files without calling of writeProductNodes. This may be at the time when a dimap product was opened and the data should be continuously changed in the same product file without an previous call to the saveProductNodes to this product writer.- Parameters:
outputFile- the dimap header file location.- Throws:
IOException- if an I/O error occurs
-
writeBandRasterData
public void writeBandRasterData(Band sourceBand, int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight, ProductData sourceBuffer, ProgressMonitor pm) throws IOException
Writes raster data from the given in-memory source buffer into the data sink specified by the given source band and region.Source band
The source band is used to identify the data sink in which this method transfers the sample values given in the source buffer. The method does not modify the pixel data of the given source band at all.Source buffer
The first element of the source buffer corresponds to the givensourceOffsetXandsourceOffsetYof the source region. These parameters are an offset within the band's raster data and not an offset within the source buffer.
The number of elements in the buffer must be exactly besourceWidth * sourceHeight. The pixel values to be writte are considered to be stored in line-by-line order, so the raster X co-ordinate varies faster than the Y.Source region
The given destination region specified by thesourceOffsetX,sourceOffsetY,sourceWidthandsourceHeightparameters is given in the source band's raster co-ordinates. These co-ordinates are identical with the destination raster co-ordinates since product writers do not support spectral or spatial subsets.- Parameters:
sourceBand- the source band which identifies the data sink to which to write the sample valuessourceOffsetX- the X-offset in the band's raster co-ordinatessourceOffsetY- the Y-offset in the band's raster co-ordinatessourceWidth- the width of region to be written given in the band's raster co-ordinatessourceHeight- the height of region to be written given in the band's raster co-ordinatessourceBuffer- the source buffer which provides the sample values to be writtenpm- a monitor to inform the user about progress- Throws:
IOException- if an I/O error occurs- See Also:
AbstractBand.getRasterWidth(),AbstractBand.getRasterHeight()
-
deleteOutput
public void deleteOutput() throws IOExceptionDeletes the physically representation of the product from the hard disk.- Throws:
IOException- if an I/O error occurs
-
flush
public void flush() throws IOExceptionWrites all data in memory to disk. After a flush operation, the writer can be closed safely- Throws:
IOException- on failure
-
close
public void close() throws IOExceptionCloses all output streams currently open.- Throws:
IOException- on failure
-
shouldWrite
public boolean shouldWrite(ProductNode node)
Description copied from class:AbstractProductWriterReturns wether the given product node is to be written.- Specified by:
shouldWritein interfaceProductWriter- Overrides:
shouldWritein classAbstractProductWriter- Parameters:
node- the product node- Returns:
trueif so
-
isIncrementalMode
public boolean isIncrementalMode()
Returns whether this product writer writes only modified product nodes.- Specified by:
isIncrementalModein interfaceProductWriter- Overrides:
isIncrementalModein classAbstractProductWriter- Returns:
trueif so
-
setIncrementalMode
public void setIncrementalMode(boolean enabled)
Enables resp. disables incremental writing of this product writer. By default, a reader should enable progress listening.- Specified by:
setIncrementalModein interfaceProductWriter- Overrides:
setIncrementalModein classAbstractProductWriter- Parameters:
enabled- enables or disables progress listening.
-
removeBand
public void removeBand(Band band)
Description copied from class:AbstractProductWriterOverwrite this method to physicaly delete aBandfrom the writer's output file.- Specified by:
removeBandin interfaceProductWriter- Overrides:
removeBandin classAbstractProductWriter- Parameters:
band- The band to delete.
-
addExtender
public void addExtender(DimapProductWriter.WriterExtender writerExtender)
-
-