mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 10:20:04 +00:00 
			
		
		
		
	Request available level 3 products
This commit is contained in:
		
							parent
							
								
									d2597354b4
								
							
						
					
					
						commit
						12d8aaf8a6
					
				
					 5 changed files with 51 additions and 0 deletions
				
			
		|  | @ -56,6 +56,16 @@ TEST(AwsLevel3DataProvider, Refresh) | |||
|    EXPECT_EQ(newObjects, totalObjects); | ||||
| } | ||||
| 
 | ||||
| TEST(AwsLevel3DataProvider, GetAvailableProducts) | ||||
| { | ||||
|    AwsLevel3DataProvider provider("KLSX", "N0B"); | ||||
| 
 | ||||
|    provider.RequestAvailableProducts(); | ||||
|    auto products = provider.GetAvailableProducts(); | ||||
| 
 | ||||
|    EXPECT_GT(products.size(), 0); | ||||
| } | ||||
| 
 | ||||
| TEST(AwsLevel3DataProvider, TimePointValid) | ||||
| { | ||||
|    using namespace std::chrono; | ||||
|  |  | |||
|  | @ -33,6 +33,9 @@ public: | |||
|    static std::chrono::system_clock::time_point | ||||
|    GetTimePointFromKey(const std::string& key); | ||||
| 
 | ||||
|    void                     RequestAvailableProducts(); | ||||
|    std::vector<std::string> GetAvailableProducts(); | ||||
| 
 | ||||
| protected: | ||||
|    std::string GetPrefix(std::chrono::system_clock::time_point date); | ||||
| 
 | ||||
|  |  | |||
|  | @ -100,6 +100,19 @@ public: | |||
|    virtual std::chrono::system_clock::time_point | ||||
|    GetTimePointByKey(const std::string& key) const = 0; | ||||
| 
 | ||||
|    /**
 | ||||
|     * Requests available NEXRAD products for the current radar site, and adds | ||||
|     * the list to the cache. | ||||
|     */ | ||||
|    virtual void RequestAvailableProducts(); | ||||
| 
 | ||||
|    /**
 | ||||
|     * Gets the list of available NEXRAD products for the current radar site. | ||||
|     * | ||||
|     * @return Available NEXRAD products | ||||
|     */ | ||||
|    virtual std::vector<std::string> GetAvailableProducts(); | ||||
| 
 | ||||
| private: | ||||
|    class Impl; | ||||
|    std::unique_ptr<Impl> p; | ||||
|  |  | |||
|  | @ -118,6 +118,24 @@ AwsLevel3DataProvider::GetTimePointFromKey(const std::string& key) | |||
|    return time; | ||||
| } | ||||
| 
 | ||||
| void AwsLevel3DataProvider::RequestAvailableProducts() | ||||
| { | ||||
|    p->ListProducts(); | ||||
| } | ||||
| 
 | ||||
| std::vector<std::string> AwsLevel3DataProvider::GetAvailableProducts() | ||||
| { | ||||
|    std::shared_lock readLock(productMutex_); | ||||
| 
 | ||||
|    auto siteProductMap = productMap_.find(p->radarSite_); | ||||
|    if (siteProductMap != productMap_.cend()) | ||||
|    { | ||||
|       return siteProductMap->second; | ||||
|    } | ||||
| 
 | ||||
|    return {}; | ||||
| } | ||||
| 
 | ||||
| void AwsLevel3DataProvider::Impl::ListProducts() | ||||
| { | ||||
|    std::shared_lock readLock(productMutex_); | ||||
|  |  | |||
|  | @ -22,5 +22,12 @@ NexradDataProvider::NexradDataProvider(NexradDataProvider&&) noexcept = default; | |||
| NexradDataProvider& | ||||
| NexradDataProvider::operator=(NexradDataProvider&&) noexcept = default; | ||||
| 
 | ||||
| void NexradDataProvider::RequestAvailableProducts() {} | ||||
| 
 | ||||
| std::vector<std::string> NexradDataProvider::GetAvailableProducts() | ||||
| { | ||||
|    return {}; | ||||
| } | ||||
| 
 | ||||
| } // namespace provider
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat