mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 06:20: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) |    if (p->maps_.size() > 2 && p->maps_.at(2) != nullptr) | ||||||
|    { |    { | ||||||
|       p->SelectRadarProduct( |       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) |    if (p->maps_.size() > 3 && p->maps_.at(3) != nullptr) | ||||||
|    { |    { | ||||||
|       p->SelectRadarProduct( |       p->SelectRadarProduct( | ||||||
|          p->maps_.at(3), common::RadarProductGroup::Level3, "N0G", 154); |          p->maps_.at(3), common::RadarProductGroup::Level3, "N0G", 0); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    connect(qApp, |    connect(qApp, | ||||||
|  |  | ||||||
|  | @ -15,7 +15,12 @@ struct MapContext | ||||||
| { | { | ||||||
|    explicit MapContext( |    explicit MapContext( | ||||||
|       std::shared_ptr<view::RadarProductView> radarProductView = nullptr) : |       std::shared_ptr<view::RadarProductView> radarProductView = nullptr) : | ||||||
|        gl_ {}, settings_ {}, radarProductView_ {radarProductView} |        gl_ {}, | ||||||
|  |        settings_ {}, | ||||||
|  |        radarProductView_ {radarProductView}, | ||||||
|  |        radarProductGroup_ {common::RadarProductGroup::Unknown}, | ||||||
|  |        radarProduct_ {"???"}, | ||||||
|  |        radarProductCode_ {0} | ||||||
|    { |    { | ||||||
|    } |    } | ||||||
|    ~MapContext() = default; |    ~MapContext() = default; | ||||||
|  | @ -29,6 +34,9 @@ struct MapContext | ||||||
|    gl::OpenGLFunctions                     gl_; |    gl::OpenGLFunctions                     gl_; | ||||||
|    MapSettings                             settings_; |    MapSettings                             settings_; | ||||||
|    std::shared_ptr<view::RadarProductView> radarProductView_; |    std::shared_ptr<view::RadarProductView> radarProductView_; | ||||||
|  |    common::RadarProductGroup               radarProductGroup_; | ||||||
|  |    std::string                             radarProduct_; | ||||||
|  |    int16_t                                 radarProductCode_; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace map
 | } // namespace map
 | ||||||
|  |  | ||||||
|  | @ -267,11 +267,13 @@ void MapWidget::SelectRadarProduct(common::RadarProductGroup group, | ||||||
|       common::Level2Product level2Product = |       common::Level2Product level2Product = | ||||||
|          p->GetLevel2ProductOrDefault(productName); |          p->GetLevel2ProductOrDefault(productName); | ||||||
|       productName               = common::GetLevel2Name(level2Product); |       productName               = common::GetLevel2Name(level2Product); | ||||||
|  |       p->selectedLevel2Product_ = level2Product; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    if (radarProductView == nullptr || |    if (radarProductView == nullptr || | ||||||
|        radarProductView->GetRadarProductGroup() != group || |        radarProductView->GetRadarProductGroup() != group || | ||||||
|        radarProductView->GetRadarProductName() != productName) |        radarProductView->GetRadarProductName() != productName || | ||||||
|  |        p->context_->radarProductCode_ != productCode) | ||||||
|    { |    { | ||||||
|       p->RadarProductViewDisconnect(); |       p->RadarProductViewDisconnect(); | ||||||
| 
 | 
 | ||||||
|  | @ -282,12 +284,14 @@ void MapWidget::SelectRadarProduct(common::RadarProductGroup group, | ||||||
| 
 | 
 | ||||||
|       radarProductViewCreated = true; |       radarProductViewCreated = true; | ||||||
|    } |    } | ||||||
|    radarProductView->SelectTime(p->selectedTime_); |  | ||||||
| 
 | 
 | ||||||
|    if (group == common::RadarProductGroup::Level2) |    p->context_->radarProductGroup_ = group; | ||||||
|  |    p->context_->radarProduct_      = productName; | ||||||
|  |    p->context_->radarProductCode_  = productCode; | ||||||
|  | 
 | ||||||
|  |    if (radarProductView != nullptr) | ||||||
|    { |    { | ||||||
|       p->selectedLevel2Product_ = common::GetLevel2Product(productName); |       radarProductView->SelectTime(p->selectedTime_); | ||||||
|    } |  | ||||||
| 
 | 
 | ||||||
|       if (radarProductViewCreated) |       if (radarProductViewCreated) | ||||||
|       { |       { | ||||||
|  | @ -301,6 +305,7 @@ void MapWidget::SelectRadarProduct(common::RadarProductGroup group, | ||||||
|       { |       { | ||||||
|          radarProductView->Update(); |          radarProductView->Update(); | ||||||
|       } |       } | ||||||
|  |    } | ||||||
| 
 | 
 | ||||||
|    if (p->autoRefreshEnabled_) |    if (p->autoRefreshEnabled_) | ||||||
|    { |    { | ||||||
|  | @ -315,14 +320,7 @@ void MapWidget::SelectRadarProduct( | ||||||
|    common::RadarProductGroup             group = record->radar_product_group(); |    common::RadarProductGroup             group = record->radar_product_group(); | ||||||
|    const std::string                     product     = record->radar_product(); |    const std::string                     product     = record->radar_product(); | ||||||
|    std::chrono::system_clock::time_point time        = record->time(); |    std::chrono::system_clock::time_point time        = record->time(); | ||||||
| 
 |    int16_t                               productCode = record->product_code(); | ||||||
|    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(); |  | ||||||
|    } |  | ||||||
| 
 | 
 | ||||||
|    logger_->debug("SelectRadarProduct: {}, {}, {}, {}", |    logger_->debug("SelectRadarProduct: {}, {}, {}, {}", | ||||||
|                   radarId, |                   radarId, | ||||||
|  | @ -598,10 +596,9 @@ void MapWidgetImpl::AutoRefreshConnect() | ||||||
|              const std::string&                    product, |              const std::string&                    product, | ||||||
|              std::chrono::system_clock::time_point latestTime) |              std::chrono::system_clock::time_point latestTime) | ||||||
|          { |          { | ||||||
|             if (autoRefreshEnabled_ && context_->radarProductView_ != nullptr && |             if (autoRefreshEnabled_ && context_->radarProductGroup_ == group && | ||||||
|                 context_->radarProductView_->GetRadarProductGroup() == group && |  | ||||||
|                 (group == common::RadarProductGroup::Level2 || |                 (group == common::RadarProductGroup::Level2 || | ||||||
|                  context_->radarProductView_->GetRadarProductName() == product)) |                  context_->radarProduct_ == product)) | ||||||
|             { |             { | ||||||
|                // Create file request
 |                // Create file request
 | ||||||
|                std::shared_ptr<request::NexradFileRequest> request = |                std::shared_ptr<request::NexradFileRequest> request = | ||||||
|  |  | ||||||
|  | @ -29,6 +29,7 @@ public: | ||||||
|    ~RadarProductRecordImpl() {} |    ~RadarProductRecordImpl() {} | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<wsr88d::NexradFile>   nexradFile_; |    std::shared_ptr<wsr88d::NexradFile>   nexradFile_; | ||||||
|  |    int16_t                               productCode_; | ||||||
|    std::string                           radarId_; |    std::string                           radarId_; | ||||||
|    std::string                           radarProduct_; |    std::string                           radarProduct_; | ||||||
|    common::RadarProductGroup             radarProductGroup_; |    common::RadarProductGroup             radarProductGroup_; | ||||||
|  | @ -51,6 +52,7 @@ RadarProductRecord::RadarProductRecord( | ||||||
|       p->radarProductGroup_ = common::RadarProductGroup::Level2; |       p->radarProductGroup_ = common::RadarProductGroup::Level2; | ||||||
|       p->radarId_           = level2File->icao(); |       p->radarId_           = level2File->icao(); | ||||||
|       p->siteId_            = common::GetSiteId(p->radarId_); |       p->siteId_            = common::GetSiteId(p->radarId_); | ||||||
|  |       p->productCode_       = 0; | ||||||
|       julianDate            = level2File->julian_date(); |       julianDate            = level2File->julian_date(); | ||||||
|       milliseconds          = level2File->milliseconds(); |       milliseconds          = level2File->milliseconds(); | ||||||
|    } |    } | ||||||
|  | @ -60,6 +62,7 @@ RadarProductRecord::RadarProductRecord( | ||||||
|       p->radarProduct_      = level3File->wmo_header()->product_category(); |       p->radarProduct_      = level3File->wmo_header()->product_category(); | ||||||
|       p->siteId_            = level3File->wmo_header()->product_designator(); |       p->siteId_            = level3File->wmo_header()->product_designator(); | ||||||
|       p->radarId_           = config::GetRadarIdFromSiteId(p->siteId_); |       p->radarId_           = config::GetRadarIdFromSiteId(p->siteId_); | ||||||
|  |       p->productCode_       = level3File->message()->header().message_code(); | ||||||
| 
 | 
 | ||||||
|       auto descriptionBlock = level3File->message()->description_block(); |       auto descriptionBlock = level3File->message()->description_block(); | ||||||
| 
 | 
 | ||||||
|  | @ -100,6 +103,11 @@ std::shared_ptr<wsr88d::NexradFile> RadarProductRecord::nexrad_file() const | ||||||
|    return p->nexradFile_; |    return p->nexradFile_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | int16_t RadarProductRecord::product_code() const | ||||||
|  | { | ||||||
|  |    return p->productCode_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| std::string RadarProductRecord::radar_id() const | std::string RadarProductRecord::radar_id() const | ||||||
| { | { | ||||||
|    return p->radarId_; |    return p->radarId_; | ||||||
|  |  | ||||||
|  | @ -31,6 +31,7 @@ public: | ||||||
|    std::shared_ptr<wsr88d::Ar2vFile>     level2_file() const; |    std::shared_ptr<wsr88d::Ar2vFile>     level2_file() const; | ||||||
|    std::shared_ptr<wsr88d::Level3File>   level3_file() const; |    std::shared_ptr<wsr88d::Level3File>   level3_file() const; | ||||||
|    std::shared_ptr<wsr88d::NexradFile>   nexrad_file() const; |    std::shared_ptr<wsr88d::NexradFile>   nexrad_file() const; | ||||||
|  |    int16_t                               product_code() const; | ||||||
|    std::string                           radar_id() const; |    std::string                           radar_id() const; | ||||||
|    std::string                           radar_product() const; |    std::string                           radar_product() const; | ||||||
|    common::RadarProductGroup             radar_product_group() const; |    common::RadarProductGroup             radar_product_group() const; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat