Global Mapper SDK
GM_ProjectPointToECEF
Projects a point to ECEF (earth-centered earth-fixed) coordinates referenced to some datum (normally WGS84) from coordinates in some projection.
Syntax
C++
Copy
GM_DLL_EXPORTED GM_Error_t32 __stdcall GM_ProjectPointToECEF
(
double aXIn, // IN: X coordinate of input point
double aYIn, // IN: Y coordinate of input point
double aZIn, // IN: Z coordinate of input point (meters above ellipsoid), usually 0
double* aX, // OUT: ECEF X coordinate of input
double* aY, // OUT: ECEF Y coordinate of input
double* aZ, // OUT: ECEF Z coordinate of input
DATUM aDatum, // IN: datum for ECEF conversion (normally GM_DATUM_WGS_84)
const GM_Projection_t* aProjIn // IN: projection of input point (NULL for current projection)
)
Example
Copy
// Convert a sample lat/lon point to ECEF
GM_Projection_t theGeoProj;
::memset( &theGeoProj, 0, sizeof theGeoProj );
theGeoProj.mProjSys = GM_PRJ_GEO;
theGeoProj.mDatum = GM_DATUM_WGS_84;
theGeoProj.mUnit = GM_PRJ_UNIT_ARC_DEGREES;
double theLat = 39.0;
double theLon = -90.0;
double theX, theY, theZ;
GM_Error_t32 theErr = GM_ProjectPointToECEF( theLon, theLat, &theX, &theY, &theZ, GM_DATUM_WGS_84, &theGeoProj );
// Convert back, yielding the same point as you started with
double theRevLat, theRevLon;
theErr = GM_ProjectPointFromECEF( theX, theY, theZ, &theRevLon, &theRevLat, GM_DATUM_WGS_84, &theGeoProj );