Replace boost/units in favor of units library

This commit is contained in:
Dan Paulat 2023-08-18 10:45:52 -05:00
parent 12833202b7
commit 35b90fa98d
15 changed files with 67 additions and 67 deletions

View file

@ -232,11 +232,9 @@ void PlacefileIcons::Render(
if (p->thresholded_)
{
// If thresholding is enabled, set the map distance
// TODO: nautical miles
auto mapDistance =
util::maplibre::GetMapDistance(params).value() / 1852.0f;
gl.glUniform1f(p->uMapDistanceLocation_,
static_cast<float>(mapDistance));
units::length::nautical_miles<float> mapDistance =
util::maplibre::GetMapDistance(params);
gl.glUniform1f(p->uMapDistanceLocation_, mapDistance.value());
}
else
{
@ -328,9 +326,10 @@ void PlacefileIcons::Impl::Update()
continue;
}
// TODO: nautical miles
GLint threshold =
static_cast<GLint>(std::roundf(di->threshold_.value() / 1852.0f));
// Threshold value
units::length::nautical_miles<double> threshold = di->threshold_;
GLint thresholdValue =
static_cast<GLint>(std::round(threshold.value()));
// Latitude and longitude coordinates in degrees
const float lat = static_cast<float>(di->latitude_);
@ -355,8 +354,8 @@ void PlacefileIcons::Impl::Update()
const float by = std::roundf(ty - ih);
// Angle in degrees
// TODO: Properly convert
const float a = static_cast<float>(di->angle_.value());
units::angle::degrees<float> angle = di->angle_;
const float a = angle.value();
// Texture coordinates
const std::size_t iconRow = (di->iconNumber_ - 1) / icon.columns_;
@ -387,12 +386,12 @@ void PlacefileIcons::Impl::Update()
lat, lon, lx, ty, ls, tt, mc0, mc1, mc2, mc3, a // TL
});
thresholds.insert(thresholds.end(),
{threshold, //
threshold,
threshold,
threshold,
threshold,
threshold});
{thresholdValue, //
thresholdValue,
thresholdValue,
thresholdValue,
thresholdValue,
thresholdValue});
numVertices_ += 6;
}

View file

@ -6,7 +6,6 @@
#include <GL/glu.h>
#include <boost/container/stable_vector.hpp>
#include <boost/units/base_units/metric/nautical_mile.hpp>
#if defined(_WIN32)
typedef void (*_GLUfuncptr)(void);
@ -216,11 +215,9 @@ void PlacefilePolygons::Render(
if (p->thresholded_)
{
// If thresholding is enabled, set the map distance
// TODO: nautical miles
auto mapDistance =
util::maplibre::GetMapDistance(params).value() / 1852.0f;
gl.glUniform1f(p->uMapDistanceLocation_,
static_cast<float>(mapDistance));
units::length::nautical_miles<float> mapDistance =
util::maplibre::GetMapDistance(params);
gl.glUniform1f(p->uMapDistanceLocation_, mapDistance.value());
}
else
{
@ -311,9 +308,9 @@ void PlacefilePolygons::Impl::Tessellate(
// Default color to "Color" statement
boost::gil::rgba8_pixel_t lastColor = di->color_;
// TODO: nautical miles
currentThreshold_ =
static_cast<GLint>(std::roundf(di->threshold_.value() / 1852.0f));
// Current threshold
units::length::nautical_miles<double> threshold = di->threshold_;
currentThreshold_ = static_cast<GLint>(std::round(threshold.value()));
gluTessBeginPolygon(tessellator_, this);

View file

@ -8,7 +8,6 @@
#include <scwx/common/geographic.hpp>
#include <scwx/util/logger.hpp>
#include <boost/units/base_units/metric/nautical_mile.hpp>
#include <fmt/format.h>
#include <imgui.h>
#include <mbgl/util/constants.hpp>
@ -69,7 +68,7 @@ public:
bool thresholded_ {true};
ImFont* monospaceFont_ {};
boost::units::quantity<boost::units::si::length> mapDistance_ {};
units::length::nautical_miles<double> mapDistance_ {};
std::shared_ptr<gl::draw::PlacefileIcons> placefileIcons_;
std::shared_ptr<gl::draw::PlacefilePolygons> placefilePolygons_;

View file

@ -1,3 +1,5 @@
#define NOMINMAX
#include <scwx/qt/model/alert_model.hpp>
#include <scwx/qt/config/county_database.hpp>
#include <scwx/qt/manager/text_event_manager.hpp>

View file

@ -18,15 +18,14 @@ const ::GeographicLib::Geodesic& DefaultGeodesic()
return geodesic_;
}
boost::units::quantity<boost::units::si::length>
units::length::meters<double>
GetDistance(double lat1, double lon1, double lat2, double lon2)
{
double distance;
util::GeographicLib::DefaultGeodesic().Inverse(
lat1, lon1, lat2, lon2, distance);
return static_cast<boost::units::quantity<boost::units::si::length>>(
distance * boost::units::si::meter_base_unit::unit_type());
return units::length::meters<double> {distance};
}
} // namespace GeographicLib

View file

@ -1,8 +1,7 @@
#pragma once
#include <GeographicLib/Geodesic.hpp>
#include <boost/units/quantity.hpp>
#include <boost/units/systems/si/length.hpp>
#include <units/length.h>
namespace scwx
{
@ -30,7 +29,7 @@ const ::GeographicLib::Geodesic& DefaultGeodesic();
*
* @return distance between point 1 and point 2
*/
boost::units::quantity<boost::units::si::length>
units::length::meters<double>
GetDistance(double lat1, double lon1, double lat2, double lon2);
} // namespace GeographicLib

View file

@ -12,11 +12,12 @@ namespace util
namespace maplibre
{
boost::units::quantity<boost::units::si::length>
units::length::meters<double>
GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params)
{
return QMapLibreGL::metersPerPixelAtLatitude(params.latitude, params.zoom) *
(params.width + params.height) / 2.0 * boost::units::si::meters;
return units::length::meters<double>(
QMapLibreGL::metersPerPixelAtLatitude(params.latitude, params.zoom) *
(params.width + params.height) / 2.0);
}
glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate)

View file

@ -1,9 +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>
#include <units/length.h>
namespace scwx
{
@ -14,7 +13,7 @@ namespace util
namespace maplibre
{
boost::units::quantity<boost::units::si::length>
units::length::meters<double>
GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params);
glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate);