# Class AbstractDatum

Object
FormattableObject
AbstractIdentifiedObject
AbstractDatum

All Implemented Interfaces:
  `Serializable`, `Formattable`, `Deprecable`, `LenientComparable`, `Printable`, `Datum`, `IdentifiedObject`

Direct Known Subclasses:
  `DefaultEngineeringDatum`, `DefaultGeodeticDatum`, `DefaultImageDatum`, `DefaultParametricDatum`, `DefaultTemporalDatum`, `DefaultVerticalDatum`

public class AbstractDatum extends AbstractIdentifiedObject implements Datum
Specifies the relationship of a Coordinate System to the earth. A datum can be defined as a set of real points on the earth that have coordinates. Each datum subtype can be associated with only specific types of coordinate systems, thus creating specific types of coordinate reference system.

## Instantiation

This class is conceptually abstract, even if it is technically possible to instantiate it. Typical applications should create instances of the most specific subclass prefixed by `Default` instead.

## Immutability and thread safety

This base class is immutable if the property values (not necessarily the map itself) given to the constructor are also immutable. Most SIS subclasses and related classes are immutable under similar conditions. This means that unless otherwise noted in the javadoc, `Datum` instances created using only SIS factories and static constants can be shared by many objects and passed between threads without synchronization.

Since:
  0.4
See Also:
  - `AbstractCS`
  - `AbstractCRS`
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `ANCHOR_DEFINITION_KEY`
  Key for the `"anchorDefinition"` property to be given to the `DatumFactory​.createFoo(Map, ...)` methods.
  `static final String`
  `ANCHOR_EPOCH_KEY`
  Key for the `"anchorEpoch"` property to be given to the `DatumFactory​.createFoo(Map, ...)` methods.
  `static final String`
  `CONVENTIONAL_RS_KEY`
  Key for the `"conventionalRS"` property to be given to the `DatumFactory​.createFoo(Map, ...)` methods.
  `static final String`
  `PUBLICATION_DATE_KEY`
  Key for the `"publicationDate"` property to be given to the `DatumFactory​.createFoo(Map, ...)` methods.

  ### Fields inherited from class AbstractIdentifiedObject

  `DEPRECATED_KEY, DOMAINS_KEY, LOCALE_KEY`

  ### Fields inherited from interface Datum

  `ANCHOR_POINT_KEY, DOMAIN_OF_VALIDITY_KEY, REALIZATION_EPOCH_KEY, SCOPE_KEY`

  ### Fields inherited from interface IdentifiedObject

  `ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `AbstractDatum(Map<String,?> properties)`
  Creates a datum from the given properties.
  `protected`
  `AbstractDatum(Datum datum)`
  Creates a new datum with the same values as the specified one.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AbstractDatum`
  `castOrCopy(Datum object)`
  Returns a SIS datum implementation with the values of the given arbitrary implementation.
  `boolean`
  `equals(Object object, ComparisonMode mode)`
  Compares the specified object with this datum for equality.
  `protected String`
  `formatTo(Formatter formatter)`
  Formats the inner part of the Well Known Text (WKT) representation for this datum.
  `Optional<InternationalString>`
  `getAnchorDefinition()`
  Returns a description of the relationship used to anchor the coordinate system to the Earth or alternate object.
  `Optional<Temporal>`
  `getAnchorEpoch()`
  Returns the epoch at which a static datum matches a dynamic datum from which it has been derived.
  `InternationalString`
  `getAnchorPoint()`
  Deprecated.
  Renamed `getAnchorDefinition()` as of ISO 19111:2019.
  `Optional<IdentifiedObject>`
  `getConventionalRS()`
  Returns the name, identifier, alias and remarks for the reference system realized by this reference frame.
  `Extent`
  `getDomainOfValidity()`
  Deprecated.
  Replaced by `AbstractIdentifiedObject​.getDomains()` as of ISO 19111:2019.
  `Class<? extends Datum>`
  `getInterface()`
  Returns the GeoAPI interface implemented by this class.
  `Optional<Temporal>`
  `getPublicationDate()`
  Returns the date on which the datum definition was published.
  `Date`
  `getRealizationEpoch()`
  Deprecated.
  Since ISO 19111:2019, replaced by `getAnchorEpoch()`.
  `InternationalString`
  `getScope()`
  Deprecated.
  Replaced by `AbstractIdentifiedObject​.getDomains()` as of ISO 19111:2019.
  `boolean`
  `isHeuristicMatchForName(String name)`
  Returns `true` if either the primary name or at least one alias matches the given string according heuristic rules.

  ### Methods inherited from class AbstractIdentifiedObject

  `castOrCopy, equals, formatTo, getAlias, getDescription, getDomains, getIdentifiers, getName, getRemarks, hashCode, isDeprecated`

  ### Methods inherited from class FormattableObject

  `print, toString, toString, 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 Details

  - ### ANCHOR_DEFINITION_KEY

    public static final String ANCHOR_DEFINITION_KEY
    Key for the `"anchorDefinition"` property to be given to the `DatumFactory​.createFoo(Map, ...)` methods. This is used for setting the value to be returned by `getAnchorDefinition()`.
    Since:
      1.5
    See Also:
      - invalid reference

            DatumFactory

      - `getAnchorDefinition()`
      - Constant Field Values

  - ### ANCHOR_EPOCH_KEY

    public static final String ANCHOR_EPOCH_KEY
    Key for the `"anchorEpoch"` property to be given to the `DatumFactory​.createFoo(Map, ...)` methods. This is used for setting the value to be returned by `getAnchorEpoch()`.
    Since:
      1.5
    See Also:
      - invalid reference

            DatumFactory

      - `getAnchorEpoch()`
      - Constant Field Values

  - ### PUBLICATION_DATE_KEY

    public static final String PUBLICATION_DATE_KEY
    Key for the `"publicationDate"` property to be given to the `DatumFactory​.createFoo(Map, ...)` methods. This is used for setting the value to be returned by `getPublicationDate()`.
    Since:
      1.5
    See Also:
      - Constant Field Values

  - ### CONVENTIONAL_RS_KEY

    public static final String CONVENTIONAL_RS_KEY
    Key for the `"conventionalRS"` property to be given to the `DatumFactory​.createFoo(Map, ...)` methods. This is used for setting the value to be returned by `getConventionalRS()`.
    Since:
      1.5
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### AbstractDatum

    public AbstractDatum(Map<String,?> properties)
    Creates a datum from the given properties. The properties given in argument follow the same rules as for the super-class constructor. Additionally, the following properties are understood by this constructor:

    Recognized properties (non exhaustive list)
    Property name | Value type | Returned by
    --- | --- | ---
    "anchorPoint" | `InternationalString` or `String` | `getAnchorDefinition()`
    "anchorEpoch" | `Temporal` | `getAnchorEpoch()`
    "publicationDate" | `Temporal` | `getPublicationDate()`
    "conventionalRS" | `IdentifiedObject` | `getConventionalRS()`
    Defined in parent class (reminder)
    "name" | `ReferenceIdentifier` or `String` | `AbstractIdentifiedObject.getName()`
    "alias" | `GenericName` or `CharSequence` (optionally as array) | `AbstractIdentifiedObject.getAlias()`
    "identifiers" | `ReferenceIdentifier` (optionally as array) | `AbstractIdentifiedObject.getIdentifiers()`
    "domains" | `DefaultObjectDomain` (optionally as array) | `AbstractIdentifiedObject.getDomains()`
    "remarks" | `InternationalString` or `String` | `AbstractIdentifiedObject.getRemarks()`

    Parameters:
      `properties` - the properties to be given to the identified object.

  - ### AbstractDatum

    protected AbstractDatum(Datum datum)
    Creates a new datum with the same values as the specified one. This copy constructor provides a way to convert an arbitrary implementation into a SIS 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:
      `datum` - the datum to copy.

- ## Method Details

  - ### castOrCopy

    public static AbstractDatum castOrCopy(Datum object)
    Returns a SIS datum implementation with the values of the given arbitrary implementation. This method performs the first applicable action in the following choices:
    - If the given object is `null`, then this method returns `null`.
    - Otherwise if the given object is an instance of `GeodeticDatum`, `VerticalDatum`, `TemporalDatum`, `EngineeringDatum` or `ImageDatum`, then this method delegates to the `castOrCopy(…)` method of the corresponding SIS subclass. Note that if the given object implements more than one of the above-cited interfaces, then the `castOrCopy(…)` method to be used is unspecified.
    - Otherwise if the given object is already an instance of `AbstractDatum`, then it is returned unchanged.
    - Otherwise a new `AbstractDatum` instance is created using the copy constructor and returned. Note that this is a shallow copy operation, because the other properties contained in the given object are not recursively copied.
    Parameters:
      `object` - the object to get as a SIS implementation, or `null` if none.
    Returns:
      a SIS implementation containing the values of the given object (may be the given object itself), or `null` if the argument was null.

  - ### getInterface

    public Class<? extends Datum> getInterface()
    Returns the GeoAPI interface implemented by this class. The default implementation returns `Datum​.class`. Subclasses implementing a more specific GeoAPI interface shall override this method.
    Overrides:
      `getInterface` in class `AbstractIdentifiedObject`
    Returns:
      the datum interface implemented by this class.

  - ### getAnchorDefinition

    public Optional<InternationalString> getAnchorDefinition()
    Returns a description of the relationship used to anchor the coordinate system to the Earth or alternate object. Also known as the "origin", especially for Engineering and Image Datums.
    - For a geodetic reference frame, the anchor may be the point(s) where the relationship between geoid and ellipsoid is defined.
    - For an engineering datum, the anchor may be an identified physical point with the orientation defined relative to the object.
    - For a temporal datum, see their origin instead.
    Returns:
      description, possibly including coordinates, of the point or points used to anchor the datum to the Earth.
    Since:
      1.5

  - ### getAnchorPoint

    @Deprecated(since="1.5") public InternationalString getAnchorPoint()
    Deprecated.
    Renamed `getAnchorDefinition()` as of ISO 19111:2019.
    Returns a description of the point(s) used to anchor the datum to the Earth.
    Specified by:
      `getAnchorPoint` in interface `Datum`
    Returns:
      a description of the point(s) used to anchor the datum to the Earth.

  - ### getAnchorEpoch

    public Optional<Temporal> getAnchorEpoch()
    Returns the epoch at which a static datum matches a dynamic datum from which it has been derived. This time may be precise or merely a year (e.g. 1983 for NAD83).
    Returns:
      epoch at which a static datum matches a dynamic datum from which it has been derived.
    Since:
      1.5
    See Also:
      - `Year`
      - `YearMonth`
      - `LocalDate`

  - ### getRealizationEpoch

    @Deprecated(since="1.5") public Date getRealizationEpoch()
    Deprecated.
    Since ISO 19111:2019, replaced by `getAnchorEpoch()`.
    The time after which this datum definition is valid.
    Specified by:
      `getRealizationEpoch` in interface `Datum`
    Returns:
      the time after which this datum definition is valid, or `null` if none.

  - ### getDomainOfValidity

    @Deprecated(since="1.4") public Extent getDomainOfValidity()
    Deprecated.
    Replaced by `AbstractIdentifiedObject​.getDomains()` as of ISO 19111:2019.
    Returns the region or timeframe in which this datum is valid, or `null` if unspecified.
    Specified by:
      `getDomainOfValidity` in interface `Datum`
    Returns:
      area or region or timeframe in which this datum is valid, or `null`.

  - ### getScope

    @Deprecated(since="1.4") public InternationalString getScope()
    Deprecated.
    Replaced by `AbstractIdentifiedObject​.getDomains()` as of ISO 19111:2019.
    Returns the domain or limitations of usage, or `null` if unspecified.
    Specified by:
      `getScope` in interface `Datum`
    Returns:
      description of domain of usage, or limitations of usage, for which this datum object is valid.

  - ### getPublicationDate

    public Optional<Temporal> getPublicationDate()
    Returns the date on which the datum definition was published.
    Returns:
      date on which the datum definition was published.
    Since:
      1.5

  - ### getConventionalRS

    public Optional<IdentifiedObject> getConventionalRS()
    Returns the name, identifier, alias and remarks for the reference system realized by this reference frame. All datums that are members of a datum ensemble shall have the same conventional reference system.
    Returns:
      reference system realized by this reference frame.
    Since:
      1.5

  - ### isHeuristicMatchForName

    public boolean isHeuristicMatchForName(String name)
    Returns `true` if either the primary name or at least one alias matches the given string according heuristic rules. This method performs the comparison documented in the super-class, with the following additional flexibility:
    - The `"D_"` prefix (used in ESRI datum names), if presents in the given name or in this datum name, is ignored.
    - If this datum is an instance of `DefaultGeodeticDatum`, then the prime meridian name may also be ignored.

    #### Future evolutions

    This method implements heuristic rules learned from experience while trying to provide inter-operability with different data producers. Those rules may be adjusted in any future SIS version according experience gained while working with more data producers.
    Overrides:
      `isHeuristicMatchForName` in class `AbstractIdentifiedObject`
    Parameters:
      `name` - the name to compare.
    Returns:
      `true` if the primary name or at least one alias matches the specified `name`.
    See Also:
      - `IdentifiedObjects​.isHeuristicMatchForName(IdentifiedObject, String)`
      - `Characters​.Filter​.LETTERS_AND_DIGITS`

  - ### equals

    public boolean equals(Object object, ComparisonMode mode)
    Compares the specified object with this datum for equality. If the `mode` argument value is `STRICT` or `BY_CONTRACT`, then all available properties are compared including the anchor definition, anchor epoch, and the domains.

    #### Static versus dynamic datum

    If this datum implements the `DynamicReferenceFrame` interface, then the given object needs to also implement that interface and provide the same reference epoch for being considered equal. Conversely, if this datum does not implement `DynamicReferenceFrame`, then the given object also need to not implement that interface for being considered equal. This condition is relaxed with `ComparisonMode​.COMPATIBILITY` if the two reference frames have a common identifier or an equivalent name.
    Specified by:
      `equals` in interface `LenientComparable`
    Overrides:
      `equals` in class `AbstractIdentifiedObject`
    Parameters:
      `object` - the object to compare to `this`.
      `mode` - the strictness level of the comparison.
    Returns:
      `true` if both objects are equal.
    See Also:
      - `AbstractIdentifiedObject​.computeHashCode()`
      - `Utilities​.deepEquals(Object, Object, ComparisonMode)`

  - ### formatTo

    protected String formatTo(Formatter formatter)
    Formats the inner part of the Well Known Text (WKT) representation for this datum. See `AbstractIdentifiedObject​.formatTo(Formatter)` for more information.

    #### Default implementation

    The default implementation appends the datum name and returns `"Member"` if this datum is formatted inside a `ENSEMBLE` WKT element, or `null` otherwise.
    Overrides:
      `formatTo` in class `AbstractIdentifiedObject`
    Parameters:
      `formatter` - the formatter where to format the inner content of this WKT element.
    Returns:
      the CamelCase keyword for the WKT element, or `null` if unknown.
    See Also:
      - `FormattableObject​.toWKT()`
      - `FormattableObject​.toString()`