|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectBuilder<CoordinateReferenceSystem>
ReferencingBuilder
public class ReferencingBuilder
Builds referencing objects from an IIOMetadata object. This class uses a
MetadataAccessor for reading and writing the attribute values in the
IIOMetadata object given at construction time. By default, this class
uses an accessor for the "RectifiedGridDomain/CoordinateReferenceSystem"
node of the "geotk-coverageio_3.07"
format. However a different accessor can be given to the constructor.
Note:
This class exists because we do not use the reflection mechanism like what we do for
ISO 19115-2 metadata. Dedicated code is needed because the mapping between Image I/O
metadata and the referencing objects is more indirect. For example the kind of object
to create depends on the value of the "type" attribute.
The main methods in this class are build() for reading, and
setCoordinateReferenceSystem(...)
for writing. The other getter methods are provided mostly as hooks that subclasses can override.
The table below summarizes them:
| coverage/geotk-coverageio (download) | View source code for this class |
| Constructor Summary | |
|---|---|
ReferencingBuilder(IIOMetadata metadata)
Creates a new metadata helper for the given metadata. |
|
ReferencingBuilder(MetadataAccessor accessor)
Creates a new metadata helper using the given accessor. |
|
| Method Summary | ||
|---|---|---|
CoordinateReferenceSystem |
build()
Returns the coordinate reference system, or null if it can not be created. |
|
protected MetadataAccessor |
createMetadataAccessor(MetadataAccessor parent,
String path,
String childPath)
Creates the accessor for a child element. |
|
|
getCoordinateReferenceSystem(Class<T> baseType)
Gets the coordinate reference system. |
|
|
getCoordinateSystem(Class<T> baseType)
Gets the coordinate system. |
|
|
getDatum(Class<T> baseType)
Gets the datum. |
|
protected
|
getDefault(Class<T> type)
Returns a default object of the given class. |
|
protected Ellipsoid |
getEllipsoid(MetadataAccessor datumAccessor)
Gets the ellipsoid. |
|
boolean |
getIgnoreUserObject()
Returns true if this helper class should not
get or
set the User Object
node property. |
|
CoordinateReferenceSystem |
getOptionalCRS()
Deprecated. Renamed build(). |
|
protected PrimeMeridian |
getPrimeMeridian(MetadataAccessor datumAccessor)
Gets the prime meridian. |
|
void |
setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
Sets the coordinate reference system to the given value. |
|
void |
setCoordinateSystem(CoordinateSystem cs)
Sets the coordinate system to the given value. |
|
void |
setDatum(Datum datum)
Sets the datum to the given value. |
|
void |
setIgnoreUserObject(boolean ignore)
Sets whatever this helper class is allowed to get or set the User Object node property. |
|
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReferencingBuilder(IIOMetadata metadata)
throws NoSuchElementException
metadata - The Image I/O metadata. An instance of the SpatialMetadata
sub-class is recommended, but not mandatory.
NoSuchElementException - If the underlying IIOMetadata
is read only and doesn't
contains a node for the element to fetch.public ReferencingBuilder(MetadataAccessor accessor)
createMetadataAccessor
method.
accessor - The accessor to the Coordinate Reference System node.| Method Detail |
|---|
public boolean getIgnoreUserObject()
true if this helper class should not
get or
set the User Object
node property. The default value is false, in which case:
ReferencingBuilder class will
set the user object to
the given value, if possible.ReferencingBuilder class will
get the user object and return
it if it exist.
If this method returns true, then the above steps are skipped. This implies
that every call to a getter method will create a new object from the values declared
in node attributes.
true if user objects should be ignored.IIOMetadataNode.getUserObject(),
MetadataAccessor.getUserObject()public void setIgnoreUserObject(boolean ignore)
getIgnoreUserObject() for more information.
ignore - true if user objects should be ignored.public CoordinateReferenceSystem build()
null if it can not be created.
This method delegates to getCoordinateReferenceSystem(Class) and catch the
exception. If an exception has been thrown, the exception is
logged and this method returns null.
build in class Builder<CoordinateReferenceSystem>null if none.@Deprecated public CoordinateReferenceSystem getOptionalCRS()
build().
public <T extends CoordinateReferenceSystem> T getCoordinateReferenceSystem(Class<T> baseType)
throws FactoryException
null
in the default implementation.
T - The compile-time type of baseType.baseType - The expected CRS type.
null if the CRS
can not be parsed and there is no default value.
FactoryException - If the coordinate reference system can not be created.public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
crs - The coordinate reference system.DerivedCRS case.
public <T extends CoordinateSystem> T getCoordinateSystem(Class<T> baseType)
throws FactoryException
DefaultEllipsoidalCS.GEODETIC_2D,
DefaultCartesianCS.GENERIC_2D or null
(depending on the baseType argument) in the default implementation.
T - The compile-time type of baseType.baseType - The expected coordinate system type.
null if the coordinate system
can not be parsed and there is no default value.
FactoryException - If the coordinate system can not be created.public void setCoordinateSystem(CoordinateSystem cs)
cs - The coordinate system, or null if none.
public <T extends Datum> T getDatum(Class<T> baseType)
throws FactoryException
DefaultGeodeticDatum.WGS84
in the default implementation.
T - The compile-time type of baseType.baseType - The expected datum type.
null if the datum can not be parsed
and there is no default value.
FactoryException - If the datum can not be created.VerticalDatum, TemporalDatum and ImageDatum are not yet
implemented.public void setDatum(Datum datum)
datum - The datum, or null if none.
protected Ellipsoid getEllipsoid(MetadataAccessor datumAccessor)
throws FactoryException
DefaultEllipsoid.WGS84
in the default implementation.
datumAccessor - The accessor of the datum enclosing the ellipsoid.
null if the ellipsoid can not be parsed
and there is no default value.
FactoryException - If the ellipsoid can not be created.
protected PrimeMeridian getPrimeMeridian(MetadataAccessor datumAccessor)
throws FactoryException
DefaultPrimeMeridian.GREENWICH
in the default implementation.
datumAccessor - The accessor of the datum enclosing the prime meridian.
null if the prime meridian can not be
parsed and there is no default value.
FactoryException - If the prime meridian can not be created.
protected <T extends IdentifiedObject> T getDefault(Class<T> type)
throws FactoryException
The default implementation delegates to SpatialMetadataFormat.getDefaultValue(Class)
for every types except CoordinateReferenceSystem. The later method is preferred to
IIOMetadataFormat.getObjectDefaultValue(String) because the default value may depend
on the "type" attribute in the enclosing element. For example if the CRS type is
"geographic", then the default coordinate system shall be a EllipsoidalCS.
But if the CRS type is "projected" instead, then the default coordinate system shall
rather be a CartesianCS.
Subclasses can override this method if they want to provide different default values.
T - The compile-time type of the type argument.type - The type of the object to be returned.
null if none.
FactoryException - If the default object can not be created.SpatialMetadataFormat.getDefaultValue(Class),
IIOMetadataFormat.getObjectDefaultValue(String)
protected MetadataAccessor createMetadataAccessor(MetadataAccessor parent,
String path,
String childPath)
"Datum"
element inside the "CoordinateReferenceSystem" element.
The default implementation is implemented as below:
Subclasses can override this method in order to create different accessors, for example in order to use different names for the child elements.return new MetadataAccessor(parent, path, childPath);
parent - The accessor for which the path is relative.path - The path to the node of interest.childPath - The path to the child elements, or null if none.
MetadataAccessor.MetadataAccessor(MetadataAccessor, String, String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||