mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:40:06 +00:00 
			
		
		
		
	renamed all POI/point of intrest to marker
This commit is contained in:
		
							parent
							
								
									cd16902635
								
							
						
					
					
						commit
						31940441ed
					
				
					 11 changed files with 153 additions and 157 deletions
				
			
		|  | @ -6,7 +6,7 @@ | |||
| #include <scwx/qt/manager/alert_manager.hpp> | ||||
| #include <scwx/qt/manager/hotkey_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/radar_product_manager.hpp> | ||||
| #include <scwx/qt/manager/text_event_manager.hpp> | ||||
|  | @ -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<manager::HotkeyManager> hotkeyManager_ { | ||||
|       manager::HotkeyManager::Instance()}; | ||||
|    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::TextEventManager> textEventManager_; | ||||
|    std::shared_ptr<manager::TimelineManager>  timelineManager_; | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| #include <scwx/qt/manager/poi_manager.hpp> | ||||
| #include <scwx/qt/types/poi_types.hpp> | ||||
| #include <scwx/qt/manager/marker_manager.hpp> | ||||
| #include <scwx/qt/types/marker_types.hpp> | ||||
| #include <scwx/qt/util/json.hpp> | ||||
| #include <scwx/qt/main/application.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
|  | @ -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<std::shared_ptr<POIRecord>> poiRecords_ {}; | ||||
|    std::string markerSettingsPath_ {}; | ||||
|    std::vector<std::shared_ptr<MarkerRecord>> markerRecords_ {}; | ||||
| 
 | ||||
|    POIManager* self_; | ||||
|    MarkerManager* self_; | ||||
| 
 | ||||
