Function Geodesic.tryInverse

Solve the shortest inverse geodesic problem without throwing.

bool tryInverse(
  const GeographicCoordinate!T start,
  const GeographicCoordinate!T end,
  out GeodesicInverseResult!T result
) const pure nothrow @nogc @safe;

The final azimuth is the forward heading of the same oriented geodesic continuing beyond the endpoint, not the back azimuth. Coincident endpoints return canonical positive-zero distance and azimuths. Distance uses the ellipsoid linear unit; azimuths use the canonical interval from -pi inclusive to +pi exclusive.

Parameters

NameDescription
start Geographic start position.
end Geographic endpoint.
result Receives distance, initial azimuth, and final azimuth.

Returns

true when the prepared solver is valid and a finite representable shortest-geodesic solution is produced; otherwise false. Before validation, result is reset to GeodesicInverseResult!T.init.

Example

Example using bool tryInverse( const GeographicCoordinate!T start, const GeographicCoordinate!T end, out.

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));

GeodesicInverseResult!double result;
assert(solver.tryInverse(vienna, newYork, result));
assert(result.distance > 6_000_000.0);
assert(result.distance < 7_000_000.0);