org.geotools.coverage
Class TransformedCoverage

java.lang.Object
  extended by javax.media.jai.PropertySourceImpl
      extended by org.geotools.coverage.AbstractCoverage
          extended by org.geotools.coverage.TransformedCoverage
All Implemented Interfaces:
java.io.Serializable, javax.media.jai.PropertySource, org.opengis.coverage.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
Version:
$Id: TransformedCoverage.java 33885 2009-09-10 17:35:27Z simonegiannecchini $
Author:
Martin Desruisseaux (IRD)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.geotools.coverage.AbstractCoverage
AbstractCoverage.Renderable
 
Field Summary
protected  org.opengis.coverage.Coverage coverage
          The wrapped coverage.
 
Fields inherited from class org.geotools.coverage.AbstractCoverage
crs
 
Fields inherited from class javax.media.jai.PropertySourceImpl
cachedPropertyNames, properties, propertySources
 
Constructor Summary
protected TransformedCoverage(java.lang.CharSequence name, org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.coverage.Coverage coverage)
          Creates a new coverage wrapping the specified one.
 
Method Summary
 java.lang.Object evaluate(org.opengis.geometry.DirectPosition coord)
          Returns the value vector for a given point in the coverage.
 boolean[] evaluate(org.opengis.geometry.DirectPosition coord, boolean[] dest)
          Returns a sequence of boolean values for a given point in the coverage.
 byte[] evaluate(org.opengis.geometry.DirectPosition coord, byte[] dest)
          Returns a sequence of byte values for a given point in the coverage.
 double[] evaluate(org.opengis.geometry.DirectPosition coord, double[] dest)
          Returns a sequence of double values for a given point in the coverage.
 float[] evaluate(org.opengis.geometry.DirectPosition coord, float[] dest)
          Returns a sequence of float values for a given point in the coverage.
 int[] evaluate(org.opengis.geometry.DirectPosition coord, int[] dest)
          Returns a sequence of integer values for a given point in the coverage.
 org.opengis.geometry.Envelope getEnvelope()
          Returns the envelope.
 int getNumSampleDimensions()
          The number of sample dimensions in the coverage.
 org.opengis.coverage.SampleDimension getSampleDimension(int index)
          Retrieve sample dimension information for the coverage.
static org.opengis.coverage.Coverage reproject(java.lang.CharSequence name, org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.coverage.Coverage coverage)
          Creates a new coverage wrapping the specified one with a different CRS.
 
Methods inherited from class org.geotools.coverage.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 javax.media.jai.PropertySourceImpl
getProperties, getProperty, getPropertyClass, getPropertyNames, getPropertyNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

coverage

protected final org.opengis.coverage.Coverage coverage
The wrapped coverage.

Constructor Detail

TransformedCoverage

protected TransformedCoverage(java.lang.CharSequence name,
                              org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                              org.opengis.coverage.Coverage coverage)
                       throws org.opengis.referencing.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:
org.opengis.referencing.FactoryException - if no transformation can be found from the coverage CRS to the specified CRS.
Method Detail

reproject

public static org.opengis.coverage.Coverage reproject(java.lang.CharSequence name,
                                                      org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                                                      org.opengis.coverage.Coverage coverage)
                                               throws org.opengis.referencing.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:
org.opengis.referencing.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 org.opengis.coverage.SampleDimension getSampleDimension(int index)
                                                        throws java.lang.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:
java.lang.IndexOutOfBoundsException - if index is out of bounds.

getEnvelope

public org.opengis.geometry.Envelope getEnvelope()
Returns the envelope.

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

evaluate

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

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

evaluate

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

Specified by:
evaluate in interface org.opengis.coverage.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:
org.opengis.coverage.PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
org.opengis.coverage.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(org.opengis.geometry.DirectPosition coord,
                             byte[] dest)
                      throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of byte values for a given point in the coverage.

Specified by:
evaluate in interface org.opengis.coverage.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:
org.opengis.coverage.PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
org.opengis.coverage.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(org.opengis.geometry.DirectPosition coord,
                            int[] dest)
                     throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of integer values for a given point in the coverage.

Specified by:
evaluate in interface org.opengis.coverage.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:
org.opengis.coverage.PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
org.opengis.coverage.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(org.opengis.geometry.DirectPosition coord,
                              float[] dest)
                       throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of float values for a given point in the coverage.

Specified by:
evaluate in interface org.opengis.coverage.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:
org.opengis.coverage.PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
org.opengis.coverage.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(org.opengis.geometry.DirectPosition coord,
                               double[] dest)
                        throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of double values for a given point in the coverage.

Specified by:
evaluate in interface org.opengis.coverage.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:
org.opengis.coverage.PointOutsideCoverageException - if the evaluation failed because the input point has invalid coordinates.
org.opengis.coverage.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-2010 Geotools. All Rights Reserved.