org.geotools.coverage.io
Class ExoreferencedGridCoverageReader

java.lang.Object
  extended byorg.geotools.coverage.io.AbstractGridCoverageReader
      extended byorg.geotools.coverage.io.ExoreferencedGridCoverageReader

public class ExoreferencedGridCoverageReader
extends AbstractGridCoverageReader

An implementation of AbstractGridCoverageReader using informations parsed by a MetadataBuilder object. This reader is typically used for format that stores pixel values and geographic metadata in separated files. For example, pixel values may be stored as a PNG images ou a RAW binary file, and geographic metadata (coordinate system, geographic location, etc.) may be stored in a separated text file. The text file is parsed by a MetadataBuilder object, while the pixel values are read by a ImageReader object.

Since:
2.2
Version:
$Id: ExoreferencedGridCoverageReader.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
protected  MetadataBuilder metadata
          The object to use for parsing the meta-data.
 
Fields inherited from class org.geotools.coverage.io.AbstractGridCoverageReader
formatName, reader
 
Constructor Summary
ExoreferencedGridCoverageReader(java.lang.String formatName, MetadataBuilder parser)
          Construct a new ExoreferencedGridCoverageReader using the specified MetadataBuilder.
ExoreferencedGridCoverageReader(java.lang.String formatName, java.lang.String extension, MetadataBuilder parser)
          Construct a new ExoreferencedGridCoverageReader using the specified MetadataBuilder.
 
Method Summary
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem(int index)
          Returns the coordinate system for the GridCoverage to be read.
 org.opengis.spatialschema.geometry.Envelope getEnvelope(int index)
          Returns the envelope for the GridCoverage to be read.
 org.opengis.coverage.grid.GridRange getGridRange(int index)
          Returns the grid range for the GridCoverage to be read.
 org.opengis.coverage.SampleDimension[] getSampleDimensions(int index)
          Returns the sample dimensions for each band of the GridCoverage to be read.
 void reset()
          Restores the AbstractGridCoverageReader to its initial state.
 void setInput(java.lang.Object input, boolean seekForwardOnly)
          Sets the input source to the given object.
 void setLocale(java.util.Locale locale)
          Sets the current Locale of this AbstractGridCoverageReader to the given value.
protected  java.lang.String toImageFileName(java.lang.String filename)
          Returns the filename for image data.
 
Methods inherited from class org.geotools.coverage.io.AbstractGridCoverageReader
getGridCoverage, getImageReaders, getLocale, getName, getNumImages
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metadata

protected MetadataBuilder metadata
The object to use for parsing the meta-data.

Constructor Detail

ExoreferencedGridCoverageReader

public ExoreferencedGridCoverageReader(java.lang.String formatName,
                                       MetadataBuilder parser)
Construct a new ExoreferencedGridCoverageReader using the specified MetadataBuilder.

Parameters:
formatName - The name for this format. This format name should be understood by ImageIO.getImageReadersByFormatName(String), unless AbstractGridCoverageReader.getImageReaders(java.lang.Object) is overriden.
parser - The MetadataBuilder to use for reading geographic metadata.

ExoreferencedGridCoverageReader

public ExoreferencedGridCoverageReader(java.lang.String formatName,
                                       java.lang.String extension,
                                       MetadataBuilder parser)
Construct a new ExoreferencedGridCoverageReader using the specified MetadataBuilder.

Parameters:
formatName - The name for this format. This format name should be understood by ImageIO.getImageReadersByFormatName(String), unless AbstractGridCoverageReader.getImageReaders(java.lang.Object) is overriden.
extension - Filename's extensions for file of this format.
parser - The MetadataBuilder to use for reading geographic metadata.
Method Detail

reset

public void reset()
           throws java.io.IOException
Restores the AbstractGridCoverageReader to its initial state.

Overrides:
reset in class AbstractGridCoverageReader
Throws:
java.io.IOException - if an error occurs while disposing resources.

setInput

public void setInput(java.lang.Object input,
                     boolean seekForwardOnly)
              throws java.io.IOException
