mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:50:05 +00:00 
			
		
		
		
	Initial handling of multiple time sweeps in individual level 2 files
This commit is contained in:
		
							parent
							
								
									b466ac818c
								
							
						
					
					
						commit
						f1e35532b9
					
				
					 1 changed files with 100 additions and 47 deletions
				
			
		|  | @ -176,9 +176,9 @@ public: | ||||||
|    void RefreshData(std::shared_ptr<ProviderManager> providerManager); |    void RefreshData(std::shared_ptr<ProviderManager> providerManager); | ||||||
|    void RefreshDataSync(std::shared_ptr<ProviderManager> providerManager); |    void RefreshDataSync(std::shared_ptr<ProviderManager> providerManager); | ||||||
| 
 | 
 | ||||||
|    std::tuple<std::shared_ptr<types::RadarProductRecord>, |    std::map<std::chrono::system_clock::time_point, | ||||||
|               std::chrono::system_clock::time_point> |             std::shared_ptr<types::RadarProductRecord>> | ||||||
|    GetLevel2ProductRecord(std::chrono::system_clock::time_point time); |    GetLevel2ProductRecords(std::chrono::system_clock::time_point time); | ||||||
|    std::tuple<std::shared_ptr<types::RadarProductRecord>, |    std::tuple<std::shared_ptr<types::RadarProductRecord>, | ||||||
|               std::chrono::system_clock::time_point> |               std::chrono::system_clock::time_point> | ||||||
|    GetLevel3ProductRecord(const std::string&                    product, |    GetLevel3ProductRecord(const std::string&                    product, | ||||||
|  | @ -1151,14 +1151,15 @@ void RadarProductManagerImpl::PopulateProductTimes( | ||||||
|                   }); |                   }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::tuple<std::shared_ptr<types::RadarProductRecord>, | std::map<std::chrono::system_clock::time_point, | ||||||
|            std::chrono::system_clock::time_point> |          std::shared_ptr<types::RadarProductRecord>> | ||||||
| RadarProductManagerImpl::GetLevel2ProductRecord( | RadarProductManagerImpl::GetLevel2ProductRecords( | ||||||
|    std::chrono::system_clock::time_point time) |    std::chrono::system_clock::time_point time) | ||||||
| { | { | ||||||
|    std::shared_ptr<types::RadarProductRecord> record {nullptr}; |    std::map<std::chrono::system_clock::time_point, | ||||||
|    RadarProductRecordMap::const_pointer       recordPtr {nullptr}; |             std::shared_ptr<types::RadarProductRecord>> | ||||||
|    std::chrono::system_clock::time_point      recordTime {time}; |                                                      records {}; | ||||||
|  |    std::vector<RadarProductRecordMap::const_pointer> recordPtrs {}; | ||||||
| 
 | 
 | ||||||
|    // Ensure Level 2 product records are updated
 |    // Ensure Level 2 product records are updated
 | ||||||
|    PopulateLevel2ProductTimes(time); |    PopulateLevel2ProductTimes(time); | ||||||
|  | @ -1167,13 +1168,31 @@ RadarProductManagerImpl::GetLevel2ProductRecord( | ||||||
|        time == std::chrono::system_clock::time_point {}) |        time == std::chrono::system_clock::time_point {}) | ||||||
|    { |    { | ||||||
|       // If a default-initialized time point is given, return the latest record
 |       // If a default-initialized time point is given, return the latest record
 | ||||||
|       recordPtr = &(*level2ProductRecords_.rbegin()); |       recordPtrs.push_back(&(*level2ProductRecords_.rbegin())); | ||||||
|    } |    } | ||||||
|    else |    else | ||||||
|    { |    { | ||||||
|       recordPtr = |       // Get the requested record
 | ||||||
|          scwx::util::GetBoundedElementPointer(level2ProductRecords_, time); |       auto recordIt = | ||||||
|  |          scwx::util::GetBoundedElementIterator(level2ProductRecords_, time); | ||||||
|  | 
 | ||||||
|  |       if (recordIt != level2ProductRecords_.cend()) | ||||||
|  |       { | ||||||
|  |          recordPtrs.push_back(&(*(recordIt))); | ||||||
|  | 
 | ||||||
|  |          // The requested time may be in the previous record, so get that too
 | ||||||
|  |          if (recordIt != level2ProductRecords_.cbegin()) | ||||||
|  |          { | ||||||
|  |             recordPtrs.push_back(&(*(--recordIt))); | ||||||
|          } |          } | ||||||
|  |       } | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    // For each record pointer
 | ||||||
|  |    for (auto& recordPtr : recordPtrs) | ||||||
|  |    { | ||||||
|  |       std::shared_ptr<types::RadarProductRecord> record {nullptr}; | ||||||
|  |       std::chrono::system_clock::time_point      recordTime {time}; | ||||||
| 
 | 
 | ||||||
|       if (recordPtr != nullptr) |       if (recordPtr != nullptr) | ||||||
|       { |       { | ||||||
|  | @ -1204,7 +1223,14 @@ RadarProductManagerImpl::GetLevel2ProductRecord( | ||||||
|          self_->LoadLevel2Data(recordTime, request); |          self_->LoadLevel2Data(recordTime, request); | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|    return {record, recordTime}; |       if (record != nullptr) | ||||||
|  |       { | ||||||
|  |          // Return valid records
 | ||||||
|  |          records.insert_or_assign(recordTime, record); | ||||||
|  |       } | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return records; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::tuple<std::shared_ptr<types::RadarProductRecord>, | std::tuple<std::shared_ptr<types::RadarProductRecord>, | ||||||
|  | @ -1377,19 +1403,46 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType, | ||||||
| { | { | ||||||
|    std::shared_ptr<wsr88d::rda::ElevationScan> radarData    = nullptr; |    std::shared_ptr<wsr88d::rda::ElevationScan> radarData    = nullptr; | ||||||
|    float                                       elevationCut = 0.0f; |    float                                       elevationCut = 0.0f; | ||||||
|    std::vector<float>                          elevationCuts; |    std::vector<float>                          elevationCuts {}; | ||||||
|  |    std::chrono::system_clock::time_point       foundTime {}; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<types::RadarProductRecord> record; |    auto records = p->GetLevel2ProductRecords(time); | ||||||
|    std::tie(record, time) = p->GetLevel2ProductRecord(time); | 
 | ||||||
|  |    for (auto& recordPair : records) | ||||||
|  |    { | ||||||
|  |       auto& record = recordPair.second; | ||||||
| 
 | 
 | ||||||
|       if (record != nullptr) |       if (record != nullptr) | ||||||
|       { |       { | ||||||
|       std::tie(radarData, elevationCut, elevationCuts) = |          std::shared_ptr<wsr88d::rda::ElevationScan> recordRadarData = nullptr; | ||||||
|  |          float                                       recordElevationCut = 0.0f; | ||||||
|  |          std::vector<float>                          recordElevationCuts; | ||||||
|  | 
 | ||||||
|  |          std::tie(recordRadarData, recordElevationCut, recordElevationCuts) = | ||||||
|             record->level2_file()->GetElevationScan( |             record->level2_file()->GetElevationScan( | ||||||
|                dataBlockType, elevation, time); |                dataBlockType, elevation, time); | ||||||
|  | 
 | ||||||
|  |          if (recordRadarData != nullptr) | ||||||
|  |          { | ||||||
|  |             auto& radarData0 = (*recordRadarData)[0]; | ||||||
|  |             auto  collectionTime = | ||||||
|  |                scwx::util::TimePoint(radarData0->modified_julian_date(), | ||||||
|  |                                      radarData0->collection_time()); | ||||||
|  | 
 | ||||||
|  |             // Find the newest radar data, not newer than the selected time
 | ||||||
|  |             if (radarData == nullptr || | ||||||
|  |                 (collectionTime <= time && foundTime < collectionTime)) | ||||||
|  |             { | ||||||
|  |                radarData     = recordRadarData; | ||||||
|  |                elevationCut  = recordElevationCut; | ||||||
|  |                elevationCuts = std::move(recordElevationCuts); | ||||||
|  |                foundTime     = collectionTime; | ||||||
|  |             } | ||||||
|  |          } | ||||||
|  |       } | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    return {radarData, elevationCut, elevationCuts, time}; |    return {radarData, elevationCut, elevationCuts, foundTime}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::tuple<std::shared_ptr<wsr88d::rpg::Level3Message>, | std::tuple<std::shared_ptr<wsr88d::rpg::Level3Message>, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat