Function GeocentricCoordinate.tryFromComponents

Make an Earth-centred XYZ position without throwing.

static bool tryFromComponents(
  const T x,
  const T y,
  const T z,
  out GeocentricCoordinate result
) pure nothrow @nogc @safe;

Use this checked factory when any component might be missing or non-finite. All three values must use the same linear unit.

Parameters

NameDescription
x Finite geocentric X component.
y Finite geocentric Y component.
z Finite geocentric Z component.
result Receives the constructed coordinate on success.

Returns

true on success; false when any component is NaN or infinite. On failure result is initialized to .init on entry and has no guaranteed value on failure.

Example

Example checking finite geocentric components without throwing.

import geodesy;
GeocentricCoordinate!double point;
assert(GeocentricCoordinate!double.tryFromComponents(
    4_085_000.0, 1_260_000.0, 4_717_000.0, point));
assert(point.x == 4_085_000.0);