From 8e7892875a91fbe8c8fd34ba1001e8a0fe1c0752 Mon Sep 17 00:00:00 2001 From: dellaert Date: Tue, 6 Nov 2018 17:32:31 -0500 Subject: [PATCH] Check GeographicLib version --- gtsam/navigation/tests/testGPSFactor.cpp | 12 +++++++++--- gtsam/navigation/tests/testGeographicLib.cpp | 17 +++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/gtsam/navigation/tests/testGPSFactor.cpp b/gtsam/navigation/tests/testGPSFactor.cpp index 293bffa00..9457f501d 100644 --- a/gtsam/navigation/tests/testGPSFactor.cpp +++ b/gtsam/navigation/tests/testGPSFactor.cpp @@ -22,19 +22,26 @@ #include +#include #include using namespace std; using namespace gtsam; using namespace GeographicLib; +#if GEOGRAPHICLIB_VERSION_MINOR<37 +static const auto& kWGS84 = Geocentric::WGS84; +#else +static const auto& kWGS84 = Geocentric::WGS84(); +#endif + // ************************************************************************* namespace example { // ENU Origin is where the plane was in hold next to runway const double lat0 = 33.86998, lon0 = -84.30626, h0 = 274; // Convert from GPS to ENU -LocalCartesian origin_ENU(lat0, lon0, h0, Geocentric::WGS84); +LocalCartesian origin_ENU(lat0, lon0, h0, kWGS84); // Dekalb-Peachtree Airport runway 2L const double lat = 33.87071, lon = -84.30482, h = 274; @@ -107,8 +114,7 @@ TEST(GPSData, init) { // GPS Reading 1 will be ENU origin double t1 = 84831; Point3 NED1(0, 0, 0); - LocalCartesian enu(35.4393283333333, -119.062986666667, 275.54, - Geocentric::WGS84); + LocalCartesian enu(35.4393283333333, -119.062986666667, 275.54, kWGS84); // GPS Readin 2 double t2 = 84831.5; diff --git a/gtsam/navigation/tests/testGeographicLib.cpp b/gtsam/navigation/tests/testGeographicLib.cpp index aaa01b54d..6c495faf5 100644 --- a/gtsam/navigation/tests/testGeographicLib.cpp +++ b/gtsam/navigation/tests/testGeographicLib.cpp @@ -15,6 +15,7 @@ * @author Frank Dellaert */ +#include #include #include #include @@ -29,21 +30,27 @@ using namespace std; using namespace GeographicLib; // Dekalb-Peachtree Airport runway 2L -const double lat = 33.87071, lon = -84.30482, h = 274; +static const double lat = 33.87071, lon = -84.30482, h = 274; + +#if GEOGRAPHICLIB_VERSION_MINOR<37 +static const auto& kWGS84 = Geocentric::WGS84; +#else +static const auto& kWGS84 = Geocentric::WGS84(); +#endif //************************************************************************** TEST( GeographicLib, Geocentric) { // From lat-lon to geocentric double X, Y, Z; - Geocentric::WGS84.Forward(lat, lon, h, X, Y, Z); + kWGS84.Forward(lat, lon, h, X, Y, Z); EXPECT_DOUBLES_EQUAL(526, X/1000, 1); EXPECT_DOUBLES_EQUAL(-5275, Y/1000, 1); EXPECT_DOUBLES_EQUAL(3535, Z/1000, 1); // From geocentric to lat-lon double lat_, lon_, h_; - Geocentric::WGS84.Reverse(X, Y, Z, lat_, lon_, h_); + kWGS84.Reverse(X, Y, Z, lat_, lon_, h_); EXPECT_DOUBLES_EQUAL(lat, lat_, 1e-5); EXPECT_DOUBLES_EQUAL(lon, lon_, 1e-5); EXPECT_DOUBLES_EQUAL(h, h_, 1e-5); @@ -69,11 +76,9 @@ TEST( GeographicLib, UTM) { //************************************************************************** TEST( GeographicLib, ENU) { - const Geocentric& earth = Geocentric::WGS84; - // ENU Origin is where the plane was in hold next to runway const double lat0 = 33.86998, lon0 = -84.30626, h0 = 274; - LocalCartesian enu(lat0, lon0, h0, earth); + LocalCartesian enu(lat0, lon0, h0, kWGS84); // From lat-lon to geocentric double E, N, U;