org.apache.sis.referencing.datum

## Class DefaultEllipsoid

- Object
- - FormattableObject
  - - AbstractIdentifiedObject
    - - DefaultEllipsoid

- All Implemented Interfaces:
    Serializable, Deprecable, LenientComparable, Ellipsoid, IdentifiedObject

      public class DefaultEllipsoid
      extends AbstractIdentifiedObject
      implements Ellipsoid

  Geometric figure that can be used to describe the approximate shape of the earth. In mathematical terms, it is a surface formed by the rotation of an ellipse about its minor axis. An ellipsoid requires two defining parameters:
  - semi-major axis and inverse flattening, or
  - semi-major axis and semi-minor axis.
  Some numerical values derived from the above properties are:
  - authalic radius
  - eccentricity
  Distance calculations
  This class contains an `orthodromicDistance(double, double, double, double)` convenience method for calculating distances on great circles.
  Creating new ellipsoid instances
  New instances can be created either directly by specifying all information to a factory method (choices 3 and 4 below), or indirectly by specifying the identifier of an entry in a database (choices 1 and 2 below). In particular, the EPSG database provides definitions for many ellipsoids, and Apache SIS provides convenience shortcuts for some of them.

  Choice 1 in the following list is the easiest but most restrictive way to get an ellipsoid. The other choices provide more freedom. Each choice delegates its work to the subsequent items (in the default configuration), so this list can been seen as top to bottom API.

  1. Create an `Ellipsoid` from one of the static convenience shortcuts listed in `CommonCRS​.ellipsoid()`.
  2. Create an `Ellipsoid` from an identifier in a database by invoking `DatumAuthorityFactory​.createEllipsoid(String)`.
  3. Create an `Ellipsoid` by invoking the `DatumFactory​.createEllipsoid(…)` or `createFlattenedSphere(…)` method (implemented for example by `GeodeticObjectFactory`).
  4. Create a `DefaultEllipsoid` by invoking the `createEllipsoid(…)` or `createFlattenedSphere(…)` static methods defined in this class.
  Example: the following code gets the WGS84 ellipsoid:

      Ellipsoid e = CommonCRS.WGS84.ellipsoid();

  Immutability and thread safety
  This class is immutable and thus thread-safe if the property values (not necessarily the map itself) given to the constructors are also immutable. Unless otherwise noted in the javadoc, this condition holds if all components were created using only SIS factories and static constants.
  Since:
    0.4
  See Also:
    `CommonCRS​.ellipsoid()`, `GeodeticAuthorityFactory​.createEllipsoid(String)`, Serialized Form

  Defined in the `sis-referencing` module

