mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:50:05 +00:00 
			
		
		
		
	Get coordinates from radar site configuration
This commit is contained in:
		
							parent
							
								
									29ce4b1eb8
								
							
						
					
					
						commit
						3620bfd13a
					
				
					 8 changed files with 93 additions and 36 deletions
				
			
		|  | @ -211,7 +211,13 @@ void MapWidget::SelectRadarProduct(common::Level2Product product) | |||
|       this, | ||||
|       [&]() | ||||
|       { | ||||
|          RadarRangeLayer::Update(p->map_, radarProductView->range()); | ||||
|          std::shared_ptr<config::RadarSite> radarSite = | ||||
|             p->radarProductManager_->radar_site(); | ||||
| 
 | ||||
|          RadarRangeLayer::Update( | ||||
|             p->map_, | ||||
|             radarProductView->range(), | ||||
|             {radarSite->latitude(), radarSite->longitude()}); | ||||
|          update(); | ||||
|          emit RadarSweepUpdated(); | ||||
|       }, | ||||
|  | @ -301,6 +307,9 @@ void MapWidget::AddLayers() | |||
|    std::unique_ptr<QMapbox::CustomLayerHostInterface> pColorTableHost = | ||||
|       std::make_unique<LayerWrapper>(p->colorTableLayer_); | ||||
| 
 | ||||
|    std::shared_ptr<config::RadarSite> radarSite = | ||||
|       p->radarProductManager_->radar_site(); | ||||
| 
 | ||||
|    QString before = "ferry"; | ||||
| 
 | ||||
|    for (const QString& layer : p->map_->layerIds()) | ||||
|  | @ -315,8 +324,9 @@ void MapWidget::AddLayers() | |||
|    } | ||||
| 
 | ||||
|    p->map_->addCustomLayer("radar", std::move(pHost), before); | ||||
|    RadarRangeLayer::Add( | ||||
|       p->map_, p->context_->radarProductView_->range(), before); | ||||
|    RadarRangeLayer::Add(p->map_, | ||||
|                         p->context_->radarProductView_->range(), | ||||
|                         {radarSite->latitude(), radarSite->longitude()}); | ||||
|    p->map_->addCustomLayer("colorTable", std::move(pColorTableHost)); | ||||
|    p->map_->addCustomLayer("overlay", std::move(pOverlayHost)); | ||||
| } | ||||
|  | @ -421,8 +431,11 @@ void MapWidget::initializeGL() | |||
|            p.get(), | ||||
|            &MapWidgetImpl::Update); | ||||
| 
 | ||||
|    // Set default location to KLSX.
 | ||||
|    p->map_->setCoordinateZoom(QMapbox::Coordinate(38.6986, -90.6828), 9); | ||||
|    // Set default location to radar site
 | ||||
|    std::shared_ptr<config::RadarSite> radarSite = | ||||
|       p->radarProductManager_->radar_site(); | ||||
|    p->map_->setCoordinateZoom({radarSite->latitude(), radarSite->longitude()}, | ||||
|                               9); | ||||
|    p->UpdateStoredMapParameters(); | ||||
| 
 | ||||
|    QString styleUrl = qgetenv("MAPBOX_STYLE_URL"); | ||||
|  |  | |||
|  | @ -13,10 +13,12 @@ namespace map | |||
| 
 | ||||
| static const std::string logPrefix_ = "[scwx::qt::map::radar_range_layer] "; | ||||
| 
 | ||||
| static std::shared_ptr<QMapbox::Feature> GetRangeCircle(float range); | ||||
| static std::shared_ptr<QMapbox::Feature> | ||||
| GetRangeCircle(float range, QMapbox::Coordinate center); | ||||
| 
 | ||||
| void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map, | ||||
|                           float                      range, | ||||
|                           QMapbox::Coordinate        center, | ||||
|                           const QString&             before) | ||||
| { | ||||
|    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Add()"; | ||||
|  | @ -30,7 +32,8 @@ void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map, | |||
|       map->removeSource("rangeCircleSource"); | ||||
|    } | ||||
| 
 | ||||
|    std::shared_ptr<QMapbox::Feature> rangeCircle = GetRangeCircle(range); | ||||
|    std::shared_ptr<QMapbox::Feature> rangeCircle = | ||||
|       GetRangeCircle(range, center); | ||||
| 
 | ||||
|    map->addSource( | ||||
|       "rangeCircleSource", | ||||
|  | @ -43,15 +46,19 @@ void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map, | |||
|       "rangeCircleLayer", "line-color", "rgba(128, 128, 128, 128)"); | ||||
| } | ||||
| 
 | ||||
| void RadarRangeLayer::Update(std::shared_ptr<QMapboxGL> map, float range) | ||||
| void RadarRangeLayer::Update(std::shared_ptr<QMapboxGL> map, | ||||
|                              float                      range, | ||||
|                              QMapbox::Coordinate        center) | ||||
| { | ||||
|    std::shared_ptr<QMapbox::Feature> rangeCircle = GetRangeCircle(range); | ||||
|    std::shared_ptr<QMapbox::Feature> rangeCircle = | ||||
|       GetRangeCircle(range, center); | ||||
| 
 | ||||
|    map->updateSource("rangeCircleSource", | ||||
|                      {{"data", QVariant::fromValue(*rangeCircle)}}); | ||||
| } | ||||
| 
 | ||||
| static std::shared_ptr<QMapbox::Feature> GetRangeCircle(float range) | ||||
| static std::shared_ptr<QMapbox::Feature> | ||||
| GetRangeCircle(float range, QMapbox::Coordinate center) | ||||
| { | ||||
|    GeographicLib::Geodesic geodesic(GeographicLib::Constants::WGS84_a(), | ||||
|                                     GeographicLib::Constants::WGS84_f()); | ||||
|  | @ -59,8 +66,6 @@ static std::shared_ptr<QMapbox::Feature> GetRangeCircle(float range) | |||
|    constexpr float angleDelta  = 0.5f; | ||||
|    constexpr float angleDeltaH = angleDelta / 2.0f; | ||||
| 
 | ||||
|    const QMapbox::Coordinate radar {38.6986, -90.6828}; | ||||
| 
 | ||||
|    float angle = -angleDeltaH; | ||||
| 
 | ||||
|    QMapbox::Coordinates geometry; | ||||
|  | @ -70,8 +75,8 @@ static std::shared_ptr<QMapbox::Feature> GetRangeCircle(float range) | |||
|       double latitude; | ||||
|       double longitude; | ||||
| 
 | ||||
|       geodesic.Direct(radar.first, | ||||
|                       radar.second, | ||||
|       geodesic.Direct(center.first, | ||||
|                       center.second, | ||||
|                       angle, | ||||
|                       range * 1000.0f, | ||||
|                       latitude, | ||||
|  |  | |||
|  | @ -13,8 +13,11 @@ namespace RadarRangeLayer | |||
| 
 | ||||
| void Add(std::shared_ptr<QMapboxGL> map, | ||||
|          float                      range, | ||||
|          QMapbox::Coordinate        center, | ||||
|          const QString&             before = QString()); | ||||
| void Update(std::shared_ptr<QMapboxGL> map, float range); | ||||
| void Update(std::shared_ptr<QMapboxGL> map, | ||||
|             float                      range, | ||||
|             QMapbox::Coordinate        center); | ||||
| 
 | ||||
| } // namespace RadarRangeLayer
 | ||||
| } // namespace map
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat