Merge pull request #344 from dpaulat/hotfix/live-level2-data-not-latest

Ensure live level 2 data displays correct scans
This commit is contained in:
Dan Paulat 2025-01-20 23:47:39 -06:00 committed by GitHub
commit 42314a64b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 8 deletions

View file

@ -1508,9 +1508,9 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
if (recordRadarData != nullptr)
{
auto& radarData0 = (*recordRadarData)[0];
auto collectionTime =
auto collectionTime = std::chrono::floor<std::chrono::seconds>(
scwx::util::TimePoint(radarData0->modified_julian_date(),
radarData0->collection_time());
radarData0->collection_time()));
// Find the newest radar data, not newer than the selected time
if (radarData == nullptr ||

View file

@ -1800,9 +1800,18 @@ void MapWidgetImpl::RadarProductManagerConnect()
context_->radar_product_group() == group &&
(group == common::RadarProductGroup::Level2 ||
context_->radar_product() == product))
{
if (group == common::RadarProductGroup::Level2)
{
// Level 2 products may have multiple time points,
// ensure the latest is selected
widget_->SelectRadarProduct(group, product);
}
else
{
widget_->SelectRadarProduct(record);
}
}
});
}

View file

@ -23,6 +23,7 @@
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <fmt/chrono.h>
#if defined(__GNUC__)
# pragma GCC diagnostic pop
@ -187,10 +188,12 @@ Ar2vFile::GetElevationScan(rda::DataBlockType dataBlockType,
for (auto& scan : elevationScans)
{
auto& scanTime = scan.first;
auto scanTime = std::chrono::floor<std::chrono::seconds>(scan.first);
if (elevationScan == nullptr ||
(scanTime <= time && scanTime > foundTime))
((scanTime <= time ||
time == std::chrono::system_clock::time_point {}) &&
scanTime > foundTime))
{
elevationScan = scan.second;
foundTime = scanTime;
@ -253,10 +256,13 @@ bool Ar2vFile::LoadData(std::istream& is)
if (dataValid)
{
auto timePoint = util::TimePoint(p->julianDate_, p->milliseconds_);
logger_->debug("Filename: {}", p->tapeFilename_);
logger_->debug("Extension: {}", p->extensionNumber_);
logger_->debug("Date: {}", p->julianDate_);
logger_->debug("Time: {}", p->milliseconds_);
logger_->debug("Date: {} ({:%Y-%m-%d})", p->julianDate_, timePoint);
logger_->debug(
"Time: {} ({:%H:%M:%S})", p->milliseconds_, timePoint);
logger_->debug("ICAO: {}", p->icao_);
size_t decompressedRecords = p->DecompressLDMRecords(is);