Function PseudoMercator.tryForward

Project a geographic coordinate on the bounded Pseudo-Mercator sheet.

bool tryForward(
  const GeographicCoordinate!T source,
  out ProjectedCoordinate!T result
) const pure nothrow @nogc @safe;

Latitude must lie in the supported closed interval [-88,+88] degrees. Longitude is interpreted on the principal wrapped sheet relative to the configured natural origin. Output uses the ellipsoid linear unit.

Parameters

NameDescription
source Geographic source coordinate.
result Receives projected easting and northing on success.

Returns

true when this operation is valid, the source is in the supported domain, and the projected result is finite and representable; otherwise false. On failure result is initialized to .init on entry and has no guaranteed value on failure.

Example

Example projecting a geographic coordinate without throwing.

import geodesy;
const projection = PseudoMercator!double.fromParameters(
    wgs84!double(), Longitude!double.fromDegrees(0.0), 0.0, 0.0);
const source = GeographicCoordinate!double.fromComponents(
    Latitude!double.fromDegrees(48.20849),
    Longitude!double.fromDegrees(16.37208));
ProjectedCoordinate!double result;
assert(projection.tryForward(source, result));
assert(result.easting > 0.0);