From 96db63d5f35deb0e1879eb832f418e9ec0e8d2b2 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Mon, 12 Jun 2023 00:10:56 -0500 Subject: [PATCH] If the time in the filename and file data differ, the filename should take precedence This is required for properly indexing the file. If the file data is used, the data is stored under the file data index. Before the file is loaded, the data retrieval is attempted using the filename as the time. --- .../scwx/qt/manager/radar_product_manager.cpp | 18 +++++++++++++++--- .../scwx/qt/types/radar_product_record.cpp | 5 +++++ .../scwx/qt/types/radar_product_record.hpp | 4 +++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp b/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp index dd7c8d35..e9bb8463 100644 --- a/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp @@ -210,7 +210,8 @@ public: static void LoadNexradFile(CreateNexradFileFunction load, std::shared_ptr request, - std::mutex& mutex); + std::mutex& mutex, + std::chrono::system_clock::time_point time = {}); const std::string radarId_; bool initialized_; @@ -801,7 +802,8 @@ void RadarProductManagerImpl::LoadProviderData( return nexradFile; }, request, - loadDataMutex); + loadDataMutex, + time); } void RadarProductManager::LoadLevel2Data( @@ -912,7 +914,8 @@ void RadarProductManager::LoadFile( void RadarProductManagerImpl::LoadNexradFile( CreateNexradFileFunction load, std::shared_ptr request, - std::mutex& mutex) + std::mutex& mutex, + std::chrono::system_clock::time_point time) { scwx::util::async( [=, &mutex]() @@ -929,6 +932,15 @@ void RadarProductManagerImpl::LoadNexradFile( { record = types::RadarProductRecord::Create(nexradFile); + // If the time is already determined, override the time in the file. + // Sometimes, level 2 data has been seen to be a few seconds off + // between filename and file data. Overriding this can help prevent + // issues with locating and storing the correct records. + if (time != std::chrono::system_clock::time_point {}) + { + record->set_time(time); + } + std::shared_ptr manager = RadarProductManager::Instance(record->radar_id()); diff --git a/scwx-qt/source/scwx/qt/types/radar_product_record.cpp b/scwx-qt/source/scwx/qt/types/radar_product_record.cpp index ce402342..6a1953e3 100644 --- a/scwx-qt/source/scwx/qt/types/radar_product_record.cpp +++ b/scwx-qt/source/scwx/qt/types/radar_product_record.cpp @@ -133,6 +133,11 @@ std::chrono::system_clock::time_point RadarProductRecord::time() const return p->time_; } +void RadarProductRecord::set_time(std::chrono::system_clock::time_point time) +{ + p->time_ = time; +} + std::shared_ptr RadarProductRecord::Create(std::shared_ptr nexradFile) { diff --git a/scwx-qt/source/scwx/qt/types/radar_product_record.hpp b/scwx-qt/source/scwx/qt/types/radar_product_record.hpp index ab1775d0..dd27ccbc 100644 --- a/scwx-qt/source/scwx/qt/types/radar_product_record.hpp +++ b/scwx-qt/source/scwx/qt/types/radar_product_record.hpp @@ -22,7 +22,7 @@ public: explicit RadarProductRecord(std::shared_ptr nexradFile); ~RadarProductRecord(); - RadarProductRecord(const RadarProductRecord&) = delete; + RadarProductRecord(const RadarProductRecord&) = delete; RadarProductRecord& operator=(const RadarProductRecord&) = delete; RadarProductRecord(RadarProductRecord&&) noexcept; @@ -38,6 +38,8 @@ public: std::string site_id() const; std::chrono::system_clock::time_point time() const; + void set_time(std::chrono::system_clock::time_point time); + static std::shared_ptr Create(std::shared_ptr nexradFile);