mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:50:06 +00:00 
			
		
		
		
	Update map location on alert "Go"
This commit is contained in:
		
							parent
							
								
									e75666d7a2
								
							
						
					
					
						commit
						899cb041e5
					
				
					 3 changed files with 70 additions and 8 deletions
				
			
		|  | @ -530,7 +530,12 @@ void MainWindowImpl::ConnectOtherSignals() | |||
|       &ui::AlertDockWidget::MoveMap, | ||||
|       this, | ||||
|       [=](double latitude, double longitude) | ||||
|       { activeMap_->SetMapLocation(latitude, longitude); }, | ||||
|       { | ||||
|          for (map::MapWidget* map : maps_) | ||||
|          { | ||||
|             map->SetMapLocation(latitude, longitude, true); | ||||
|          } | ||||
|       }, | ||||
|       Qt::QueuedConnection); | ||||
|    connect(mainWindow_, | ||||
|            &MainWindow::ActiveMapMoved, | ||||
|  |  | |||
|  | @ -424,21 +424,31 @@ void MapWidget::SelectRadarProduct( | |||
|    SelectRadarProduct(group, product, productCode); | ||||
| } | ||||
| 
 | ||||
| void MapWidget::SelectRadarSite(const std::string& id) | ||||
| void MapWidget::SelectRadarSite(const std::string& id, bool updateCoordinates) | ||||
| { | ||||
|    logger_->debug("Selecting radar site: {}", id); | ||||
| 
 | ||||
|    std::shared_ptr<config::RadarSite> radarSite = config::RadarSite::Get(id); | ||||
| 
 | ||||
|    SelectRadarSite(radarSite, updateCoordinates); | ||||
| } | ||||
| 
 | ||||
| void MapWidget::SelectRadarSite(std::shared_ptr<config::RadarSite> radarSite, | ||||
|                                 bool updateCoordinates) | ||||
| { | ||||
|    // Verify radar site is valid and has changed
 | ||||
|    if (radarSite != nullptr && | ||||
|        (p->radarProductManager_ == nullptr || | ||||
|         id != p->radarProductManager_->radar_site()->id())) | ||||
|         radarSite->id() != p->radarProductManager_->radar_site()->id())) | ||||
|    { | ||||
|       auto radarProductView = p->context_->radar_product_view(); | ||||
| 
 | ||||
|       p->map_->setCoordinate({radarSite->latitude(), radarSite->longitude()}); | ||||
|       p->SetRadarSite(id); | ||||
|       if (updateCoordinates) | ||||
|       { | ||||
|          p->map_->setCoordinate( | ||||
|             {radarSite->latitude(), radarSite->longitude()}); | ||||
|       } | ||||
|       p->SetRadarSite(radarSite->id()); | ||||
|       p->Update(); | ||||
| 
 | ||||
|       // Select products from new site
 | ||||
|  | @ -480,12 +490,29 @@ void MapWidget::SetAutoRefresh(bool enabled) | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void MapWidget::SetMapLocation(double latitude, double longitude) | ||||
| void MapWidget::SetMapLocation(double latitude, | ||||
|                                double longitude, | ||||
|                                bool   updateRadarSite) | ||||
| { | ||||
|    if (p->map_ != nullptr && p->prevLatitude_ != latitude || | ||||
|        p->prevLongitude_ != longitude) | ||||
|    { | ||||
|       // Update the map location
 | ||||
|       p->map_->setCoordinate({latitude, longitude}); | ||||
| 
 | ||||
|       // If the radar site should be updated based on the new location
 | ||||
|       if (updateRadarSite) | ||||
|       { | ||||
|          // Find the nearest WSR-88D radar
 | ||||
|          std::shared_ptr<config::RadarSite> nearestRadarSite = | ||||
|             config::RadarSite::FindNearest(latitude, longitude, "wsr88d"); | ||||
| 
 | ||||
|          // If found, select it
 | ||||
|          if (nearestRadarSite != nullptr) | ||||
|          { | ||||
|             SelectRadarSite(nearestRadarSite->id(), false); | ||||
|          } | ||||
|       } | ||||
|    } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -48,10 +48,40 @@ public: | |||
|                            const std::string&        product, | ||||
|                            int16_t                   productCode); | ||||
|    void SelectRadarProduct(std::shared_ptr<types::RadarProductRecord> record); | ||||
|    void SelectRadarSite(const std::string& radarSite); | ||||
| 
 | ||||
|    /**
 | ||||
|     * @brief Selects a radar site. | ||||
|     * | ||||
|     * @param [in] radarSite ID of the requested radar site | ||||
|     * @param [in] updateCoordinates Whether to update the map coordinates to the | ||||
|     * requested radar site location. Default is true. | ||||
|     */ | ||||
|    void SelectRadarSite(const std::string& id, bool updateCoordinates = true); | ||||
| 
 | ||||
|    /**
 | ||||
|     * @brief Selects a radar site. | ||||
|     * | ||||
|     * @param [in] radarSite Shared pointer to the requested radar site | ||||
|     * @param [in] updateCoordinates Whether to update the map coordinates to the | ||||
|     * requested radar site location. Default is true. | ||||
|     */ | ||||
|    void SelectRadarSite(std::shared_ptr<config::RadarSite> radarSite, | ||||
|                         bool updateCoordinates = true); | ||||
| 
 | ||||
|    void SetActive(bool isActive); | ||||
|    void SetAutoRefresh(bool enabled); | ||||
|    void SetMapLocation(double latitude, double longitude); | ||||
| 
 | ||||
|    /**
 | ||||
|     * @brief Sets the current map location. | ||||
|     * | ||||
|     * @param [in] latitude Latitude in degrees | ||||
|     * @param [in] longitude Longitude in degrees | ||||
|     * @param [in] updateRadarSite Whether to update the selected radar site to | ||||
|     * the closest WSR-88D site. Default is false. | ||||
|     */ | ||||
|    void SetMapLocation(double latitude, | ||||
|                        double longitude, | ||||
|                        bool   updateRadarSite = false); | ||||
|    void SetMapParameters(double latitude, | ||||
|                          double longitude, | ||||
|                          double zoom, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat