Geodetic Templates - ObjectVision/GeoDMS GitHub Wiki

This page provides a list of GeoDMS Template implementations with common geodetic operations, such as conversion between geodetic coordinate and datum systems (ie: spherical [longitude, latitude, height] to WGS84 ECEF [X, Y, Z] frame).

[[Template]] plh2xyzVec
{   
    [[unit]]<uint32> rowset;
    [[attribute]]<float64> lat (rowset);
    [[attribute]]<float64> lon (rowset);
     
    [[parameter]] <float64> a          := 6378137.0;             // WGS84 equatorial radius
    [[parameter]] <float64> f          := 1.0 / 298.257223563;   // Earth flattening
    [[parameter]] <float64> e2         := 2.0 * f - f * f;       // excentricity e (squared)
    [[attribute]] <float64> N (rowset) := a / sqrt (1.0-e2 * sqr(sin(lat*pi()/180.0))); // Kromtestraal Oost-West richting
    [[attribute]] <float64> X (rowset) := N * cos(lat*pi()/180.0) * cos]lon*pi()/180.0);
    [[attribute]] <float64> Y (rowset) := N * cos (lat*pi()/180.0) * sin (lon*pi()/180.0);
    [[attribute]] <float64> Z (rowset) := (N-e2*N)*sin (lat * pi()/180.0);
}
[[Template]] plh2xyzParam
{
    [[parameter]] <float64> lat;
    [[parameter]] <float64> lon;

    [[parameter]] <float64> a  := 6378137.0;             // WGS84 equatorial radius
    [[parameter]] <float64> f  := 1.0 / 298.257223563;   // Earth flattening
    [[parameter]] <float64> e2 := 2.0 * f - f * f;       // excentricity e (squared)
    [[parameter]] <float64> N  := a / sqrt(1.0-e2 * sqr(sin(lat*pi()/180.0))); // Kromtestraal Oost-West richting
    [[parameter]] <float64> X := N * cos(lat*pi()/180.0) * cos(lon*pi()/180.0);
    [[parameter]] <float64> Y := N * cos(lat*pi()/180.0) * sin(lon*pi()/180.0);
    [[parameter]] <float64> Z := (N-e2*N)*sin(lat * pi()/180.0);
}
[[Template]] Haversine
{
    [[parameter]] <float64> lat1_degrees: isHidden="True";
    [[parameter]] <float64> lat2_degrees;
    [[parameter]] <float64> lon1_degrees;
    [[parameter]] <float64> lon2_degrees;
    [[parameter]] <float64> lat1_radian := lat1_degrees * pi() / 180.0;
    [[parameter]] <float64> lat2_radian := lat2_degrees * pi() / 180.0;
    [[parameter]] <float64> lon1_radian := lon1_degrees * pi() / 180.0;
    [[parameter]] <float64> lon2_radian := lon2_degrees * pi() / 180.0;
    [[parameter]] <float64>     deltaLon_radian := lon1_radian - lon2_radian;
    [[parameter]] <float64>     deltaLat_radian := lat1_radian - lat2_radian;
    [[parameter]] <float64> a               := sqr(sin(deltaLat_radian/2d)) + (((cos(lat1_radian) * cos(lat2_radian))) * sqr(sin(deltaLon_radian/2d)));
    [[parameter]] <km>          distance        := (2d * 6371d * atan(sqrt(a) / (sqrt(1d - a))))[km];
}
⚠️ **GitHub.com Fallback** ⚠️