mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 04:50:06 +00:00 
			
		
		
		
	Allow product code to be retrieved from file instead of always being caller-supplied
This commit is contained in:
		
							parent
							
								
									e911882bb7
								
							
						
					
					
						commit
						0a890f5df8
					
				
					 5 changed files with 47 additions and 33 deletions
				
			
		|  | @ -148,12 +148,12 @@ MainWindow::MainWindow(QWidget* parent) : | |||
|    if (p->maps_.size() > 2 && p->maps_.at(2) != nullptr) | ||||
|    { | ||||
|       p->SelectRadarProduct( | ||||
|          p->maps_.at(2), common::RadarProductGroup::Level3, "N0B", 153); | ||||
|          p->maps_.at(2), common::RadarProductGroup::Level3, "N0B", 0); | ||||
|    } | ||||
|    if (p->maps_.size() > 3 && p->maps_.at(3) != nullptr) | ||||
|    { | ||||
|       p->SelectRadarProduct( | ||||
|          p->maps_.at(3), common::RadarProductGroup::Level3, "N0G", 154); | ||||
|          p->maps_.at(3), common::RadarProductGroup::Level3, "N0G", 0); | ||||
|    } | ||||
| 
 | ||||
|    connect(qApp, | ||||
|  |  | |||
|  | @ -15,7 +15,12 @@ struct MapContext | |||
| { | ||||
|    explicit MapContext( | ||||
|       std::shared_ptr<view::RadarProductView> radarProductView = nullptr) : | ||||
|        gl_ {}, settings_ {}, radarProductView_ {radarProductView} | ||||
|        gl_ {}, | ||||
|        settings_ {}, | ||||
|        radarProductView_ {radarProductView}, | ||||
|        radarProductGroup_ {common::RadarProductGroup::Unknown}, | ||||
|        radarProduct_ {"???"}, | ||||
|        radarProductCode_ {0} | ||||
|    { | ||||
|    } | ||||
|    ~MapContext() = default; | ||||
|  | @ -29,6 +34,9 @@ struct MapContext | |||
|    gl::OpenGLFunctions                     gl_; | ||||
|    MapSettings                             settings_; | ||||
|    std::shared_ptr<view::RadarProductView> radarProductView_; | ||||
|    common::RadarProductGroup               radarProductGroup_; | ||||
|    std::string                             radarProduct_; | ||||
|    int16_t                                 radarProductCode_; | ||||
| }; | ||||
| 
 | ||||
| } // namespace map
 | ||||