- - ### Field Summary

    - ### Fields inherited from class AbstractIdentifiedObject

      `DEPRECATED_KEY, LOCALE_KEY`

    - ### Fields inherited from interface IdentifiedObject

      `ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `DefaultEllipsoid(Ellipsoid ellipsoid)` Creates a new ellipsoid with the same values than the specified one.
    `protected` | `DefaultEllipsoid(Map<String,?> properties, double semiMajorAxis, double semiMinorAxis, double inverseFlattening, boolean ivfDefinitive, Unit<Length> unit)` Creates a new ellipsoid using the specified axis length.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DefaultEllipsoid` | `castOrCopy(Ellipsoid object)` Returns a SIS ellipsoid implementation with the same values than the given arbitrary implementation.
    `protected long` | `computeHashCode()` Invoked by `hashCode()` for computing the hash code when first needed.
    `static DefaultEllipsoid` | `createEllipsoid(Map<String,?> properties, double semiMajorAxis, double semiMinorAxis, Unit<Length> unit)` Creates a new ellipsoid using the specified properties and axis length.
    `static DefaultEllipsoid` | `createFlattenedSphere(Map<String,?> properties, double semiMajorAxis, double inverseFlattening, Unit<Length> unit)` Creates a new ellipsoid using the specified properties, axis length and inverse flattening value.
    `boolean` | `equals(Object object, ComparisonMode mode)` Compares this ellipsoid with the specified object for equality.
    `double` | `flatteningDifference(Ellipsoid other)` Returns the difference between the flattening factor of two ellipsoids.
    `protected String` | `formatTo(Formatter formatter)` Formats this ellipsoid as a Well Known Text `Ellipsoid[…]` element.
    `double` | `getAuthalicRadius()` Returns the radius of a hypothetical sphere having the same surface than this ellipsoid.
    `Unit<Length>` | `getAxisUnit()` Returns the linear unit of the semi-major and semi-minor axis values.
    `double` | `getEccentricity()` The ratio of the distance between the center and a focus of the ellipse to the length of its semi-major axis.
    `double` | `getEccentricitySquared()` Returns the square of the `eccentricity` value.
    `Class<? extends Ellipsoid>` | `getInterface()` Returns the GeoAPI interface implemented by this class.
    `double` | `getInverseFlattening()` Returns the value of the inverse of the flattening constant.
    `double` | `getSemiMajorAxis()` Length of the semi-major axis of the ellipsoid.
    `double` | `getSemiMinorAxis()` Length of the semi-minor axis of the ellipsoid.
    `boolean` | `isIvfDefinitive()` Indicates if the inverse flattening is definitive for this ellipsoid.
    `boolean` | `isSphere()` `true` if the ellipsoid is degenerate and is actually a sphere.
    `double` | `orthodromicDistance(double λ1, double φ1, double λ2, double φ2)` Returns the orthodromic distance between two geographic coordinates.
    `double` | `semiMajorAxisDifference(Ellipsoid other)` Returns the difference between the semi-major axis length of two ellipsoids.

    - ### Methods inherited from class AbstractIdentifiedObject

      `castOrCopy, equals, getAlias, getDescription, getIdentifiers, getName, getRemarks, hashCode, isDeprecated, isHeuristicMatchForName`

    - ### 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`

