diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 01ff239e..6edb022d 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -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/media_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/radar_product_manager.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/media_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/radar_product_manager.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_product_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_range_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_product_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_range_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/map_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/radar_product_record.hpp source/scwx/qt/types/text_event_key.hpp diff --git a/scwx-qt/source/scwx/qt/main/main_window.cpp b/scwx-qt/source/scwx/qt/main/main_window.cpp index 77c130a4..836d6784 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.cpp +++ b/scwx-qt/source/scwx/qt/main/main_window.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -92,7 +92,7 @@ public: updateDialog_ {nullptr}, alertManager_ {manager::AlertManager::Instance()}, placefileManager_ {manager::PlacefileManager::Instance()}, - poiManager_ {manager::POIManager::Instance()}, + markerManager_ {manager::MarkerManager::Instance()}, positionManager_ {manager::PositionManager::Instance()}, textEventManager_ {manager::TextEventManager::Instance()}, timelineManager_ {manager::TimelineManager::Instance()}, @@ -219,7 +219,7 @@ public: std::shared_ptr hotkeyManager_ { manager::HotkeyManager::Instance()}; std::shared_ptr placefileManager_; - std::shared_ptr poiManager_; + std::shared_ptr markerManager_; std::shared_ptr positionManager_; std::shared_ptr textEventManager_; std::shared_ptr timelineManager_; diff --git a/scwx-qt/source/scwx/qt/manager/marker_manager.cpp b/scwx-qt/source/scwx/qt/manager/marker_manager.cpp index 9124bed4..15e8f044 100644 --- a/scwx-qt/source/scwx/qt/manager/marker_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/marker_manager.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include #include @@ -18,37 +18,37 @@ namespace qt 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 std::string kNameName_ = "name"; static const std::string kLatitudeName_ = "latitude"; static const std::string kLongitudeName_ = "longitude"; -class POIManager::Impl +class MarkerManager::Impl { public: - class POIRecord; + class MarkerRecord; - explicit Impl(POIManager* self) : self_ {self} {} + explicit Impl(MarkerManager* self) : self_ {self} {} ~Impl() {} - std::string poiSettingsPath_ {}; - std::vector> poiRecords_ {}; + std::string markerSettingsPath_ {}; + std::vector> markerRecords_ {}; - POIManager* self_; + MarkerManager* self_; - void InitializePOISettings(); - void ReadPOISettings(); - void WritePOISettings(); - std::shared_ptr GetPOIByName(const std::string& name); + void InitializeMarkerSettings(); + void ReadMarkerSettings(); + void WriteMarkerSettings(); + std::shared_ptr GetMarkerByName(const std::string& name); }; -class POIManager::Impl::POIRecord +class MarkerManager::Impl::MarkerRecord { public: - POIRecord(std::string name, double latitude, double longitude) : + MarkerRecord(std::string name, double latitude, double longitude) : name_ {name}, latitude_ {latitude}, longitude_ {longitude} { } @@ -59,17 +59,17 @@ public: friend void tag_invoke(boost::json::value_from_tag, boost::json::value& jv, - const std::shared_ptr& record) + const std::shared_ptr& record) { jv = {{kNameName_, record->name_}, {kLatitudeName_, record->latitude_}, {kLongitudeName_, record->longitude_}}; } - friend POIRecord tag_invoke(boost::json::value_to_tag, + friend MarkerRecord tag_invoke(boost::json::value_to_tag, const boost::json::value& jv) { - return POIRecord( + return MarkerRecord( boost::json::value_to(jv.at(kNameName_)), boost::json::value_to(jv.at(kLatitudeName_)), boost::json::value_to(jv.at(kLongitudeName_))); @@ -77,7 +77,7 @@ public: }; -void POIManager::Impl::InitializePOISettings() +void MarkerManager::Impl::InitializeMarkerSettings() { std::string appDataPath { 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 - if (std::filesystem::exists(poiSettingsPath_)) + // Determine if marker settings exists + 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 - auto& poiArray = poiJson.as_array(); - poiRecords_.reserve(poiArray.size()); - for (auto& poiEntry : poiArray) + // For each marker entry + auto& markerArray = markerJson.as_array(); + markerRecords_.reserve(markerArray.size()); + for (auto& markerEntry : markerArray) { try { - POIRecord record = - boost::json::value_to(poiEntry); + MarkerRecord record = + boost::json::value_to(markerEntry); if (!record.name_.empty()) { - poiRecords_.emplace_back(std::make_shared( + markerRecords_.emplace_back(std::make_shared( record.name_, record.latitude_, record.longitude_)); } } 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_); - util::json::WriteJsonFile(poiSettingsPath_, poiJson); + auto markerJson = boost::json::value_from(markerRecords_); + util::json::WriteJsonFile(markerSettingsPath_, markerJson); } -std::shared_ptr -POIManager::Impl::GetPOIByName(const std::string& name) +std::shared_ptr +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; } -POIManager::POIManager() : p(std::make_unique(this)) +MarkerManager::MarkerManager() : p(std::make_unique(this)) { // TODO THREADING? try { - p->InitializePOISettings(); + p->InitializeMarkerSettings(); - // Read POI settings on startup + // Read Marker settings on startup //main::Application::WaitForInitialization(); - p->ReadPOISettings(); + p->ReadMarkerSettings(); } catch (const std::exception& ex) { @@ -174,66 +174,66 @@ POIManager::POIManager() : p(std::make_unique(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 -types::PointOfInterest POIManager::get_poi(size_t index) +types::MarkerInfo MarkerManager::get_marker(size_t index) { - std::shared_ptr poiRecord = - p->poiRecords_[index]; - return types::PointOfInterest( - poiRecord->name_, poiRecord->latitude_, poiRecord->longitude_); + std::shared_ptr markerRecord = + p->markerRecords_[index]; + return types::MarkerInfo( + 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 poiRecord = - p->GetPOIByName(name); - return types::PointOfInterest( - poiRecord->name_, poiRecord->latitude_, poiRecord->longitude_); + std::shared_ptr markerRecord = + p->GetMarkerByName(name); + return types::MarkerInfo( + 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 poiRecord = - p->poiRecords_[index]; - poiRecord->name_ = poi.name_; - poiRecord->latitude_ = poi.latitude_; - poiRecord->longitude_ = poi.longitude_; + std::shared_ptr markerRecord = + p->markerRecords_[index]; + markerRecord->name_ = marker.name_; + markerRecord->latitude_ = marker.latitude_; + markerRecord->longitude_ = marker.longitude_; } -void POIManager::set_poi(const std::string& name, - const types::PointOfInterest& poi) +void MarkerManager::set_marker(const std::string& name, + const types::MarkerInfo& marker) { - std::shared_ptr poiRecord = - p->GetPOIByName(name); - poiRecord->name_ = poi.name_; - poiRecord->latitude_ = poi.latitude_; - poiRecord->longitude_ = poi.longitude_; + std::shared_ptr markerRecord = + p->GetMarkerByName(name); + markerRecord->name_ = marker.name_; + markerRecord->latitude_ = marker.latitude_; + 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( - poi.name_, poi.latitude_, poi.longitude_)); + p->markerRecords_.emplace_back(std::make_shared( + 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; } - std::shared_ptr poiRecord = - p->poiRecords_[from]; + std::shared_ptr markerRecord = + p->markerRecords_[from]; 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++) { - p->poiRecords_[i] = p->poiRecords_[i + 1]; + p->markerRecords_[i] = p->markerRecords_[i + 1]; } - p->poiRecords_[to] = poiRecord; + p->markerRecords_[to] = markerRecord; } else { 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::Instance() +std::shared_ptr MarkerManager::Instance() { - static std::weak_ptr poiManagerReference_ {}; + static std::weak_ptr markerManagerReference_ {}; - std::shared_ptr poiManager = poiManagerReference_.lock(); + std::shared_ptr markerManager = markerManagerReference_.lock(); - if (poiManager == nullptr) + if (markerManager == nullptr) { - poiManager = std::make_shared(); - poiManagerReference_ = poiManager; + markerManager = std::make_shared(); + markerManagerReference_ = markerManager; } - return poiManager; + return markerManager; } } // namespace manager diff --git a/scwx-qt/source/scwx/qt/manager/marker_manager.hpp b/scwx-qt/source/scwx/qt/manager/marker_manager.hpp index 63144cc8..55631d6e 100644 --- a/scwx-qt/source/scwx/qt/manager/marker_manager.hpp +++ b/scwx-qt/source/scwx/qt/manager/marker_manager.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -13,23 +13,23 @@ namespace qt namespace manager { -class POIManager : public QObject +class MarkerManager : public QObject { Q_OBJECT public: - explicit POIManager(); - ~POIManager(); + explicit MarkerManager(); + ~MarkerManager(); - size_t poi_count(); - types::PointOfInterest get_poi(size_t index); - types::PointOfInterest get_poi(const std::string& name); - void set_poi(size_t index, const types::PointOfInterest& poi); - void set_poi(const std::string& name, const types::PointOfInterest& poi); - void add_poi(const types::PointOfInterest& poi); - void move_poi(size_t from, size_t to); + size_t marker_count(); + types::MarkerInfo get_marker(size_t index); + types::MarkerInfo get_marker(const std::string& name); + void set_marker(size_t index, const types::MarkerInfo& marker); + void set_marker(const std::string& name, const types::MarkerInfo& marker); + void add_marker(const types::MarkerInfo& marker); + void move_marker(size_t from, size_t to); - static std::shared_ptr Instance(); + static std::shared_ptr Instance(); private: class Impl; diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index 4837f387..098a6378 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -82,7 +82,7 @@ public: radarProductLayer_ {nullptr}, overlayLayer_ {nullptr}, placefileLayer_ {nullptr}, - poiLayer_ {nullptr}, + markerLayer_ {nullptr}, colorTableLayer_ {nullptr}, autoRefreshEnabled_ {true}, autoUpdateEnabled_ {true}, @@ -225,7 +225,7 @@ public: std::shared_ptr overlayLayer_; std::shared_ptr overlayProductLayer_ {nullptr}; std::shared_ptr placefileLayer_; - std::shared_ptr poiLayer_; + std::shared_ptr markerLayer_; std::shared_ptr colorTableLayer_; std::shared_ptr radarSiteLayer_ {nullptr}; @@ -1236,9 +1236,9 @@ void MapWidgetImpl::AddLayer(types::LayerType type, break; // Create the radar site layer - case types::InformationLayer::POILayer: - poiLayer_ = std::make_shared(context_); - AddLayer(layerName, poiLayer_, before); + case types::InformationLayer::Markers: + markerLayer_ = std::make_shared(context_); + AddLayer(layerName, markerLayer_, before); break; default: diff --git a/scwx-qt/source/scwx/qt/map/marker_layer.cpp b/scwx-qt/source/scwx/qt/map/marker_layer.cpp index 4bfb4338..f899f55d 100644 --- a/scwx-qt/source/scwx/qt/map/marker_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/marker_layer.cpp @@ -1,7 +1,7 @@ -#include -#include +#include +#include #include -#include +#include #include #include @@ -12,11 +12,11 @@ namespace qt 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_); -class POILayer::Impl +class MarkerLayer::Impl { public: explicit Impl(std::shared_ptr context) : @@ -25,65 +25,65 @@ public: } ~Impl() {} - void ReloadPOIs(); + void ReloadMarkers(); - const std::string& poiIconName_ { + const std::string& markerIconName_ { types::GetTextureName(types::ImageTexture::Cursor17)}; std::shared_ptr geoIcons_; }; -void POILayer::Impl::ReloadPOIs() +void MarkerLayer::Impl::ReloadMarkers() { - auto poiManager = manager::POIManager::Instance(); + auto markerManager = manager::MarkerManager::Instance(); 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 icon = geoIcons_->AddIcon(); - geoIcons_->SetIconTexture(icon, poiIconName_, 0); - geoIcons_->SetIconLocation(icon, poi.latitude_, poi.longitude_); + geoIcons_->SetIconTexture(icon, markerIconName_, 0); + geoIcons_->SetIconLocation(icon, marker.latitude_, marker.longitude_); } geoIcons_->FinishIcons(); } -POILayer::POILayer(const std::shared_ptr& context) : +MarkerLayer::MarkerLayer(const std::shared_ptr& context) : DrawLayer(context), - p(std::make_unique(context)) + p(std::make_unique(context)) { AddDrawItem(p->geoIcons_); } -POILayer::~POILayer() = default; +MarkerLayer::~MarkerLayer() = default; -void POILayer::Initialize() +void MarkerLayer::Initialize() { logger_->debug("Initialize()"); DrawLayer::Initialize(); p->geoIcons_->StartIconSheets(); - p->geoIcons_->AddIconSheet(p->poiIconName_); + p->geoIcons_->AddIconSheet(p->markerIconName_); p->geoIcons_->FinishIconSheets(); } -void POILayer::Render( +void MarkerLayer::Render( const QMapLibre::CustomLayerRenderParameters& params) { - //auto poiManager = manager::POIManager::Instance(); + //auto markerManager = manager::MarkerManager::Instance(); gl::OpenGLFunctions& gl = context()->gl(); // TODO. do not redo this every time - p->ReloadPOIs(); + p->ReloadMarkers(); DrawLayer::Render(params); SCWX_GL_CHECK_ERROR(); } -void POILayer::Deinitialize() +void MarkerLayer::Deinitialize() { logger_->debug("Deinitialize()"); diff --git a/scwx-qt/source/scwx/qt/map/marker_layer.hpp b/scwx-qt/source/scwx/qt/map/marker_layer.hpp index 5bc12660..9cd0674c 100644 --- a/scwx-qt/source/scwx/qt/map/marker_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/marker_layer.hpp @@ -11,13 +11,13 @@ namespace qt namespace map { -class POILayer : public DrawLayer +class MarkerLayer : public DrawLayer { Q_OBJECT public: - explicit POILayer(const std::shared_ptr& context); - ~POILayer(); + explicit MarkerLayer(const std::shared_ptr& context); + ~MarkerLayer(); void Initialize() override final; void Render(const QMapLibre::CustomLayerRenderParameters&) override final; diff --git a/scwx-qt/source/scwx/qt/model/layer_model.cpp b/scwx-qt/source/scwx/qt/model/layer_model.cpp index fbc565b5..23d05cd6 100644 --- a/scwx-qt/source/scwx/qt/model/layer_model.cpp +++ b/scwx-qt/source/scwx/qt/model/layer_model.cpp @@ -43,7 +43,7 @@ static const std::vector kDefaultLayers_ { types::InformationLayer::RadarSite, 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::Alert, awips::Phenomenon::Tornado, true}, {types::LayerType::Alert, awips::Phenomenon::SnowSquall, true}, diff --git a/scwx-qt/source/scwx/qt/types/layer_types.cpp b/scwx-qt/source/scwx/qt/types/layer_types.cpp index 3ab775e3..bd607cc7 100644 --- a/scwx-qt/source/scwx/qt/types/layer_types.cpp +++ b/scwx-qt/source/scwx/qt/types/layer_types.cpp @@ -31,7 +31,7 @@ static const std::unordered_map informationLayerName_ {{InformationLayer::MapOverlay, "Map Overlay"}, {InformationLayer::RadarSite, "Radar Sites"}, {InformationLayer::ColorTable, "Color Table"}, - {InformationLayer::POILayer, "Point of Interest"}, + {InformationLayer::Markers, "Location Markers"}, {InformationLayer::Unknown, "?"}}; static const std::unordered_map mapLayerName_ { diff --git a/scwx-qt/source/scwx/qt/types/layer_types.hpp b/scwx-qt/source/scwx/qt/types/layer_types.hpp index 04a4aef9..bfc10839 100644 --- a/scwx-qt/source/scwx/qt/types/layer_types.hpp +++ b/scwx-qt/source/scwx/qt/types/layer_types.hpp @@ -44,7 +44,7 @@ enum class InformationLayer MapOverlay, RadarSite, ColorTable, - POILayer, + Markers, Unknown }; diff --git a/scwx-qt/source/scwx/qt/types/marker_types.hpp b/scwx-qt/source/scwx/qt/types/marker_types.hpp index 922ea364..1fd02111 100644 --- a/scwx-qt/source/scwx/qt/types/marker_types.hpp +++ b/scwx-qt/source/scwx/qt/types/marker_types.hpp @@ -9,20 +9,16 @@ namespace qt namespace types { -struct PointOfInterest +struct MarkerInfo { - PointOfInterest(std::string name, - double latitude, - double longitude) : - name_ {name}, - latitude_ {latitude}, - longitude_ {longitude} + MarkerInfo(std::string name, double latitude, double longitude) : + name_ {name}, latitude_ {latitude}, longitude_ {longitude} { } std::string name_; - double latitude_; - double longitude_; + double latitude_; + double longitude_; }; } // namespace types