From f2f5f6a6cc055b2bc10e78172d4377d4b2b4594c Mon Sep 17 00:00:00 2001 From: artzha Date: Sun, 10 Nov 2024 12:11:03 -0600 Subject: [PATCH] [Refactor] Update gps to utm conveter utils for better clarity --- math/{conversion.h => gps_util.h} | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) rename math/{conversion.h => gps_util.h} (89%) diff --git a/math/conversion.h b/math/gps_util.h similarity index 89% rename from math/conversion.h rename to math/gps_util.h index fc992ab..3866b63 100644 --- a/math/conversion.h +++ b/math/gps_util.h @@ -1,7 +1,11 @@ +#ifndef GPS_UTIL_H_ +#define GPS_UTIL_H_ + #include #include -std::tuple gpsToUTM(double lat, double lon) { +namespace gps_util { +inline std::tuple gpsToUTM(double lat, double lon) { // Constants for UTM conversion constexpr double a = 6378137.0; // WGS-84 major axis constexpr double f = 1 / 298.257223563; // WGS-84 flattening @@ -46,9 +50,12 @@ std::tuple gpsToUTM(double lat, double lon) { return std::make_tuple(easting, northing, zone); } -std::tuple gpsToGlobalCoord(double lat0, double lon0, double lat1, double lon1) { +inline std::tuple gpsToGlobalCoord(double lat0, double lon0, double lat1, double lon1) { // Convert latitude and longitude to utm coordinates const auto& [e0, n0, zone0] = gpsToUTM(lat0, lon0); const auto& [e1, n1, zone1] = gpsToUTM(lat1, lon1); return {e1 - e0, n1 - n0}; } +} + +#endif \ No newline at end of file