Update to latest maplibre-gl-native, including rename from QMapboxGL to QMapLibreGL

This commit is contained in:
Dan Paulat 2022-10-20 22:54:53 -05:00
parent 243e874b55
commit 2ac141ea1a
30 changed files with 143 additions and 133 deletions

View file

@ -276,7 +276,7 @@ target_link_libraries(scwx-qt PUBLIC Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::OpenGLWidgets
Boost::json
Boost::timer
qmapboxgl
qmaplibregl
opengl32
freetype-gl
GeographicLib::GeographicLib

View file

@ -36,7 +36,8 @@ DrawItem::DrawItem(DrawItem&&) noexcept = default;
DrawItem& DrawItem::operator=(DrawItem&&) noexcept = default;
void DrawItem::UseDefaultProjection(
const QMapbox::CustomLayerRenderParameters& params, GLint uMVPMatrixLocation)
const QMapLibreGL::CustomLayerRenderParameters& params,
GLint uMVPMatrixLocation)
{
glm::mat4 projection = glm::ortho(0.0f,
static_cast<float>(params.width),
@ -49,29 +50,29 @@ void DrawItem::UseDefaultProjection(
// TODO: Refactor to utility class
static glm::vec2
LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate)
LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate)
{
double latitude = std::clamp(
coordinate.first, -mbgl::util::LATITUDE_MAX, mbgl::util::LATITUDE_MAX);
glm::vec2 screen {
mbgl::util::LONGITUDE_MAX + coordinate.second,
-(mbgl::util::LONGITUDE_MAX -
mbgl::util::RAD2DEG *
mbgl::util::RAD2DEG_D *
std::log(std::tan(M_PI / 4.0 +
latitude * M_PI / mbgl::util::DEGREES_MAX)))};
return screen;
}
void DrawItem::UseMapProjection(
const QMapbox::CustomLayerRenderParameters& params,
GLint uMVPMatrixLocation,
GLint uMapScreenCoordLocation)
const QMapLibreGL::CustomLayerRenderParameters& params,
GLint uMVPMatrixLocation,
GLint uMapScreenCoordLocation)
{
OpenGLFunctions& gl = p->gl_;
// TODO: Refactor to utility class
const float scale = std::pow(2.0, params.zoom) * 2.0f *
mbgl::util::tileSize / mbgl::util::DEGREES_MAX;
mbgl::util::tileSize_D / mbgl::util::DEGREES_MAX;
const float xScale = scale / params.width;
const float yScale = scale / params.height;

View file

@ -4,7 +4,7 @@
#include <memory>
#include <QMapbox>
#include <QMapLibreGL/QMapLibreGL>
namespace scwx
{
@ -27,14 +27,16 @@ public:
DrawItem(DrawItem&&) noexcept;
DrawItem& operator=(DrawItem&&) noexcept;
virtual void Initialize() = 0;
virtual void Render(const QMapbox::CustomLayerRenderParameters& params) = 0;
virtual void Deinitialize() = 0;
virtual void Initialize() = 0;
virtual void
Render(const QMapLibreGL::CustomLayerRenderParameters& params) = 0;
virtual void Deinitialize() = 0;
protected:
void UseDefaultProjection(const QMapbox::CustomLayerRenderParameters& params,
GLint uMVPMatrixLocation);
void UseMapProjection(const QMapbox::CustomLayerRenderParameters& params,
void
UseDefaultProjection(const QMapLibreGL::CustomLayerRenderParameters& params,
GLint uMVPMatrixLocation);
void UseMapProjection(const QMapLibreGL::CustomLayerRenderParameters& params,
GLint uMVPMatrixLocation,
GLint uMapScreenCoordLocation);

View file

@ -166,7 +166,7 @@ void GeoLine::Initialize()
p->dirty_ = true;
}
void GeoLine::Render(const QMapbox::CustomLayerRenderParameters& params)
void GeoLine::Render(const QMapLibreGL::CustomLayerRenderParameters& params)
{
if (p->visible_)
{

View file

@ -27,7 +27,7 @@ public:
GeoLine& operator=(GeoLine&&) noexcept;
void Initialize() override;
void Render(const QMapbox::CustomLayerRenderParameters& params) override;
void Render(const QMapLibreGL::CustomLayerRenderParameters& params) override;
void Deinitialize() override;
/**

View file

@ -122,7 +122,7 @@ void Rectangle::Initialize()
p->dirty_ = true;
}
void Rectangle::Render(const QMapbox::CustomLayerRenderParameters& params)
void Rectangle::Render(const QMapLibreGL::CustomLayerRenderParameters& params)
{
if (p->visible_)
{

View file

@ -27,7 +27,7 @@ public:
Rectangle& operator=(Rectangle&&) noexcept;
void Initialize() override;
void Render(const QMapbox::CustomLayerRenderParameters& params) override;
void Render(const QMapLibreGL::CustomLayerRenderParameters& params) override;
void Deinitialize() override;
void SetBorder(float width, boost::gil::rgba8_pixel_t color);

View file

@ -72,7 +72,7 @@ public:
std::string mapboxApiKey =
manager::SettingsManager::general_settings()->mapbox_api_key();
settings_.resetToTemplate(QMapboxGLSettings::MapboxSettings);
settings_.resetToTemplate(QMapLibreGL::Settings::MapboxSettings);
settings_.setApiKey(QString {mapboxApiKey.c_str()});
settings_.setCacheDatabasePath(QString {cacheDbPath.c_str()});
settings_.setCacheDatabaseMaximumSize(20 * 1024 * 1024);
@ -80,7 +80,6 @@ public:
~MainWindowImpl() = default;
void ConfigureMapLayout();
void ConnectAlertSignals();
void ConnectMapSignals();
void ConnectOtherSignals();
void HandleFocusChange(QWidget* focused);
@ -98,9 +97,9 @@ public:
void UpdateRadarSite();
void UpdateVcp();
MainWindow* mainWindow_;
QMapboxGLSettings settings_;
map::MapWidget* activeMap_;
MainWindow* mainWindow_;
QMapLibreGL::Settings settings_;
map::MapWidget* activeMap_;
ui::Level2ProductsWidget* level2ProductsWidget_;
ui::Level2SettingsWidget* level2SettingsWidget_;

View file

@ -18,7 +18,7 @@
#include <boost/timer/timer.hpp>
#include <fmt/chrono.h>
#include <GeographicLib/Geodesic.hpp>
#include <QMapbox>
#include <QMapLibreGL/QMapLibreGL>
namespace scwx
{
@ -304,8 +304,8 @@ void RadarProductManager::Initialize()
GeographicLib::Geodesic geodesic(GeographicLib::Constants::WGS84_a(),
GeographicLib::Constants::WGS84_f());
const QMapbox::Coordinate radar(p->radarSite_->latitude(),
p->radarSite_->longitude());
const QMapLibreGL::Coordinate radar(p->radarSite_->latitude(),
p->radarSite_->longitude());
const float gateSize = gate_size();

View file

@ -16,22 +16,22 @@ namespace map
static const std::string logPrefix_ = "scwx::qt::map::alert_layer";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
static void AddAlertLayer(std::shared_ptr<QMapboxGL> map,
const QString& idSuffix,
const QString& sourceId,
const QString& beforeLayer,
boost::gil::rgba8_pixel_t outlineColor);
static QMapbox::Feature
static void AddAlertLayer(std::shared_ptr<QMapLibreGL::Map> map,
const QString& idSuffix,
const QString& sourceId,
const QString& beforeLayer,
boost::gil::rgba8_pixel_t outlineColor);
static QMapLibreGL::Feature
CreateFeature(const awips::CodedLocation& codedLocation);
static QMapbox::Coordinate
static QMapLibreGL::Coordinate
GetMapboxCoordinate(const common::Coordinate& coordinate);
static QMapbox::Coordinates
static QMapLibreGL::Coordinates
GetMapboxCoordinates(const awips::CodedLocation& codedLocation);
static QString GetSuffix(awips::Phenomenon phenomenon, bool alertActive);
static const QVariantMap kEmptyFeatureCollection_ {
{"type", "geojson"},
{"data", QVariant::fromValue(QList<QMapbox::Feature> {})}};
{"data", QVariant::fromValue(QList<QMapLibreGL::Feature> {})}};
static const std::list<awips::Phenomenon> kAlertPhenomena_ {
awips::Phenomenon::Marine,
awips::Phenomenon::FlashFlood,
@ -70,8 +70,8 @@ class AlertLayerHandler : public QObject
static AlertLayerHandler& Instance();
QList<QMapbox::Feature>* FeatureList(awips::Phenomenon phenomenon,
bool alertActive);
QList<QMapLibreGL::Feature>* FeatureList(awips::Phenomenon phenomenon,
bool alertActive);
void HandleAlert(const types::TextEventKey& key, size_t messageIndex);
std::unordered_map<std::pair<awips::Phenomenon, bool>,
@ -116,7 +116,7 @@ void AlertLayer::Initialize()
DrawLayer::Initialize();
}
void AlertLayer::Render(const QMapbox::CustomLayerRenderParameters& params)
void AlertLayer::Render(const QMapLibreGL::CustomLayerRenderParameters& params)
{
gl::OpenGLFunctions& gl = context()->gl();
@ -210,17 +210,17 @@ void AlertLayer::AddLayers(const std::string& before)
{255, 0, 0, 255});
}
QList<QMapbox::Feature>*
QList<QMapLibreGL::Feature>*
AlertLayerHandler::FeatureList(awips::Phenomenon phenomenon, bool alertActive)
{
QList<QMapbox::Feature>* featureList = nullptr;
QList<QMapLibreGL::Feature>* featureList = nullptr;
auto key = std::make_pair(phenomenon, alertActive);
auto it = alertSourceMap_.find(key);
if (it != alertSourceMap_.cend())
{
featureList =
reinterpret_cast<QList<QMapbox::Feature>*>(it->second["data"].data());
featureList = reinterpret_cast<QList<QMapLibreGL::Feature>*>(
it->second["data"].data());
}
return featureList;
@ -286,11 +286,11 @@ AlertLayerHandler& AlertLayerHandler::Instance()
return alertLayerHandler;
}
static void AddAlertLayer(std::shared_ptr<QMapboxGL> map,
const QString& idSuffix,
const QString& sourceId,
const QString& beforeLayer,
boost::gil::rgba8_pixel_t outlineColor)
static void AddAlertLayer(std::shared_ptr<QMapLibreGL::Map> map,
const QString& idSuffix,
const QString& sourceId,
const QString& beforeLayer,
boost::gil::rgba8_pixel_t outlineColor)
{
QString bgLayerId = QString("alertPolygonLayerBg-%1").arg(idSuffix);
QString fgLayerId = QString("alertPolygonLayerFg-%1").arg(idSuffix);
@ -325,32 +325,33 @@ static void AddAlertLayer(std::shared_ptr<QMapboxGL> map,
map->setPaintProperty(fgLayerId, "line-width", "3");
}
static QMapbox::Feature CreateFeature(const awips::CodedLocation& codedLocation)
static QMapLibreGL::Feature
CreateFeature(const awips::CodedLocation& codedLocation)
{
auto mapboxCoordinates = GetMapboxCoordinates(codedLocation);
return {
QMapbox::Feature::PolygonType,
std::initializer_list<QMapbox::CoordinatesCollection> {
std::initializer_list<QMapbox::Coordinates> {{mapboxCoordinates}}}};
return {QMapLibreGL::Feature::PolygonType,
std::initializer_list<QMapLibreGL::CoordinatesCollection> {
std::initializer_list<QMapLibreGL::Coordinates> {
{mapboxCoordinates}}}};
}
static QMapbox::Coordinate
static QMapLibreGL::Coordinate
GetMapboxCoordinate(const common::Coordinate& coordinate)
{
return {coordinate.latitude_, coordinate.longitude_};
}
static QMapbox::Coordinates
static QMapLibreGL::Coordinates
GetMapboxCoordinates(const awips::CodedLocation& codedLocation)
{
auto scwxCoordinates = codedLocation.coordinates();
QMapbox::Coordinates mapboxCoordinates(scwxCoordinates.size() + 1u);
auto scwxCoordinates = codedLocation.coordinates();
QMapLibreGL::Coordinates mapboxCoordinates(scwxCoordinates.size() + 1u);
std::transform(scwxCoordinates.cbegin(),
scwxCoordinates.cend(),
mapboxCoordinates.begin(),
[](auto& coordinate) -> QMapbox::Coordinate
[](auto& coordinate) -> QMapLibreGL::Coordinate
{ return GetMapboxCoordinate(coordinate); });
mapboxCoordinates.back() = GetMapboxCoordinate(scwxCoordinates.front());

View file

@ -18,7 +18,7 @@ public:
~AlertLayer();
void Initialize() override final;
void Render(const QMapbox::CustomLayerRenderParameters&) override final;
void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final;
void Deinitialize() override final;
void AddLayers(const std::string& before = {});

View file

@ -107,7 +107,8 @@ void ColorTableLayer::Initialize()
[=]() { p->colorTableNeedsUpdate_ = true; });
}
void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params)
void ColorTableLayer::Render(
const QMapLibreGL::CustomLayerRenderParameters& params)
{
gl::OpenGLFunctions& gl = context()->gl();
auto radarProductView = context()->radar_product_view();

View file

@ -18,7 +18,7 @@ public:
~ColorTableLayer();
void Initialize() override final;
void Render(const QMapbox::CustomLayerRenderParameters&) override final;
void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final;
void Deinitialize() override final;
private:

View file

@ -42,7 +42,7 @@ void DrawLayer::Initialize()
}
}
void DrawLayer::Render(const QMapbox::CustomLayerRenderParameters& params)
void DrawLayer::Render(const QMapLibreGL::CustomLayerRenderParameters& params)
{
gl::OpenGLFunctions& gl = p->context_->gl();

View file

@ -19,7 +19,7 @@ public:
virtual ~DrawLayer();
virtual void Initialize();
virtual void Render(const QMapbox::CustomLayerRenderParameters&);
virtual void Render(const QMapLibreGL::CustomLayerRenderParameters&);
virtual void Deinitialize();
protected:

View file

@ -5,7 +5,7 @@
#include <memory>
#include <QObject>
#include <QMapboxGL>
#include <QMapLibreGL/QMapLibreGL>
namespace scwx
{
@ -24,9 +24,9 @@ public:
explicit GenericLayer(std::shared_ptr<MapContext> context);
virtual ~GenericLayer();
virtual void Initialize() = 0;
virtual void Render(const QMapbox::CustomLayerRenderParameters&) = 0;
virtual void Deinitialize() = 0;
virtual void Initialize() = 0;
virtual void Render(const QMapLibreGL::CustomLayerRenderParameters&) = 0;
virtual void Deinitialize() = 0;
protected:
std::shared_ptr<MapContext> context() const;

View file

@ -26,7 +26,7 @@ LayerWrapper::LayerWrapper(std::shared_ptr<GenericLayer> layer) :
}
LayerWrapper::~LayerWrapper() = default;
LayerWrapper::LayerWrapper(LayerWrapper&&) noexcept = default;
LayerWrapper::LayerWrapper(LayerWrapper&&) noexcept = default;
LayerWrapper& LayerWrapper::operator=(LayerWrapper&&) noexcept = default;
void LayerWrapper::initialize()
@ -34,7 +34,8 @@ void LayerWrapper::initialize()
p->layer_->Initialize();
}
void LayerWrapper::render(const QMapbox::CustomLayerRenderParameters& params)
void LayerWrapper::render(
const QMapLibreGL::CustomLayerRenderParameters& params)
{
p->layer_->Render(params);
}

View file

@ -11,20 +11,20 @@ namespace map
class LayerWrapperImpl;
class LayerWrapper : public QMapbox::CustomLayerHostInterface
class LayerWrapper : public QMapLibreGL::CustomLayerHostInterface
{
public:
explicit LayerWrapper(std::shared_ptr<GenericLayer> layer);
~LayerWrapper();
LayerWrapper(const LayerWrapper&) = delete;
LayerWrapper(const LayerWrapper&) = delete;
LayerWrapper& operator=(const LayerWrapper&) = delete;
LayerWrapper(LayerWrapper&&) noexcept;
LayerWrapper& operator=(LayerWrapper&&) noexcept;
void initialize() override final;
void render(const QMapbox::CustomLayerRenderParameters&) override final;
void render(const QMapLibreGL::CustomLayerRenderParameters&) override final;
void deinitialize() override final;
private:

View file

@ -22,7 +22,7 @@ public:
~Impl() {}
std::weak_ptr<QMapboxGL> map_;
std::weak_ptr<QMapLibreGL::Map> map_;
MapSettings settings_;
std::shared_ptr<view::RadarProductView> radarProductView_;
common::RadarProductGroup radarProductGroup_;
@ -40,7 +40,7 @@ MapContext::~MapContext() = default;
MapContext::MapContext(MapContext&&) noexcept = default;
MapContext& MapContext::operator=(MapContext&&) noexcept = default;
std::weak_ptr<QMapboxGL> MapContext::map() const
std::weak_ptr<QMapLibreGL::Map> MapContext::map() const
{
return p->map_;
}
@ -70,7 +70,7 @@ int16_t MapContext::radar_product_code() const
return p->radarProductCode_;
}
void MapContext::set_map(std::shared_ptr<QMapboxGL> map)
void MapContext::set_map(std::shared_ptr<QMapLibreGL::Map> map)
{
p->map_ = map;
}

View file

@ -4,7 +4,7 @@
#include <scwx/qt/map/map_settings.hpp>
#include <scwx/qt/view/radar_product_view.hpp>
class QMapboxGL;
#include <QMapLibreGL/QMapLibreGL>
namespace scwx
{
@ -26,14 +26,14 @@ public:
MapContext(MapContext&&) noexcept;
MapContext& operator=(MapContext&&) noexcept;
std::weak_ptr<QMapboxGL> map() const;
std::weak_ptr<QMapLibreGL::Map> map() const;
MapSettings& settings();
std::shared_ptr<view::RadarProductView> radar_product_view() const;
common::RadarProductGroup radar_product_group() const;
std::string radar_product() const;
int16_t radar_product_code() const;
void set_map(std::shared_ptr<QMapboxGL> map);
void set_map(std::shared_ptr<QMapLibreGL::Map> map);
void set_radar_product_view(
std::shared_ptr<view::RadarProductView> radarProductView);
void set_radar_product_group(common::RadarProductGroup radarProductGroup);

View file

@ -51,8 +51,8 @@ class MapWidgetImpl : public QObject
Q_OBJECT
public:
explicit MapWidgetImpl(MapWidget* widget,
const QMapboxGLSettings& settings) :
explicit MapWidgetImpl(MapWidget* widget,
const QMapLibreGL::Settings& settings) :
context_ {std::make_shared<MapContext>()},
widget_ {widget},
settings_(settings),
@ -96,10 +96,10 @@ public:
std::shared_ptr<MapContext> context_;
MapWidget* widget_;
QMapboxGLSettings settings_;
std::shared_ptr<QMapboxGL> map_;
std::list<std::string> layerList_;
MapWidget* widget_;
QMapLibreGL::Settings settings_;
std::shared_ptr<QMapLibreGL::Map> map_;
std::list<std::string> layerList_;
std::shared_ptr<manager::RadarProductManager> radarProductManager_;
@ -130,7 +130,7 @@ public slots:
void Update();
};
MapWidget::MapWidget(const QMapboxGLSettings& settings) :
MapWidget::MapWidget(const QMapLibreGL::Settings& settings) :
p(std::make_unique<MapWidgetImpl>(this, settings))
{
setFocusPolicy(Qt::StrongFocus);
@ -138,7 +138,7 @@ MapWidget::MapWidget(const QMapboxGLSettings& settings) :
MapWidget::~MapWidget()
{
// Make sure we have a valid context so we can delete the QMapboxGL.
// Make sure we have a valid context so we can delete the QMapLibreGL.
makeCurrent();
}
@ -534,8 +534,8 @@ void MapWidgetImpl::AddLayer(const std::string& id,
std::shared_ptr<GenericLayer> layer,
const std::string& before)
{
// QMapboxGL::addCustomLayer will take ownership of the std::unique_ptr
std::unique_ptr<QMapbox::CustomLayerHostInterface> pHost =
// QMapLibreGL::addCustomLayer will take ownership of the std::unique_ptr
std::unique_ptr<QMapLibreGL::CustomLayerHostInterface> pHost =
std::make_unique<LayerWrapper>(layer);
map_->addCustomLayer(id.c_str(), std::move(pHost), before.c_str());
@ -642,10 +642,11 @@ void MapWidget::initializeGL()
makeCurrent();
p->context_->gl().initializeOpenGLFunctions();
p->map_.reset(new QMapboxGL(nullptr, p->settings_, size(), pixelRatio()));
p->map_.reset(
new QMapLibreGL::Map(nullptr, p->settings_, size(), pixelRatio()));
p->context_->set_map(p->map_);
connect(p->map_.get(),
&QMapboxGL::needsRendering,
&QMapLibreGL::Map::needsRendering,
p.get(),
&MapWidgetImpl::Update);
@ -672,7 +673,10 @@ void MapWidget::initializeGL()
setWindowTitle(QString("Mapbox GL: ") + styleUrl);
}
connect(p->map_.get(), &QMapboxGL::mapChanged, this, &MapWidget::mapChanged);
connect(p->map_.get(),
&QMapLibreGL::Map::mapChanged,
this,
&MapWidget::mapChanged);
}
void MapWidget::paintGL()
@ -684,11 +688,11 @@ void MapWidget::paintGL()
p->map_->render();
}
void MapWidget::mapChanged(QMapboxGL::MapChange mapChange)
void MapWidget::mapChanged(QMapLibreGL::Map::MapChange mapChange)
{
switch (mapChange)
{
case QMapboxGL::MapChangeDidFinishLoadingStyle:
case QMapLibreGL::Map::MapChangeDidFinishLoadingStyle:
AddLayers();
break;
}

View file

@ -7,7 +7,7 @@
#include <chrono>
#include <memory>
#include <QMapboxGL>
#include <QMapLibreGL/QMapLibreGL>
#include <QOpenGLWidget>
#include <QPropertyAnimation>
@ -31,7 +31,7 @@ class MapWidget : public QOpenGLWidget
Q_OBJECT
public:
explicit MapWidget(const QMapboxGLSettings&);
explicit MapWidget(const QMapLibreGL::Settings&);
~MapWidget();
common::Level3ProductCategoryMap GetAvailableLevel3Categories();
@ -79,7 +79,7 @@ private:
friend class MapWidgetImpl;
private slots:
void mapChanged(QMapboxGL::MapChange);
void mapChanged(QMapLibreGL::Map::MapChange);
signals:
void Level3ProductsChanged();

View file

@ -100,7 +100,8 @@ void OverlayLayer::Initialize()
}
}
void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params)
void OverlayLayer::Render(
const QMapLibreGL::CustomLayerRenderParameters& params)
{
constexpr float fontSize = 16.0f;

View file

@ -18,7 +18,7 @@ public:
~OverlayLayer();
void Initialize() override final;
void Render(const QMapbox::CustomLayerRenderParameters&) override final;
void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final;
void Deinitialize() override final;
public slots:

View file

@ -26,7 +26,7 @@ static const std::string logPrefix_ = "scwx::qt::map::radar_product_layer";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
static glm::vec2
LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate);
LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate);
class RadarProductLayerImpl
{
@ -253,7 +253,7 @@ void RadarProductLayer::UpdateSweep()
}
void RadarProductLayer::Render(
const QMapbox::CustomLayerRenderParameters& params)
const QMapLibreGL::CustomLayerRenderParameters& params)
{
gl::OpenGLFunctions& gl = context()->gl();
@ -270,7 +270,7 @@ void RadarProductLayer::Render(
}
const float scale = std::pow(2.0, params.zoom) * 2.0f *
mbgl::util::tileSize / mbgl::util::DEGREES_MAX;
mbgl::util::tileSize_D / mbgl::util::DEGREES_MAX;
const float xScale = scale / params.width;
const float yScale = scale / params.height;
@ -351,14 +351,14 @@ void RadarProductLayer::UpdateColorTable()
}
static glm::vec2
LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate)
LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate)
{
double latitude = std::clamp(
coordinate.first, -mbgl::util::LATITUDE_MAX, mbgl::util::LATITUDE_MAX);
glm::vec2 screen {
mbgl::util::LONGITUDE_MAX + coordinate.second,
-(mbgl::util::LONGITUDE_MAX -
mbgl::util::RAD2DEG *
mbgl::util::RAD2DEG_D *
std::log(std::tan(M_PI / 4.0 +
latitude * M_PI / mbgl::util::DEGREES_MAX)))};
return screen;

View file

@ -18,7 +18,7 @@ public:
~RadarProductLayer();
void Initialize() override final;
void Render(const QMapbox::CustomLayerRenderParameters&) override final;
void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final;
void Deinitialize() override final;
private:

View file

@ -14,13 +14,13 @@ namespace map
static const std::string logPrefix_ = "scwx::qt::map::radar_range_layer";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
static std::shared_ptr<QMapbox::Feature>
GetRangeCircle(float range, QMapbox::Coordinate center);
static std::shared_ptr<QMapLibreGL::Feature>
GetRangeCircle(float range, QMapLibreGL::Coordinate center);
void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map,
float range,
QMapbox::Coordinate center,
const QString& before)
void RadarRangeLayer::Add(std::shared_ptr<QMapLibreGL::Map> map,
float range,
QMapLibreGL::Coordinate center,
const QString& before)
{
logger_->debug("Add()");
@ -33,7 +33,7 @@ void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map,
map->removeSource("rangeCircleSource");
}
std::shared_ptr<QMapbox::Feature> rangeCircle =
std::shared_ptr<QMapLibreGL::Feature> rangeCircle =
GetRangeCircle(range, center);
map->addSource(
@ -47,19 +47,19 @@ void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map,
"rangeCircleLayer", "line-color", "rgba(128, 128, 128, 128)");
}
void RadarRangeLayer::Update(std::shared_ptr<QMapboxGL> map,
float range,
QMapbox::Coordinate center)
void RadarRangeLayer::Update(std::shared_ptr<QMapLibreGL::Map> map,
float range,
QMapLibreGL::Coordinate center)
{
std::shared_ptr<QMapbox::Feature> rangeCircle =
std::shared_ptr<QMapLibreGL::Feature> rangeCircle =
GetRangeCircle(range, center);
map->updateSource("rangeCircleSource",
{{"data", QVariant::fromValue(*rangeCircle)}});
}
static std::shared_ptr<QMapbox::Feature>
GetRangeCircle(float range, QMapbox::Coordinate center)
static std::shared_ptr<QMapLibreGL::Feature>
GetRangeCircle(float range, QMapLibreGL::Coordinate center)
{
GeographicLib::Geodesic geodesic(GeographicLib::Constants::WGS84_a(),
GeographicLib::Constants::WGS84_f());
@ -69,7 +69,7 @@ GetRangeCircle(float range, QMapbox::Coordinate center)
float angle = -angleDeltaH;
QMapbox::Coordinates geometry;
QMapLibreGL::Coordinates geometry;
for (uint16_t azimuth = 0; azimuth <= 720; ++azimuth)
{
@ -88,11 +88,11 @@ GetRangeCircle(float range, QMapbox::Coordinate center)
angle += angleDelta;
}
std::shared_ptr<QMapbox::Feature> rangeCircle =
std::make_shared<QMapbox::Feature>(
QMapbox::Feature::LineStringType,
std::initializer_list<QMapbox::CoordinatesCollection> {
std::initializer_list<QMapbox::Coordinates> {geometry}});
std::shared_ptr<QMapLibreGL::Feature> rangeCircle =
std::make_shared<QMapLibreGL::Feature>(
QMapLibreGL::Feature::LineStringType,
std::initializer_list<QMapLibreGL::CoordinatesCollection> {
std::initializer_list<QMapLibreGL::Coordinates> {geometry}});
return rangeCircle;
}

View file

@ -1,6 +1,6 @@
#pragma once
#include <QMapboxGL>
#include <QMapLibreGL/QMapLibreGL>
namespace scwx
{
@ -11,13 +11,13 @@ namespace map
namespace RadarRangeLayer
{
void Add(std::shared_ptr<QMapboxGL> map,
float range,
QMapbox::Coordinate center,
const QString& before = QString());
void Update(std::shared_ptr<QMapboxGL> map,
float range,
QMapbox::Coordinate center);
void Add(std::shared_ptr<QMapLibreGL::Map> map,
float range,
QMapLibreGL::Coordinate center,
const QString& before = QString());
void Update(std::shared_ptr<QMapLibreGL::Map> map,
float range,
QMapLibreGL::Coordinate center);
} // namespace RadarRangeLayer
} // namespace map