- - ### Constructor Detail

    - #### DefaultEllipsoid

          protected DefaultEllipsoid(Map<String,?> properties,
                                     double semiMajorAxis,
                                     double semiMinorAxis,
                                     double inverseFlattening,
                                     boolean ivfDefinitive,
                                     Unit<Length> unit)

      Creates a new ellipsoid using the specified axis length. The properties map is given unchanged to the super-class constructor. The following table is a reminder of main (not all) properties:

      Recognized properties (non exhaustive list)
      Property name | Value type | Returned by
      --- | --- | ---
      "name" | `ReferenceIdentifier` or `String` | `AbstractIdentifiedObject.getName()`
      "alias" | `GenericName` or `CharSequence` (optionally as array) | `AbstractIdentifiedObject.getAlias()`
      "identifiers" | `ReferenceIdentifier` (optionally as array) | `AbstractIdentifiedObject.getIdentifiers()`
      "remarks" | `InternationalString` or `String` | `AbstractIdentifiedObject.getRemarks()`

      Parameters:
        `properties` - the properties to be given to the identified object.
        `semiMajorAxis` - the equatorial radius.
        `semiMinorAxis` - the polar radius.
        `inverseFlattening` - the inverse of the flattening value.
        `ivfDefinitive` - `true` if the inverse flattening is definitive.
        `unit` - the units of the semi-major and semi-minor axis values.
      See Also:
        `createEllipsoid(Map, double, double, Unit)`, `createFlattenedSphere(Map, double, double, Unit)`

    - #### DefaultEllipsoid

          protected DefaultEllipsoid(Ellipsoid ellipsoid)

      Creates a new ellipsoid with the same values than 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:
        `ellipsoid` - the ellipsoid to copy.
      See Also:
        `castOrCopy(Ellipsoid)`

  - ### Method Detail

    - #### createEllipsoid

          public static DefaultEllipsoid createEllipsoid(Map<String,?> properties,
                                                         double semiMajorAxis,
                                                         double semiMinorAxis,
                                                         Unit<Length> unit)

      Creates a new ellipsoid using the specified properties and axis length. The properties map is given unchanged to the super-class constructor.
      Parameters:
        `properties` - the properties to be given to the identified object.
        `semiMajorAxis` - the equatorial radius in the given unit.
        `semiMinorAxis` - the polar radius in the given unit.
        `unit` - the units of the semi-major and semi-minor axis values.
      Returns:
        an ellipsoid with the given axis length.
      See Also:
        `GeodeticObjectFactory​.createEllipsoid(Map, double, double, Unit)`

    - #### createFlattenedSphere

          public static DefaultEllipsoid createFlattenedSphere(Map<String,?> properties,
                                                               double semiMajorAxis,
                                                               double inverseFlattening,
                                                               Unit<Length> unit)

      Creates a new ellipsoid using the specified properties, axis length and inverse flattening value. The properties map is given unchanged to the super-class constructor.
      Parameters:
        `properties` - the properties to be given to the identified object.
        `semiMajorAxis` - the equatorial radius in the given unit.
        `inverseFlattening` - the inverse flattening value.
        `unit` - the units of the semi-major and semi-minor axis values.
      Returns:
        an ellipsoid with the given axis length.
      See Also:
        `GeodeticObjectFactory​.createFlattenedSphere(Map, double, double, Unit)`

    - #### castOrCopy

          public static DefaultEllipsoid castOrCopy(Ellipsoid object)

      Returns a SIS ellipsoid 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 SIS implementation, then the given object is returned unchanged. Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
      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 Ellipsoid> getInterface()

      Returns the GeoAPI interface implemented by this class. The SIS implementation returns `Ellipsoid​.class`.
      Note for implementors: Subclasses usually do not need to override this method since GeoAPI does not define `Ellipsoid` sub-interface. Overriding possibility is left mostly for implementors who wish to extend GeoAPI with their own set of interfaces.
      Overrides:
        `getInterface` in class `AbstractIdentifiedObject`
      Returns:
        `Ellipsoid​.class` or a user-defined sub-interface.

    - #### getAxisUnit

          public Unit<Length> getAxisUnit()

      Returns the linear unit of the semi-major and semi-minor axis values.
      Specified by:
        `getAxisUnit` in interface `Ellipsoid`
      Returns:
        the axis linear unit.

    - #### getSemiMajorAxis

          public double getSemiMajorAxis()

      Length of the semi-major axis of the ellipsoid. This is the equatorial radius in axis linear unit.
      Specified by:
        `getSemiMajorAxis` in interface `Ellipsoid`
      Returns:
        length of semi-major axis.

    - #### getSemiMinorAxis

          public double getSemiMinorAxis()

      Length of the semi-minor axis of the ellipsoid. This is the polar radius in axis linear unit.
      Specified by:
        `getSemiMinorAxis` in interface `Ellipsoid`
      Returns:
        length of semi-minor axis.

    - #### getAuthalicRadius

          public double getAuthalicRadius()

      Returns the radius of a hypothetical sphere having the same surface than this ellipsoid. The radius is expressed in axis linear unit.
      Returns:
        the radius of a sphere having the same surface than this ellipsoid.
      See Also:
        `CommonCRS​.SPHERE`

    - #### getEccentricity

          public double getEccentricity()

      The ratio of the distance between the center and a focus of the ellipse to the length of its semi-major axis. The eccentricity can alternately be computed from the equation: ℯ = √(2f - f²) where f is the flattening factor (not inverse).
      Returns:
        ℯ, the eccentricity of this ellipsoid.

    - #### getEccentricitySquared

          public double getEccentricitySquared()

      Returns the square of the `eccentricity` value.
      Purpose: this convenience method is provided because ℯ² is frequently used in coordinate operations, actually more often than ℯ. This convenience method avoids the cost of computing the square root when not needed.
      Returns:
        ℯ², the square of the eccentricity value.
      Since:
        0.7

    - #### getInverseFlattening

          public double getInverseFlattening()

      Returns the value of the inverse of the flattening constant. Flattening is a value used to indicate how closely an ellipsoid approaches a spherical shape. The inverse flattening is related to the equatorial/polar radius by the formula:

      > ivf = re / (re - rp).

      For perfect spheres (i.e. if `isSphere()` returns `true`), the `Double​.POSITIVE_INFINITY` value is used.
      Specified by:
        `getInverseFlattening` in interface `Ellipsoid`
      Returns:
        the inverse flattening value.

    - #### isIvfDefinitive

          public boolean isIvfDefinitive()

      Indicates if the inverse flattening is definitive for this ellipsoid. Some ellipsoids use the IVF as the defining value, and calculate the polar radius whenever asked. Other ellipsoids use the polar radius to calculate the IVF whenever asked. This distinction can be important to avoid floating-point rounding errors.
      Specified by:
        `isIvfDefinitive` in interface `Ellipsoid`
      Returns:
        `true` if the inverse flattening is definitive, or `false` if the polar radius is definitive.

    - #### isSphere

          public boolean isSphere()

      `true` if the ellipsoid is degenerate and is actually a sphere. The sphere is completely defined by the semi-major axis, which is the radius of the sphere.
      Specified by:
        `isSphere` in interface `Ellipsoid`
      Returns:
        `true` if the ellipsoid is degenerate and is actually a sphere.

    - #### orthodromicDistance

          public double orthodromicDistance(double λ1,
                                            double φ1,
                                            double λ2,
                                            double φ2)

      Returns the orthodromic distance between two geographic coordinates. The orthodromic distance is the shortest distance between two points on a ellipsoid's surface. The orthodromic path is always on a great circle.
      Note: Orthodromic distances are different than the loxodromic distance. The later is a longer distance on a path with a constant direction on the compass.
      Parameters:
        `λ1` - longitude of first point (in decimal degrees).
        `φ1` - latitude of first point (in decimal degrees).
        `λ2` - longitude of second point (in decimal degrees).
        `φ2` - latitude of second point (in decimal degrees).
      Returns:
        the orthodromic distance (in the units of this ellipsoid's axis).

    - #### semiMajorAxisDifference

          public double semiMajorAxisDifference(Ellipsoid other)

      Returns the difference between the semi-major axis length of two ellipsoids. If the two ellipsoid does not use the same unit of measurement, than the axis length of the other ellipsoid is converted into the units of this ellipsoid axis.
      Example: `WGS84​.semiMajorAxisDifference(ED50)` returns 251 metres. This information is a parameter of Molodensky transformations.
      Parameters:
        `other` - the other ellipsoid from which to get semi-major axis length difference.
      Returns:
        (other ellipsoid semi-major axis) - (this ellipsoid semi-major axis).
      Since:
        0.7

    - #### flatteningDifference

          public double flatteningDifference(Ellipsoid other)

      Returns the difference between the flattening factor of two ellipsoids. This method returns 0 if the two ellipsoids are equal.
      Example: `WGS84​.flatteningDifference(ED50)` returns approximatively 1.41927E-05. This information is a parameter of Molodensky transformations.
      Parameters:
        `other` - the other ellipsoid from which to get flattening difference.
      Returns:
        (other ellipsoid flattening) - (this ellipsoid flattening).
      Since:
        0.7

    - #### equals

          public boolean equals(Object object,
                                ComparisonMode mode)

      Compares this ellipsoid 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 coordinate transformations.
      Returns:
        `true` if both objects are equal.
      See Also:
        `AbstractIdentifiedObject​.computeHashCode()`, `Utilities​.deepEquals(Object, Object, ComparisonMode)`

    - #### computeHashCode

          protected long computeHashCode()

      Invoked by `hashCode()` for computing the hash code when first needed. See `AbstractIdentifiedObject​.computeHashCode()` for more information.
      Overrides:
        `computeHashCode` in class `AbstractIdentifiedObject`
      Returns:
        the hash code value. This value may change in any future Apache SIS version.

    - #### formatTo

          protected String formatTo(Formatter formatter)

      Formats this ellipsoid as a Well Known Text `Ellipsoid[…]` element.
      Overrides:
        `formatTo` in class `AbstractIdentifiedObject`
      Parameters:
        `formatter` - the formatter where to format the inner content of this WKT element.
      Returns:
        `"Ellipsoid"` (WKT 2) or `"Spheroid"` (WKT 1).
      See Also:
        WKT 2 specification §8.2.1

Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.