mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 14:50:05 +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"]
|
[submodule "external/date"]
|
||||||
path = external/date
|
path = external/date
|
||||||
url = https://github.com/HowardHinnant/date.git
|
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
|
hsluv-c.cmake
|
||||||
imgui.cmake
|
imgui.cmake
|
||||||
mapbox-gl-native.cmake
|
mapbox-gl-native.cmake
|
||||||
stb.cmake)
|
stb.cmake
|
||||||
|
units.cmake)
|
||||||
|
|
||||||
include(aws-sdk-cpp.cmake)
|
include(aws-sdk-cpp.cmake)
|
||||||
include(date.cmake)
|
include(date.cmake)
|
||||||
|
|
@ -19,3 +20,4 @@ include(hsluv-c.cmake)
|
||||||
include(imgui.cmake)
|
include(imgui.cmake)
|
||||||
include(mapbox-gl-native.cmake)
|
include(mapbox-gl-native.cmake)
|
||||||
include(stb.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 (p->thresholded_)
|
||||||
{
|
{
|
||||||
// If thresholding is enabled, set the map distance
|
// If thresholding is enabled, set the map distance
|
||||||
// TODO: nautical miles
|
units::length::nautical_miles<float> mapDistance =
|
||||||
auto mapDistance =
|
util::maplibre::GetMapDistance(params);
|
||||||
util::maplibre::GetMapDistance(params).value() / 1852.0f;
|
gl.glUniform1f(p->uMapDistanceLocation_, mapDistance.value());
|
||||||
gl.glUniform1f(p->uMapDistanceLocation_,
|
|
||||||
static_cast<float>(mapDistance));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -328,9 +326,10 @@ void PlacefileIcons::Impl::Update()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: nautical miles
|
// Threshold value
|
||||||
GLint threshold =
|
units::length::nautical_miles<double> threshold = di->threshold_;
|
||||||
static_cast<GLint>(std::roundf(di->threshold_.value() / 1852.0f));
|
GLint thresholdValue =
|
||||||
|
static_cast<GLint>(std::round(threshold.value()));
|
||||||
|
|
||||||
// Latitude and longitude coordinates in degrees
|
// Latitude and longitude coordinates in degrees
|
||||||
const float lat = static_cast<float>(di->latitude_);
|
const float lat = static_cast<float>(di->latitude_);
|
||||||
|
|
@ -355,8 +354,8 @@ void PlacefileIcons::Impl::Update()
|
||||||
const float by = std::roundf(ty - ih);
|
const float by = std::roundf(ty - ih);
|
||||||
|
|
||||||
// Angle in degrees
|
// Angle in degrees
|
||||||
// TODO: Properly convert
|
units::angle::degrees<float> angle = di->angle_;
|
||||||
const float a = static_cast<float>(di->angle_.value());
|
const float a = angle.value();
|
||||||
|
|
||||||
// Texture coordinates
|
// Texture coordinates
|
||||||
const std::size_t iconRow = (di->iconNumber_ - 1) / icon.columns_;
|
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
|
lat, lon, lx, ty, ls, tt, mc0, mc1, mc2, mc3, a // TL
|
||||||
});
|
});
|
||||||
thresholds.insert(thresholds.end(),
|
thresholds.insert(thresholds.end(),
|
||||||
{threshold, //
|
{thresholdValue, //
|
||||||
threshold,
|
thresholdValue,
|
||||||
threshold,
|
thresholdValue,
|
||||||
threshold,
|
thresholdValue,
|
||||||
threshold,
|
thresholdValue,
|
||||||
threshold});
|
thresholdValue});
|
||||||
|
|
||||||
numVertices_ += 6;
|
numVertices_ += 6;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <boost/container/stable_vector.hpp>
|
#include <boost/container/stable_vector.hpp>
|
||||||
#include <boost/units/base_units/metric/nautical_mile.hpp>
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
typedef void (*_GLUfuncptr)(void);
|
typedef void (*_GLUfuncptr)(void);
|
||||||
|
|
@ -216,11 +215,9 @@ void PlacefilePolygons::Render(
|
||||||
if (p->thresholded_)
|
if (p->thresholded_)
|
||||||
{
|
{
|
||||||
// If thresholding is enabled, set the map distance
|
// If thresholding is enabled, set the map distance
|
||||||
// TODO: nautical miles
|
units::length::nautical_miles<float> mapDistance =
|
||||||
auto mapDistance =
|
util::maplibre::GetMapDistance(params);
|
||||||
util::maplibre::GetMapDistance(params).value() / 1852.0f;
|
gl.glUniform1f(p->uMapDistanceLocation_, mapDistance.value());
|
||||||
gl.glUniform1f(p->uMapDistanceLocation_,
|
|
||||||
static_cast<float>(mapDistance));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -311,9 +308,9 @@ void PlacefilePolygons::Impl::Tessellate(
|
||||||
// Default color to "Color" statement
|
// Default color to "Color" statement
|
||||||
boost::gil::rgba8_pixel_t lastColor = di->color_;
|
boost::gil::rgba8_pixel_t lastColor = di->color_;
|
||||||
|
|
||||||
// TODO: nautical miles
|
// Current threshold
|
||||||
currentThreshold_ =
|
units::length::nautical_miles<double> threshold = di->threshold_;
|
||||||
static_cast<GLint>(std::roundf(di->threshold_.value() / 1852.0f));
|
currentThreshold_ = static_cast<GLint>(std::round(threshold.value()));
|
||||||
|
|
||||||
gluTessBeginPolygon(tessellator_, this);
|
gluTessBeginPolygon(tessellator_, this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
#include <scwx/common/geographic.hpp>
|
#include <scwx/common/geographic.hpp>
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
#include <boost/units/base_units/metric/nautical_mile.hpp>
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <mbgl/util/constants.hpp>
|
#include <mbgl/util/constants.hpp>
|
||||||
|
|
@ -69,7 +68,7 @@ public:
|
||||||
bool thresholded_ {true};
|
bool thresholded_ {true};
|
||||||
ImFont* monospaceFont_ {};
|
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::PlacefileIcons> placefileIcons_;
|
||||||
std::shared_ptr<gl::draw::PlacefilePolygons> placefilePolygons_;
|
std::shared_ptr<gl::draw::PlacefilePolygons> placefilePolygons_;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#define NOMINMAX
|
||||||
|
|
||||||
#include <scwx/qt/model/alert_model.hpp>
|
#include <scwx/qt/model/alert_model.hpp>
|
||||||
#include <scwx/qt/config/county_database.hpp>
|
#include <scwx/qt/config/county_database.hpp>
|
||||||
#include <scwx/qt/manager/text_event_manager.hpp>
|
#include <scwx/qt/manager/text_event_manager.hpp>
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,14 @@ const ::GeographicLib::Geodesic& DefaultGeodesic()
|
||||||
return geodesic_;
|
return geodesic_;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::units::quantity<boost::units::si::length>
|
units::length::meters<double>
|
||||||
GetDistance(double lat1, double lon1, double lat2, double lon2)
|
GetDistance(double lat1, double lon1, double lat2, double lon2)
|
||||||
{
|
{
|
||||||
double distance;
|
double distance;
|
||||||
util::GeographicLib::DefaultGeodesic().Inverse(
|
util::GeographicLib::DefaultGeodesic().Inverse(
|
||||||
lat1, lon1, lat2, lon2, distance);
|
lat1, lon1, lat2, lon2, distance);
|
||||||
|
|
||||||
return static_cast<boost::units::quantity<boost::units::si::length>>(
|
return units::length::meters<double> {distance};
|
||||||
distance * boost::units::si::meter_base_unit::unit_type());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GeographicLib
|
} // namespace GeographicLib
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <GeographicLib/Geodesic.hpp>
|
#include <GeographicLib/Geodesic.hpp>
|
||||||
#include <boost/units/quantity.hpp>
|
#include <units/length.h>
|
||||||
#include <boost/units/systems/si/length.hpp>
|
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +29,7 @@ const ::GeographicLib::Geodesic& DefaultGeodesic();
|
||||||
*
|
*
|
||||||
* @return distance between point 1 and point 2
|
* @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);
|
GetDistance(double lat1, double lon1, double lat2, double lon2);
|
||||||
|
|
||||||
} // namespace GeographicLib
|
} // namespace GeographicLib
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,12 @@ namespace util
|
||||||
namespace maplibre
|
namespace maplibre
|
||||||
{
|
{
|
||||||
|
|
||||||
boost::units::quantity<boost::units::si::length>
|
units::length::meters<double>
|
||||||
GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params)
|
GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params)
|
||||||
{
|
{
|
||||||
return QMapLibreGL::metersPerPixelAtLatitude(params.latitude, params.zoom) *
|
return units::length::meters<double>(
|
||||||
(params.width + params.height) / 2.0 * boost::units::si::meters;
|
QMapLibreGL::metersPerPixelAtLatitude(params.latitude, params.zoom) *
|
||||||
|
(params.width + params.height) / 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate)
|
glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMapLibreGL/types.hpp>
|
#include <QMapLibreGL/types.hpp>
|
||||||
#include <boost/units/quantity.hpp>
|
|
||||||
#include <boost/units/systems/si/length.hpp>
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <units/length.h>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -14,7 +13,7 @@ namespace util
|
||||||
namespace maplibre
|
namespace maplibre
|
||||||
{
|
{
|
||||||
|
|
||||||
boost::units::quantity<boost::units::si::length>
|
units::length::meters<double>
|
||||||
GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params);
|
GetMapDistance(const QMapLibreGL::CustomLayerRenderParameters& params);
|
||||||
glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate);
|
glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/gil/typedefs.hpp>
|
#include <boost/gil/typedefs.hpp>
|
||||||
#include <boost/units/quantity.hpp>
|
#include <units/angle.h>
|
||||||
#include <boost/units/systems/angle/degrees.hpp>
|
#include <units/length.h>
|
||||||
#include <boost/units/systems/si/length.hpp>
|
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -72,7 +71,7 @@ public:
|
||||||
struct DrawItem
|
struct DrawItem
|
||||||
{
|
{
|
||||||
ItemType itemType_ {ItemType::Unknown};
|
ItemType itemType_ {ItemType::Unknown};
|
||||||
boost::units::quantity<boost::units::si::length> threshold_ {};
|
units::length::nautical_miles<double> threshold_ {};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IconDrawItem : DrawItem
|
struct IconDrawItem : DrawItem
|
||||||
|
|
@ -83,7 +82,7 @@ public:
|
||||||
double longitude_ {};
|
double longitude_ {};
|
||||||
double x_ {};
|
double x_ {};
|
||||||
double y_ {};
|
double y_ {};
|
||||||
boost::units::quantity<boost::units::degree::plane_angle> angle_ {};
|
units::degrees<double> angle_ {};
|
||||||
std::size_t fileNumber_ {0u};
|
std::size_t fileNumber_ {0u};
|
||||||
std::size_t iconNumber_ {0u};
|
std::size_t iconNumber_ {0u};
|
||||||
std::string hoverText_ {};
|
std::string hoverText_ {};
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/units/base_units/metric/nautical_mile.hpp>
|
|
||||||
|
using namespace units::literals;
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -58,8 +59,7 @@ public:
|
||||||
std::chrono::seconds refresh_ {-1};
|
std::chrono::seconds refresh_ {-1};
|
||||||
|
|
||||||
// Parsing state
|
// Parsing state
|
||||||
boost::units::quantity<boost::units::si::length> threshold_ {
|
units::length::nautical_miles<double> threshold_ {999.0_nmi};
|
||||||
999.0 * boost::units::metric::nautical_mile_base_unit::unit_type()};
|
|
||||||
boost::gil::rgba8_pixel_t color_ {255, 255, 255, 255};
|
boost::gil::rgba8_pixel_t color_ {255, 255, 255, 255};
|
||||||
ColorMode colorMode_ {ColorMode::RGBA};
|
ColorMode colorMode_ {ColorMode::RGBA};
|
||||||
std::vector<Object> objectStack_ {};
|
std::vector<Object> objectStack_ {};
|
||||||
|
|
@ -245,9 +245,7 @@ void Placefile::Impl::ProcessLine(const std::string& line)
|
||||||
if (tokenList.size() >= 1)
|
if (tokenList.size() >= 1)
|
||||||
{
|
{
|
||||||
threshold_ =
|
threshold_ =
|
||||||
static_cast<boost::units::quantity<boost::units::si::length>>(
|
units::length::nautical_miles<double>(std::stod(tokenList[0]));
|
||||||
std::stod(tokenList[0]) *
|
|
||||||
boost::units::metric::nautical_mile_base_unit::unit_type());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (boost::istarts_with(line, timeRangeKey_))
|
else if (boost::istarts_with(line, timeRangeKey_))
|
||||||
|
|
@ -384,10 +382,7 @@ void Placefile::Impl::ProcessLine(const std::string& line)
|
||||||
di->x_,
|
di->x_,
|
||||||
di->y_);
|
di->y_);
|
||||||
|
|
||||||
di->angle_ = static_cast<
|
di->angle_ = units::angle::degrees<double>(std::stod(tokenList[2]));
|
||||||
boost::units::quantity<boost::units::degree::plane_angle>>(
|
|
||||||
std::stod(tokenList[2]) *
|
|
||||||
boost::units::angle::degree_base_unit::unit_type());
|
|
||||||
|
|
||||||
di->fileNumber_ = std::stoul(tokenList[3]);
|
di->fileNumber_ = std::stoul(tokenList[3]);
|
||||||
di->iconNumber_ = std::stoul(tokenList[4]);
|
di->iconNumber_ = std::stoul(tokenList[4]);
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,8 @@ target_link_libraries(wxdata PUBLIC aws-cpp-sdk-core
|
||||||
aws-cpp-sdk-s3
|
aws-cpp-sdk-s3
|
||||||
cpr::cpr
|
cpr::cpr
|
||||||
LibXml2::LibXml2
|
LibXml2::LibXml2
|
||||||
spdlog::spdlog)
|
spdlog::spdlog
|
||||||
|
units::units)
|
||||||
target_link_libraries(wxdata INTERFACE Boost::iostreams
|
target_link_libraries(wxdata INTERFACE Boost::iostreams
|
||||||
BZip2::BZip2
|
BZip2::BZip2
|
||||||
hsluv-c)
|
hsluv-c)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue