Struct Geodesic

Prepared direct/inverse geodesic solver for one reference ellipsoid.

struct Geodesic(T)
  
if (isGeodesyScalar!T);

Supported ellipsoids satisfy a > 0 and 0 <= f <= 0.01; no Earth-size restriction applies. Linear distances use the same unit as the ellipsoid semi-major axis. Exact spheres and supported oblate ellipsoids are handled.

.init is invalid. Prepare a solver once and reuse it for multiple direct or inverse operations.

Direct operations accept finite signed distance. Negative distance follows the same oriented geodesic backward. Inverse operations return the shortest geodesic and canonical coincident-point semantics.

Properties

NameTypeDescription
ellipsoid[get] Ellipsoid!TThe ellipsoid used by this solver.
isSphere[get] boolTrue when the prepared ellipsoid is exactly spherical.
isValid[get] boolTrue when this solver represents the supported ellipsoid profile.

Methods

NameDescription
direct (start, initialAzimuth, distance) Solve the direct geodesic problem with throwing failure semantics.
fromEllipsoid (ellipsoid) Prepare a reusable direct/inverse solver.
inverse (start, end) Solve the shortest inverse geodesic problem with throwing semantics.
tryDirect (start, initialAzimuth, distance, result) Solve the direct geodesic problem without throwing.
tryFromEllipsoid (ellipsoid, result) Prepare a reusable direct/inverse solver without throwing.
tryInverse (start, end, result) Solve the shortest inverse geodesic problem without throwing.

Example

Example using struct Geodesic(T) if (isGeodesyScalar!T).

import geodesy;

const solver = Geodesic!double.fromEllipsoid(wgs84!double());

const vienna = GeographicCoordinate!double.fromComponents(
    Latitude!double.fromDegrees(48.20849),
    Longitude!double.fromDegrees(16.37208));

const newYork = GeographicCoordinate!double.fromComponents(
    Latitude!double.fromDegrees(40.7128),
    Longitude!double.fromDegrees(-74.0060));

const inverse = solver.inverse(vienna, newYork);
const direct = solver.direct(
    vienna, inverse.initialAzimuth, inverse.distance);

assert(inverse.distance > 0.0);
assert(direct.position.latitude.degrees < 41.0);