Sets the input source to the given object. The input must be File or an URL object. The input source must be the metadata file or URL. The image file or URL will be derived from the metadata filename by a call to toImageFileName(java.lang.String), which may be overriden.

Overrides:
setInput in class AbstractGridCoverageReader
Parameters:
input - The File or URL to be read.
seekForwardOnly - if true, grid coverages and metadata may only be read in ascending order from the input source.
Throws:
java.io.IOException - if an I/O operation failed.
java.lang.IllegalArgumentException - if input is not an instance of a classe supported by this reader.

toImageFileName

protected java.lang.String toImageFileName(java.lang.String filename)
Returns the filename for image data. This method is invoked by setInput(java.lang.Object, boolean) after metadata has been loaded. Default implementation just replace the file extension by the extension argument specified to the constructor.

Parameters:
filename - The filename part of metadata file. This is the filename part of the file supplied by users to setInput(java.lang.Object, boolean).
Returns:
The filename to use for for the image file. The directory is assumed to be the same than the metadata file.

getCoordinateReferenceSystem

public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem(int index)
                                                                                   throws java.io.IOException
Returns the coordinate system for the GridCoverage to be read. The default implementation invokes metadata.getCoordinateReferenceSystem().

Specified by:
getCoordinateReferenceSystem in class AbstractGridCoverageReader
Parameters:
index - The index of the image to be queried.
Returns:
The coordinate system for the GridCoverage at the specified index.
Throws:
java.lang.IllegalStateException - if the input source has not been set.
java.lang.IndexOutOfBoundsException - if the supplied index is out of bounds.
java.io.IOException - if an error occurs reading the width information from the input source.

getEnvelope

public org.opengis.spatialschema.geometry.Envelope getEnvelope(int index)
                                                        throws java.io.IOException
Returns the envelope for the GridCoverage to be read. The default implementation invokes metadata.getEnvelope().

Specified by:
getEnvelope in class AbstractGridCoverageReader
Parameters:
index - The index of the image to be queried.
Returns:
The envelope for the GridCoverage at the specified index.
Throws:
java.lang.IllegalStateException - if the input source has not been set.
java.lang.IndexOutOfBoundsException - if the supplied index is out of bounds.
java.io.IOException - if an error occurs reading the width information from the input source.

getGridRange

public org.opengis.coverage.grid.GridRange getGridRange(int index)
                                                 throws java.io.IOException
Returns the grid range for the GridCoverage to be read. The default implementation try to invoke metadata.getGridRange(), and fallback to super.getGridRange(index) if the later fails.

Overrides:
getGridRange in class AbstractGridCoverageReader
Parameters:
index - The index of the image to be queried.
Returns:
The grid range for the GridCoverage at the specified index.
Throws:
java.lang.IllegalStateException - if the input source has not been set.
java.lang.IndexOutOfBoundsException - if the supplied index is out of bounds.
java.io.IOException - if an error occurs reading the width information from the input source.

getSampleDimensions

public org.opengis.coverage.SampleDimension[] getSampleDimensions(int index)
                                                           throws java.io.IOException
Returns the sample dimensions for each band of the GridCoverage to be read. If sample dimensions are not known, then this method returns null. The default implementation invokes metadata.getSampleDimensions().

Overrides:
getSampleDimensions in class AbstractGridCoverageReader
Parameters:
index - The index of the image to be queried.
Returns:
The category lists for the GridCoverage at the specified index. This array's length must be equals to the number of bands in GridCoverage.
Throws:
java.lang.IllegalStateException - if the input source has not been set.
java.lang.IndexOutOfBoundsException - if the supplied index is out of bounds.
java.io.IOException - if an error occurs reading the width information from the input source.

setLocale

public void setLocale(java.util.Locale locale)
Sets the current Locale of this AbstractGridCoverageReader to the given value. A value of null removes any previous setting, and indicates that the reader should localize as it sees fit.

Overrides:
setLocale in class AbstractGridCoverageReader


Copyright © GeoTools. All Rights Reserved.