|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractGridCoverage2DReader
public abstract class AbstractGridCoverage2DReader
This class is a first attempt for providing a way to get more informations out of a single 2D raster datasets (x,y). It is worth to remark that for the moment this is thought for 2D rasters not for 3D or 4D rasters (x,y,z,t).
The main drawback I see with the current GeoApi GridCoverageReader interface
is that there is no way to get real information about a raster source unless
you instantiate a GridCoverage. As an instance it is impossible to know the
envelope, the number of overviews, the tile size. This information is needed
in order to perform decimation on reading or to use built-in overviews
This really impacts the ability to exploit raster datasets in a desktop
environment where caching is crucial.
| Field Summary | |
|---|---|
protected boolean |
closeMe
Temp variable used in many readers. |
protected GridCoverageFactory |
coverageFactory
GridCoverageFactory instance. |
protected String |
coverageName
Coverage name |
protected CoordinateReferenceSystem |
crs
crs for this coverage |
static String |
ELEVATION_DOMAIN
Elevation domain (comma separated list of values) |
static String |
ELEVATION_DOMAIN_MAXIMUM
Elevation domain maximum value |
static String |
ELEVATION_DOMAIN_MINIMUM
Elevation domain minimum value |
static String |
ELEVATION_DOMAIN_RESOLUTION
Elevation domain resolution |
static double |
EPS
|
static String |
FILE_SOURCE_PROPERTY
If a coverage has this property is means it been read straight out of a file without any sub-setting, it means the coverage represents the full contents of the file. |
protected boolean |
gzipped
In case we are trying to read from a GZipped file this will be set to true. |
static String |
HAS_ELEVATION_DOMAIN
Whether the elevation is expressed as a full domain or min/max/resolution (true if domain list available) |
static String |
HAS_TIME_DOMAIN
If the time domain is available (or if a min/max/resolution approach has been chosen) |
protected double[] |
highestRes
Highest resolution availaible for this reader. |
protected Hints |
hints
Hints used by the AbstractGridCoverage2DReader subclasses. |
protected ImageInputStream |
inStream
Input stream that can be used to initialize subclasses of AbstractGridCoverage2DReader. |
protected ImageInputStreamSpi |
inStreamSPI
|
protected int |
numOverviews
This contains the number of overviews.aaa |
protected GeneralEnvelope |
originalEnvelope
Envelope read from file |
protected GridEnvelope |
originalGridRange
The original GridRange for the GridCoverage2D of this
reader. |
protected double[][] |
overViewResolutions
Resolutions avialaible through an overviews based mechanism. |
protected MathTransform |
raster2Model
2DGridToWorld math transform. |
protected Object |
source
Source to read from |
static String |
TIME_DOMAIN
The time domain (comma separated list of values) |
static String |
TIME_DOMAIN_MAXIMUM
The time domain max value |
static String |
TIME_DOMAIN_MINIMUM
The time domain min value |
static String |
TIME_DOMAIN_RESOLUTION
Time domain resolution (when using min/max/resolution) |
| Constructor Summary | |
|---|---|
protected |
AbstractGridCoverage2DReader()
Default protected constructor. |
|
AbstractGridCoverage2DReader(Object input)
Creates a new instance of a AIGReader. |
|
AbstractGridCoverage2DReader(Object input,
Hints hints)
Creates a new instance of a AIGReader. |
| Method Summary | |
|---|---|
protected GridCoverage |
createImageCoverage(PlanarImage image)
Creates a GridCoverage for the provided PlanarImage using
the originalEnvelope that was provided for this coverage. |
protected GridCoverage2D |
createImageCoverage(PlanarImage image,
MathTransform raster2Model)
Creates a GridCoverage for the provided PlanarImage using
the raster2Model that was provided for this coverage. |
protected void |
decimationOnReadingControl(Integer imageChoice,
ImageReadParam readP,
double[] requestedRes)
This method is responsible for evaluating possible subsampling factors once the best resolution level has been found, in case we have support for overviews, or starting from the original coverage in case there are no overviews available. |
void |
dispose()
Disposes this reader. |
protected void |
finalize()
Forcing disposal of this AbstractGridCoverage2DReader which may
keep an ImageInputStream open. |
CoordinateReferenceSystem |
getCrs()
Retrieves the CoordinateReferenceSystem for dataset pointed by
this AbstractGridCoverage2DReader. |
String |
getCurrentSubname()
Returns the name for the next grid coverage to be read from the input source. |
Set<ParameterDescriptor<List>> |
getDynamicParameters()
Return the set of dynamic parameterDescriptors (the ones related to domains) for this reader. |
int |
getGridCoverageCount()
|
ServiceInfo |
getInfo()
Information about this source. |
String[] |
getMetadataNames()
Returns the list of metadata keywords associated with the input source as a whole (not associated with any particular grid coverage). |
String |
getMetadataValue(String name)
Retrieve the metadata value for a given metadata name. |
GeneralEnvelope |
getOriginalEnvelope()
Retrieves the GeneralEnvelope for this
AbstractGridCoverage2DReader. |
GridEnvelope |
getOriginalGridRange()
Retrieves the GeneralGridEnvelope that represents the raster grid
dimensions of the highest resolution level in this dataset. |
MathTransform |
getOriginalGridToWorld(PixelInCell pixInCell)
Retrieves the original grid to world transformation for this AbstractGridCoverage2DReader. |
double[] |
getReadingResolutions(OverviewPolicy policy,
double[] requestedResolution)
Returns the actual resolution used to read the data given the specified target resolution and the specified overview policy |
protected static double[] |
getResolution(GeneralEnvelope envelope,
Rectangle2D dim,
CoordinateReferenceSystem crs)
This method is responsible for computing the resolutions in for the provided grid geometry in the provided crs. |
Object |
getSource()
Retrieves the source for this AbstractGridCoverage2DReader. |
boolean |
hasMoreGridCoverages()
Returns true if there is at least one more grid coverage
available on the stream. |
String[] |
listSubNames()
Retrieve the list of grid coverages contained within the input source. |
abstract GridCoverage2D |
read(GeneralParameterValue[] parameters)
Read the current grid coverage from the stream. |
protected Integer |
setReadParams(OverviewPolicy overviewPolicy,
ImageReadParam readP,
GeneralEnvelope requestedEnvelope,
Rectangle requestedDim)
This method is responsible for preparing the read param for doing an ImageReader.read(int, ImageReadParam). |
void |
skip()
Skip the current grid coverage without reading it, and move the stream position to the next grid coverage. |
| Methods inherited from class Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface GridCoverageReader |
|---|
getFormat |
| Field Detail |
|---|
public static final String TIME_DOMAIN
public static final String TIME_DOMAIN_RESOLUTION
public static final String HAS_TIME_DOMAIN
public static final String TIME_DOMAIN_MAXIMUM
public static final String TIME_DOMAIN_MINIMUM
public static final String HAS_ELEVATION_DOMAIN
public static final String ELEVATION_DOMAIN
public static final String ELEVATION_DOMAIN_MAXIMUM
public static final String ELEVATION_DOMAIN_MINIMUM
public static final String ELEVATION_DOMAIN_RESOLUTION
public static final String FILE_SOURCE_PROPERTY
public static final double EPS
protected int numOverviews
protected MathTransform raster2Model
protected CoordinateReferenceSystem crs
protected GeneralEnvelope originalEnvelope
protected String coverageName
protected Object source
protected Hints hints
AbstractGridCoverage2DReader subclasses.
protected double[] highestRes
protected boolean closeMe
protected boolean gzipped
protected GridEnvelope originalGridRange
GridRange for the GridCoverage2D of this
reader.
protected ImageInputStream inStream
AbstractGridCoverage2DReader.
protected double[][] overViewResolutions
protected GridCoverageFactory coverageFactory
GridCoverageFactory instance.
protected ImageInputStreamSpi inStreamSPI
| Constructor Detail |
|---|
protected AbstractGridCoverage2DReader()
public AbstractGridCoverage2DReader(Object input)
throws DataSourceException
AIGReader. I assume nothing about file extension.
input - Source object for which we want to build an AIGReader.
DataSourceException
public AbstractGridCoverage2DReader(Object input,
Hints hints)
throws DataSourceException
AIGReader. I assume nothing about file extension.
input - Source object for which we want to build an AIGReader.hints - Hints to be used by this reader throughout his life.
DataSourceException| Method Detail |
|---|
public abstract GridCoverage2D read(GeneralParameterValue[] parameters)
throws IllegalArgumentException,
IOException
Example:
The method hasMoreGridCoverages() should be invoked first in order to verify that a
coverage is available.
read in interface GridCoverageReaderparameters - Optional parameters matching Format.getReadParameters().
InvalidParameterNameException - if a parameter in parameters doesn't have a recognized name.
InvalidParameterValueException - if a parameter in parameters doesn't have a valid value.
ParameterNotFoundException - if a parameter was required for the operation but was not provided in the parameters list.
CannotCreateGridCoverageException - if the coverage can't be created for a logical reason (for example an unsupported
format, or an inconsistency found in the data).
IOException - if a read operation failed for some other input/output reason, including
FileNotFoundException if no file with the given name can be
found, or IIOException if an error was thrown by the
underlying image library.
IllegalArgumentException
protected Integer setReadParams(OverviewPolicy overviewPolicy,
ImageReadParam readP,
GeneralEnvelope requestedEnvelope,
Rectangle requestedDim)
throws IOException,
TransformException
ImageReader.read(int, ImageReadParam).
This method is responsible for preparing the read param for doing an
ImageReader.read(int, ImageReadParam). It sets the passed
ImageReadParam in terms of decimation on reading using the
provided requestedEnvelope and requestedDim to evaluate the needed
resolution. It also returns and Integer representing the index of
the raster to be read when dealing with multipage raster.
overviewPolicy - it can be one of Hints#VALUE_OVERVIEW_POLICY_IGNORE,
Hints#VALUE_OVERVIEW_POLICY_NEAREST,
Hints#VALUE_OVERVIEW_POLICY_QUALITY or
Hints#VALUE_OVERVIEW_POLICY_SPEED. It specifies the
policy to compute the overviews level upon request.readP - an instance of ImageReadParam for setting the
subsampling factors.requestedEnvelope - the GeneralEnvelope we are requesting.requestedDim - the requested dimensions.
IOException
TransformException
public double[] getReadingResolutions(OverviewPolicy policy,
double[] requestedResolution)
policy - resolutions -
protected final void decimationOnReadingControl(Integer imageChoice,
ImageReadParam readP,
double[] requestedRes)
imageChoice - readP - requestedRes -
protected final GridCoverage createImageCoverage(PlanarImage image)
throws IOException
GridCoverage for the provided PlanarImage using
the originalEnvelope that was provided for this coverage.
image - contains the data for the coverage to create.
GridCoverage
IOException
protected final GridCoverage2D createImageCoverage(PlanarImage image,
MathTransform raster2Model)
throws IOException
GridCoverage for the provided PlanarImage using
the raster2Model that was provided for this coverage.
This method is vital when working with coverages that have a raster to model transformation that is not a simple scale and translate.
image - contains the data for the coverage to create.raster2Model - is the MathTransform that maps from the raster space
to the model space.
GridCoverage
IOException
protected static final double[] getResolution(GeneralEnvelope envelope,
Rectangle2D dim,
CoordinateReferenceSystem crs)
throws DataSourceException
It is worth to note that the returned resolution array is of length of 2
and it always is lon, lat for the moment.
It might be worth to remove the axes reordering code when we are
confident enough with the code to handle the north-up crs.
TODO use orthodromic distance?
envelope - the GeneralEnvelopedim - crs -
DataSourceExceptionpublic final CoordinateReferenceSystem getCrs()
CoordinateReferenceSystem for dataset pointed by
this AbstractGridCoverage2DReader.
CoordinateReferenceSystem for dataset pointed by this
AbstractGridCoverage2DReader.public final GridEnvelope getOriginalGridRange()
GeneralGridEnvelope that represents the raster grid
dimensions of the highest resolution level in this dataset.
GeneralGridEnvelope that represents the raster grid
dimensions of the highest resolution level in this dataset.public final GeneralEnvelope getOriginalEnvelope()
GeneralEnvelope for this
AbstractGridCoverage2DReader.
GeneralEnvelope for this
AbstractGridCoverage2DReader.public final MathTransform getOriginalGridToWorld(PixelInCell pixInCell)
AbstractGridCoverage2DReader.
pixInCell - specifies the datum of the transformation we want.
AbstractGridCoverage2DReader.public final Object getSource()
AbstractGridCoverage2DReader.
getSource in interface GridCoverageReaderAbstractGridCoverage2DReader.public void dispose()
This method just tries to close the underlying ImageInputStream.
dispose in interface GridCoverageReaderpublic void skip()
GridCoverageReader
skip in interface GridCoverageReaderGridCoverageReader.skip()public boolean hasMoreGridCoverages()
GridCoverageReadertrue if there is at least one more grid coverage
available on the stream.
hasMoreGridCoverages in interface GridCoverageReaderGridCoverageReader.hasMoreGridCoverages()public String[] listSubNames()
GridCoverageReader
listSubNames in interface GridCoverageReaderGridCoverageReader.listSubNames()public String getCurrentSubname()
GridCoverageReader
getCurrentSubname in interface GridCoverageReaderGridCoverageReader.getCurrentSubname()public String[] getMetadataNames()
GridCoverageReader
getMetadataNames in interface GridCoverageReaderGridCoverageReader.getMetadataNames()public String getMetadataValue(String name)
GridCoverageReader
getMetadataValue in interface GridCoverageReadername - Metadata keyword for which to retrieve metadata.
GridCoverageReader.getMetadataNames().GridCoverageReader.getMetadataValue(java.lang.String)public int getGridCoverageCount()
org.opengis.coverage.grid.GridCoverageReader#getGridCoverageCount()public ServiceInfo getInfo()
Subclasses should provide additional format specific information.
protected void finalize()
throws Throwable
AbstractGridCoverage2DReader which may
keep an ImageInputStream open.
finalize in class ObjectThrowablepublic Set<ParameterDescriptor<List>> getDynamicParameters()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||