Package org.geotools.referencing.datum
Class DefaultEllipsoid
- Object
-
- Formattable
-
- AbstractIdentifiedObject
-
- DefaultEllipsoid
-
- All Implemented Interfaces:
Serializable
,Ellipsoid
,IdentifiedObject
,PROJFormattable
public class DefaultEllipsoid extends AbstractIdentifiedObject implements Ellipsoid, PROJFormattable
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.
- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultEllipsoid
CLARKE_1866
Clarke 1866 ellipsoid with axis in metres.static DefaultEllipsoid
GRS80
GRS 80 ellipsoid with axis in metres.static DefaultEllipsoid
INTERNATIONAL_1924
International 1924 ellipsoid with axis in metres.static DefaultEllipsoid
SPHERE
A sphere with a radius of 6371000 metres.static DefaultEllipsoid
WGS84
WGS 1984 ellipsoid with axis in metres.-
Fields inherited from class AbstractIdentifiedObject
EMPTY_ALIAS_ARRAY, EMPTY_IDENTIFIER_ARRAY, IDENTIFIER_COMPARATOR, NAME_COMPARATOR, REMARKS_COMPARATOR
-
Fields inherited from class Formattable
SINGLE_LINE
-
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultEllipsoid(Map<String,?> properties, double semiMajorAxis, double semiMinorAxis, double inverseFlattening, boolean ivfDefinitive, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length.protected
DefaultEllipsoid(Ellipsoid ellipsoid)
Constructs a new ellipsoid with the same values than the specified one.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DefaultEllipsoid
createEllipsoid(String name, double semiMajorAxis, double semiMinorAxis, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length.static DefaultEllipsoid
createEllipsoid(Map<String,?> properties, double semiMajorAxis, double semiMinorAxis, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length.static DefaultEllipsoid
createFlattenedSphere(String name, double semiMajorAxis, double inverseFlattening, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length and inverse flattening value.static DefaultEllipsoid
createFlattenedSphere(Map<String,?> properties, double semiMajorAxis, double inverseFlattening, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length and inverse flattening value.boolean
equals(AbstractIdentifiedObject object, boolean compareMetadata)
Compare this ellipsoid with the specified object for equality.String
formatPROJ(PROJFormatter formatter)
Format the inner part of a PROJFormattable object.protected String
formatWKT(Formatter formatter)
Format the inner part of a Well Known Text (WKT) element.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 semimajor axis.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.int
hashCode()
Returns a hash value for this 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 x1, double y1, double x2, double y2)
Returns the orthodromic distance between two geographic coordinates.double
orthodromicDistance(Point2D P1, Point2D P2)
Returns the orthodromic distance between two geographic coordinates.static DefaultEllipsoid
wrap(Ellipsoid ellipsoid)
Wraps an arbitrary ellipsoid into a Geotools implementation.-
Methods inherited from class AbstractIdentifiedObject
asSet, ensureAngularUnit, ensureLinearUnit, ensureNonNull, ensureNonNull, ensureTimeUnit, equals, equals, equals, equals, getAlias, getIdentifier, getIdentifier, getIdentifiers, getName, getName, getName, getProperties, getProperties, getRemarks, nameMatches, nameMatches, nameMatches
-
Methods inherited from class Formattable
cleanupThreadLocals, toString, toWKT, toWKT, toWKT, toWKT
-
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
-
-
-
-
Field Detail
-
WGS84
public static final DefaultEllipsoid WGS84
WGS 1984 ellipsoid with axis in metres. This ellipsoid is used in GPS systems and is the default for mostorg.geotools
packages.
-
GRS80
public static final DefaultEllipsoid GRS80
GRS 80 ellipsoid with axis in metres.- Since:
- 2.2
-
INTERNATIONAL_1924
public static final DefaultEllipsoid INTERNATIONAL_1924
International 1924 ellipsoid with axis in metres.
-
CLARKE_1866
public static final DefaultEllipsoid CLARKE_1866
Clarke 1866 ellipsoid with axis in metres.- Since:
- 2.2
-
SPHERE
public static final DefaultEllipsoid SPHERE
A sphere with a radius of 6371000 metres. Spheres use a simplier algorithm for orthodromic distance computation, which may be faster and more robust.
-
-
Constructor Detail
-
DefaultEllipsoid
protected DefaultEllipsoid(Ellipsoid ellipsoid)
Constructs a new ellipsoid with the same values than the specified one. This copy constructor provides a way to wrap an arbitrary implementation into a Geotools 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.- Since:
- 2.2
- See Also:
wrap(org.geotools.api.referencing.datum.Ellipsoid)
-
DefaultEllipsoid
protected DefaultEllipsoid(Map<String,?> properties, double semiMajorAxis, double semiMinorAxis, double inverseFlattening, boolean ivfDefinitive, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length. The properties map is given unchanged to the super-class constructor.- Parameters:
properties
- Set of properties. Should contains at least"name"
.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(java.lang.String, double, double, javax.measure.Unit<javax.measure.quantity.Length>)
,createFlattenedSphere(java.lang.String, double, double, javax.measure.Unit<javax.measure.quantity.Length>)
-
-
Method Detail
-
createEllipsoid
public static DefaultEllipsoid createEllipsoid(String name, double semiMajorAxis, double semiMinorAxis, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length.- Parameters:
name
- The ellipsoid name.semiMajorAxis
- The equatorial radius.semiMinorAxis
- The polar radius.unit
- The units of the semi-major and semi-minor axis values.- Returns:
- An ellipsoid with the given axis length.
-
createEllipsoid
public static DefaultEllipsoid createEllipsoid(Map<String,?> properties, double semiMajorAxis, double semiMinorAxis, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length. The properties map is given unchanged to the super-class constructor.- Parameters:
properties
- Set of properties. Should contains at least"name"
.semiMajorAxis
- The equatorial radius.semiMinorAxis
- The polar radius.unit
- The units of the semi-major and semi-minor axis values.- Returns:
- An ellipsoid with the given axis length.
-
createFlattenedSphere
public static DefaultEllipsoid createFlattenedSphere(String name, double semiMajorAxis, double inverseFlattening, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length and inverse flattening value.- Parameters:
name
- The ellipsoid name.semiMajorAxis
- The equatorial radius.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.
-
createFlattenedSphere
public static DefaultEllipsoid createFlattenedSphere(Map<String,?> properties, double semiMajorAxis, double inverseFlattening, Unit<Length> unit)
Constructs a new ellipsoid using the specified axis length and inverse flattening value. The properties map is given unchanged to the super-class constructor.- Parameters:
properties
- Set of properties. Should contains at least"name"
.semiMajorAxis
- The equatorial radius.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.
-
wrap
public static DefaultEllipsoid wrap(Ellipsoid ellipsoid)
Wraps an arbitrary ellipsoid into a Geotools implementation. This method is usefull iforthodromic distance computation
(for example) are desired. If the supplied ellipsoid is already an instance ofDefaultEllipsoid
or isnull
, then it is returned unchanged.- Parameters:
ellipsoid
- The ellipsoid to wrap.- Returns:
- The given ellipsoid as a
DefaultEllipsoid
instance.
-
getAxisUnit
public Unit<Length> getAxisUnit()
Returns the linear unit of the semi-major and semi-minor axis values.- Specified by:
getAxisUnit
in interfaceEllipsoid
- 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 interfaceEllipsoid
- 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 interfaceEllipsoid
- Returns:
- Length of semi-minor axis.
-
getEccentricity
public double getEccentricity()
The ratio of the distance between the center and a focus of the ellipse to the length of its semimajor axis. The eccentricity can alternately be computed from the equation:e=sqrt(2f-f²)
.- Returns:
- The eccentricity of this ellipsoid.
-
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 formulaivf = re/(re-rp).
For perfect spheres (i.e. if
isSphere()
returnstrue
), theDouble.POSITIVE_INFINITY
value is used.- Specified by:
getInverseFlattening
in interfaceEllipsoid
- 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 interfaceEllipsoid
- Returns:
true
if the inverse flattening is definitive, orfalse
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.
-
orthodromicDistance
public double orthodromicDistance(Point2D P1, Point2D P2)
Returns the orthodromic distance between two geographic coordinates. The orthodromic distance is the shortest distance between two points on a sphere's surface. The default implementation delegates the work toorthodromicDistance(double,double,double,double)
.- Parameters:
P1
- Longitude and latitude of first point (in decimal degrees).P2
- Longitude and latitude of second point (in decimal degrees).- Returns:
- The orthodromic distance (in the units of this ellipsoid).
-
orthodromicDistance
public double orthodromicDistance(double x1, double y1, double x2, double y2)
Returns the orthodromic distance between two geographic coordinates. The orthodromic distance is the shortest distance between two points on a sphere's surface. The orthodromic path is always on a great circle. This is different from the loxodromic distance, which is a longer distance on a path with a constant direction on the compass.- Parameters:
x1
- Longitude of first point (in decimal degrees).y1
- Latitude of first point (in decimal degrees).x2
- Longitude of second point (in decimal degrees).y2
- Latitude of second point (in decimal degrees).- Returns:
- The orthodromic distance (in the units of this ellipsoid's axis).
-
equals
public boolean equals(AbstractIdentifiedObject object, boolean compareMetadata)
Compare this ellipsoid with the specified object for equality.- Overrides:
equals
in classAbstractIdentifiedObject
- Parameters:
object
- The object to compare tothis
.compareMetadata
-true
for performing a strict comparaison, orfalse
for comparing only properties relevant to transformations.- Returns:
true
if both objects are equal.
-
hashCode
public int hashCode()
Returns a hash value for this ellipsoid. Name, remarks and the like are not taken in account. In other words, two ellipsoids will return the same hash value if they are equal in the sense ofequals
(AbstractIdentifiedObject, false)- Overrides:
hashCode
in classAbstractIdentifiedObject
- Returns:
- The hash code value. This value doesn't need to be the same in past or future versions of this class.
-
formatWKT
protected String formatWKT(Formatter formatter)
Format the inner part of a Well Known Text (WKT) element.- Overrides:
formatWKT
in classFormattable
- Parameters:
formatter
- The formatter to use.- Returns:
- The WKT element name, which is "SPHEROID"
- See Also:
Formattable.toWKT()
,Formattable.toString()
-
formatPROJ
public String formatPROJ(PROJFormatter formatter)
Description copied from interface:PROJFormattable
Format the inner part of a PROJFormattable object.This method is automatically invoked by
PROJFormatter.append(PROJFormattable)
.For example for a element (
DefaultOperationMethod
) of type Projection, the formatter will invoke this method to prepend the "+proj=" String for completing the PROJ String before appending the Projection Name (e.g. lcc for a Lambert Conformal Conic)- Specified by:
formatPROJ
in interfacePROJFormattable
- Parameters:
formatter
- The PROJFormatter to use.- Returns:
- The proj String of the PROJ element type if any. (e.g. +ellps= for named ellipsoids, +datum= for named datums).
-
-