Module geodesy.conversion
Convert between latitude/longitude/height and Earth-centred X/Y/Z.
Use geodeticToGeocentric to turn a geographic position with ellipsoidal
height into Cartesian coordinates. Use geocentricToGeodetic to get
latitude, longitude and ellipsoidal height back. Both operations need the
reference ellipsoid used by the coordinates. This changes the coordinate
representation, **not** the geodetic datum or reference frame; use an
appropriate frame transformation separately when the source and target
datums differ. Height means height above the ellipsoid, not mean sea level.
The conversions follow EPSG method 9602 and handle difficult reverse cases.
Standards
EPSG method 9602 -- Geographic/geocentric conversions.
Units
Ellipsoidal height, geocentric X/Y/Z, and ellipsoid axes use the same caller-selected linear unit.
Numerics
The oblate reverse combines a Fukushima/Halley fast path with a stabilized Vermeille/Karney-style fallback. Public float reverse conversion uses double working precision. The exact geocentre is rejected because it has no unique geodetic inverse.
Performance
Checked conversion paths are allocation-free. The hybrid reverse was selected only after numerical acceptance and controlled release-mode benchmarking against the previous implementation and external references.
Validation
Validated with EPSG/IOGP reference data, deterministic difficult-domain corpora, GeographicLib, and PROJ where its semantics provide a suitable independent comparison.
See Also
GeodeticCoordinate, GeocentricCoordinate, Ellipsoid
Date
September 26, 2026
Functions
| Name | Description |
|---|---|
geocentricToGeodetic(source, ellipsoid)
|
Convert Earth-centred XYZ back to latitude, longitude and height. |
geodeticToGeocentric(source, ellipsoid)
|
Convert latitude, longitude and ellipsoidal height to Earth-centred XYZ. |
tryGeocentricToGeodetic(source, ellipsoid, result)
|
Convert geocentric Cartesian coordinates to geodetic coordinates. |
tryGeodeticToGeocentric(source, ellipsoid, result)
|
Convert latitude, longitude and ellipsoidal height to Earth-centred XYZ. |