mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 07:00:04 +00:00
Active Volume Times for Radar Product Manager
This commit is contained in:
parent
a9f5a766cc
commit
a7a34e063c
2 changed files with 75 additions and 2 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
#include <execution>
|
#include <execution>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(push, 0)
|
# pragma warning(push, 0)
|
||||||
|
|
@ -245,7 +246,7 @@ public:
|
||||||
std::shared_ptr<ProviderManager>,
|
std::shared_ptr<ProviderManager>,
|
||||||
boost::hash<boost::uuids::uuid>>
|
boost::hash<boost::uuids::uuid>>
|
||||||
refreshMap_ {};
|
refreshMap_ {};
|
||||||
std::mutex refreshMapMutex_ {};
|
std::shared_mutex refreshMapMutex_ {};
|
||||||
};
|
};
|
||||||
|
|
||||||
RadarProductManager::RadarProductManager(const std::string& radarId) :
|
RadarProductManager::RadarProductManager(const std::string& radarId) :
|
||||||
|
|
@ -676,6 +677,66 @@ void RadarProductManagerImpl::RefreshData(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<std::chrono::system_clock::time_point>
|
||||||
|
RadarProductManager::GetActiveVolumeTimes(
|
||||||
|
std::chrono::system_clock::time_point time)
|
||||||
|
{
|
||||||
|
std::unordered_set<std::shared_ptr<provider::NexradDataProvider>>
|
||||||
|
providers {};
|
||||||
|
std::set<std::chrono::system_clock::time_point> volumeTimes;
|
||||||
|
std::mutex volumeTimesMutex {};
|
||||||
|
|
||||||
|
// Lock the refresh map
|
||||||
|
std::shared_lock refreshLock {p->refreshMapMutex_};
|
||||||
|
|
||||||
|
// For each entry in the refresh map (refresh is enabled)
|
||||||
|
for (auto& refreshEntry : p->refreshMap_)
|
||||||
|
{
|
||||||
|
// Add the provider for the current entry
|
||||||
|
providers.insert(refreshEntry.second->provider_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock the refresh map
|
||||||
|
refreshLock.unlock();
|
||||||
|
|
||||||
|
// For each provider (in parallel)
|
||||||
|
std::for_each(
|
||||||
|
std::execution::par_unseq,
|
||||||
|
providers.begin(),
|
||||||
|
providers.end(),
|
||||||
|
[&](const std::shared_ptr<provider::NexradDataProvider>& provider)
|
||||||
|
{
|
||||||
|
const auto today = std::chrono::floor<std::chrono::days>(time);
|
||||||
|
const auto yesterday = today - std::chrono::days {1};
|
||||||
|
const auto dates = {yesterday, today};
|
||||||
|
|
||||||
|
// For today and yesterday (in parallel)
|
||||||
|
std::for_each(std::execution::par_unseq,
|
||||||
|
dates.begin(),
|
||||||
|
dates.end(),
|
||||||
|
[&](const auto& date)
|
||||||
|
{
|
||||||
|
// Query the provider for volume time points
|
||||||
|
auto timePoints = provider->GetTimePointsByDate(date);
|
||||||
|
|
||||||
|
// TODO: Note, this will miss volume times present in
|
||||||
|
// Level 2 products with a second scan
|
||||||
|
|
||||||
|
// Lock the merged volume time list
|
||||||
|
std::unique_lock volumeTimesLock {volumeTimesMutex};
|
||||||
|
|
||||||
|
// Copy time points to the merged list
|
||||||
|
std::copy(
|
||||||
|
timePoints.begin(),
|
||||||
|
timePoints.end(),
|
||||||
|
std::inserter(volumeTimes, volumeTimes.end()));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Return merged volume times list
|
||||||
|
return volumeTimes;
|
||||||
|
}
|
||||||
|
|
||||||
void RadarProductManagerImpl::LoadProviderData(
|
void RadarProductManagerImpl::LoadProviderData(
|
||||||
std::chrono::system_clock::time_point time,
|
std::chrono::system_clock::time_point time,
|
||||||
std::shared_ptr<ProviderManager> providerManager,
|
std::shared_ptr<ProviderManager> providerManager,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include <scwx/wsr88d/level3_file.hpp>
|
#include <scwx/wsr88d/level3_file.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
@ -63,6 +64,17 @@ public:
|
||||||
bool enabled,
|
bool enabled,
|
||||||
boost::uuids::uuid uuid = boost::uuids::nil_uuid());
|
boost::uuids::uuid uuid = boost::uuids::nil_uuid());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets a merged list of the volume times for products with refresh
|
||||||
|
* enabled. The volume times will be for the current and previous day.
|
||||||
|
*
|
||||||
|
* @param [in] time Current date to provide to volume time query
|
||||||
|
*
|
||||||
|
* @return Merged list of active volume times
|
||||||
|
*/
|
||||||
|
std::set<std::chrono::system_clock::time_point>
|
||||||
|
GetActiveVolumeTimes(std::chrono::system_clock::time_point time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get level 2 radar data for a data block type, elevation, and time.
|
* @brief Get level 2 radar data for a data block type, elevation, and time.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue