org.geotools.coverage
Class AbstractCoverage

java.lang.Object
  extended byjavax.media.jai.PropertySourceImpl
      extended byorg.geotools.coverage.AbstractCoverage
All Implemented Interfaces:
org.opengis.coverage.Coverage, javax.media.jai.PropertySource, java.io.Serializable
Direct Known Subclasses:
AbstractGridCoverage, CoverageStack, SpatioTemporalCoverage3D, TransformedCoverage

public abstract class AbstractCoverage
extends javax.media.jai.PropertySourceImpl
implements org.opengis.coverage.Coverage

Base class of all coverage type. The essential property of coverage is to be able to generate a value for any point within its domain. How coverage is represented internally is not a concern. For example consider the following different internal representations of coverage:

Grid coverages are typically 2D while other coverages may be 3D or 4D. The dimension of grid coverage may be queried in many ways: All those methods should returns the same number. Note that the dimension of grid coverage is not the same than the number of sample dimensions. The later may be better understood as the number of bands for 2D grid coverage.

Since:
2.1
Version:
$Id: AbstractCoverage.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Serialized Form

Nested Class Summary
protected  class AbstractCoverage.Renderable
          A view of a coverage as a renderable image.
 
Field Summary
protected  org.opengis.referencing.crs.CoordinateReferenceSystem crs
          The coordinate reference system, or if there is none.
 
Fields inherited from class javax.media.jai.PropertySourceImpl
cachedPropertyNames, properties, propertySources
 
Constructor Summary
protected AbstractCoverage(java.lang.CharSequence name, org.opengis.referencing.crs.CoordinateReferenceSystem crs, javax.media.jai.PropertySource source, java.util.Map properties)
          Constructs a coverage using the specified coordinate reference system.
protected AbstractCoverage(java.lang.CharSequence name, org.opengis.coverage.Coverage coverage)
          Constructs a new coverage with the same parameters than the specified coverage.
 
Method Summary
 void dispose()
          Provides a hint that a coverage will no longer be accessed from a reference in user space.
 boolean[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord, boolean[] dest)
          Returns a sequence of boolean values for a given point in the coverage.
 byte[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord, byte[] dest)
          Returns a sequence of byte values for a given point in the coverage.
 double[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord, double[] dest)
          Returns a sequence of double values for a given point in the coverage.
 float[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord, float[] dest)
          Returns a sequence of float values for a given point in the coverage.
 int[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord, int[] dest)
          Returns a sequence of integer values for a given point in the coverage.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
          Returns the coordinate reference system.
 int getDimension()
          Returns the dimension of the grid coverage.
 org.opengis.util.InternationalString[] getDimensionNames()
          Returns the names of each dimension in this coverage.
 java.lang.String[] getDimensionNames(java.util.Locale locale)
          Deprecated. Replaced by getDimensionNames().
 org.opengis.spatialschema.geometry.Envelope getEnvelope()
          Returns the bounding box for the coverage domain in coordinate reference system coordinates.
 java.util.Locale getLocale()
          Returns the default locale for logging, error messages, etc.
 java.lang.String[] getMetadataNames()
          List of metadata keywords for a coverage.
 java.lang.String getMetadataValue(java.lang.String name)
          Retrieve the metadata value for a given metadata name.
 org.opengis.util.InternationalString getName()
          Returns the coverage name.
 java.awt.image.renderable.RenderableImage getRenderableImage(int xAxis, int yAxis)
          Returns 2D view of this grid coverage as a renderable image.
 java.util.List getSources()
          Returns the source data for a coverage.
 void show()
          Display this coverage in a windows.
 void show(int xAxis, int yAxis)
          Display this coverage in a windows.
 java.lang.String toString()
          Returns a string repr?sentation of this coverage.
 
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
 
Methods inherited from interface org.opengis.coverage.Coverage
evaluate, getNumSampleDimensions, getSampleDimension
 

Field Detail

crs

protected final org.opengis.referencing.crs.CoordinateReferenceSystem crs
The coordinate reference system, or if there is none.

Constructor Detail

AbstractCoverage

protected AbstractCoverage(java.lang.CharSequence name,
                           org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                           javax.media.jai.PropertySource source,
                           java.util.Map properties)
Constructs a coverage using the specified coordinate reference system. If the coordinate reference system is , then the subclasses must override getDimension().

