mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-29 18:40:06 +00:00
Replace boost/units in favor of units library
This commit is contained in:
parent
12833202b7
commit
35b90fa98d
15 changed files with 67 additions and 67 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -31,3 +31,6 @@
|
|||
[submodule "external/date"]
|
||||
path = external/date
|
||||
url = https://github.com/HowardHinnant/date.git
|
||||
[submodule "external/units"]
|
||||
path = external/units
|
||||
url = https://github.com/nholthaus/units.git
|
||||
|
|
|
|||
4
external/CMakeLists.txt
vendored
4
external/CMakeLists.txt
vendored
|
|
@ -10,7 +10,8 @@ set_property(DIRECTORY
|
|||
hsluv-c.cmake
|
||||
imgui.cmake
|
||||
mapbox-gl-native.cmake
|
||||
stb.cmake)
|
||||
stb.cmake
|
||||
units.cmake)
|
||||
|
||||
include(aws-sdk-cpp.cmake)
|
||||
include(date.cmake)
|
||||
|
|
@ -19,3 +20,4 @@ include(hsluv-c.cmake)
|
|||
include(imgui.cmake)
|
||||
include(mapbox-gl-native.cmake)
|
||||
include(stb.cmake)
|
||||
include(units.cmake)
|
||||
|
|
|
|||
1
external/units
vendored
Submodule
1
external/units
vendored
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit da6dd9176e8515323c75030d5e51ee19cf6c9afd
|
||||
4
external/units.cmake
vendored
Normal file
4
external/units.cmake
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
set(PROJECT_NAME scwx-units)
|
||||
|
||||
add_subdirectory(units)
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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_;
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include <boost/gil/typedefs.hpp>
|
||||
#include <boost/units/quantity.hpp>
|
||||
#include <boost/units/systems/angle/degrees.hpp>
|
||||
#include <boost/units/systems/si/length.hpp>
|
||||
#include <units/angle.h>
|
||||
#include <units/length.h>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
|
|
@ -71,22 +70,22 @@ public:
|
|||
|
||||
struct DrawItem
|
||||
{
|
||||
ItemType itemType_ {ItemType::Unknown};
|
||||
boost::units::quantity<boost::units::si::length> threshold_ {};
|
||||
ItemType itemType_ {ItemType::Unknown};
|
||||
units::length::nautical_miles<double> threshold_ {};
|
||||
};
|
||||
|
||||
struct IconDrawItem : DrawItem
|
||||
{
|
||||
IconDrawItem() { itemType_ = ItemType::Icon; }
|
||||
|
||||
double latitude_ {};
|
||||
double longitude_ {};
|
||||
double x_ {};
|
||||
double y_ {};
|
||||
boost::units::quantity<boost::units::degree::plane_angle> angle_ {};
|
||||
std::size_t fileNumber_ {0u};
|
||||
std::size_t iconNumber_ {0u};
|
||||
std::string hoverText_ {};
|
||||
double latitude_ {};
|
||||
double longitude_ {};
|
||||
double x_ {};
|
||||
double y_ {};
|
||||
units::degrees<double> angle_ {};
|
||||
std::size_t fileNumber_ {0u};
|
||||
std::size_t iconNumber_ {0u};
|
||||
std::string hoverText_ {};
|
||||
};
|
||||
|
||||
struct TextDrawItem : DrawItem
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
#include <unordered_map>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/units/base_units/metric/nautical_mile.hpp>
|
||||
|
||||
using namespace units::literals;
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
|
|
@ -58,11 +59,10 @@ public:
|
|||
std::chrono::seconds refresh_ {-1};
|
||||
|
||||
// Parsing state
|
||||
boost::units::quantity<boost::units::si::length> threshold_ {
|
||||
999.0 * boost::units::metric::nautical_mile_base_unit::unit_type()};
|
||||
boost::gil::rgba8_pixel_t color_ {255, 255, 255, 255};
|
||||
ColorMode colorMode_ {ColorMode::RGBA};
|
||||
std::vector<Object> objectStack_ {};
|
||||
units::length::nautical_miles<double> threshold_ {999.0_nmi};
|
||||
boost::gil::rgba8_pixel_t color_ {255, 255, 255, 255};
|
||||
ColorMode colorMode_ {ColorMode::RGBA};
|
||||
std::vector<Object> objectStack_ {};
|
||||
DrawingStatement currentStatement_ {DrawingStatement::Standard};
|
||||
std::shared_ptr<DrawItem> currentDrawItem_ {nullptr};
|
||||
std::vector<PolygonDrawItem::Element> currentPolygonContour_ {};
|
||||
|
|
@ -245,9 +245,7 @@ void Placefile::Impl::ProcessLine(const std::string& line)
|
|||
if (tokenList.size() >= 1)
|
||||
{
|
||||
threshold_ =
|
||||
static_cast<boost::units::quantity<boost::units::si::length>>(
|
||||
std::stod(tokenList[0]) *
|
||||
boost::units::metric::nautical_mile_base_unit::unit_type());
|
||||
units::length::nautical_miles<double>(std::stod(tokenList[0]));
|
||||
}
|
||||
}
|
||||
else if (boost::istarts_with(line, timeRangeKey_))
|
||||
|
|
@ -384,10 +382,7 @@ void Placefile::Impl::ProcessLine(const std::string& line)
|
|||
di->x_,
|
||||
di->y_);
|
||||
|
||||
di->angle_ = static_cast<
|
||||
boost::units::quantity<boost::units::degree::plane_angle>>(
|
||||
std::stod(tokenList[2]) *
|
||||
boost::units::angle::degree_base_unit::unit_type());
|
||||
di->angle_ = units::angle::degrees<double>(std::stod(tokenList[2]));
|
||||
|
||||
di->fileNumber_ = std::stoul(tokenList[3]);
|
||||
di->iconNumber_ = std::stoul(tokenList[4]);
|
||||
|
|
|
|||
|
|
@ -259,7 +259,8 @@ target_link_libraries(wxdata PUBLIC aws-cpp-sdk-core
|
|||
aws-cpp-sdk-s3
|
||||
cpr::cpr
|
||||
LibXml2::LibXml2
|
||||
spdlog::spdlog)
|
||||
spdlog::spdlog
|
||||
units::units)
|
||||
target_link_libraries(wxdata INTERFACE Boost::iostreams
|
||||
BZip2::BZip2
|
||||
hsluv-c)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue