From 5e1b1a5ba6a5e13ad6275852d3ff9b47fb8db85c Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 16 Aug 2023 00:15:08 -0500 Subject: [PATCH] Map distance helper function --- scwx-qt/source/scwx/qt/util/maplibre.cpp | 8 ++++++++ scwx-qt/source/scwx/qt/util/maplibre.hpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/scwx-qt/source/scwx/qt/util/maplibre.cpp b/scwx-qt/source/scwx/qt/util/maplibre.cpp index c2170425..5b3f331e 100644 --- a/scwx-qt/source/scwx/qt/util/maplibre.cpp +++ b/scwx-qt/source/scwx/qt/util/maplibre.cpp @@ -1,5 +1,6 @@ #include +#include #include namespace scwx @@ -11,6 +12,13 @@ namespace util namespace maplibre { +boost::units::quantity +GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params) +{ + return QMapLibreGL::metersPerPixelAtLatitude(params.latitude, params.zoom) * + (params.width + params.height) / 2.0 * boost::units::si::meters; +} + glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate) { static constexpr double RAD2DEG_D = 180.0 / M_PI; diff --git a/scwx-qt/source/scwx/qt/util/maplibre.hpp b/scwx-qt/source/scwx/qt/util/maplibre.hpp index 03d548de..65aa4409 100644 --- a/scwx-qt/source/scwx/qt/util/maplibre.hpp +++ b/scwx-qt/source/scwx/qt/util/maplibre.hpp @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include namespace scwx @@ -12,6 +14,8 @@ namespace util namespace maplibre { +boost::units::quantity +GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params); glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate); } // namespace maplibre