|    void InitializePOISettings(); | ||||
|    void ReadPOISettings(); | ||||
|    void WritePOISettings(); | ||||
|    std::shared_ptr<POIRecord> GetPOIByName(const std::string& name); | ||||
|    void InitializeMarkerSettings(); | ||||
|    void ReadMarkerSettings(); | ||||
|    void WriteMarkerSettings(); | ||||
|    std::shared_ptr<MarkerRecord> 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<POIRecord>& record) | ||||
|                           const std::shared_ptr<MarkerRecord>& record) | ||||
|    { | ||||
|       jv = {{kNameName_, record->name_}, | ||||
|             {kLatitudeName_, record->latitude_}, | ||||
|             {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) | ||||
|    { | ||||
|       return POIRecord( | ||||
|       return MarkerRecord( | ||||
|          boost::json::value_to<std::string>(jv.at(kNameName_)), | ||||
|          boost::json::value_to<double>(jv.at(kLatitudeName_)), | ||||
|          boost::json::value_to<double>(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<POIRecord>(poiEntry); | ||||
|             MarkerRecord record = | ||||
|                boost::json::value_to<MarkerRecord>(markerEntry); | ||||
| 
 | ||||
|             if (!record.name_.empty()) | ||||
|             { | ||||
|                poiRecords_.emplace_back(std::make_shared<POIRecord>( | ||||
|                markerRecords_.emplace_back(std::make_shared<MarkerRecord>( | ||||
|                   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::POIRecord> | ||||
| POIManager::Impl::GetPOIByName(const std::string& name) | ||||
| std::shared_ptr<MarkerManager::Impl::MarkerRecord> | ||||
| 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<Impl>(this)) | ||||
| MarkerManager::MarkerManager() : p(std::make_unique<Impl>(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<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
 | ||||
| types::PointOfInterest POIManager::get_poi(size_t index) | ||||
| types::MarkerInfo MarkerManager::get_marker(size_t index) | ||||
| { | ||||
|    std::shared_ptr<POIManager::Impl::POIRecord> poiRecord = | ||||
|       p->poiRecords_[index]; | ||||
|    return types::PointOfInterest( | ||||
|       poiRecord->name_, poiRecord->latitude_, poiRecord->longitude_); | ||||
|    std::shared_ptr<MarkerManager::Impl::MarkerRecord> 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<POIManager::Impl::POIRecord> poiRecord = | ||||
|       p->GetPOIByName(name); | ||||
|    return types::PointOfInterest( | ||||
|       poiRecord->name_, poiRecord->latitude_, poiRecord->longitude_); | ||||
|    std::shared_ptr<MarkerManager::Impl::MarkerRecord> 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<POIManager::Impl::POIRecord> poiRecord = | ||||
|       p->poiRecords_[index]; | ||||
|    poiRecord->name_      = poi.name_; | ||||
|    poiRecord->latitude_  = poi.latitude_; | ||||
|    poiRecord->longitude_ = poi.longitude_; | ||||
|    std::shared_ptr<MarkerManager::Impl::MarkerRecord> 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<POIManager::Impl::POIRecord> poiRecord = | ||||
|       p->GetPOIByName(name); | ||||
|    poiRecord->name_      = poi.name_; | ||||
|    poiRecord->latitude_  = poi.latitude_; | ||||
|    poiRecord->longitude_ = poi.longitude_; | ||||
|    std::shared_ptr<MarkerManager::Impl::MarkerRecord> 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<Impl::POIRecord>( | ||||
|       poi.name_, poi.latitude_, poi.longitude_)); | ||||
|    p->markerRecords_.emplace_back(std::make_shared<Impl::MarkerRecord>( | ||||
|       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<POIManager::Impl::POIRecord> poiRecord = | ||||
|       p->poiRecords_[from]; | ||||
|    std::shared_ptr<MarkerManager::Impl::MarkerRecord> 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> 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>(); | ||||
|       poiManagerReference_ = poiManager; | ||||
|       markerManager = std::make_shared<MarkerManager>(); | ||||
|       markerManagerReference_ = markerManager; | ||||
|    } | ||||
| 
 | ||||
|    return poiManager; | ||||
|    return markerManager; | ||||
| } | ||||
| 
 | ||||
| } // namespace manager
 | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/qt/types/poi_types.hpp> | ||||
| #include <scwx/qt/types/marker_types.hpp> | ||||
| 
 | ||||
| #include <string> | ||||
| 
 | ||||
|  | @ -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<POIManager> Instance(); | ||||
|    static std::shared_ptr<MarkerManager> Instance(); | ||||
| 
 | ||||
| private: | ||||
|    class Impl; | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ | |||
| #include <scwx/qt/map/overlay_layer.hpp> | ||||
| #include <scwx/qt/map/overlay_product_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_range_layer.hpp> | ||||
| #include <scwx/qt/map/radar_site_layer.hpp> | ||||
|  | @ -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>        overlayLayer_; | ||||
|    std::shared_ptr<OverlayProductLayer> overlayProductLayer_ {nullptr}; | ||||
|    std::shared_ptr<PlacefileLayer>      placefileLayer_; | ||||
|    std::shared_ptr<POILayer>            poiLayer_; | ||||
|    std::shared_ptr<MarkerLayer>            markerLayer_; | ||||
|    std::shared_ptr<ColorTableLayer>     colorTableLayer_; | ||||
|    std::shared_ptr<RadarSiteLayer>      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<POILayer>(context_); | ||||
|          AddLayer(layerName, poiLayer_, before); | ||||
|       case types::InformationLayer::Markers: | ||||
|          markerLayer_ = std::make_shared<MarkerLayer>(context_); | ||||
|          AddLayer(layerName, markerLayer_, before); | ||||
|          break; | ||||
| 
 | ||||
|       default: | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| #include <scwx/qt/map/poi_layer.hpp> | ||||
| #include <scwx/qt/manager/poi_manager.hpp> | ||||
| #include <scwx/qt/map/marker_layer.hpp> | ||||
| #include <scwx/qt/manager/marker_manager.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/gl/draw/geo_icons.hpp> | ||||
| 
 | ||||
|  | @ -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<MapContext> 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<gl::draw::GeoIcons>  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<gl::draw::GeoIconDrawItem> 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<MapContext>& context) : | ||||
| MarkerLayer::MarkerLayer(const std::shared_ptr<MapContext>& context) : | ||||
|    DrawLayer(context), | ||||
|    p(std::make_unique<POILayer::Impl>(context)) | ||||
|    p(std::make_unique<MarkerLayer::Impl>(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()"); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<MapContext>& context); | ||||
|    ~POILayer(); | ||||
|    explicit MarkerLayer(const std::shared_ptr<MapContext>& context); | ||||
|    ~MarkerLayer(); | ||||
| 
 | ||||
|    void Initialize() override final; | ||||
|    void Render(const QMapLibre::CustomLayerRenderParameters&) override final; | ||||
|  |  | |||
|  | @ -43,7 +43,7 @@ static const std::vector<types::LayerInfo> 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}, | ||||
|  |  | |||
|  | @ -31,7 +31,7 @@ static const std::unordered_map<InformationLayer, std::string> | |||
|    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<MapLayer, std::string> mapLayerName_ { | ||||
|  |  | |||
|  | @ -44,7 +44,7 @@ enum class InformationLayer | |||
|    MapOverlay, | ||||
|    RadarSite, | ||||
|    ColorTable, | ||||
|    POILayer, | ||||
|    Markers, | ||||
|    Unknown | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AdenKoperczak
						AdenKoperczak