mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 17:00:05 +00:00
Add poi layer
This commit is contained in:
parent
c2209908a0
commit
ec4387112e
4 changed files with 132 additions and 0 deletions
97
scwx-qt/source/scwx/qt/map/poi_layer.cpp
Normal file
97
scwx-qt/source/scwx/qt/map/poi_layer.cpp
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
#include <scwx/qt/map/poi_layer.hpp>
|
||||||
|
#include <scwx/qt/manager/poi_manager.hpp>
|
||||||
|
#include <scwx/util/logger.hpp>
|
||||||
|
#include <scwx/qt/types/poi_types.hpp>
|
||||||
|
#include <scwx/qt/types/texture_types.hpp>
|
||||||
|
#include <scwx/qt/gl/draw/geo_icons.hpp>
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace qt
|
||||||
|
{
|
||||||
|
namespace map
|
||||||
|
{
|
||||||
|
|
||||||
|
static const std::string logPrefix_ = "scwx::qt::map::poi_layer";
|
||||||
|
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||||
|
|
||||||
|
|
||||||
|
class POILayer::Impl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit Impl(std::shared_ptr<MapContext> context) :
|
||||||
|
geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~Impl() {}
|
||||||
|
|
||||||
|
void ReloadPOIs();
|
||||||
|
|
||||||
|
const std::string& poiIconName_ {
|
||||||
|
types::GetTextureName(types::ImageTexture::Crosshairs24)};
|
||||||
|
|
||||||
|
std::shared_ptr<gl::draw::GeoIcons> geoIcons_;
|
||||||
|
};
|
||||||
|
|
||||||
|
void POILayer::Impl::ReloadPOIs()
|
||||||
|
{
|
||||||
|
logger_->debug("ReloadPOIs");
|
||||||
|
auto poiManager = manager::POIManager::Instance();
|
||||||
|
|
||||||
|
geoIcons_->StartIcons();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < poiManager->poi_count(); i++)
|
||||||
|
{
|
||||||
|
types::PointOfInterest poi = poiManager->get_poi(i);
|
||||||
|
std::shared_ptr<gl::draw::GeoIconDrawItem> icon = geoIcons_->AddIcon();
|
||||||
|
geoIcons_->SetIconTexture(icon, poiIconName_, 0);
|
||||||
|
geoIcons_->SetIconLocation(icon, poi.latitude_, poi.longitude_);
|
||||||
|
}
|
||||||
|
|
||||||
|
geoIcons_->FinishIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
POILayer::POILayer(const std::shared_ptr<MapContext>& context) :
|
||||||
|
DrawLayer(context),
|
||||||
|
p(std::make_unique<POILayer::Impl>(context))
|
||||||
|
{
|
||||||
|
AddDrawItem(p->geoIcons_);
|
||||||
|
}
|
||||||
|
|
||||||
|
POILayer::~POILayer() = default;
|
||||||
|
|
||||||
|
void POILayer::Initialize()
|
||||||
|
{
|
||||||
|
logger_->debug("Initialize()");
|
||||||
|
DrawLayer::Initialize();
|
||||||
|
|
||||||
|
p->geoIcons_->StartIconSheets();
|
||||||
|
p->geoIcons_->AddIconSheet(p->poiIconName_);
|
||||||
|
p->geoIcons_->FinishIconSheets();
|
||||||
|
}
|
||||||
|
|
||||||
|
void POILayer::Render(
|
||||||
|
const QMapLibre::CustomLayerRenderParameters& params)
|
||||||
|
{
|
||||||
|
//auto poiManager = manager::POIManager::Instance();
|
||||||
|
gl::OpenGLFunctions& gl = context()->gl();
|
||||||
|
|
||||||
|
// TODO. do not redo this every time
|
||||||
|
p->ReloadPOIs();
|
||||||
|
|
||||||
|
DrawLayer::Render(params);
|
||||||
|
|
||||||
|
SCWX_GL_CHECK_ERROR();
|
||||||
|
}
|
||||||
|
|
||||||
|
void POILayer::Deinitialize()
|
||||||
|
{
|
||||||
|
logger_->debug("Deinitialize()");
|
||||||
|
|
||||||
|
DrawLayer::Deinitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace map
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace scwx
|
||||||
|
|
||||||
33
scwx-qt/source/scwx/qt/map/poi_layer.hpp
Normal file
33
scwx-qt/source/scwx/qt/map/poi_layer.hpp
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <scwx/qt/map/draw_layer.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace qt
|
||||||
|
{
|
||||||
|
namespace map
|
||||||
|
{
|
||||||
|
|
||||||
|
class POILayer : public DrawLayer
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit POILayer(const std::shared_ptr<MapContext>& context);
|
||||||
|
~POILayer();
|
||||||
|
|
||||||
|
void Initialize() override final;
|
||||||
|
void Render(const QMapLibre::CustomLayerRenderParameters&) override final;
|
||||||
|
void Deinitialize() override final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
std::unique_ptr<Impl> p;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace map
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace scwx
|
||||||
|
|
@ -31,6 +31,7 @@ static const std::unordered_map<InformationLayer, std::string>
|
||||||
informationLayerName_ {{InformationLayer::MapOverlay, "Map Overlay"},
|
informationLayerName_ {{InformationLayer::MapOverlay, "Map Overlay"},
|
||||||
{InformationLayer::RadarSite, "Radar Sites"},
|
{InformationLayer::RadarSite, "Radar Sites"},
|
||||||
{InformationLayer::ColorTable, "Color Table"},
|
{InformationLayer::ColorTable, "Color Table"},
|
||||||
|
{InformationLayer::POILayer, "Point of Interest"},
|
||||||
{InformationLayer::Unknown, "?"}};
|
{InformationLayer::Unknown, "?"}};
|
||||||
|
|
||||||
static const std::unordered_map<MapLayer, std::string> mapLayerName_ {
|
static const std::unordered_map<MapLayer, std::string> mapLayerName_ {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ enum class InformationLayer
|
||||||
MapOverlay,
|
MapOverlay,
|
||||||
RadarSite,
|
RadarSite,
|
||||||
ColorTable,
|
ColorTable,
|
||||||
|
POILayer,
|
||||||
Unknown
|
Unknown
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue