mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:20:06 +00:00
Update to latest maplibre-gl-native, including rename from QMapboxGL to QMapLibreGL
This commit is contained in:
parent
243e874b55
commit
2ac141ea1a
30 changed files with 143 additions and 133 deletions
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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 = {});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue