Function geocentricToGeodetic

Convert Earth-centred XYZ back to latitude, longitude and height.

GeodeticCoordinate!T geocentricToGeodetic(T)(
  const GeocentricCoordinate!T source,
  const Ellipsoid!T ellipsoid
) @safe
if (isGeodesyScalar!T);

Use this form when conversion failure should raise an exception; use tryGeocentricToGeodetic to handle failure through a bool result.

Parameters

NameDescription
source Geocentric Cartesian coordinate to convert.
ellipsoid Reference ellipsoid in the same linear unit as X/Y/Z.

Returns

The finite geodetic coordinate.

Throws

GeodesyValueException when the ellipsoid is invalid, the source is the exact geocentre, or no finite representable inverse can be produced.

Example

Example converting ECEF coordinates to a geodetic position.

import geodesy;
const source = GeocentricCoordinate!double.fromComponents(
    4_085_000.0, 1_260_000.0, 4_717_000.0);
const geo = geocentricToGeodetic(source, wgs84!double());
assert(geo.latitude.degrees > 0.0);