mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 11:00:06 +00:00 
			
		
		
		
	Add NEXRAD data provider function to get time points by date
This commit is contained in:
		
							parent
							
								
									3bee6f65e5
								
							
						
					
					
						commit
						a9f5a766cc
					
				
					 4 changed files with 83 additions and 9 deletions
				
			
		|  | @ -9,6 +9,7 @@ | |||
| 
 | ||||
| #include <aws/s3/model/GetObjectRequest.h> | ||||
| #include <aws/s3/model/ListObjectsV2Request.h> | ||||
| #include <fmt/chrono.h> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
|  | @ -156,6 +157,45 @@ std::string AwsNexradDataProvider::FindLatestKey() | |||
|    return key; | ||||
| } | ||||
| 
 | ||||
| std::vector<std::chrono::system_clock::time_point> | ||||
| AwsNexradDataProvider::GetTimePointsByDate( | ||||
|    std::chrono::system_clock::time_point date) | ||||
| { | ||||
|    const auto day = std::chrono::floor<std::chrono::days>(date); | ||||
| 
 | ||||
|    std::vector<std::chrono::system_clock::time_point> timePoints {}; | ||||
| 
 | ||||
|    logger_->debug("GetTimePointsByDate: {}", day); | ||||
| 
 | ||||
|    std::shared_lock lock(p->objectsMutex_); | ||||
| 
 | ||||
|    // Is the date present in the date list?
 | ||||
|    if (std::find(p->objectDates_.cbegin(), p->objectDates_.cend(), day) == | ||||
|        p->objectDates_.cend()) | ||||
|    { | ||||
|       // Temporarily unlock mutex
 | ||||
|       lock.unlock(); | ||||
| 
 | ||||
|       // List objects, since the date is not present in the date list
 | ||||
|       ListObjects(date); | ||||
| 
 | ||||
|       // Re-lock mutex
 | ||||
|       lock.lock(); | ||||
|    } | ||||
| 
 | ||||
|    // Determine objects to retrieve
 | ||||
|    auto objectsBegin = p->objects_.lower_bound(day); | ||||
|    auto objectsEnd   = p->objects_.lower_bound(day + std::chrono::days {1}); | ||||
| 
 | ||||
|    // Copy time points to destination vector
 | ||||
|    std::transform(objectsBegin, | ||||
|                   objectsEnd, | ||||
|                   std::back_inserter(timePoints), | ||||
|                   [](const auto& object) { return object.first; }); | ||||
| 
 | ||||
|    return timePoints; | ||||
| } | ||||
| 
 | ||||
| std::pair<size_t, size_t> | ||||
| AwsNexradDataProvider::ListObjects(std::chrono::system_clock::time_point date) | ||||
| { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat