renamed all POI/point of intrest to marker

This commit is contained in:
AdenKoperczak 2024-10-04 19:31:47 -04:00
parent cd16902635
commit 31940441ed
11 changed files with 153 additions and 157 deletions

View file

@ -95,7 +95,7 @@ set(HDR_MANAGER source/scwx/qt/manager/alert_manager.hpp
source/scwx/qt/manager/log_manager.hpp source/scwx/qt/manager/log_manager.hpp
source/scwx/qt/manager/media_manager.hpp source/scwx/qt/manager/media_manager.hpp
source/scwx/qt/manager/placefile_manager.hpp source/scwx/qt/manager/placefile_manager.hpp
source/scwx/qt/manager/poi_manager.hpp source/scwx/qt/manager/marker_manager.hpp
source/scwx/qt/manager/position_manager.hpp source/scwx/qt/manager/position_manager.hpp
source/scwx/qt/manager/radar_product_manager.hpp source/scwx/qt/manager/radar_product_manager.hpp
source/scwx/qt/manager/radar_product_manager_notifier.hpp source/scwx/qt/manager/radar_product_manager_notifier.hpp
@ -112,7 +112,7 @@ set(SRC_MANAGER source/scwx/qt/manager/alert_manager.cpp
source/scwx/qt/manager/log_manager.cpp source/scwx/qt/manager/log_manager.cpp
source/scwx/qt/manager/media_manager.cpp source/scwx/qt/manager/media_manager.cpp
source/scwx/qt/manager/placefile_manager.cpp source/scwx/qt/manager/placefile_manager.cpp
source/scwx/qt/manager/poi_manager.cpp source/scwx/qt/manager/marker_manager.cpp
source/scwx/qt/manager/position_manager.cpp source/scwx/qt/manager/position_manager.cpp
source/scwx/qt/manager/radar_product_manager.cpp source/scwx/qt/manager/radar_product_manager.cpp
source/scwx/qt/manager/radar_product_manager_notifier.cpp source/scwx/qt/manager/radar_product_manager_notifier.cpp
@ -134,7 +134,7 @@ set(HDR_MAP source/scwx/qt/map/alert_layer.hpp
source/scwx/qt/map/overlay_layer.hpp source/scwx/qt/map/overlay_layer.hpp
source/scwx/qt/map/overlay_product_layer.hpp source/scwx/qt/map/overlay_product_layer.hpp
source/scwx/qt/map/placefile_layer.hpp source/scwx/qt/map/placefile_layer.hpp
source/scwx/qt/map/poi_layer.hpp source/scwx/qt/map/marker_layer.hpp
source/scwx/qt/map/radar_product_layer.hpp source/scwx/qt/map/radar_product_layer.hpp
source/scwx/qt/map/radar_range_layer.hpp source/scwx/qt/map/radar_range_layer.hpp
source/scwx/qt/map/radar_site_layer.hpp) source/scwx/qt/map/radar_site_layer.hpp)
@ -149,7 +149,7 @@ set(SRC_MAP source/scwx/qt/map/alert_layer.cpp
source/scwx/qt/map/overlay_layer.cpp source/scwx/qt/map/overlay_layer.cpp
source/scwx/qt/map/overlay_product_layer.cpp source/scwx/qt/map/overlay_product_layer.cpp
source/scwx/qt/map/placefile_layer.cpp source/scwx/qt/map/placefile_layer.cpp
source/scwx/qt/map/poi_layer.cpp source/scwx/qt/map/marker_layer.cpp
source/scwx/qt/map/radar_product_layer.cpp source/scwx/qt/map/radar_product_layer.cpp
source/scwx/qt/map/radar_range_layer.cpp source/scwx/qt/map/radar_range_layer.cpp
source/scwx/qt/map/radar_site_layer.cpp) source/scwx/qt/map/radar_site_layer.cpp)
@ -219,7 +219,7 @@ set(HDR_TYPES source/scwx/qt/types/alert_types.hpp
source/scwx/qt/types/location_types.hpp source/scwx/qt/types/location_types.hpp
source/scwx/qt/types/map_types.hpp source/scwx/qt/types/map_types.hpp
source/scwx/qt/types/media_types.hpp source/scwx/qt/types/media_types.hpp
source/scwx/qt/types/poi_types.hpp source/scwx/qt/types/marker_types.hpp
source/scwx/qt/types/qt_types.hpp source/scwx/qt/types/qt_types.hpp
source/scwx/qt/types/radar_product_record.hpp source/scwx/qt/types/radar_product_record.hpp
source/scwx/qt/types/text_event_key.hpp source/scwx/qt/types/text_event_key.hpp

View file

@ -6,7 +6,7 @@
#include <scwx/qt/manager/alert_manager.hpp> #include <scwx/qt/manager/alert_manager.hpp>
#include <scwx/qt/manager/hotkey_manager.hpp> #include <scwx/qt/manager/hotkey_manager.hpp>
#include <scwx/qt/manager/placefile_manager.hpp> #include <scwx/qt/manager/placefile_manager.hpp>
#include <scwx/qt/manager/poi_manager.hpp> #include <scwx/qt/manager/marker_manager.hpp>
#include <scwx/qt/manager/position_manager.hpp> #include <scwx/qt/manager/position_manager.hpp>
#include <scwx/qt/manager/radar_product_manager.hpp> #include <scwx/qt/manager/radar_product_manager.hpp>
#include <scwx/qt/manager/text_event_manager.hpp> #include <scwx/qt/manager/text_event_manager.hpp>
@ -92,7 +92,7 @@ public:
updateDialog_ {nullptr}, updateDialog_ {nullptr},
alertManager_ {manager::AlertManager::Instance()}, alertManager_ {manager::AlertManager::Instance()},
placefileManager_ {manager::PlacefileManager::Instance()}, placefileManager_ {manager::PlacefileManager::Instance()},
poiManager_ {manager::POIManager::Instance()}, markerManager_ {manager::MarkerManager::Instance()},
positionManager_ {manager::PositionManager::Instance()}, positionManager_ {manager::PositionManager::Instance()},
textEventManager_ {manager::TextEventManager::Instance()}, textEventManager_ {manager::TextEventManager::Instance()},
timelineManager_ {manager::TimelineManager::Instance()}, timelineManager_ {manager::TimelineManager::Instance()},
@ -219,7 +219,7 @@ public:
std::shared_ptr<manager::HotkeyManager> hotkeyManager_ { std::shared_ptr<manager::HotkeyManager> hotkeyManager_ {
manager::HotkeyManager::Instance()}; manager::HotkeyManager::Instance()};
std::shared_ptr<manager::PlacefileManager> placefileManager_; std::shared_ptr<manager::PlacefileManager> placefileManager_;
std::shared_ptr<manager::POIManager> poiManager_; std::shared_ptr<manager::MarkerManager> markerManager_;
std::shared_ptr<manager::PositionManager> positionManager_; std::shared_ptr<manager::PositionManager> positionManager_;
std::shared_ptr<manager::TextEventManager> textEventManager_; std::shared_ptr<manager::TextEventManager> textEventManager_;
std::shared_ptr<manager::TimelineManager> timelineManager_; std::shared_ptr<manager::TimelineManager> timelineManager_;

View file

@ -1,5 +1,5 @@
#include <scwx/qt/manager/poi_manager.hpp> #include <scwx/qt/manager/marker_manager.hpp>
#include <scwx/qt/types/poi_types.hpp> #include <scwx/qt/types/marker_types.hpp>
#include <scwx/qt/util/json.hpp> #include <scwx/qt/util/json.hpp>
#include <scwx/qt/main/application.hpp> #include <scwx/qt/main/application.hpp>
#include <scwx/util/logger.hpp> #include <scwx/util/logger.hpp>
@ -18,37 +18,37 @@ namespace qt
namespace manager namespace manager
{ {
static const std::string logPrefix_ = "scwx::qt::manager::poi_manager"; static const std::string logPrefix_ = "scwx::qt::manager::marker_manager";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
static const std::string kNameName_ = "name"; static const std::string kNameName_ = "name";
static const std::string kLatitudeName_ = "latitude"; static const std::string kLatitudeName_ = "latitude";
static const std::string kLongitudeName_ = "longitude"; static const std::string kLongitudeName_ = "longitude";
class POIManager::Impl class MarkerManager::Impl
{ {
public: public:
class POIRecord; class MarkerRecord;
explicit Impl(POIManager* self) : self_ {self} {} explicit Impl(MarkerManager* self) : self_ {self} {}
~Impl() {} ~Impl() {}
std::string poiSettingsPath_ {}; std::string markerSettingsPath_ {};
std::vector<std::shared_ptr<POIRecord>> poiRecords_ {}; std::vector<std::shared_ptr<MarkerRecord>> markerRecords_ {};
POIManager* self_; MarkerManager* self_;
void InitializePOISettings(); void InitializeMarkerSettings();
void ReadPOISettings(); void ReadMarkerSettings();
void WritePOISettings(); void WriteMarkerSettings();
std::shared_ptr<POIRecord> GetPOIByName(const std::string& name); std::shared_ptr<MarkerRecord> GetMarkerByName(const std::string& name);
}; };
class POIManager::Impl::POIRecord class MarkerManager::Impl::MarkerRecord
{ {
public: public:
POIRecord(std::string name, double latitude, double longitude) : MarkerRecord(std::string name, double latitude, double longitude) :
name_ {name}, latitude_ {latitude}, longitude_ {longitude} name_ {name}, latitude_ {latitude}, longitude_ {longitude}
{ {
} }
@ -59,17 +59,17 @@ public:
friend void tag_invoke(boost::json::value_from_tag, friend void tag_invoke(boost::json::value_from_tag,
boost::json::value& jv, boost::json::value& jv,
const std::shared_ptr<POIRecord>& record) const std::shared_ptr<MarkerRecord>& record)
{ {
jv = {{kNameName_, record->name_}, jv = {{kNameName_, record->name_},
{kLatitudeName_, record->latitude_}, {kLatitudeName_, record->latitude_},
{kLongitudeName_, record->longitude_}}; {kLongitudeName_, record->longitude_}};
} }
friend POIRecord tag_invoke(boost::json::value_to_tag<POIRecord>, friend MarkerRecord tag_invoke(boost::json::value_to_tag<MarkerRecord>,
const boost::json::value& jv) const boost::json::value& jv)
{ {
return POIRecord( return MarkerRecord(
boost::json::value_to<std::string>(jv.at(kNameName_)), boost::json::value_to<std::string>(jv.at(kNameName_)),
boost::json::value_to<double>(jv.at(kLatitudeName_)), boost::json::value_to<double>(jv.at(kLatitudeName_)),
boost::json::value_to<double>(jv.at(kLongitudeName_))); boost::json::value_to<double>(jv.at(kLongitudeName_)));
@ -77,7 +77,7 @@ public:
}; };
void POIManager::Impl::InitializePOISettings() void MarkerManager::Impl::InitializeMarkerSettings()
{ {
std::string appDataPath { std::string appDataPath {
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
@ -92,81 +92,81 @@ void POIManager::Impl::InitializePOISettings()
} }
} }
poiSettingsPath_ = appDataPath + "/points_of_interest.json"; markerSettingsPath_ = appDataPath + "/location-markers.json";
} }
void POIManager::Impl::ReadPOISettings() void MarkerManager::Impl::ReadMarkerSettings()
{ {
logger_->info("Reading point of interest settings"); logger_->info("Reading location marker settings");
boost::json::value poiJson = nullptr; boost::json::value markerJson = nullptr;
// Determine if poi settings exists // Determine if marker settings exists
if (std::filesystem::exists(poiSettingsPath_)) if (std::filesystem::exists(markerSettingsPath_))
{ {
poiJson = util::json::ReadJsonFile(poiSettingsPath_); markerJson = util::json::ReadJsonFile(markerSettingsPath_);
} }
if (poiJson != nullptr && poiJson.is_array()) if (markerJson != nullptr && markerJson.is_array())
{ {
// For each poi entry // For each marker entry
auto& poiArray = poiJson.as_array(); auto& markerArray = markerJson.as_array();
poiRecords_.reserve(poiArray.size()); markerRecords_.reserve(markerArray.size());
for (auto& poiEntry : poiArray) for (auto& markerEntry : markerArray)
{ {
try try
{ {
POIRecord record = MarkerRecord record =
boost::json::value_to<POIRecord>(poiEntry); boost::json::value_to<MarkerRecord>(markerEntry);
if (!record.name_.empty()) if (!record.name_.empty())
{ {
poiRecords_.emplace_back(std::make_shared<POIRecord>( markerRecords_.emplace_back(std::make_shared<MarkerRecord>(
record.name_, record.latitude_, record.longitude_)); record.name_, record.latitude_, record.longitude_));
} }
} }
catch (const std::exception& ex) catch (const std::exception& ex)
{ {
logger_->warn("Invalid point of interest entry: {}", ex.what()); logger_->warn("Invalid location marker entry: {}", ex.what());
} }
} }
logger_->debug("{} point of interest entries", poiRecords_.size()); logger_->debug("{} location marker entries", markerRecords_.size());
} }
} }
void POIManager::Impl::WritePOISettings() void MarkerManager::Impl::WriteMarkerSettings()
{ {
logger_->info("Saving point of interest settings"); logger_->info("Saving location marker settings");
auto poiJson = boost::json::value_from(poiRecords_); auto markerJson = boost::json::value_from(markerRecords_);
util::json::WriteJsonFile(poiSettingsPath_, poiJson); util::json::WriteJsonFile(markerSettingsPath_, markerJson);
} }
std::shared_ptr<POIManager::Impl::POIRecord> std::shared_ptr<MarkerManager::Impl::MarkerRecord>
POIManager::Impl::GetPOIByName(const std::string& name) MarkerManager::Impl::GetMarkerByName(const std::string& name)
{ {
for (auto& poiRecord : poiRecords_) for (auto& markerRecord : markerRecords_)
{ {
if (poiRecord->name_ == name) if (markerRecord->name_ == name)
{ {
return poiRecord; return markerRecord;
} }
} }
return nullptr; return nullptr;
} }
POIManager::POIManager() : p(std::make_unique<Impl>(this)) MarkerManager::MarkerManager() : p(std::make_unique<Impl>(this))
{ {
// TODO THREADING? // TODO THREADING?
try try
{ {
p->InitializePOISettings(); p->InitializeMarkerSettings();
// Read POI settings on startup // Read Marker settings on startup
//main::Application::WaitForInitialization(); //main::Application::WaitForInitialization();
p->ReadPOISettings(); p->ReadMarkerSettings();
} }
catch (const std::exception& ex) catch (const std::exception& ex)
{ {
@ -174,66 +174,66 @@ POIManager::POIManager() : p(std::make_unique<Impl>(this))
} }
} }
POIManager::~POIManager() MarkerManager::~MarkerManager()
{ {
p->WritePOISettings(); p->WriteMarkerSettings();
} }
size_t POIManager::poi_count() size_t MarkerManager::marker_count()
{ {
return p->poiRecords_.size(); return p->markerRecords_.size();
} }
// TODO deal with out of range/not found // TODO deal with out of range/not found
types::PointOfInterest POIManager::get_poi(size_t index) types::MarkerInfo MarkerManager::get_marker(size_t index)
{ {
std::shared_ptr<POIManager::Impl::POIRecord> poiRecord = std::shared_ptr<MarkerManager::Impl::MarkerRecord> markerRecord =
p->poiRecords_[index]; p->markerRecords_[index];
return types::PointOfInterest( return types::MarkerInfo(
poiRecord->name_, poiRecord->latitude_, poiRecord->longitude_); markerRecord->name_, markerRecord->latitude_, markerRecord->longitude_);
} }
types::PointOfInterest POIManager::get_poi(const std::string& name) types::MarkerInfo MarkerManager::get_marker(const std::string& name)
{ {
std::shared_ptr<POIManager::Impl::POIRecord> poiRecord = std::shared_ptr<MarkerManager::Impl::MarkerRecord> markerRecord =
p->GetPOIByName(name); p->GetMarkerByName(name);
return types::PointOfInterest( return types::MarkerInfo(
poiRecord->name_, poiRecord->latitude_, poiRecord->longitude_); markerRecord->name_, markerRecord->latitude_, markerRecord->longitude_);
} }
void POIManager::set_poi(size_t index, const types::PointOfInterest& poi) void MarkerManager::set_marker(size_t index, const types::MarkerInfo& marker)
{ {
std::shared_ptr<POIManager::Impl::POIRecord> poiRecord = std::shared_ptr<MarkerManager::Impl::MarkerRecord> markerRecord =
p->poiRecords_[index]; p->markerRecords_[index];
poiRecord->name_ = poi.name_; markerRecord->name_ = marker.name_;
poiRecord->latitude_ = poi.latitude_; markerRecord->latitude_ = marker.latitude_;
poiRecord->longitude_ = poi.longitude_; markerRecord->longitude_ = marker.longitude_;
} }
void POIManager::set_poi(const std::string& name, void MarkerManager::set_marker(const std::string& name,
const types::PointOfInterest& poi) const types::MarkerInfo& marker)
{ {
std::shared_ptr<POIManager::Impl::POIRecord> poiRecord = std::shared_ptr<MarkerManager::Impl::MarkerRecord> markerRecord =
p->GetPOIByName(name); p->GetMarkerByName(name);
poiRecord->name_ = poi.name_; markerRecord->name_ = marker.name_;
poiRecord->latitude_ = poi.latitude_; markerRecord->latitude_ = marker.latitude_;
poiRecord->longitude_ = poi.longitude_; markerRecord->longitude_ = marker.longitude_;
} }
void POIManager::add_poi(const types::PointOfInterest& poi) void MarkerManager::add_marker(const types::MarkerInfo& marker)
{ {
p->poiRecords_.emplace_back(std::make_shared<Impl::POIRecord>( p->markerRecords_.emplace_back(std::make_shared<Impl::MarkerRecord>(
poi.name_, poi.latitude_, poi.longitude_)); marker.name_, marker.latitude_, marker.longitude_));
} }
void POIManager::move_poi(size_t from, size_t to) void MarkerManager::move_marker(size_t from, size_t to)
{ {
if (from >= p->poiRecords_.size() || to >= p->poiRecords_.size()) if (from >= p->markerRecords_.size() || to >= p->markerRecords_.size())
{ {
return; return;
} }
std::shared_ptr<POIManager::Impl::POIRecord> poiRecord = std::shared_ptr<MarkerManager::Impl::MarkerRecord> markerRecord =
p->poiRecords_[from]; p->markerRecords_[from];
if (from == to) if (from == to)
{ {
@ -242,33 +242,33 @@ void POIManager::move_poi(size_t from, size_t to)
{ {
for (size_t i = from; i < to; i++) for (size_t i = from; i < to; i++)
{ {
p->poiRecords_[i] = p->poiRecords_[i + 1]; p->markerRecords_[i] = p->markerRecords_[i + 1];
} }
p->poiRecords_[to] = poiRecord; p->markerRecords_[to] = markerRecord;
} }
else else
{ {
for (size_t i = from; i > to; i--) for (size_t i = from; i > to; i--)
{ {
p->poiRecords_[i] = p->poiRecords_[i - 1]; p->markerRecords_[i] = p->markerRecords_[i - 1];
} }
p->poiRecords_[to] = poiRecord; p->markerRecords_[to] = markerRecord;
} }
} }
std::shared_ptr<POIManager> POIManager::Instance() std::shared_ptr<MarkerManager> MarkerManager::Instance()
{ {
static std::weak_ptr<POIManager> poiManagerReference_ {}; static std::weak_ptr<MarkerManager> markerManagerReference_ {};
std::shared_ptr<POIManager> poiManager = poiManagerReference_.lock(); std::shared_ptr<MarkerManager> markerManager = markerManagerReference_.lock();
if (poiManager == nullptr) if (markerManager == nullptr)
{ {
poiManager = std::make_shared<POIManager>(); markerManager = std::make_shared<MarkerManager>();
poiManagerReference_ = poiManager; markerManagerReference_ = markerManager;
} }
return poiManager; return markerManager;
} }
} // namespace manager } // namespace manager

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <scwx/qt/types/poi_types.hpp> #include <scwx/qt/types/marker_types.hpp>
#include <string> #include <string>
@ -13,23 +13,23 @@ namespace qt
namespace manager namespace manager
{ {
class POIManager : public QObject class MarkerManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit POIManager(); explicit MarkerManager();
~POIManager(); ~MarkerManager();
size_t poi_count(); size_t marker_count();
types::PointOfInterest get_poi(size_t index); types::MarkerInfo get_marker(size_t index);
types::PointOfInterest get_poi(const std::string& name); types::MarkerInfo get_marker(const std::string& name);
void set_poi(size_t index, const types::PointOfInterest& poi); void set_marker(size_t index, const types::MarkerInfo& marker);
void set_poi(const std::string& name, const types::PointOfInterest& poi); void set_marker(const std::string& name, const types::MarkerInfo& marker);
void add_poi(const types::PointOfInterest& poi); void add_marker(const types::MarkerInfo& marker);
void move_poi(size_t from, size_t to); void move_marker(size_t from, size_t to);
static std::shared_ptr<POIManager> Instance(); static std::shared_ptr<MarkerManager> Instance();
private: private:
class Impl; class Impl;

View file

@ -12,7 +12,7 @@
#include <scwx/qt/map/overlay_layer.hpp> #include <scwx/qt/map/overlay_layer.hpp>
#include <scwx/qt/map/overlay_product_layer.hpp> #include <scwx/qt/map/overlay_product_layer.hpp>
#include <scwx/qt/map/placefile_layer.hpp> #include <scwx/qt/map/placefile_layer.hpp>
#include <scwx/qt/map/poi_layer.hpp> #include <scwx/qt/map/marker_layer.hpp>
#include <scwx/qt/map/radar_product_layer.hpp> #include <scwx/qt/map/radar_product_layer.hpp>
#include <scwx/qt/map/radar_range_layer.hpp> #include <scwx/qt/map/radar_range_layer.hpp>
#include <scwx/qt/map/radar_site_layer.hpp> #include <scwx/qt/map/radar_site_layer.hpp>
@ -82,7 +82,7 @@ public:
radarProductLayer_ {nullptr}, radarProductLayer_ {nullptr},
overlayLayer_ {nullptr}, overlayLayer_ {nullptr},
placefileLayer_ {nullptr}, placefileLayer_ {nullptr},
poiLayer_ {nullptr}, markerLayer_ {nullptr},
colorTableLayer_ {nullptr}, colorTableLayer_ {nullptr},
autoRefreshEnabled_ {true}, autoRefreshEnabled_ {true},
autoUpdateEnabled_ {true}, autoUpdateEnabled_ {true},
@ -225,7 +225,7 @@ public:
std::shared_ptr<OverlayLayer> overlayLayer_; std::shared_ptr<OverlayLayer> overlayLayer_;
std::shared_ptr<OverlayProductLayer> overlayProductLayer_ {nullptr}; std::shared_ptr<OverlayProductLayer> overlayProductLayer_ {nullptr};
std::shared_ptr<PlacefileLayer> placefileLayer_; std::shared_ptr<PlacefileLayer> placefileLayer_;
std::shared_ptr<POILayer> poiLayer_; std::shared_ptr<MarkerLayer> markerLayer_;
std::shared_ptr<ColorTableLayer> colorTableLayer_; std::shared_ptr<ColorTableLayer> colorTableLayer_;
std::shared_ptr<RadarSiteLayer> radarSiteLayer_ {nullptr}; std::shared_ptr<RadarSiteLayer> radarSiteLayer_ {nullptr};
@ -1236,9 +1236,9 @@ void MapWidgetImpl::AddLayer(types::LayerType type,
break; break;
// Create the radar site layer // Create the radar site layer
case types::InformationLayer::POILayer: case types::InformationLayer::Markers:
poiLayer_ = std::make_shared<POILayer>(context_); markerLayer_ = std::make_shared<MarkerLayer>(context_);
AddLayer(layerName, poiLayer_, before); AddLayer(layerName, markerLayer_, before);
break; break;
default: default:

View file

@ -1,7 +1,7 @@
#include <scwx/qt/map/poi_layer.hpp> #include <scwx/qt/map/marker_layer.hpp>
#include <scwx/qt/manager/poi_manager.hpp> #include <scwx/qt/manager/marker_manager.hpp>
#include <scwx/util/logger.hpp> #include <scwx/util/logger.hpp>
#include <scwx/qt/types/poi_types.hpp> #include <scwx/qt/types/marker_types.hpp>
#include <scwx/qt/types/texture_types.hpp> #include <scwx/qt/types/texture_types.hpp>
#include <scwx/qt/gl/draw/geo_icons.hpp> #include <scwx/qt/gl/draw/geo_icons.hpp>
@ -12,11 +12,11 @@ namespace qt
namespace map namespace map
{ {
static const std::string logPrefix_ = "scwx::qt::map::poi_layer"; static const std::string logPrefix_ = "scwx::qt::map::marker_layer";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class POILayer::Impl class MarkerLayer::Impl
{ {
public: public:
explicit Impl(std::shared_ptr<MapContext> context) : explicit Impl(std::shared_ptr<MapContext> context) :
@ -25,65 +25,65 @@ public:
} }
~Impl() {} ~Impl() {}
void ReloadPOIs(); void ReloadMarkers();
const std::string& poiIconName_ { const std::string& markerIconName_ {
types::GetTextureName(types::ImageTexture::Cursor17)}; types::GetTextureName(types::ImageTexture::Cursor17)};
std::shared_ptr<gl::draw::GeoIcons> geoIcons_; std::shared_ptr<gl::draw::GeoIcons> geoIcons_;
}; };
void POILayer::Impl::ReloadPOIs() void MarkerLayer::Impl::ReloadMarkers()
{ {
auto poiManager = manager::POIManager::Instance(); auto markerManager = manager::MarkerManager::Instance();
geoIcons_->StartIcons(); geoIcons_->StartIcons();
for (size_t i = 0; i < poiManager->poi_count(); i++) for (size_t i = 0; i < markerManager->marker_count(); i++)
{ {
types::PointOfInterest poi = poiManager->get_poi(i); types::MarkerInfo marker = markerManager->get_marker(i);
std::shared_ptr<gl::draw::GeoIconDrawItem> icon = geoIcons_->AddIcon(); std::shared_ptr<gl::draw::GeoIconDrawItem> icon = geoIcons_->AddIcon();
geoIcons_->SetIconTexture(icon, poiIconName_, 0); geoIcons_->SetIconTexture(icon, markerIconName_, 0);
geoIcons_->SetIconLocation(icon, poi.latitude_, poi.longitude_); geoIcons_->SetIconLocation(icon, marker.latitude_, marker.longitude_);
} }
geoIcons_->FinishIcons(); geoIcons_->FinishIcons();
} }
POILayer::POILayer(const std::shared_ptr<MapContext>& context) : MarkerLayer::MarkerLayer(const std::shared_ptr<MapContext>& context) :
DrawLayer(context), DrawLayer(context),
p(std::make_unique<POILayer::Impl>(context)) p(std::make_unique<MarkerLayer::Impl>(context))
{ {
AddDrawItem(p->geoIcons_); AddDrawItem(p->geoIcons_);
} }
POILayer::~POILayer() = default; MarkerLayer::~MarkerLayer() = default;
void POILayer::Initialize() void MarkerLayer::Initialize()
{ {
logger_->debug("Initialize()"); logger_->debug("Initialize()");
DrawLayer::Initialize(); DrawLayer::Initialize();
p->geoIcons_->StartIconSheets(); p->geoIcons_->StartIconSheets();
p->geoIcons_->AddIconSheet(p->poiIconName_); p->geoIcons_->AddIconSheet(p->markerIconName_);
p->geoIcons_->FinishIconSheets(); p->geoIcons_->FinishIconSheets();
} }
void POILayer::Render( void MarkerLayer::Render(
const QMapLibre::CustomLayerRenderParameters& params) const QMapLibre::CustomLayerRenderParameters& params)
{ {
//auto poiManager = manager::POIManager::Instance(); //auto markerManager = manager::MarkerManager::Instance();
gl::OpenGLFunctions& gl = context()->gl(); gl::OpenGLFunctions& gl = context()->gl();
// TODO. do not redo this every time // TODO. do not redo this every time
p->ReloadPOIs(); p->ReloadMarkers();
DrawLayer::Render(params); DrawLayer::Render(params);
SCWX_GL_CHECK_ERROR(); SCWX_GL_CHECK_ERROR();
} }
void POILayer::Deinitialize() void MarkerLayer::Deinitialize()
{ {
logger_->debug("Deinitialize()"); logger_->debug("Deinitialize()");

View file

@ -11,13 +11,13 @@ namespace qt
namespace map namespace map
{ {
class POILayer : public DrawLayer class MarkerLayer : public DrawLayer
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit POILayer(const std::shared_ptr<MapContext>& context); explicit MarkerLayer(const std::shared_ptr<MapContext>& context);
~POILayer(); ~MarkerLayer();
void Initialize() override final; void Initialize() override final;
void Render(const QMapLibre::CustomLayerRenderParameters&) override final; void Render(const QMapLibre::CustomLayerRenderParameters&) override final;

View file

@ -43,7 +43,7 @@ static const std::vector<types::LayerInfo> kDefaultLayers_ {
types::InformationLayer::RadarSite, types::InformationLayer::RadarSite,
false, false,
{false, false, false, false}}, {false, false, false, false}},
{types::LayerType::Information, types::InformationLayer::POILayer, true}, {types::LayerType::Information, types::InformationLayer::Markers, true},
{types::LayerType::Data, types::DataLayer::RadarRange, true}, {types::LayerType::Data, types::DataLayer::RadarRange, true},
{types::LayerType::Alert, awips::Phenomenon::Tornado, true}, {types::LayerType::Alert, awips::Phenomenon::Tornado, true},
{types::LayerType::Alert, awips::Phenomenon::SnowSquall, true}, {types::LayerType::Alert, awips::Phenomenon::SnowSquall, true},

View file

@ -31,7 +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::Markers, "Location Markers"},
{InformationLayer::Unknown, "?"}}; {InformationLayer::Unknown, "?"}};
static const std::unordered_map<MapLayer, std::string> mapLayerName_ { static const std::unordered_map<MapLayer, std::string> mapLayerName_ {

View file

@ -44,7 +44,7 @@ enum class InformationLayer
MapOverlay, MapOverlay,
RadarSite, RadarSite,
ColorTable, ColorTable,
POILayer, Markers,
Unknown Unknown
}; };

View file

@ -9,20 +9,16 @@ namespace qt
namespace types namespace types
{ {
struct PointOfInterest struct MarkerInfo
{ {
PointOfInterest(std::string name, MarkerInfo(std::string name, double latitude, double longitude) :
double latitude, name_ {name}, latitude_ {latitude}, longitude_ {longitude}
double longitude) :
name_ {name},
latitude_ {latitude},
longitude_ {longitude}
{ {
} }
std::string name_; std::string name_;
double latitude_; double latitude_;
double longitude_; double longitude_;
}; };
} // namespace types } // namespace types