org.geotools.coverage
Class TransformedCoverage

Object
  extended by PropertySourceImpl
      extended by AbstractCoverage
          extended by TransformedCoverage
All Implemented Interfaces:
Serializable, PropertySource, Coverage

public class TransformedCoverage
extends AbstractCoverage

A coverage wrapping an other one with a different coordinate reference system. The coordinate transformation is applied on the fly every time an evaluate method is invoked. It may be efficient if few points are queried, but become ineficient if a large amount of points is queried. In the later case, consider reprojecting the whole grid coverage instead.

Note: This class is not thread safe for performance reasons. If desired, users should create one instance of TransformedCoverage for each thread.

Since:
2.1
Author:
Martin Desruisseaux (IRD)
See Also:
Serialized Form
Module:
modules/library/coverage (gt-coverage.jar)

Nested Class Summary
 
Nested classes/interfaces inherited from class AbstractCoverage
AbstractCoverage.Renderable
 
Field Summary
protected  Coverage coverage
          The wrapped coverage.
 
Fields inherited from class AbstractCoverage
crs
 
Fields inherited from class PropertySourceImpl
cachedPropertyNames, properties, propertySources
 
Constructor Summary
protected TransformedCoverage(CharSequence name, CoordinateReferenceSystem crs, Coverage coverage)
          Creates a new coverage wrapping the specified one.
 
Method Summary
 Object evaluate(DirectPosition coord)
          Returns the value vector for a given point in the coverage.
 boolean[] evaluate(DirectPosition coord, boolean[] dest)
          Returns a sequence of boolean values for a given point in the coverage.
 byte[] evaluate(DirectPosition coord, byte[] dest)
          Returns a sequence of byte values for a given point in the coverage.
 double[] evaluate(DirectPosition coord, double[] dest)
          Returns a sequence of double values for a given point in the coverage.
 float[] evaluate(DirectPosition coord, float[] dest)
          Returns a sequence of float values for a given point in the coverage.
 int[] evaluate(DirectPosition coord, int[] dest)
          Returns a sequence of integer values for a given point in the coverage.
 Envelope getEnvelope()
          Returns the envelope.
 int getNumSampleDimensions()
          The number of sample dimensions in the coverage.
 SampleDimension getSampleDimension(int index)
          Retrieve sample dimension information for the coverage.
static Coverage reproject(CharSequence name, CoordinateReferenceSystem crs, Coverage coverage)
          Creates a new coverage wrapping the specified one with a different CRS.
 
Methods inherited from class AbstractCoverage
dispose, evaluate, evaluateInverse, find, find, getCommonPointRule, getCoordinateReferenceSystem, getDimension, getDomainElements, getDomainExtents, getLocale, getName, getRangeElements, getRangeType, getRenderableImage, getSources, list, select, show, show, show, toString
 
Methods inherited from class PropertySourceImpl
getProperties, getProperty, getPropertyClass, getPropertyNames, getPropertyNames
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

coverage

protected final Coverage coverage
The wrapped coverage.

Constructor Detail

TransformedCoverage

protected TransformedCoverage(CharSequence name,
                              CoordinateReferenceSystem crs,
                              Coverage coverage)
                       throws FactoryException
Creates a new coverage wrapping the specified one.

Parameters:
name - The name for this new coverage.
crs - The crs for this coverage.
coverage - The coverage to wraps.
Throws:
FactoryException - if no transformation can be found from the coverage CRS to the specified CRS.
Method Detail

reproject

public static Coverage reproject(CharSequence name,
                                 CoordinateReferenceSystem crs,
                                 Coverage coverage)
                          throws FactoryException
Creates a new coverage wrapping the specified one with a different CRS. If the specified coverage already uses the specified CRS (or an equivalent one), it is returned unchanged.

Parameters:
name - The name for this new coverage.
crs - The crs for this coverage.
coverage - The coverage to wraps.
Returns:
A coverage using the specified CRS.
Throws:
FactoryException - if no transformation can be found from the coverage CRS to the specified CRS.

getNumSampleDimensions

public int getNumSampleDimensions()
The number of sample dimensions in the coverage. For grid coverages, a sample dimension is a band.

Returns:
The number of sample dimensions in the coverage.

getSampleDimension

public SampleDimension getSampleDimension(int index)
                                   throws IndexOutOfBoundsException
Retrieve sample dimension information for the coverage.

Parameters:
index - Index for sample dimension to retrieve. Indices are numbered 0 to (n-1).
Returns:
Sample dimension information for the coverage.
Throws:
IndexOutOfBoundsException - if index is out of bounds.

getEnvelope

public Envelope getEnvelope()
Returns the envelope.

Specified by:
getEnvelope in interface Coverage
Overrides:
getEnvelope in class AbstractCoverage
Returns:
The bounding box for the coverage domain in coordinate system coordinates.

evaluate

public final Object evaluate(DirectPosition coord)
                      throws CannotEvaluateException
Returns the value vector for a given point in the coverage.

Parameters:
coord - The coordinate point where to evaluate.
Throws:
PointOutsideCoverageException - if coord is outside coverage.
CannotEvaluateException - if the computation failed for some other reason.

evaluate

public final boolean[] evaluate(DirectPosition coord,
                                boolean[] dest)
                         throws CannotEvaluateException
Returns a sequence of boolean values for a given point in the coverage.

Specified by:
evaluate in interface Coverage
Overrides:
evaluate in class AbstractCoverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or null to create a new array.
Returns:
The dest array, or a newly created array if dest was null.
Throws:
PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
CannotEvaluateException - if the values can't be computed at the specified coordinate for an other reason. It may be thrown if the coverage data type can't be converted to boolean by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

evaluate

public final byte[] evaluate(DirectPosition coord,
                             byte[] dest)
                      throws CannotEvaluateException
Returns a sequence of byte values for a given point in the coverage.

Specified by:
evaluate in interface Coverage
Overrides:
evaluate in class AbstractCoverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or null to create a new array.
Returns:
The dest array, or a newly created array if dest was null.
Throws:
PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
CannotEvaluateException - if the values can't be computed at the specified coordinate for an other reason. It may be thrown if the coverage data type can't be converted to byte by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

evaluate

public final int[] evaluate(DirectPosition coord,
                            int[] dest)
                     throws CannotEvaluateException
Returns a sequence of integer values for a given point in the coverage.

Specified by:
evaluate in interface Coverage
Overrides:
evaluate in class AbstractCoverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or null to create a new array.
Returns:
The dest array, or a newly created array if dest was null.
Throws:
PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
CannotEvaluateException - if the values can't be computed at the specified coordinate for an other reason. It may be thrown if the coverage data type can't be converted to int by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

evaluate

public final float[] evaluate(DirectPosition coord,
                              float[] dest)
                       throws CannotEvaluateException
Returns a sequence of float values for a given point in the coverage.

Specified by:
evaluate in interface Coverage
Overrides:
evaluate in class AbstractCoverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or null to create a new array.
Returns:
The dest array, or a newly created array if dest was null.
Throws:
PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
CannotEvaluateException - if the values can't be computed at the specified coordinate for an other reason. It may be thrown if the coverage data type can't be converted to float by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

evaluate

public final double[] evaluate(DirectPosition coord,
                               double[] dest)
                        throws CannotEvaluateException
Returns a sequence of double values for a given point in the coverage.

Specified by:
evaluate in interface Coverage
Overrides:
evaluate in class AbstractCoverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or null to create a new array.
Returns:
The dest array, or a newly created array if dest was null.
Throws:
PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
CannotEvaluateException - if the values can't be computed at the specified coordinate for an other reason. It may be thrown if the coverage data type can't be converted to double by an identity or widening conversion. Subclasses may relax this constraint if appropriate.


Copyright © 1996-2009 Geotools. All Rights Reserved.