From 5ff7202c3ecdc432d3dd404a5a7a804d3afd449c Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sun, 18 Jul 2021 10:22:34 -0500 Subject: [PATCH] Use GeographicLib --- CMakeLists.txt | 2 +- scwx-qt/scwx-qt.cmake | 6 +++--- .../source/scwx/qt/map/radar_range_layer.cpp | 19 +++++-------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7935fd1..05261370 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,10 +13,10 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) include(${PROJECT_SOURCE_DIR}/external/cmake-conan/conan.cmake) conan_cmake_configure(REQUIRES boost/1.76.0 + geographiclib/1.52 glm/0.9.9.8 gtest/cci.20210126 openssl/1.1.1k - proj/8.1.0 vulkan-loader/1.2.172 GENERATORS cmake cmake_find_package diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 5dcd9456..0e46e74a 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -12,8 +12,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Boost) +find_package(geographiclib) find_package(glm) -find_package(proj) # QtCreator supports the following variables for Android, which are identical to qmake Android variables. # Check https://doc.qt.io/qt/deployment-android.html for more information. @@ -105,5 +105,5 @@ target_link_libraries(scwx-qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Boost::log qmapboxgl opengl32 - glm::glm - PROJ::proj) + GeographicLib::GeographicLib + glm::glm) diff --git a/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp index 584f5f8e..2560e180 100644 --- a/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp @@ -1,9 +1,8 @@ #include #include -#include +#include #include -#include namespace scwx { @@ -12,14 +11,12 @@ namespace qt static const std::string logPrefix_ = "[scwx::qt::map::radar_range_layer] "; -static constexpr double EARTH_FLATTENING = 1 / 298.257223563; - void RadarRangeLayer::Add(std::shared_ptr map, const QString& before) { BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Add()"; - geod_geodesic g; - geod_init(&g, mbgl::util::EARTH_RADIUS_M, EARTH_FLATTENING); + GeographicLib::Geodesic geodesic(GeographicLib::Constants::WGS84_a(), + GeographicLib::Constants::WGS84_f()); constexpr float range = 460.0f * 1000.0f; @@ -37,14 +34,8 @@ void RadarRangeLayer::Add(std::shared_ptr map, const QString& before) double latitude; double longitude; - geod_direct(&g, - radar.first, - radar.second, - angle, - range, - &latitude, - &longitude, - nullptr); + geodesic.Direct( + radar.first, radar.second, angle, range, latitude, longitude); geometry.append({latitude, longitude});