File syn_geo.h¶
FileList > src > syntropic > util > syn_geo.h
Go to the source code of this file
Geodetic coordinate transformations and distance calculation library. More...
#include "../common/syn_defs.h"#include "../proto/syn_nmea.h"#include <stdbool.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_ENU Local East-North-Up (ENU) 3D Cartesian coordinates in meters. |
| struct | SYN_GeoPos Structured Geographic Position with accuracy bound and fix quality. |
Public Functions¶
| Type | Name |
|---|---|
| double | syn_geo_3d_distance_m (const SYN_ENU * p1, const SYN_ENU * p2) Compute 3D Euclidean Cartesian distance between two ENU points. |
| SYN_Status | syn_geo_ecef_to_enu (double x, double y, double z, double ref_lat_deg, double ref_lon_deg, double ref_alt_m, SYN_ENU * out_enu) Convert global ECEF coordinates to a Local East-North-Up (ENU) frame. |
| SYN_Status | syn_geo_ecef_to_wgs84 (double x, double y, double z, double * out_lat, double * out_lon, double * out_alt) Convert Earth-Centered Earth-Fixed (ECEF) coordinates back to WGS-84 Geodetic. |
| double | syn_geo_haversine_m (double lat1_deg, double lon1_deg, double lat2_deg, double lon2_deg) Compute 2D surface geodesic distance using the Haversine formula. |
| SYN_Status | syn_geo_pos_from_gga (const SYN_NMEA_GGA * gga, SYN_GeoPos * out_pos) Populate a SYN_GeoPos structure from a parsed NMEA GGA sentence. |
| SYN_Status | syn_geo_wgs84_to_ecef (double lat_deg, double lon_deg, double alt_m, double * out_x, double * out_y, double * out_z) Convert WGS-84 Geodetic coordinates to Earth-Centered Earth-Fixed (ECEF). |
| SYN_Status | syn_geo_wgs84_to_enu (double lat_deg, double lon_deg, double alt_m, double ref_lat_deg, double ref_lon_deg, double ref_alt_m, SYN_ENU * out_enu) Direct conversion from WGS-84 Geodetic to Local East-North-Up (ENU). |
Macros¶
| Type | Name |
|---|---|
| define | SYN_GEO_WGS84_A 6378137.0 |
| define | SYN_GEO_WGS84_E2 0.0066943799901413165 |
| define | SYN_GEO_WGS84_INV_F 298.257223563 |
Detailed Description¶
Provides 64-bit precision WGS-84 ellipsoid coordinate transformations between spherical GNSS coordinates (Latitude, Longitude, Altitude) and 3D metric Cartesian frames: * ECEF (Earth-Centered Earth-Fixed): Global (X, Y, Z) in meters. * ENU (East-North-Up): Local (East, North, Up) in meters relative to an origin reference station (Lat0, Lon0, Alt0).
Preserves sub-millimeter mathematical precision, fully supporting 1 cm RTK Fixed GNSS positioning data parsed from NMEA sentences.
Usage:
SYN_GeoPos base, rover;
// ... initialize base and rover positions ...
SYN_ENU local_enu;
syn_geo_wgs84_to_enu(rover.latitude, rover.longitude, rover.altitude_m,
base.latitude, base.longitude, base.altitude_m,
&local_enu);
// local_enu.east_m, local_enu.north_m, local_enu.up_m are in meters!
Public Functions Documentation¶
function syn_geo_3d_distance_m¶
Compute 3D Euclidean Cartesian distance between two ENU points.
Parameters:
p1Point 1 ENU coordinates in meters. Must not be NULL.p2Point 2 ENU coordinates in meters. Must not be NULL.
Returns:
3D Euclidean distance in meters.
function syn_geo_ecef_to_enu¶
Convert global ECEF coordinates to a Local East-North-Up (ENU) frame.
SYN_Status syn_geo_ecef_to_enu (
double x,
double y,
double z,
double ref_lat_deg,
double ref_lon_deg,
double ref_alt_m,
SYN_ENU * out_enu
)
Computes metric Cartesian offsets (East, North, Up) relative to a reference station origin (ref_lat_deg, ref_lon_deg, ref_alt_m).
Parameters:
xTarget ECEF X in meters.yTarget ECEF Y in meters.zTarget ECEF Z in meters.ref_lat_degReference origin Latitude in decimal degrees.ref_lon_degReference origin Longitude in decimal degrees.ref_alt_mReference origin Altitude in meters.out_enuOutput ENU Cartesian coordinates. Must not be NULL.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if out_enu is NULL.
function syn_geo_ecef_to_wgs84¶
Convert Earth-Centered Earth-Fixed (ECEF) coordinates back to WGS-84 Geodetic.
SYN_Status syn_geo_ecef_to_wgs84 (
double x,
double y,
double z,
double * out_lat,
double * out_lon,
double * out_alt
)
Uses Bowring's closed-form algorithm for high precision.
Parameters:
xECEF X coordinate in meters.yECEF Y coordinate in meters.zECEF Z coordinate in meters.out_latOutput Latitude in decimal degrees. Must not be NULL.out_lonOutput Longitude in decimal degrees. Must not be NULL.out_altOutput Altitude in meters. Must not be NULL.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if outputs are NULL.
function syn_geo_haversine_m¶
Compute 2D surface geodesic distance using the Haversine formula.
Parameters:
lat1_degPoint 1 Latitude in decimal degrees.lon1_degPoint 1 Longitude in decimal degrees.lat2_degPoint 2 Latitude in decimal degrees.lon2_degPoint 2 Longitude in decimal degrees.
Returns:
2D Surface distance in meters.
function syn_geo_pos_from_gga¶
Populate a SYN_GeoPos structure from a parsed NMEA GGA sentence.
Assigns automatic accuracy estimate based on fix quality: * RTK_FIXED: 0.01 m (1 cm) * RTK_FLOAT: 0.20 m (20 cm) * DGPS: 1.00 m * GPS: 2.50 m * INVALID/EST: 50.0 m
Parameters:
ggaParsed NMEA GGA sentence. Must not be NULL.out_posOutput SYN_GeoPos struct. Must not be NULL.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if args are NULL.
function syn_geo_wgs84_to_ecef¶
Convert WGS-84 Geodetic coordinates to Earth-Centered Earth-Fixed (ECEF).
SYN_Status syn_geo_wgs84_to_ecef (
double lat_deg,
double lon_deg,
double alt_m,
double * out_x,
double * out_y,
double * out_z
)
Parameters:
lat_degLatitude in decimal degrees (-90 to +90).lon_degLongitude in decimal degrees (-180 to +180).alt_mAltitude above ellipsoid/MSL in meters.out_xOutput ECEF X coordinate in meters. Must not be NULL.out_yOutput ECEF Y coordinate in meters. Must not be NULL.out_zOutput ECEF Z coordinate in meters. Must not be NULL.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if outputs are NULL.
function syn_geo_wgs84_to_enu¶
Direct conversion from WGS-84 Geodetic to Local East-North-Up (ENU).
SYN_Status syn_geo_wgs84_to_enu (
double lat_deg,
double lon_deg,
double alt_m,
double ref_lat_deg,
double ref_lon_deg,
double ref_alt_m,
SYN_ENU * out_enu
)
Convenience function combining WGS84->ECEF and ECEF->ENU.
Parameters:
lat_degTarget Latitude in decimal degrees.lon_degTarget Longitude in decimal degrees.alt_mTarget Altitude in meters.ref_lat_degReference origin Latitude in decimal degrees.ref_lon_degReference origin Longitude in decimal degrees.ref_alt_mReference origin Altitude in meters.out_enuOutput ENU Cartesian coordinates in meters.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if out_enu is NULL.
Macro Definition Documentation¶
define SYN_GEO_WGS84_A¶
WGS-84 Semi-major axis in meters (a).
define SYN_GEO_WGS84_E2¶
WGS-84 First eccentricity squared (e^2 = 2f - f^2).
define SYN_GEO_WGS84_INV_F¶
WGS-84 Inverse flattening (1/f).
The documentation for this class was generated from the following file src/syntropic/util/syn_geo.h