|  |  | |||
|  | @ -266,12 +266,14 @@ void MapWidget::SelectRadarProduct(common::RadarProductGroup group, | |||
|    { | ||||
|       common::Level2Product level2Product = | ||||
|          p->GetLevel2ProductOrDefault(productName); | ||||
|       productName = common::GetLevel2Name(level2Product); | ||||
|       productName               = common::GetLevel2Name(level2Product); | ||||
|       p->selectedLevel2Product_ = level2Product; | ||||
|    } | ||||
| 
 | ||||
|    if (radarProductView == nullptr || | ||||
|        radarProductView->GetRadarProductGroup() != group || | ||||
|        radarProductView->GetRadarProductName() != productName) | ||||
|        radarProductView->GetRadarProductName() != productName || | ||||
|        p->context_->radarProductCode_ != productCode) | ||||
|    { | ||||
|       p->RadarProductViewDisconnect(); | ||||
| 
 | ||||
|  | @ -282,24 +284,27 @@ void MapWidget::SelectRadarProduct(common::RadarProductGroup group, | |||
| 
 | ||||
|       radarProductViewCreated = true; | ||||
|    } | ||||
|    radarProductView->SelectTime(p->selectedTime_); | ||||
| 
 | ||||
|    if (group == common::RadarProductGroup::Level2) | ||||
|    { | ||||
|       p->selectedLevel2Product_ = common::GetLevel2Product(productName); | ||||
|    } | ||||
|    p->context_->radarProductGroup_ = group; | ||||
|    p->context_->radarProduct_      = productName; | ||||
|    p->context_->radarProductCode_  = productCode; | ||||
| 
 | ||||
|    if (radarProductViewCreated) | ||||
|    if (radarProductView != nullptr) | ||||
|    { | ||||
|       const std::string palette = | ||||
|          (group == common::RadarProductGroup::Level2) ? | ||||
|             common::GetLevel2Palette(common::GetLevel2Product(productName)) : | ||||
|             common::GetLevel3Palette(productCode); | ||||
|       p->InitializeNewRadarProductView(palette); | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       radarProductView->Update(); | ||||
|       radarProductView->SelectTime(p->selectedTime_); | ||||
| 
 | ||||
|       if (radarProductViewCreated) | ||||
|       { | ||||
|          const std::string palette = | ||||
|             (group == common::RadarProductGroup::Level2) ? | ||||
|                common::GetLevel2Palette(common::GetLevel2Product(productName)) : | ||||
|                common::GetLevel3Palette(productCode); | ||||
|          p->InitializeNewRadarProductView(palette); | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|          radarProductView->Update(); | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|    if (p->autoRefreshEnabled_) | ||||
|  | @ -313,16 +318,9 @@ void MapWidget::SelectRadarProduct( | |||
| { | ||||
|    const std::string                     radarId = record->radar_id(); | ||||
|    common::RadarProductGroup             group = record->radar_product_group(); | ||||
|    const std::string                     product = record->radar_product(); | ||||
|    std::chrono::system_clock::time_point time    = record->time(); | ||||
| 
 | ||||
|    int16_t productCode = 0; | ||||
| 
 | ||||
|    std::shared_ptr<wsr88d::Level3File> level3File = record->level3_file(); | ||||
|    if (level3File != nullptr && level3File->message() != nullptr) | ||||
|    { | ||||
|       productCode = level3File->message()->header().message_code(); | ||||
|    } | ||||
|    const std::string                     product     = record->radar_product(); | ||||
|    std::chrono::system_clock::time_point time        = record->time(); | ||||
|    int16_t                               productCode = record->product_code(); | ||||
| 
 | ||||
|    logger_->debug("SelectRadarProduct: {}, {}, {}, {}", | ||||
|                   radarId, | ||||
|  | @ -598,10 +596,9 @@ void MapWidgetImpl::AutoRefreshConnect() | |||
|              const std::string&                    product, | ||||
|              std::chrono::system_clock::time_point latestTime) | ||||
|          { | ||||
|             if (autoRefreshEnabled_ && context_->radarProductView_ != nullptr && | ||||
|                 context_->radarProductView_->GetRadarProductGroup() == group && | ||||
|             if (autoRefreshEnabled_ && context_->radarProductGroup_ == group && | ||||
|                 (group == common::RadarProductGroup::Level2 || | ||||
|                  context_->radarProductView_->GetRadarProductName() == product)) | ||||
|                  context_->radarProduct_ == product)) | ||||
|             { | ||||
|                // Create file request
 | ||||
|                std::shared_ptr<request::NexradFileRequest> request = | ||||
|  |  | |||
|  | @ -29,6 +29,7 @@ public: | |||
|    ~RadarProductRecordImpl() {} | ||||
| 
 | ||||
|    std::shared_ptr<wsr88d::NexradFile>   nexradFile_; | ||||
|    int16_t                               productCode_; | ||||
|    std::string                           radarId_; | ||||
|    std::string                           radarProduct_; | ||||
|    common::RadarProductGroup             radarProductGroup_; | ||||
|  | @ -51,6 +52,7 @@ RadarProductRecord::RadarProductRecord( | |||
|       p->radarProductGroup_ = common::RadarProductGroup::Level2; | ||||
|       p->radarId_           = level2File->icao(); | ||||
|       p->siteId_            = common::GetSiteId(p->radarId_); | ||||
|       p->productCode_       = 0; | ||||
|       julianDate            = level2File->julian_date(); | ||||
|       milliseconds          = level2File->milliseconds(); | ||||
|    } | ||||
|  | @ -60,6 +62,7 @@ RadarProductRecord::RadarProductRecord( | |||
|       p->radarProduct_      = level3File->wmo_header()->product_category(); | ||||
|       p->siteId_            = level3File->wmo_header()->product_designator(); | ||||
|       p->radarId_           = config::GetRadarIdFromSiteId(p->siteId_); | ||||
|       p->productCode_       = level3File->message()->header().message_code(); | ||||
| 
 | ||||
|       auto descriptionBlock = level3File->message()->description_block(); | ||||
| 
 | ||||
|  | @ -100,6 +103,11 @@ std::shared_ptr<wsr88d::NexradFile> RadarProductRecord::nexrad_file() const | |||
|    return p->nexradFile_; | ||||
| } | ||||
| 
 | ||||
| int16_t RadarProductRecord::product_code() const | ||||
| { | ||||
|    return p->productCode_; | ||||
| } | ||||
| 
 | ||||
| std::string RadarProductRecord::radar_id() const | ||||
| { | ||||
|    return p->radarId_; | ||||
|  |  | |||
|  | @ -31,6 +31,7 @@ public: | |||
|    std::shared_ptr<wsr88d::Ar2vFile>     level2_file() const; | ||||
|    std::shared_ptr<wsr88d::Level3File>   level3_file() const; | ||||
|    std::shared_ptr<wsr88d::NexradFile>   nexrad_file() const; | ||||
|    int16_t                               product_code() const; | ||||
|    std::string                           radar_id() const; | ||||
|    std::string                           radar_product() const; | ||||
|    common::RadarProductGroup             radar_product_group() const; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat