mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:20:06 +00:00
Fix level 2 display
This commit is contained in:
parent
b18491b2a0
commit
1b49e317e4
7 changed files with 96 additions and 18 deletions
|
|
@ -849,7 +849,8 @@ void MainWindowImpl::SelectRadarProduct(map::MapWidget* mapWidget,
|
||||||
UpdateRadarProductSettings();
|
UpdateRadarProductSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
mapWidget->SelectRadarProduct(group, productName, productCode);
|
mapWidget->SelectRadarProduct(
|
||||||
|
group, productName, productCode, mapWidget->GetSelectedTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowImpl::SetActiveMap(map::MapWidget* mapWidget)
|
void MainWindowImpl::SetActiveMap(map::MapWidget* mapWidget)
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,7 @@ public:
|
||||||
std::shared_mutex& recordMutex,
|
std::shared_mutex& recordMutex,
|
||||||
std::mutex& loadDataMutex,
|
std::mutex& loadDataMutex,
|
||||||
std::shared_ptr<request::NexradFileRequest> request);
|
std::shared_ptr<request::NexradFileRequest> request);
|
||||||
|
void PopulateLevel2ProductTimes(std::chrono::system_clock::time_point time);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LoadNexradFile(CreateNexradFileFunction load,
|
LoadNexradFile(CreateNexradFileFunction load,
|
||||||
|
|
@ -944,6 +945,59 @@ void RadarProductManagerImpl::LoadNexradFile(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RadarProductManagerImpl::PopulateLevel2ProductTimes(
|
||||||
|
std::chrono::system_clock::time_point time)
|
||||||
|
{
|
||||||
|
const auto today = std::chrono::floor<std::chrono::days>(time);
|
||||||
|
const auto yesterday = today - std::chrono::days {1};
|
||||||
|
const auto tomorrow = today + std::chrono::days {1};
|
||||||
|
const auto dates = {yesterday, today, tomorrow};
|
||||||
|
|
||||||
|
std::set<std::chrono::system_clock::time_point> volumeTimes {};
|
||||||
|
std::mutex volumeTimesMutex {};
|
||||||
|
|
||||||
|
// For yesterday, today and tomorrow (in parallel)
|
||||||
|
std::for_each(std::execution::par_unseq,
|
||||||
|
dates.begin(),
|
||||||
|
dates.end(),
|
||||||
|
[&, this](const auto& date)
|
||||||
|
{
|
||||||
|
// Don't query for a time point in the future
|
||||||
|
if (date > std::chrono::system_clock::now())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query the provider for volume time points
|
||||||
|
auto timePoints =
|
||||||
|
level2ProviderManager_->provider_->GetTimePointsByDate(
|
||||||
|
date);
|
||||||
|
|
||||||
|
// 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()));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Lock the level 2 product record map
|
||||||
|
std::unique_lock lock {level2ProductRecordMutex_};
|
||||||
|
|
||||||
|
// Merge volume times into map
|
||||||
|
std::transform(
|
||||||
|
volumeTimes.cbegin(),
|
||||||
|
volumeTimes.cend(),
|
||||||
|
std::inserter(level2ProductRecords_, level2ProductRecords_.begin()),
|
||||||
|
[](const std::chrono::system_clock::time_point& time)
|
||||||
|
{
|
||||||
|
return std::pair<std::chrono::system_clock::time_point,
|
||||||
|
std::weak_ptr<types::RadarProductRecord>>(
|
||||||
|
time, std::weak_ptr<types::RadarProductRecord> {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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>
|
||||||
RadarProductManagerImpl::GetLevel2ProductRecord(
|
RadarProductManagerImpl::GetLevel2ProductRecord(
|
||||||
|
|
@ -953,6 +1007,9 @@ RadarProductManagerImpl::GetLevel2ProductRecord(
|
||||||
RadarProductRecordMap::const_pointer recordPtr {nullptr};
|
RadarProductRecordMap::const_pointer recordPtr {nullptr};
|
||||||
std::chrono::system_clock::time_point recordTime {time};
|
std::chrono::system_clock::time_point recordTime {time};
|
||||||
|
|
||||||
|
// Ensure Level 2 product records are updated
|
||||||
|
PopulateLevel2ProductTimes(time);
|
||||||
|
|
||||||
if (!level2ProductRecords_.empty() &&
|
if (!level2ProductRecords_.empty() &&
|
||||||
time == std::chrono::system_clock::time_point {})
|
time == std::chrono::system_clock::time_point {})
|
||||||
{
|
{
|
||||||
|
|
@ -967,12 +1024,9 @@ RadarProductManagerImpl::GetLevel2ProductRecord(
|
||||||
|
|
||||||
if (recordPtr != nullptr)
|
if (recordPtr != nullptr)
|
||||||
{
|
{
|
||||||
if (time == std::chrono::system_clock::time_point {} ||
|
// Don't check for an exact time match for level 2 products
|
||||||
time == recordPtr->first)
|
recordTime = recordPtr->first;
|
||||||
{
|
record = recordPtr->second.lock();
|
||||||
recordTime = recordPtr->first;
|
|
||||||
record = recordPtr->second.lock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record == nullptr &&
|
if (record == nullptr &&
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,21 @@ std::shared_ptr<config::RadarSite> MapWidget::GetRadarSite() const
|
||||||
return radarSite;
|
return radarSite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::chrono::system_clock::time_point MapWidget::GetSelectedTime() const
|
||||||
|
{
|
||||||
|
auto radarProductView = p->context_->radar_product_view();
|
||||||
|
std::chrono::system_clock::time_point time;
|
||||||
|
|
||||||
|
// If there is an active radar product view
|
||||||
|
if (radarProductView != nullptr)
|
||||||
|
{
|
||||||
|
// Select the time associated with the active radar product
|
||||||
|
time = radarProductView->GetSelectedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
std::uint16_t MapWidget::GetVcp() const
|
std::uint16_t MapWidget::GetVcp() const
|
||||||
{
|
{
|
||||||
auto radarProductView = p->context_->radar_product_view();
|
auto radarProductView = p->context_->radar_product_view();
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,16 @@ public:
|
||||||
explicit MapWidget(const QMapLibreGL::Settings&);
|
explicit MapWidget(const QMapLibreGL::Settings&);
|
||||||
~MapWidget();
|
~MapWidget();
|
||||||
|
|
||||||
common::Level3ProductCategoryMap GetAvailableLevel3Categories();
|
common::Level3ProductCategoryMap GetAvailableLevel3Categories();
|
||||||
float GetElevation() const;
|
float GetElevation() const;
|
||||||
std::vector<float> GetElevationCuts() const;
|
std::vector<float> GetElevationCuts() const;
|
||||||
std::vector<std::string> GetLevel3Products();
|
std::vector<std::string> GetLevel3Products();
|
||||||
std::string GetMapStyle() const;
|
std::string GetMapStyle() const;
|
||||||
common::RadarProductGroup GetRadarProductGroup() const;
|
common::RadarProductGroup GetRadarProductGroup() const;
|
||||||
std::string GetRadarProductName() const;
|
std::string GetRadarProductName() const;
|
||||||
std::shared_ptr<config::RadarSite> GetRadarSite() const;
|
std::shared_ptr<config::RadarSite> GetRadarSite() const;
|
||||||
std::uint16_t GetVcp() const;
|
std::chrono::system_clock::time_point GetSelectedTime() const;
|
||||||
|
std::uint16_t GetVcp() const;
|
||||||
|
|
||||||
void SelectElevation(float elevation);
|
void SelectElevation(float elevation);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,8 @@ void Level2ProductView::ConnectRadarProductManager()
|
||||||
{
|
{
|
||||||
if (record->radar_product_group() ==
|
if (record->radar_product_group() ==
|
||||||
common::RadarProductGroup::Level2 &&
|
common::RadarProductGroup::Level2 &&
|
||||||
record->time() == selected_time())
|
std::chrono::floor<std::chrono::seconds>(record->time()) ==
|
||||||
|
selected_time())
|
||||||
{
|
{
|
||||||
// If the data associated with the currently selected time is
|
// If the data associated with the currently selected time is
|
||||||
// reloaded, update the view
|
// reloaded, update the view
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,11 @@ RadarProductView::GetCfpMomentData() const
|
||||||
return std::tie(data, dataSize, componentSize);
|
return std::tie(data, dataSize, componentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::chrono::system_clock::time_point RadarProductView::GetSelectedTime() const
|
||||||
|
{
|
||||||
|
return p->selectedTime_;
|
||||||
|
}
|
||||||
|
|
||||||
void RadarProductView::ComputeSweep()
|
void RadarProductView::ComputeSweep()
|
||||||
{
|
{
|
||||||
logger_->debug("ComputeSweep()");
|
logger_->debug("ComputeSweep()");
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ public:
|
||||||
virtual std::tuple<const void*, std::size_t, std::size_t>
|
virtual std::tuple<const void*, std::size_t, std::size_t>
|
||||||
GetMomentData() const = 0;
|
GetMomentData() const = 0;
|
||||||
virtual std::tuple<const void*, std::size_t, std::size_t>
|
virtual std::tuple<const void*, std::size_t, std::size_t>
|
||||||
GetCfpMomentData() const;
|
GetCfpMomentData() const;
|
||||||
|
std::chrono::system_clock::time_point GetSelectedTime() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ConnectRadarProductManager() = 0;
|
virtual void ConnectRadarProductManager() = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue