File syn_geo.c¶
FileList > src > syntropic > util > syn_geo.c
Go to the source code of this file
Geodetic coordinate transformations and distance calculation implementation.
#include "../util/syn_assert.h"#include "syn_geo.h"#include <math.h>#include <stddef.h>
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 | DEG_TO_RAD (M\_PI / 180.0) |
| define | M_PI 3.14159265358979323846 |
| define | RAD_TO_DEG (180.0 / M\_PI) |
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 DEG_TO_RAD¶
define M_PI¶
define RAD_TO_DEG¶
The documentation for this class was generated from the following file src/syntropic/util/syn_geo.c