Parameters:
name - The coverage name.
crs - The coordinate reference system. This specifies the coordinate system used when accessing a coverage or grid coverage with the methods.
source - The source for this coverage, or if none. Source may be (but is not limited to) a PlanarImage or an other object.
properties - The set of properties for this coverage, or if there is none. "Properties" in Java Advanced Imaging is what OpenGIS calls "Metadata". Keys are String objects (CaselessStringKey are accepted as well), while values may be any Object.

AbstractCoverage

protected AbstractCoverage(java.lang.CharSequence name,
                           org.opengis.coverage.Coverage coverage)
Constructs a new coverage with the same parameters than the specified coverage. Note: This constructor keeps a strong reference to the source coverage (through PropertySourceImpl). In many cases, it is not a problem since GridCoverage will retains a strong reference to its source anyway.

Parameters:
name - The name for this coverage, or for the same than .
coverage - The source coverage.
Method Detail

getName

public org.opengis.util.InternationalString getName()
Returns the coverage name. The default implementation returns the name specified at construction time.


getSources

public java.util.List getSources()
Returns the source data for a coverage. The default implementation returns an empty list.

Specified by:
getSources in interface org.opengis.coverage.Coverage

getCoordinateReferenceSystem

public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
Returns the coordinate reference system. This specifies the CRS used when accessing a coverage or grid coverage with the methods. It is also the coordinate reference system of the coordinates used with the math transform GridGeometry.getGridToCoordinateSystem(). A grid coverage can be accessed (re-projected) with new coordinate reference system with the GridCoverageProcessor component. In this case, a new instance of a grid coverage is created.

Note: If a coverage does not have an associated coordinate reference system, the returned value will be . The GridGeometry.getGridToCoordinateSystem()) attribute should also be if the coordinate reference system is .

Specified by:
getCoordinateReferenceSystem in interface org.opengis.coverage.Coverage
Returns:
The coordinate reference system, or if this coverage does not have an associated CRS.
See Also:
GridGeometry.getGridToCoordinateSystem()

getEnvelope

public org.opengis.spatialschema.geometry.Envelope getEnvelope()
Returns the bounding box for the coverage domain in coordinate reference system coordinates. May be null if this coverage has no associated coordinate reference system. For grid coverages, the grid cells are centered on each grid coordinate. The envelope for a 2-D grid coverage includes the following corner positions.
 (Minimum row - 0.5, Minimum column - 0.5) for the minimum coordinates
 (Maximum row - 0.5, Maximum column - 0.5) for the maximum coordinates
 
The default implementation returns the domain of validity of the CRS, if there is one.

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

getDimension

public int getDimension()
Returns the dimension of the grid coverage. The default implementation returns the dimension of the underlying coordinate reference system.

Returns:
The number of dimensions of this coverage.

getDimensionNames

public org.opengis.util.InternationalString[] getDimensionNames()
Returns the names of each dimension in this coverage. Typically these names are "x", "y", "z" and "t". The number of items in the sequence is the number of dimensions in the coverage. Grid coverages are typically 2D (x, y) while other coverages may be 3D (x, y, z) or 4D (x, y, z, t). The number of dimensions of the coverage is the number of entries in the list of dimension names. The default implementation ask for coordinate system axis names, or returns "x", "y"... if this coverage has no CRS.

Specified by:
getDimensionNames in interface org.opengis.coverage.Coverage
Returns:
The names of each dimension. The array's length is equals to getDimension().

getDimensionNames

public final java.lang.String[] getDimensionNames(java.util.Locale locale)
Deprecated. Replaced by getDimensionNames().

Returns the names of each dimension in this coverage.


evaluate

public boolean[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord,
                          boolean[] dest)
                   throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of boolean values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor. The CRS of the point is the same as the grid coverage coordinate reference system.

Specified by:
evaluate in interface org.opengis.coverage.Coverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or to create a new array.
Returns:
The array, or a newly created array if was null.
Throws:
org.opengis.coverage.CannotEvaluateException - if the values can't be computed at the specified coordinate. More specifically, PointOutsideCoverageException is thrown if the evaluation failed because the input point has invalid coordinates. This exception may also be throws if the coverage data type can't be converted to by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

evaluate

public byte[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord,
                       byte[] dest)
                throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of byte values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor. The CRS of the point is the same as the coverage coordinate reference system.

Specified by:
evaluate in interface org.opengis.coverage.Coverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or to create a new array.
Returns:
The array, or a newly created array if was null.
Throws:
org.opengis.coverage.CannotEvaluateException - if the values can't be computed at the specified coordinate. More specifically, PointOutsideCoverageException is thrown if the evaluation failed because the input point has invalid coordinates. This exception may also be throws if the coverage data type can't be converted to by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

