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 class
DimapProductWriter.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 void
addExtender(DimapProductWriter.WriterExtender writerExtender)
void
close()
Closes all output streams currently open.void
deleteOutput()
Deletes the physically representation of the product from the hard disk.void
flush()
Writes all data in memory to disk.Map<Band,ImageOutputStream>
getBandOutputStreams()
Returns all band output streams opened so far.File
getOutputDir()
Returns the output directory of the product beeing written.void
initDirs(File outputFile)
Initializes all the internal file and directory elements from the given output file.boolean
isIncrementalMode()
Returns whether this product writer writes only modified product nodes.void
removeBand(Band band)
Overwrite this method to physicaly delete aBand
from the writer's output file.void
setIncrementalMode(boolean enabled)
Enables resp.void
setUseCache(boolean useCache)
boolean
shouldWrite(ProductNode node)
Returns wether the given product node is to be written.void
writeBandRasterData(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 void
writeProductNodesImpl()
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 IOException
Writes the in-memory representation of a data product. This method was called bywriteProductNodes(product, output)
of the AbstractProductWriter.- Specified by:
writeProductNodesImpl
in classAbstractProductWriter
- Throws:
IllegalArgumentException
- ifoutput
type 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 givensourceOffsetX
andsourceOffsetY
of 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
,sourceWidth
andsourceHeight
parameters 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 IOException
Deletes the physically representation of the product from the hard disk.- Throws:
IOException
- if an I/O error occurs
-
flush
public void flush() throws IOException
Writes 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 IOException
Closes all output streams currently open.- Throws:
IOException
- on failure
-
shouldWrite
public boolean shouldWrite(ProductNode node)
Description copied from class:AbstractProductWriter
Returns wether the given product node is to be written.- Specified by:
shouldWrite
in interfaceProductWriter
- Overrides:
shouldWrite
in classAbstractProductWriter
- Parameters:
node
- the product node- Returns:
true
if so
-
isIncrementalMode
public boolean isIncrementalMode()
Returns whether this product writer writes only modified product nodes.- Specified by:
isIncrementalMode
in interfaceProductWriter
- Overrides:
isIncrementalMode
in classAbstractProductWriter
- Returns:
true
if 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:
setIncrementalMode
in interfaceProductWriter
- Overrides:
setIncrementalMode
in classAbstractProductWriter
- Parameters:
enabled
- enables or disables progress listening.
-
removeBand
public void removeBand(Band band)
Description copied from class:AbstractProductWriter
Overwrite this method to physicaly delete aBand
from the writer's output file.- Specified by:
removeBand
in interfaceProductWriter
- Overrides:
removeBand
in classAbstractProductWriter
- Parameters:
band
- The band to delete.
-
addExtender
public void addExtender(DimapProductWriter.WriterExtender writerExtender)
-
-