Struct TopocentricFrame
A prepared local East/North/Up frame.
struct TopocentricFrame(T)
if (isGeodesyScalar!T);
The frame binds an ellipsoid, a geocentric origin, and the local ENU
orientation derived from the origin's geodetic latitude and longitude.
is deliberately invalid; prepare a frame explicitly from either a
geodetic or geocentric origin before use.
Direct geocentric conversions implement EPSG method 9836. Direct geodetic conversions implement EPSG method 9837 by composing EPSG 9602 with 9836. All linear coordinates must use the same unit as the ellipsoid axes.
The prepared numerical state uses Epsg9602WorkingScalar!T:
- float -> double
- double -> double
- real -> real
This prevents composed float operations from materializing Earth-scale ECEF intermediates in binary32 before local subtraction.
At a geodetic pole, the explicitly supplied longitude defines ENU orientation. A geocentric origin at the exact geocentre is rejected because its geodetic inverse is not unique.
Properties
| Name | Type | Description |
|---|---|---|
ellipsoid[get]
|
Ellipsoid!T | Ellipsoid associated with the frame. |
isValid[get]
|
bool | True when this frame has been explicitly prepared from a valid origin. |
Methods
| Name | Description |
|---|---|
fromGeocentricOrigin
(ellipsoid, origin)
|
Prepare a frame from a geocentric origin. |
fromGeodeticOrigin
(ellipsoid, origin)
|
Prepare a frame from a geodetic origin. |
geocentricToTopocentric
(source)
|
Convert geocentric Cartesian coordinates to local East/North/Up. |
geodeticToTopocentric
(source)
|
Convert a geodetic coordinate directly to local East/North/Up. |
topocentricToGeocentric
(source)
|
Convert local East/North/Up to geocentric Cartesian coordinates. |
topocentricToGeodetic
(source)
|
Convert local East/North/Up directly to a geodetic coordinate. |
tryFromGeocentricOrigin
(ellipsoid, origin, result)
|
Prepare a frame from a geocentric origin without throwing. |
tryFromGeodeticOrigin
(ellipsoid, origin, result)
|
Prepare a frame from a geodetic origin without throwing. |
tryGeocentricToTopocentric
(source, result)
|
Convert geocentric Cartesian coordinates to local East/North/Up. |
tryGeodeticToTopocentric
(source, result)
|
Convert a geodetic coordinate directly to local East/North/Up. |
tryTopocentricToGeocentric
(source, result)
|
Convert local East/North/Up to geocentric Cartesian coordinates. |
tryTopocentricToGeodetic
(source, result)
|
Convert local East/North/Up directly to a geodetic coordinate. |
Example
Example using struct TopocentricFrame(T) if (isGeodesyScalar!T).
import geodesy;
const origin = GeodeticCoordinate!double .fromComponents(
Latitude!double .fromDegrees(48.20849),
Longitude!double .fromDegrees(16.37208),
171.0);
const frame = TopocentricFrame!double .fromGeodeticOrigin(
wgs84!double(), origin);
const nearby = GeodeticCoordinate!double .fromComponents(
Latitude!double .fromDegrees(48.20850),
Longitude!double .fromDegrees(16.37210),
172.0);
const local = frame .geodeticToTopocentric(nearby);
const back = frame .topocentricToGeodetic(local);
assert(frame .isValid);
assert(local .east == local .east);
assert(back .latitude .degrees > 48.0);