Map distance helper function

This commit is contained in:
Dan Paulat 2023-08-16 00:15:08 -05:00
parent 2113cb9ba8
commit 5e1b1a5ba6
2 changed files with 12 additions and 0 deletions

View file

@ -1,5 +1,6 @@
#include <scwx/qt/util/maplibre.hpp>
#include <QMapLibreGL/utils.hpp>
#include <mbgl/util/constants.hpp>
namespace scwx
@ -11,6 +12,13 @@ namespace util
namespace maplibre
{
boost::units::quantity<boost::units::si::length>
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;

View file

@ -1,6 +1,8 @@
#pragma once
#include <QMapLibreGL/types.hpp>
#include <boost/units/quantity.hpp>
#include <boost/units/systems/si/length.hpp>
#include <glm/gtc/type_ptr.hpp>
namespace scwx
@ -12,6 +14,8 @@ namespace util
namespace maplibre
{
boost::units::quantity<boost::units::si::length>
GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params);
glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate);
} // namespace maplibre