|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.esa.beam.framework.dataio.AbstractProductReader
public abstract class AbstractProductReader
The AbstractProductReader class can be used as a base class for new product reader implementations. The
only two methods which clients must implement are readProductNodes() and readBandData
methods.
readProductNodes(java.lang.Object, org.esa.beam.framework.dataio.ProductSubsetDef),
readBandRasterData(org.esa.beam.framework.datamodel.Band, int, int, int, int, org.esa.beam.framework.datamodel.ProductData, com.bc.ceres.core.ProgressMonitor)| Constructor Summary | |
|---|---|
protected |
AbstractProductReader(ProductReaderPlugIn readerPlugIn)
Constructs a new abstract product reader. |
| Method Summary | |
|---|---|
void |
close()
Closes the access to all currently opened resources such as file input streams and all resources of this children directly owned by this reader. |
protected static void |
configurePreferredTileSize(Product product)
|
protected TiePointGrid |
createTiePointGrid(String gridName,
int gridWidth,
int gridHeight,
float offsetX,
float offsetY,
float subSamplingX,
float subSamplingY,
float[] tiePoints)
Creates a tie point grid from the given properties. |
protected int |
getGridDiscontinutity(String name)
Used by the createTiePointGrid method in order to determine
the discontinuity mode for angle tie-point grids. |
Object |
getInput()
Retrives the current output destination object. |
TreeNode<File> |
getProductComponents()
Retrieves a set of TreeNode objects that represent the physical product structure as stored on the harddrive. |
ProductReaderPlugIn |
getReaderPlugIn()
Returns the plug-in which created this product reader. |
ProductSubsetDef |
getSubsetDef()
Returns the subset information with which this data product is read from its physical source. |
protected boolean |
isInstanceOfValidInputType(Object input)
Checks if the given object is an instance of one of the valid input types for this product reader. |
boolean |
isMetadataIgnored()
Checks if this reader ignores metadata or not. |
boolean |
isNodeAccepted(String name)
Tests whether or not a product node (a band, a tie-point grid or metadata element) with the given name is accepted with respect to the optional spectral band subset. |
void |
readBandRasterData(Band destBand,
int destOffsetX,
int destOffsetY,
int destWidth,
int destHeight,
ProductData destBuffer,
com.bc.ceres.core.ProgressMonitor pm)
Reads raster data from the data source specified by the given destination band into the given in-memory buffer and region. |
protected abstract void |
readBandRasterDataImpl(int sourceOffsetX,
int sourceOffsetY,
int sourceWidth,
int sourceHeight,
int sourceStepX,
int sourceStepY,
Band destBand,
int destOffsetX,
int destOffsetY,
int destWidth,
int destHeight,
ProductData destBuffer,
com.bc.ceres.core.ProgressMonitor pm)
The template method which is called by the method after an optional spatial subset has been applied to the input parameters. |
Product |
readProductNodes(Object input,
ProductSubsetDef subsetDef)
Reads the nodes of a data product and returns an in-memory representation of it. |
protected abstract Product |
readProductNodesImpl()
Provides an implementation of the readProductNodes interface method. |
protected void |
setInput(Object input)
|
protected void |
setSubsetDef(ProductSubsetDef subsetDef)
Sets the subset information. |
String |
toString()
Returns a string representation of the reader. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractProductReader(ProductReaderPlugIn readerPlugIn)
readerPlugIn - the reader plug-in which created this reader, can be null for internal reader
implementations| Method Detail |
|---|
public ProductReaderPlugIn getReaderPlugIn()
getReaderPlugIn in interface ProductReadernullpublic Object getInput()
null if the
setInput() method has not been called so far.
getInput in interface ProductReaderprotected void setInput(Object input)
public boolean isMetadataIgnored()
true if sopublic ProductSubsetDef getSubsetDef()
getSubsetDef in interface ProductReadernullprotected void setSubsetDef(ProductSubsetDef subsetDef)
readProductNodes method.
subsetDef - the subset definitionpublic boolean isNodeAccepted(String name)
name - the node name
true if so
public Product readProductNodes(Object input,
ProductSubsetDef subsetDef)
throws IOException
The given subset info can be used to specify spatial and spectral portions of the original proudct. If the subset is omitted, the complete product is read in.
Whether the band data - the actual pixel values - is read in immediately or later when pixels are requested, is up to the implementation.
readProductNodes in interface ProductReaderinput - an object representing a valid output for this product reader, might be a
ImageInputStream or other Object to use for future decoding.subsetDef - a spectral or spatial subset (or both) of the product. If null, the entire product
is read in
IllegalArgumentException - if input type is not supported (see ProductReaderPlugIn.getInputTypes()).
IOException - if an I/O error occurs
IllegalFileFormatException - if the file format is unknown.
protected abstract Product readProductNodesImpl()
throws IOException
readProductNodes interface method. Clients implementing this
method can be sure that the input object and eventually the subset information has already been set.
This method is called as a last step in the readProductNodes(input, subsetInfo) method.
IOException - if an I/O error occurs
public void readBandRasterData(Band destBand,
int destOffsetX,
int destOffsetY,
int destWidth,
int destHeight,
ProductData destBuffer,
com.bc.ceres.core.ProgressMonitor pm)
throws IOException
For a complete description, please refer to the ProductReader.readBandRasterData(org.esa.beam.framework.datamodel.Band, int, int, int, int, org.esa.beam.framework.datamodel.ProductData, com.bc.ceres.core.ProgressMonitor) interface definition}
of this method.
The AbstractProductReader implements this method using the Template Method pattern. The
template method in this case is the abstract method to which the call is delegated after an optional spatial
subset given by getSubsetDef() has been applied to the input parameters.
readBandRasterData in interface ProductReaderdestBand - the destination band which identifies the data source from which to read the sample valuesdestOffsetX - the X-offset in the band's raster co-ordinatesdestOffsetY - the Y-offset in the band's raster co-ordinatesdestWidth - the width of region to be read given in the band's raster co-ordinatesdestHeight - the height of region to be read given in the band's raster co-ordinatesdestBuffer - the destination buffer which receives the sample values to be readpm - a monitor to inform the user about progress
IOException - if an I/O error occurs
IllegalArgumentException - if the number of elements destination buffer not equals destWidth *
destHeight or the destination region is out of the band's rasterreadBandRasterDataImpl(int, int, int, int, int, int, org.esa.beam.framework.datamodel.Band, int, int, int, int, org.esa.beam.framework.datamodel.ProductData, com.bc.ceres.core.ProgressMonitor),
getSubsetDef(),
ProductReader.readBandRasterData(org.esa.beam.framework.datamodel.Band, int, int, int, int, org.esa.beam.framework.datamodel.ProductData, com.bc.ceres.core.ProgressMonitor),
RasterDataNode.getRasterWidth(),
RasterDataNode.getRasterHeight()
protected abstract void readBandRasterDataImpl(int sourceOffsetX,
int sourceOffsetY,
int sourceWidth,
int sourceHeight,
int sourceStepX,
int sourceStepY,
Band destBand,
int destOffsetX,
int destOffsetY,
int destWidth,
int destHeight,
ProductData destBuffer,
com.bc.ceres.core.ProgressMonitor pm)
throws IOException
The destination band, buffer and region parameters are exactly the ones passed to the original call. Since
the destOffsetX and destOffsetY parameters are already taken into acount in the
sourceOffsetX and sourceOffsetY parameters, an implementor of this method is free to
ignore them.
sourceOffsetX - the absolute X-offset in source raster co-ordinatessourceOffsetY - the absolute Y-offset in source raster co-ordinatessourceWidth - the width of region providing samples to be read given in source raster co-ordinatessourceHeight - the height of region providing samples to be read given in source raster co-ordinatessourceStepX - the sub-sampling in X direction within the region providing samples to be readsourceStepY - the sub-sampling in Y direction within the region providing samples to be readdestBand - the destination band which identifies the data source from which to read the sample valuesdestOffsetX - the X-offset in the band's raster co-ordinatesdestOffsetY - the Y-offset in the band's raster co-ordinatesdestWidth - the width of region to be read given in the band's raster co-ordinatesdestHeight - the height of region to be read given in the band's raster co-ordinatesdestBuffer - the destination buffer which receives the sample values to be readpm - a monitor to inform the user about progress
IOException - if an I/O error occursreadBandRasterData(org.esa.beam.framework.datamodel.Band, int, int, int, int, org.esa.beam.framework.datamodel.ProductData, com.bc.ceres.core.ProgressMonitor),
getSubsetDef()
public void close()
throws IOException
This method should be called only if it is for sure that this object instance will never be used again. The
results of referencing an instance of this class after a call to close() are undefined.
Overrides of this method should always call super.close(); after disposing this instance.
close in interface ProductReaderIOException - if an I/O error occurspublic TreeNode<File> getProductComponents()
protected boolean isInstanceOfValidInputType(Object input)
input - the input object passed to readProductNodes(Object, ProductSubsetDef)
true if soProductReaderPlugIn.getInputTypes()protected int getGridDiscontinutity(String name)
createTiePointGrid method in order to determine
the discontinuity mode for angle tie-point grids.
The default implementation returns TiePointGrid.DISCONT_AT_180 for
the names "lon", "long" or "longitude" ignoring letter case,
TiePointGrid.DISCONT_NONE otherwise.
name - the grid name
TiePointGrid.DISCONT_NONE, TiePointGrid.DISCONT_AT_180 and TiePointGrid.DISCONT_AT_360.
protected TiePointGrid createTiePointGrid(String gridName,
int gridWidth,
int gridHeight,
float offsetX,
float offsetY,
float subSamplingX,
float subSamplingY,
float[] tiePoints)
The method uses the getGridDiscontinutity(String) method in order to
creater an appropriate angular tie-point grids.
gridName - the grid namegridWidth - the grid's raster widthgridHeight - the grid's raster heightoffsetX - the grid origin's X-coordinate in pixel unitsoffsetY - the grid origin's Y-coordinate in pixel unitssubSamplingX - the grid subsampling's X in pixel unitssubSamplingY - the grid subsampling's Y in pixel unitstiePoints - the tie-points
protected static void configurePreferredTileSize(Product product)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||