mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:40:05 +00:00
Setting up for merging last and current scan's, and having archive and chunks
This commit is contained in:
parent
fc83a7a36f
commit
a754d66844
8 changed files with 143 additions and 23 deletions
|
|
@ -134,6 +134,8 @@ public:
|
||||||
level3ProductsInitialized_ {false},
|
level3ProductsInitialized_ {false},
|
||||||
radarSite_ {config::RadarSite::Get(radarId)},
|
radarSite_ {config::RadarSite::Get(radarId)},
|
||||||
level2ProviderManager_ {std::make_shared<ProviderManager>(
|
level2ProviderManager_ {std::make_shared<ProviderManager>(
|
||||||
|
self_, radarId_, common::RadarProductGroup::Level2)},
|
||||||
|
level2ChunksProviderManager_ {std::make_shared<ProviderManager>(
|
||||||
self_, radarId_, common::RadarProductGroup::Level2)}
|
self_, radarId_, common::RadarProductGroup::Level2)}
|
||||||
{
|
{
|
||||||
if (radarSite_ == nullptr)
|
if (radarSite_ == nullptr)
|
||||||
|
|
@ -144,10 +146,14 @@ public:
|
||||||
|
|
||||||
level2ProviderManager_->provider_ =
|
level2ProviderManager_->provider_ =
|
||||||
provider::NexradDataProviderFactory::CreateLevel2DataProvider(radarId);
|
provider::NexradDataProviderFactory::CreateLevel2DataProvider(radarId);
|
||||||
|
level2ChunksProviderManager_->provider_ =
|
||||||
|
provider::NexradDataProviderFactory::CreateLevel2ChunksDataProvider(
|
||||||
|
radarId);
|
||||||
}
|
}
|
||||||
~RadarProductManagerImpl()
|
~RadarProductManagerImpl()
|
||||||
{
|
{
|
||||||
level2ProviderManager_->Disable();
|
level2ProviderManager_->Disable();
|
||||||
|
level2ChunksProviderManager_->Disable();
|
||||||
|
|
||||||
std::shared_lock lock(level3ProviderManagerMutex_);
|
std::shared_lock lock(level3ProviderManagerMutex_);
|
||||||
std::for_each(std::execution::par_unseq,
|
std::for_each(std::execution::par_unseq,
|
||||||
|
|
@ -251,6 +257,7 @@ public:
|
||||||
std::shared_mutex level3ProductRecordMutex_ {};
|
std::shared_mutex level3ProductRecordMutex_ {};
|
||||||
|
|
||||||
std::shared_ptr<ProviderManager> level2ProviderManager_;
|
std::shared_ptr<ProviderManager> level2ProviderManager_;
|
||||||
|
std::shared_ptr<ProviderManager> level2ChunksProviderManager_;
|
||||||
std::unordered_map<std::string, std::shared_ptr<ProviderManager>>
|
std::unordered_map<std::string, std::shared_ptr<ProviderManager>>
|
||||||
level3ProviderManagerMap_ {};
|
level3ProviderManagerMap_ {};
|
||||||
std::shared_mutex level3ProviderManagerMutex_ {};
|
std::shared_mutex level3ProviderManagerMutex_ {};
|
||||||
|
|
@ -639,6 +646,7 @@ void RadarProductManager::EnableRefresh(common::RadarProductGroup group,
|
||||||
if (group == common::RadarProductGroup::Level2)
|
if (group == common::RadarProductGroup::Level2)
|
||||||
{
|
{
|
||||||
p->EnableRefresh(uuid, p->level2ProviderManager_, enabled);
|
p->EnableRefresh(uuid, p->level2ProviderManager_, enabled);
|
||||||
|
p->EnableRefresh(uuid, p->level2ChunksProviderManager_, enabled);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -986,6 +994,12 @@ void RadarProductManager::LoadLevel2Data(
|
||||||
p->level2ProductRecordMutex_,
|
p->level2ProductRecordMutex_,
|
||||||
p->loadLevel2DataMutex_,
|
p->loadLevel2DataMutex_,
|
||||||
request);
|
request);
|
||||||
|
p->LoadProviderData(time,
|
||||||
|
p->level2ChunksProviderManager_,
|
||||||
|
p->level2ProductRecords_,
|
||||||
|
p->level2ProductRecordMutex_,
|
||||||
|
p->loadLevel2DataMutex_,
|
||||||
|
request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadarProductManager::LoadLevel3Data(
|
void RadarProductManager::LoadLevel3Data(
|
||||||
|
|
@ -1162,6 +1176,10 @@ void RadarProductManagerImpl::PopulateLevel2ProductTimes(
|
||||||
level2ProductRecords_,
|
level2ProductRecords_,
|
||||||
level2ProductRecordMutex_,
|
level2ProductRecordMutex_,
|
||||||
time);
|
time);
|
||||||
|
PopulateProductTimes(level2ChunksProviderManager_,
|
||||||
|
level2ProductRecords_,
|
||||||
|
level2ProductRecordMutex_,
|
||||||
|
time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadarProductManagerImpl::PopulateLevel3ProductTimes(
|
void RadarProductManagerImpl::PopulateLevel3ProductTimes(
|
||||||
|
|
@ -1504,35 +1522,104 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
|
||||||
|
|
||||||
auto records = p->GetLevel2ProductRecords(time);
|
auto records = p->GetLevel2ProductRecords(time);
|
||||||
|
|
||||||
for (auto& recordPair : records)
|
//TODO decide when to use chunked vs archived data.
|
||||||
|
if (true)
|
||||||
{
|
{
|
||||||
auto& record = recordPair.second;
|
auto currentFile = std::dynamic_pointer_cast<wsr88d::Ar2vFile>(
|
||||||
|
p->level2ChunksProviderManager_->provider_->LoadLatestObject());
|
||||||
if (record != nullptr)
|
std::shared_ptr<wsr88d::rda::ElevationScan> currentRadarData = nullptr;
|
||||||
|
float currentElevationCut = 0.0f;
|
||||||
|
std::vector<float> currentElevationCuts;
|
||||||
|
if (currentFile != nullptr)
|
||||||
{
|
{
|
||||||
std::shared_ptr<wsr88d::rda::ElevationScan> recordRadarData = nullptr;
|
std::tie(currentRadarData, currentElevationCut, currentElevationCuts) =
|
||||||
float recordElevationCut = 0.0f;
|
currentFile->GetElevationScan(dataBlockType, elevation, time);
|
||||||
std::vector<float> recordElevationCuts;
|
}
|
||||||
|
|
||||||
std::tie(recordRadarData, recordElevationCut, recordElevationCuts) =
|
std::shared_ptr<wsr88d::rda::ElevationScan> lastRadarData = nullptr;
|
||||||
record->level2_file()->GetElevationScan(
|
float lastElevationCut = 0.0f;
|
||||||
dataBlockType, elevation, time);
|
std::vector<float> lastElevationCuts;
|
||||||
|
auto lastFile = std::dynamic_pointer_cast<wsr88d::Ar2vFile>(
|
||||||
|
p->level2ChunksProviderManager_->provider_->LoadSecondLatestObject());
|
||||||
|
if (lastFile != nullptr)
|
||||||
|
{
|
||||||
|
std::tie(lastRadarData, lastElevationCut, lastElevationCuts) =
|
||||||
|
lastFile->GetElevationScan(dataBlockType, elevation, time);
|
||||||
|
}
|
||||||
|
|
||||||
if (recordRadarData != nullptr)
|
if (currentRadarData != nullptr)
|
||||||
|
{
|
||||||
|
if (lastRadarData != nullptr)
|
||||||
{
|
{
|
||||||
auto& radarData0 = (*recordRadarData)[0];
|
auto& radarData0 = (*currentRadarData)[0];
|
||||||
auto collectionTime = std::chrono::floor<std::chrono::seconds>(
|
auto collectionTime = std::chrono::floor<std::chrono::seconds>(
|
||||||
scwx::util::TimePoint(radarData0->modified_julian_date(),
|
scwx::util::TimePoint(radarData0->modified_julian_date(),
|
||||||
radarData0->collection_time()));
|
radarData0->collection_time()));
|
||||||
|
|
||||||
// Find the newest radar data, not newer than the selected time
|
// TODO merge data
|
||||||
if (radarData == nullptr ||
|
radarData = currentRadarData;
|
||||||
(collectionTime <= time && foundTime < collectionTime))
|
elevationCut = currentElevationCut;
|
||||||
|
elevationCuts = std::move(currentElevationCuts);
|
||||||
|
foundTime = collectionTime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto& radarData0 = (*currentRadarData)[0];
|
||||||
|
auto collectionTime = std::chrono::floor<std::chrono::seconds>(
|
||||||
|
scwx::util::TimePoint(radarData0->modified_julian_date(),
|
||||||
|
radarData0->collection_time()));
|
||||||
|
|
||||||
|
radarData = currentRadarData;
|
||||||
|
elevationCut = currentElevationCut;
|
||||||
|
elevationCuts = std::move(currentElevationCuts);
|
||||||
|
foundTime = collectionTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (lastRadarData != nullptr)
|
||||||
|
{
|
||||||
|
auto& radarData0 = (*lastRadarData)[0];
|
||||||
|
auto collectionTime = std::chrono::floor<std::chrono::seconds>(
|
||||||
|
scwx::util::TimePoint(radarData0->modified_julian_date(),
|
||||||
|
radarData0->collection_time()));
|
||||||
|
|
||||||
|
radarData = lastRadarData;
|
||||||
|
elevationCut = lastElevationCut;
|
||||||
|
elevationCuts = std::move(lastElevationCuts);
|
||||||
|
foundTime = collectionTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto& recordPair : records)
|
||||||
|
{
|
||||||
|
auto& record = recordPair.second;
|
||||||
|
|
||||||
|
if (record != nullptr)
|
||||||
|
{
|
||||||
|
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(
|
||||||
|
dataBlockType, elevation, time);
|
||||||
|
|
||||||
|
if (recordRadarData != nullptr)
|
||||||
{
|
{
|
||||||
radarData = recordRadarData;
|
auto& radarData0 = (*recordRadarData)[0];
|
||||||
elevationCut = recordElevationCut;
|
auto collectionTime = std::chrono::floor<std::chrono::seconds>(
|
||||||
elevationCuts = std::move(recordElevationCuts);
|
scwx::util::TimePoint(radarData0->modified_julian_date(),
|
||||||
foundTime = collectionTime;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ public:
|
||||||
std::shared_ptr<wsr88d::NexradFile>
|
std::shared_ptr<wsr88d::NexradFile>
|
||||||
LoadObjectByTime(std::chrono::system_clock::time_point time) override;
|
LoadObjectByTime(std::chrono::system_clock::time_point time) override;
|
||||||
std::shared_ptr<wsr88d::NexradFile> LoadLatestObject() override;
|
std::shared_ptr<wsr88d::NexradFile> LoadLatestObject() override;
|
||||||
|
std::shared_ptr<wsr88d::NexradFile> LoadSecondLatestObject() override;
|
||||||
std::pair<size_t, size_t> Refresh() override;
|
std::pair<size_t, size_t> Refresh() override;
|
||||||
|
|
||||||
void RequestAvailableProducts() override;
|
void RequestAvailableProducts() override;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ public:
|
||||||
std::shared_ptr<wsr88d::NexradFile>
|
std::shared_ptr<wsr88d::NexradFile>
|
||||||
LoadObjectByTime(std::chrono::system_clock::time_point time) override;
|
LoadObjectByTime(std::chrono::system_clock::time_point time) override;
|
||||||
std::shared_ptr<wsr88d::NexradFile> LoadLatestObject() override;
|
std::shared_ptr<wsr88d::NexradFile> LoadLatestObject() override;
|
||||||
|
std::shared_ptr<wsr88d::NexradFile> LoadSecondLatestObject() override;
|
||||||
std::pair<size_t, size_t> Refresh() override;
|
std::pair<size_t, size_t> Refresh() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,15 @@ public:
|
||||||
virtual std::shared_ptr<wsr88d::NexradFile>
|
virtual std::shared_ptr<wsr88d::NexradFile>
|
||||||
LoadLatestObject() = 0;
|
LoadLatestObject() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the second NEXRAD file object
|
||||||
|
*
|
||||||
|
* @return NEXRAD data
|
||||||
|
*/
|
||||||
|
virtual std::shared_ptr<wsr88d::NexradFile>
|
||||||
|
LoadSecondLatestObject() = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists NEXRAD objects for the current date, and adds them to the cache. If
|
* Lists NEXRAD objects for the current date, and adds them to the cache. If
|
||||||
* no objects have been added to the cache for the current date, the previous
|
* no objects have been added to the cache for the current date, the previous
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ public:
|
||||||
static std::shared_ptr<NexradDataProvider>
|
static std::shared_ptr<NexradDataProvider>
|
||||||
CreateLevel2DataProvider(const std::string& radarSite);
|
CreateLevel2DataProvider(const std::string& radarSite);
|
||||||
|
|
||||||
|
static std::shared_ptr<NexradDataProvider>
|
||||||
|
CreateLevel2ChunksDataProvider(const std::string& radarSite);
|
||||||
|
|
||||||
static std::shared_ptr<NexradDataProvider>
|
static std::shared_ptr<NexradDataProvider>
|
||||||
CreateLevel3DataProvider(const std::string& radarSite,
|
CreateLevel3DataProvider(const std::string& radarSite,
|
||||||
const std::string& product);
|
const std::string& product);
|
||||||
|
|
|
||||||
|
|
@ -603,7 +603,13 @@ AwsLevel2ChunksDataProvider::LoadObjectByTime(
|
||||||
std::shared_ptr<wsr88d::NexradFile>
|
std::shared_ptr<wsr88d::NexradFile>
|
||||||
AwsLevel2ChunksDataProvider::LoadLatestObject()
|
AwsLevel2ChunksDataProvider::LoadLatestObject()
|
||||||
{
|
{
|
||||||
return LoadObjectByTime(FindLatestTime());
|
return p->currentScan_.nexradFile_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<wsr88d::NexradFile>
|
||||||
|
AwsLevel2ChunksDataProvider::LoadSecondLatestObject()
|
||||||
|
{
|
||||||
|
return p->lastScan_.nexradFile_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AwsLevel2ChunksDataProvider::Impl::GetScanNumber(const std::string& prefix)
|
int AwsLevel2ChunksDataProvider::Impl::GetScanNumber(const std::string& prefix)
|
||||||
|
|
|
||||||
|
|
@ -351,6 +351,12 @@ std::shared_ptr<wsr88d::NexradFile> AwsNexradDataProvider::LoadLatestObject()
|
||||||
return LoadObjectByKey(FindLatestKey());
|
return LoadObjectByKey(FindLatestKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<wsr88d::NexradFile>
|
||||||
|
AwsNexradDataProvider::LoadSecondLatestObject()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<size_t, size_t> AwsNexradDataProvider::Refresh()
|
std::pair<size_t, size_t> AwsNexradDataProvider::Refresh()
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include <scwx/provider/nexrad_data_provider_factory.hpp>
|
#include <scwx/provider/nexrad_data_provider_factory.hpp>
|
||||||
//#include <scwx/provider/aws_level2_data_provider.hpp>
|
#include <scwx/provider/aws_level2_data_provider.hpp>
|
||||||
#include <scwx/provider/aws_level2_chunks_data_provider.hpp>
|
#include <scwx/provider/aws_level2_chunks_data_provider.hpp>
|
||||||
#include <scwx/provider/aws_level3_data_provider.hpp>
|
#include <scwx/provider/aws_level3_data_provider.hpp>
|
||||||
|
|
||||||
|
|
@ -14,6 +14,13 @@ static const std::string logPrefix_ =
|
||||||
std::shared_ptr<NexradDataProvider>
|
std::shared_ptr<NexradDataProvider>
|
||||||
NexradDataProviderFactory::CreateLevel2DataProvider(
|
NexradDataProviderFactory::CreateLevel2DataProvider(
|
||||||
const std::string& radarSite)
|
const std::string& radarSite)
|
||||||
|
{
|
||||||
|
return std::make_unique<AwsLevel2DataProvider>(radarSite);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<NexradDataProvider>
|
||||||
|
NexradDataProviderFactory::CreateLevel2ChunksDataProvider(
|
||||||
|
const std::string& radarSite)
|
||||||
{
|
{
|
||||||
return std::make_unique<AwsLevel2ChunksDataProvider>(radarSite);
|
return std::make_unique<AwsLevel2ChunksDataProvider>(radarSite);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue