org.geotools.coverage.io
Interface GridCoverageReader

All Known Implementing Classes:
AbstractGridCoverageReader, ExoreferencedGridCoverageReader

public interface GridCoverageReader

Interface for reading GridCoverage objects. Reading is a two steps process: The input file must be set first, then the actual reading is performed with the getGridCoverage(int). Example:

 GridCoverageReader reader = ...
 reader.setInput(new File("MyCoverage.dat"), true);
 GridCoverage coverage = reader.getGridCoverage(0);
 

Since:
2.4
Version:
$Id: GridCoverageReader.java 33009 2009-05-14 19:40:06Z simonegiannecchini $
Author:
Martin Desruisseaux (IRD)

Method Summary
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem(int index)
          Returns the coordinate reference system for the GridCoverage to be read.
 org.opengis.geometry.Envelope getEnvelope(int index)
          Returns the envelope for the GridCoverage to be read.
 org.opengis.coverage.grid.GridCoverage getGridCoverage(int index)
          Reads the grid coverage.
 org.opengis.coverage.grid.GridEnvelope getGridRange(int index)
          Returns the grid range for the GridCoverage to be read.
 org.opengis.referencing.operation.MathTransform getMathTransform(int index)
          Returns the transform from grid range to CRS coordinates.
 java.lang.String getName(int index)
          Gets the GridCoverage name at the specified index.
 int getNumImages(boolean allowSearch)
          Returns the number of images available from the current input source.
 GridSampleDimension[] getSampleDimensions(int index)
          Returns the sample dimensions for each band of the GridCoverage to be read.
 void reset()
          Restores the GridCoverageReader to its initial state.
 void setInput(java.lang.Object input, boolean seekForwardOnly)
          Sets the input source to the given object.
 

Method Detail

setInput

void setInput(java.lang.Object input,
              boolean seekForwardOnly)
              throws java.io.IOException
Sets the input source to the given object. The input is usually a File or an URL object. But some other types (e.g. ImageInputStream) may be accepted as well.

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 a valid instance.

getNumImages

int getNumImages(boolean allowSearch)
                 throws java.io.IOException
Returns the number of images available from the current input source. Note that some image formats do not specify how many images are present in the stream. Thus determining the number of images will require the entire stream to be scanned and may require memory for buffering. The allowSearch parameter may be set to false to indicate that an exhaustive search is not desired.

Parameters:
allowSearch - If true, the true number of images will be returned even if a search is required. If false, the reader may return -1 without performing the search.
Returns:
The number of images, or -1 if allowSearch is false and a search would be required.
Throws:
java.lang.IllegalStateException - If the input source has not been set, or if the input has been specified with seekForwardOnly set to true.
java.io.IOException - If an error occurs reading the information from the input source.

getName

java.lang.String getName(int index)
                         throws java.io.IOException
Gets the GridCoverage name at the specified index.

Parameters:
index - The index of the image to be queried.
Returns:
The name 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 information from the input source.

getCoordinateReferenceSystem

org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem(int index)
                                                                                   throws java.io.IOException
Returns the coordinate reference system for the GridCoverage to be read.

Parameters:
index - The index of the image to be queried.
Returns:
The coordinate reference 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

org.opengis.geometry.Envelope getEnvelope(int index)
                                          throws java.io.IOException
Returns the envelope for the GridCoverage to be read. The envelope must have the same number of dimensions than the coordinate reference system.

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

org.opengis.coverage.grid.GridEnvelope getGridRange(int index)
                                                    throws java.io.IOException
Returns the grid range for the GridCoverage to be read. The grid range must have the same number of dimensions than the envelope.

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.

getMathTransform

org.opengis.referencing.operation.MathTransform getMathTransform(int index)
                                                                 throws java.io.IOException
Returns the transform from grid range to CRS coordinates.

Throws:
java.io.IOException

getSampleDimensions

GridSampleDimension[] 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.

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.

getGridCoverage

org.opengis.coverage.grid.GridCoverage getGridCoverage(int index)
                                                       throws java.io.IOException
Reads the grid coverage.

Parameters:
index - The index of the image to be queried.
Returns:
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.

reset

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

Throws:
java.io.IOException - if an error occurs while disposing resources.


Copyright © 1996-2010 Geotools. All Rights Reserved.