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.
This commit is contained in:
Dan Paulat 2023-06-12 00:10:56 -05:00
parent 4e5a28fcab
commit 96db63d5f3
3 changed files with 23 additions and 4 deletions

View file

@ -210,7 +210,8 @@ public:
static void
LoadNexradFile(CreateNexradFileFunction load,
std::shared_ptr<request::NexradFileRequest> 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::NexradFileRequest> 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<RadarProductManager> manager =
RadarProductManager::Instance(record->radar_id());

View file

@ -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>
RadarProductRecord::Create(std::shared_ptr<wsr88d::NexradFile> nexradFile)
{

View file

@ -22,7 +22,7 @@ public:
explicit RadarProductRecord(std::shared_ptr<wsr88d::NexradFile> 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<RadarProductRecord>
Create(std::shared_ptr<wsr88d::NexradFile> nexradFile);