Package org.apache.sis.referencing.datum
Class DefaultEllipsoid
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.AbstractIdentifiedObject
org.apache.sis.referencing.datum.DefaultEllipsoid
- All Implemented Interfaces:
Serializable,Formattable,Deprecable,LenientComparable,org.opengis.referencing.datum.Ellipsoid,org.opengis.referencing.IdentifiedObject
- Direct Known Subclasses:
Molodensky.Ellipsoid,Sphere
public class DefaultEllipsoid
extends AbstractIdentifiedObject
implements org.opengis.referencing.datum.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.
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 repository 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 be seen as top to bottom API.
- Create an
Ellipsoidfrom one of the static convenience shortcuts listed inCommonCRS.ellipsoid(). - Create an
Ellipsoidfrom an identifier in a database by invokingDatumAuthorityFactory.createEllipsoid(String). - Create an
Ellipsoidby invoking theDatumFactory.createEllipsoid(…)orcreateFlattenedSphere(…)method (implemented for example byGeodeticObjectFactory). - Create a
DefaultEllipsoidby invoking thecreateEllipsoid(…)orcreateFlattenedSphere(…)static methods defined in this class.
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
- Version:
- 1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleThe inverse of the flattening value, orDouble.POSITIVE_INFINITYif the ellipsoid is a sphere.private booleanTells if the Inverse Flattening is definitive for this ellipsoid.private doubleThe equatorial radius.private doubleThe polar radius.private static final longSerial number for inter-operability with different versions.private javax.measure.Unit<javax.measure.quantity.Length>The units of the semi-major and semi-minor axis values.Fields inherited from class org.apache.sis.referencing.AbstractIdentifiedObject
DEPRECATED_KEY, LOCALE_KEYFields inherited from interface org.opengis.referencing.IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConstructs a new object in which every attributes are set to a null value.protectedDefaultEllipsoid(Map<String, ?> properties, double semiMajorAxis, double semiMinorAxis, double inverseFlattening, boolean ivfDefinitive, javax.measure.Unit<javax.measure.quantity.Length> unit) Creates a new ellipsoid using the specified axis length.protectedDefaultEllipsoid(org.opengis.referencing.datum.Ellipsoid ellipsoid) Creates a new ellipsoid with the same values than the specified one. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidafterUnmarshal(Unmarshaller unmarshaller, Object parent) After the unmarshalling process, only one value betweensemiMinorAxisandinverseFlatteninghas been defined.static DefaultEllipsoidcastOrCopy(org.opengis.referencing.datum.Ellipsoid object) Returns a SIS ellipsoid implementation with the same values than the given arbitrary implementation.protected longInvoked byhashCode()for computing the hash code when first needed.static DefaultEllipsoidcreateEllipsoid(Map<String, ?> properties, double semiMajorAxis, double semiMinorAxis, javax.measure.Unit<javax.measure.quantity.Length> unit) Creates a new ellipsoid using the specified properties and axis length.static DefaultEllipsoidcreateFlattenedSphere(Map<String, ?> properties, double semiMajorAxis, double inverseFlattening, javax.measure.Unit<javax.measure.quantity.Length> unit) Creates a new ellipsoid using the specified properties, axis length and inverse flattening value.private DoubleDoubleComputes the square of the eccentricity value with ℯ² = 2f - f².booleanequals(Object object, ComparisonMode mode) Compares this ellipsoid with the specified object for equality.private static DoubleDoubleflattening(org.opengis.referencing.datum.Ellipsoid e) Computes the flattening factor (not inverse) of the given ellipsoid.doubleflatteningDifference(org.opengis.referencing.datum.Ellipsoid other) Returns the difference between the flattening factor of two ellipsoids.protected StringFormats this ellipsoid as a Well Known TextEllipsoid[…]element.doubleReturns the radius of a hypothetical sphere having the same surface than this ellipsoid.javax.measure.Unit<javax.measure.quantity.Length>Returns the linear unit of the semi-major and semi-minor axis values.doubleThe ratio of the distance between the center and a focus of the ellipse to the length of its semi-major axis.doubleReturns the square of theeccentricityvalue.Class<? extends org.opengis.referencing.datum.Ellipsoid>Returns the GeoAPI interface implemented by this class.doubleReturns the value of the inverse of the flattening constant.doublegetRadius(double φ) Returns the radius at the given latitude.private SecondDefiningParameterReturns the object to be marshalled as theSecondDefiningParameterXML element.doubleLength of the semi-major axis of the ellipsoid.private MeasureReturns the semi-major axis value as a measurement.doubleLength of the semi-minor axis of the ellipsoid.private voidharmonizeAxisUnits(javax.measure.Unit<javax.measure.quantity.Length> uom) Ensures that the semi-minor axis uses the same unit than the semi-major one.booleanIndicates if the inverse flattening is definitive for this ellipsoid.booleanisSphere()trueif the ellipsoid is degenerate and is actually a sphere.doublesemiMajorAxisDifference(org.opengis.referencing.datum.Ellipsoid other) Returns the difference between the semi-major axis length of two ellipsoids.private voidSets the second defining parameter value, either the inverse of the flattening value or the semi minor axis value, according to what have been defined in the second defining parameter given.private voidsetSemiMajorAxisMeasure(Measure measure) Sets the semi-major axis value.Methods inherited from class org.apache.sis.referencing.AbstractIdentifiedObject
castOrCopy, equals, formatTo, getAlias, getDescription, getIdentifiers, getName, getRemarks, hashCode, isDeprecated, isHeuristicMatchForNameMethods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toString, toWKTMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opengis.referencing.IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
semiMajorAxis
private double semiMajorAxisThe equatorial radius. This field should be considered as final. It is modified only by JAXB at unmarshalling time.- See Also:
-
semiMinorAxis
private double semiMinorAxisThe polar radius. This field should be considered as final. It is modified only by JAXB at unmarshalling time.- See Also:
-
inverseFlattening
private double inverseFlatteningThe inverse of the flattening value, orDouble.POSITIVE_INFINITYif the ellipsoid is a sphere. This field shall be considered as final. It is modified only by JAXB at unmarshalling time.- See Also:
-
ivfDefinitive
private boolean ivfDefinitiveTells if the Inverse Flattening is definitive for this ellipsoid. This field shall be considered as final. It is modified only by JAXB at unmarshalling time.- See Also:
-
unit
private javax.measure.Unit<javax.measure.quantity.Length> unitThe units of the semi-major and semi-minor axis values.
-
-
Constructor Details
-
DefaultEllipsoid
protected DefaultEllipsoid(Map<String, ?> properties, double semiMajorAxis, double semiMinorAxis, double inverseFlattening, boolean ivfDefinitive, javax.measure.Unit<javax.measure.quantity.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" ReferenceIdentifierorStringAbstractIdentifiedObject.getName()"alias" GenericNameorCharSequence(optionally as array)AbstractIdentifiedObject.getAlias()"identifiers" ReferenceIdentifier(optionally as array)AbstractIdentifiedObject.getIdentifiers()"remarks" InternationalStringorStringAbstractIdentifiedObject.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-trueif the inverse flattening is definitive.unit- the units of the semi-major and semi-minor axis values.- See Also:
-
DefaultEllipsoid
protected DefaultEllipsoid(org.opengis.referencing.datum.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:
-
DefaultEllipsoid
private DefaultEllipsoid()Constructs a new object in which every attributes are set to a null value. This is not a valid object. This constructor is strictly reserved to JAXB, which will assign values to the fields using reflection.
-
-
Method Details
-
createEllipsoid
public static DefaultEllipsoid createEllipsoid(Map<String, ?> properties, double semiMajorAxis, double semiMinorAxis, javax.measure.Unit<javax.measure.quantity.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:
-
createFlattenedSphere
public static DefaultEllipsoid createFlattenedSphere(Map<String, ?> properties, double semiMajorAxis, double inverseFlattening, javax.measure.Unit<javax.measure.quantity.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:
-
castOrCopy
Returns a SIS ellipsoid implementation with the same values than the given arbitrary implementation. If the given object isnull, then this method returnsnull. 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, ornullif none.- Returns:
- a SIS implementation containing the values of the given object (may be the
given object itself), or
nullif the argument was null.
-
getInterface
Returns the GeoAPI interface implemented by this class. The SIS implementation returnsEllipsoid.class.Note for implementers: Subclasses usually do not need to override this method since GeoAPI does not defineEllipsoidsub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their own set of interfaces.- Overrides:
getInterfacein classAbstractIdentifiedObject- Returns:
Ellipsoid.classor a user-defined sub-interface.
-
getAxisUnit
public javax.measure.Unit<javax.measure.quantity.Length> getAxisUnit()Returns the linear unit of the semi-major and semi-minor axis values.- Specified by:
getAxisUnitin interfaceorg.opengis.referencing.datum.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:
getSemiMajorAxisin interfaceorg.opengis.referencing.datum.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:
getSemiMinorAxisin interfaceorg.opengis.referencing.datum.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:
-
getRadius
public double getRadius(double φ) Returns the radius at the given latitude. Special cases:- If φ = 0°, then this is the same value as
getSemiMajorAxis(). - If φ = ±90°, then this is the same value as
getSemiMinorAxis(). - If φ is NaN, then this method returns NaN.
- Parameters:
\u03c6- latitude in degrees, from -90° to +90° inclusive.- Returns:
- radius at the given latitude.
- Since:
- 1.3
- If φ = 0°, then this is the same value as
-
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 theeccentricityvalue.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
-
eccentricitySquared
Computes the square of the eccentricity value with ℯ² = 2f - f².Implementation note: we use the flattening factor for this computation because the inverse flattening factor is usually the second defining parameter. But even if the second defining parameter of this ellipsoid was rather the semi-minor axis, the fact that we use double-double arithmetic should give the same result anyway. -
flattening
Computes the flattening factor (not inverse) of the given ellipsoid. This method chooses the formula depending on whether the defining parameter is the inverse flattening factor or the semi-minor axis length. The defining parameters are presumed fully accurate in base 10 (even if this is of course not possible in the reality), because those parameters are definitions given by authorities.Analogy: the conversion factor from inches to centimetres is 2.54 by definition. Even if we could find a more accurate value matching historical measurements, the 2.54 value is the internationally agreed value for all conversions. This value is (by convention) defined in base 10 and has no exactdoublerepresentation. -
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. ifisSphere()returnstrue), theDouble.POSITIVE_INFINITYvalue is used.- Specified by:
getInverseFlatteningin interfaceorg.opengis.referencing.datum.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:
isIvfDefinitivein interfaceorg.opengis.referencing.datum.Ellipsoid- Returns:
trueif the inverse flattening is definitive, orfalseif the polar radius is definitive.
-
isSphere
public boolean isSphere()trueif 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:
isSpherein interfaceorg.opengis.referencing.datum.Ellipsoid- Returns:
trueif the ellipsoid is degenerate and is actually a sphere.
-
semiMajorAxisDifference
public double semiMajorAxisDifference(org.opengis.referencing.datum.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(org.opengis.referencing.datum.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 approximately 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
Compares this ellipsoid with the specified object for equality.- Specified by:
equalsin interfaceLenientComparable- Overrides:
equalsin classAbstractIdentifiedObject- Parameters:
object- the object to compare tothis.mode-STRICTfor performing a strict comparison, orIGNORE_METADATAfor comparing only properties relevant to coordinate transformations.- Returns:
trueif both objects are equal.- See Also:
-
computeHashCode
protected long computeHashCode()Invoked byhashCode()for computing the hash code when first needed. SeeAbstractIdentifiedObject.computeHashCode()for more information.- Overrides:
computeHashCodein classAbstractIdentifiedObject- Returns:
- the hash code value. This value may change in any future Apache SIS version.
-
formatTo
Formats this ellipsoid as a Well Known TextEllipsoid[…]element.- Overrides:
formatToin classAbstractIdentifiedObject- Parameters:
formatter- the formatter where to format the inner content of this WKT element.- Returns:
"Ellipsoid"(WKT 2) or"Spheroid"(WKT 1).- See Also:
-
afterUnmarshal
After the unmarshalling process, only one value betweensemiMinorAxisandinverseFlatteninghas been defined. Since thesemiMajorAxishas been defined, it is now possible to calculate the value of the missing parameter using the values of those that are set. -
getSemiMajorAxisMeasure
Returns the semi-major axis value as a measurement. This method is invoked by JAXB for XML marshalling. -
setSemiMajorAxisMeasure
Sets the semi-major axis value. This method is invoked by JAXB at unmarshalling time only. -
getSecondDefiningParameter
Returns the object to be marshalled as theSecondDefiningParameterXML element. The returned object contains the values forsemiMinorAxisorinverseFlattening, according to theisIvfDefinitive()value. This method is for JAXB marshalling only. -
setSecondDefiningParameter
Sets the second defining parameter value, either the inverse of the flattening value or the semi minor axis value, according to what have been defined in the second defining parameter given. This is for JAXB unmarshalling process only. -
harmonizeAxisUnits
private void harmonizeAxisUnits(javax.measure.Unit<javax.measure.quantity.Length> uom) Ensures that the semi-minor axis uses the same unit than the semi-major one. Theunitfield shall be set to the semi-major axis unit before this method call.- Parameters:
uom- the semi-minor axis unit.
-