evaluate

public int[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord,
                      int[] dest)
               throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of integer values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor. The CRS of the point is the same as the coverage coordinate reference system.

Specified by:
evaluate in interface org.opengis.coverage.Coverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or to create a new array.
Returns:
The array, or a newly created array if was null.
Throws:
org.opengis.coverage.CannotEvaluateException - if the values can't be computed at the specified coordinate. More specifically, PointOutsideCoverageException is thrown if the evaluation failed because the input point has invalid coordinates. This exception may also be throws if the coverage data type can't be converted to by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

evaluate

public float[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord,
                        float[] dest)
                 throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of float values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor. The CRS of the point is the same as the coverage coordinate reference system.

Specified by:
evaluate in interface org.opengis.coverage.Coverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or to create a new array.
Returns:
The array, or a newly created array if was null.
Throws:
org.opengis.coverage.CannotEvaluateException - if the values can't be computed at the specified coordinate. More specifically, PointOutsideCoverageException is thrown if the evaluation failed because the input point has invalid coordinates. This exception may also be throws if the coverage data type can't be converted to by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

evaluate

public double[] evaluate(org.opengis.spatialschema.geometry.DirectPosition coord,
                         double[] dest)
                  throws org.opengis.coverage.CannotEvaluateException
Returns a sequence of double values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor. The CRS of the point is the same as the grid coverage coordinate system.

Specified by:
evaluate in interface org.opengis.coverage.Coverage
Parameters:
coord - The coordinate point where to evaluate.
dest - An array in which to store values, or to create a new array.
Returns:
The array, or a newly created array if was null.
Throws:
org.opengis.coverage.CannotEvaluateException - if the values can't be computed at the specified coordinate. More specifically, PointOutsideCoverageException is thrown if the evaluation failed because the input point has invalid coordinates. This exception may also be throws if the coverage data type can't be converted to by an identity or widening conversion. Subclasses may relax this constraint if appropriate.

getRenderableImage

public java.awt.image.renderable.RenderableImage getRenderableImage(int xAxis,
                                                                    int yAxis)
Returns 2D view of this grid coverage as a renderable image. This method allows interoperability with Java2D.

Specified by:
getRenderableImage in interface org.opengis.coverage.Coverage
Parameters:
xAxis - Dimension to use for the x display axis.
yAxis - Dimension to use for the y display axis.
Returns:
A 2D view of this grid coverage as a renderable image.

show

public void show(int xAxis,
                 int yAxis)
Display this coverage in a windows. This convenience method is used for debugging purpose. The exact appareance of the windows and the tools provided may changes in future versions.

Parameters:
xAxis - Dimension to use for the x display axis.
yAxis - Dimension to use for the y display axis.

show

public void show()
Display this coverage in a windows. This convenience method is used for debugging purpose. The exact appareance of the windows and the tools provided may changes in future versions.


getMetadataNames

public java.lang.String[] getMetadataNames()
List of metadata keywords for a coverage. If no metadata is available, the sequence will be empty. The default implementation gets the list of metadata names from the PropertySourceImpl.getPropertyNames() method.

Specified by:
getMetadataNames in interface org.opengis.coverage.Coverage
Returns:
the list of metadata keywords for a coverage.

getMetadataValue

public java.lang.String getMetadataValue(java.lang.String name)
                                  throws org.opengis.coverage.MetadataNameNotFoundException
Retrieve the metadata value for a given metadata name. The default implementation query the PropertySourceImpl.getProperty(String) method.

Specified by:
getMetadataValue in interface org.opengis.coverage.Coverage
Parameters:
name - Metadata keyword for which to retrieve data.
Returns:
the metadata value for a given metadata name.
Throws:
org.opengis.coverage.MetadataNameNotFoundException - if there is no value for the specified metadata name.

getLocale

public java.util.Locale getLocale()
Returns the default locale for logging, error messages, etc..


dispose

public void dispose()
Provides a hint that a coverage will no longer be accessed from a reference in user space. The results are equivalent to those that occur when the program loses its last reference to this coverage, the garbage collector discovers this, and finalize is called. This can be used as a hint in situations where waiting for garbage collection would be overly conservative. The results of referencing a coverage after a call to are undefined.

See Also:
PlanarImage.dispose()

toString

public java.lang.String toString()
Returns a string repr?sentation of this coverage. This string is for debugging purpose only and may change in future version.



Copyright © GeoTools. All Rights Reserved.