org.geotoolkit.referencing.datum
Class DefaultPrimeMeridian

Object
  extended by FormattableObject
      extended by AbstractIdentifiedObject
          extended by DefaultPrimeMeridian
All Implemented Interfaces:
Serializable, Formattable, LenientComparable, PrimeMeridian, IdentifiedObject

@Immutable
public class DefaultPrimeMeridian
extends AbstractIdentifiedObject
implements PrimeMeridian

A prime meridian defines the origin from which longitude values are determined. The name initial value is "Greenwich", and that value shall be used when the greenwich longitude value is zero.

Since:
1.2
Version:
3.18
Author:
Martin Desruisseaux (IRD, Geomatys), Cédric Briançon (Geomatys)
See Also:
Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

Field Summary
static DefaultPrimeMeridian GREENWICH
          The Greenwich meridian (EPSG:8901), with angular measurements in decimal degrees.
 
Fields inherited from class AbstractIdentifiedObject
EMPTY_ALIAS_ARRAY, EMPTY_IDENTIFIER_ARRAY, IDENTIFIER_COMPARATOR, NAME_COMPARATOR, REMARKS_COMPARATOR
 
Fields inherited from class FormattableObject
EPSG, GEOTIFF, INTERNAL, OGC, SINGLE_LINE
 
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
 
Constructor Summary
DefaultPrimeMeridian(Map<String,?> properties, double greenwichLongitude, Unit<Angle> angularUnit)
          Constructs a prime meridian from a set of properties.
DefaultPrimeMeridian(PrimeMeridian meridian)
          Constructs a new prime meridian with the same values than the specified one.
DefaultPrimeMeridian(String name, double greenwichLongitude)
          Constructs a prime meridian from a name.
DefaultPrimeMeridian(String name, double greenwichLongitude, Unit<Angle> angularUnit)
          Constructs a prime meridian from a name.
 
Method Summary
protected  int computeHashCode()
          Computes a hash value for this identified object.
 boolean equals(Object object, ComparisonMode mode)
          Compare this prime meridian with the specified object for equality.
 String formatWKT(Formatter formatter)
          Formats the inner part of a Well Known Text (WKT) element.
 Unit<Angle> getAngularUnit()
          Returns the angular unit of the Greenwich longitude.
 double getGreenwichLongitude()
          Longitude of the prime meridian measured from the Greenwich meridian, positive eastward.
 double getGreenwichLongitude(Unit<Angle> targetUnit)
          Returns the longitude value relative to the Greenwich Meridian, expressed in the specified units.
static DefaultPrimeMeridian wrap(PrimeMeridian object)
          Returns a Geotk prime meridian implementation with the same values than the given arbitrary implementation.
 
Methods inherited from class AbstractIdentifiedObject
equals, equals, equals, equals, getAlias, getIdentifier, getIdentifier, getIdentifiers, getName, getName, getName, getProperties, getProperties, getRemarks, hashCode, nameMatches, nameMatches, nameMatches
 
Methods inherited from class FormattableObject
getDefaultIndentation, print, setDefaultIndentation, toString, toWKT, toWKT, toWKT
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
 

Field Detail

GREENWICH

public static final DefaultPrimeMeridian GREENWICH
The Greenwich meridian (EPSG:8901), with angular measurements in decimal degrees.

Constructor Detail

DefaultPrimeMeridian

public DefaultPrimeMeridian(PrimeMeridian meridian)
Constructs a new prime meridian with the same values than the specified one. This copy constructor provides a way to wrap an arbitrary implementation into a Geotk one or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. This constructor performs a shallow copy, i.e. the properties are not cloned.

Parameters:
meridian - The prime meridian to copy.
Since:
2.2

DefaultPrimeMeridian

public DefaultPrimeMeridian(String name,
                            double greenwichLongitude)
Constructs a prime meridian from a name. The greenwichLongitude value is assumed in decimal degrees.

Parameters:
name - The datum name.
greenwichLongitude - The longitude value relative to the Greenwich Meridian.

DefaultPrimeMeridian

public DefaultPrimeMeridian(String name,
                            double greenwichLongitude,
                            Unit<Angle> angularUnit)
Constructs a prime meridian from a name.

Parameters:
name - The datum name.
greenwichLongitude - The longitude value relative to the Greenwich Meridian.
angularUnit - The angular unit of the longitude.

DefaultPrimeMeridian

public DefaultPrimeMeridian(Map<String,?> properties,
                            double greenwichLongitude,
                            Unit<Angle> angularUnit)
Constructs a prime meridian from a set of properties. The properties map is given unchanged to the super-class constructor.

Parameters:
properties - Set of properties. Should contains at least "name".
greenwichLongitude - The longitude value relative to the Greenwich Meridian.
angularUnit - The angular unit of the longitude.
Method Detail

wrap

public static DefaultPrimeMeridian wrap(PrimeMeridian object)
Returns a Geotk prime meridian implementation with the same values than the given arbitrary implementation. If the given object is null, then this method returns null. Otherwise if the given object is already a Geotk implementation, then the given object is returned unchanged. Otherwise a new Geotk implementation is created and initialized to the attribute values of the given object.

Parameters:
object - The object to wrap in a Geotk implementation, or null if none.
Returns:
A Geotk implementation containing the values of the given object (may be the given object itself), or null if the argument was null.
Since:
3.18

getGreenwichLongitude

public double getGreenwichLongitude()
Longitude of the prime meridian measured from the Greenwich meridian, positive eastward. The greenwichLongitude initial value is zero, and that value shall be used when the meridian name value is "Greenwich".

Specified by:
getGreenwichLongitude in interface PrimeMeridian
Returns:
The prime meridian Greenwich longitude, in angular unit.

getGreenwichLongitude

public double getGreenwichLongitude(Unit<Angle> targetUnit)
Returns the longitude value relative to the Greenwich Meridian, expressed in the specified units. This convenience method makes it easier to obtain longitude in decimal degrees (getGreenwichLongitude(NonSI.DEGREE_ANGLE)), regardless of the underlying angular units of this prime meridian.

Parameters:
targetUnit - The unit in which to express longitude.
Returns:
The Greenwich longitude in the given units.

getAngularUnit

public Unit<Angle> getAngularUnit()
Returns the angular unit of the Greenwich longitude.

Specified by:
getAngularUnit in interface PrimeMeridian

equals

public boolean equals(Object object,
                      ComparisonMode mode)
Compare this prime meridian with the specified object for equality.

Specified by:
equals in interface LenientComparable
Overrides:
equals in class AbstractIdentifiedObject
Parameters:
object - The object to compare to this.
mode - STRICT for performing a strict comparison, or IGNORE_METADATA for comparing only properties relevant to transformations.
Returns:
true if both objects are equal.

computeHashCode

protected int computeHashCode()
Computes a hash value for this identified object. This method is invoked by AbstractIdentifiedObject.hashCode() when first needed.

Implementation specific feature
In the Geotk implementation, the name, identifiers and remarks are not used for hash code computation. Consequently two identified objects will return the same hash value if they are equal in the sense of equals(…, ComparisonMode.IGNORE_METADATA). This feature allows users to implement metadata-insensitive HashMap.

Overrides:
computeHashCode in class AbstractIdentifiedObject
Returns:
The hash code value. This value may change between different execution of the Geotk library.

formatWKT

public String formatWKT(Formatter formatter)
Formats the inner part of a Well Known Text (WKT) element.

Specified by:
formatWKT in interface Formattable
Overrides:
formatWKT in class FormattableObject
Parameters:
formatter - The formatter to use.
Returns:
The WKT element name, which is "PRIMEM".
See Also:
FormattableObject.toWKT(), FormattableObject.toString()


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.