org.geotools.coverage.io
Class MetadataReader

java.lang.Object
  extended by org.geotools.coverage.io.MetadataReader

public class MetadataReader
extends java.lang.Object

Helper class for creating OpenGIS's object from a set of metadata.

Metadata are already stored into a geographic metadata object, which provides a representation of these metadata as a tree, trying to respect the GML in JPEG 2000 standard.

It provides a set of getXXX() methods for constructing various objects from those information. For example, the getCoordinateReferenceSystem() method constructs a CoordinateReferenceSystem object using available information.

Since:
2.2
Version:
$Id: MetadataReader.java 31486 2008-09-09 20:46:25Z desruisseaux $
Author:
Martin Desruisseaux (IRD), Cédric Briançon

Constructor Summary
MetadataReader()
          Constructs a new MetadataReader using default factories and geographic metadata.
MetadataReader(ReferencingFactoryContainer factories)
          Constructs a new MetadataReader using the specified factories.
 
Method Summary
 org.opengis.referencing.cs.CoordinateSystemAxis getAxis(int dimension)
          Constructs an axis using the information from the metadata, or returns null if the axis does not exist in the metadata tree.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
          Returns the coordinate reference system.
 org.opengis.referencing.cs.CoordinateSystem getCoordinateSystem()
          Returns the coordinate system.
 org.opengis.referencing.datum.Datum getDatum()
          Returns the datum.
 org.opengis.referencing.datum.Ellipsoid getEllipsoid()
          Returns the ellipsoid.
 org.opengis.geometry.Envelope getEnvelope()
          Returns the envelope.
 org.opengis.metadata.extent.GeographicBoundingBox getGeographicBoundingBox()
          Convenience method returning the envelope in geographic coordinate reference system.
 GeographicMetadata getGeographicMetadata()
          Returns the current geographic metadata, or null if not already defined.
 org.opengis.coverage.grid.GridEnvelope getGridRange()
          Returns the grid range.
 org.opengis.referencing.operation.Conversion getProjection()
          Returns the projection.
 void setGeographicMetadata(GeographicMetadata metadata)
          Sets the current geographic metadata.
 java.lang.String toString()
          Returns a string representation of this metadata set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetadataReader

public MetadataReader()
Constructs a new MetadataReader using default factories and geographic metadata. Do not forget to call setGeographicMetadata(GeographicMetadata) in order to fix the metadata value.


MetadataReader

public MetadataReader(ReferencingFactoryContainer factories)
Constructs a new MetadataReader using the specified factories. Do not forget to call setGeographicMetadata(org.geotools.image.io.metadata.GeographicMetadata) in order to fix the metadata value.

Parameters:
factories - The specified factories. Should not be null.
Method Detail

getAxis

public org.opengis.referencing.cs.CoordinateSystemAxis getAxis(int dimension)
                                                        throws MetadataException
Constructs an axis using the information from the metadata, or returns null if the axis does not exist in the metadata tree.

Parameters:
dimension - The dimension to consider. It should be lower than ImageGeometry.getDimension()
Returns:
An axis with information gotten from the metadata, or null if the axis does not exist for the specified dimension.
Throws:
MetadataException - if the method CSFactory.createCoordinateSystemAxis(java.util.Map, java.lang.String, org.opengis.referencing.cs.AxisDirection, javax.measure.unit.Unit) has not succeed.

getDatum

public org.opengis.referencing.datum.Datum getDatum()
                                             throws MetadataException
Returns the datum. The default implementation performs the following steps:

Throws:
MetadataException - if the datum is not defined, or if the getEllipsoid() method fails.
See Also:
getEllipsoid()

getEllipsoid

public org.opengis.referencing.datum.Ellipsoid getEllipsoid()
                                                     throws MetadataException
Returns the ellipsoid. Depending on whether ImageReferencing.semiMinorAxis or ImageReferencing.inverseFlattening has been defined, the default implementation will construct an ellispoid using DatumFactory.createEllipsoid(java.util.Map, double, double, javax.measure.unit.Unit) or DatumFactory.createFlattenedSphere(java.util.Map, double, double, javax.measure.unit.Unit) respectively.

Throws:
MetadataException - if the operation failed to create the ellipsoid.
See Also:
getUnit(String)

getProjection

public org.opengis.referencing.operation.Conversion getProjection()
                                                           throws MetadataException
Returns the projection. The default implementation performs the following steps:

Returns:
The projection.
Throws:
MetadataException - if the operation failed for some other reason (for example if a parameter value can't be parsed as a double).
See Also:
TextMetadataParser.SEMI_MAJOR, TextMetadataParser.SEMI_MINOR, TextMetadataParser.INVERSE_FLATTENING, TextMetadataParser.LATITUDE_OF_ORIGIN, TextMetadataParser.CENTRAL_MERIDIAN, TextMetadataParser.FALSE_EASTING, TextMetadataParser.FALSE_NORTHING

getCoordinateReferenceSystem

public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
                                                                                   throws MetadataException
Returns the coordinate reference system. The default implementation builds a coordinate reference system using the datum and the coordinate system defined in the metadata.

Throws:
MetadataException - if the creation of the coordinate reference system fails.
See Also:
getDatum(), getCoordinateSystem(), CoordinateReferenceSystem

getCoordinateSystem

public org.opengis.referencing.cs.CoordinateSystem getCoordinateSystem()
                                                                throws MetadataException
Returns the coordinate system. The default implementation builds a coordinate system using the axes defined in the metadata.

Throws:
MetadataException - if there is less than 2 axes defined in the metadata, or if the creation of the coordinate system failed.
See Also:
getAxis(int), CoordinateSystem

getEnvelope

public org.opengis.geometry.Envelope getEnvelope()
                                          throws MetadataException
Returns the envelope. The default implementation constructs an envelope using the values from the metadata tree

Throws:
MetadataException - if the dimension specified for the envelope is illegal

getGeographicBoundingBox

public org.opengis.metadata.extent.GeographicBoundingBox getGeographicBoundingBox()
                                                                           throws MetadataException
Convenience method returning the envelope in geographic coordinate reference system. Note that the geographic CRS doesn't need to use the 1984 datum, since geographic bounding boxes are approximative.

Throws:
MetadataException - if the operation failed. This exception may contains a TransformException as its cause.
See Also:
getEnvelope()

getGeographicMetadata

public GeographicMetadata getGeographicMetadata()
Returns the current geographic metadata, or null if not already defined.


setGeographicMetadata

public void setGeographicMetadata(GeographicMetadata metadata)
Sets the current geographic metadata. It should be called before using a getter of this class.


getGridRange

public org.opengis.coverage.grid.GridEnvelope getGridRange()
                                                    throws MetadataException
Returns the grid range. Default implementation fetchs the metadata values for nodes ImageGeometry.low and ImageGeometry.high, and transform the resulting strings into a grid range object.

Throws:
MissingMetadataException - if a required value is missing.
MetadataException - if the operation failed for some other reason.
See Also:
ImageGeometry.getGridRange(int)

toString

public java.lang.String toString()
Returns a string representation of this metadata set. The default implementation write the class name and the envelope in geographic coordinates, as returned by getGeographicBoundingBox(). Then, it append the list of all metadata as formatted by GeographicMetadata.getAsTree(java.lang.String).

Overrides:
toString in class java.lang.Object


Copyright © 1996-2010 Geotools. All Rights Reserved.