partiallaly complete merging of radar data

This commit is contained in:
AdenKoperczak 2025-04-06 16:09:48 -04:00
parent ac6d6093ec
commit 8b7a3e9781
No known key found for this signature in database
GPG key ID: 9843017036F62EE7
4 changed files with 157 additions and 2 deletions

View file

@ -1525,6 +1525,16 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
//TODO decide when to use chunked vs archived data. //TODO decide when to use chunked vs archived data.
if (true) if (true)
{ {
auto currentFile = std::dynamic_pointer_cast<wsr88d::Ar2vFile>(
p->level2ChunksProviderManager_->provider_->LoadLatestObject());
auto lastFile = std::dynamic_pointer_cast<wsr88d::Ar2vFile>(
p->level2ChunksProviderManager_->provider_->LoadSecondLatestObject());
auto radarFile =
std::make_shared<wsr88d::Ar2vFile>(currentFile, lastFile);
std::tie(radarData, elevationCut, elevationCuts) =
radarFile->GetElevationScan(dataBlockType, elevation, time);
/*
auto currentFile = std::dynamic_pointer_cast<wsr88d::Ar2vFile>( auto currentFile = std::dynamic_pointer_cast<wsr88d::Ar2vFile>(
p->level2ChunksProviderManager_->provider_->LoadLatestObject()); p->level2ChunksProviderManager_->provider_->LoadLatestObject());
std::shared_ptr<wsr88d::rda::ElevationScan> currentRadarData = nullptr; std::shared_ptr<wsr88d::rda::ElevationScan> currentRadarData = nullptr;
@ -1587,6 +1597,7 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
elevationCuts = std::move(lastElevationCuts); elevationCuts = std::move(lastElevationCuts);
foundTime = collectionTime; foundTime = collectionTime;
} }
*/
} }
else else
{ {

View file

@ -32,6 +32,8 @@ public:
Ar2vFile(Ar2vFile&&) noexcept; Ar2vFile(Ar2vFile&&) noexcept;
Ar2vFile& operator=(Ar2vFile&&) noexcept; Ar2vFile& operator=(Ar2vFile&&) noexcept;
Ar2vFile(std::shared_ptr<Ar2vFile> current, std::shared_ptr<Ar2vFile> last);
std::uint32_t julian_date() const; std::uint32_t julian_date() const;
std::uint32_t milliseconds() const; std::uint32_t milliseconds() const;
std::string icao() const; std::string icao() const;

View file

@ -676,12 +676,10 @@ std::pair<size_t, size_t> AwsLevel2ChunksDataProvider::Refresh()
} }
if (p->lastScan_.valid_) if (p->lastScan_.valid_)
{ {
/*
if (p->LoadScan(p->lastScan_)) if (p->LoadScan(p->lastScan_))
{ {
newObjects += 1; newObjects += 1;
} }
*/
totalObjects += 1; totalObjects += 1;
} }

View file

@ -5,9 +5,11 @@
#include <scwx/util/logger.hpp> #include <scwx/util/logger.hpp>
#include <scwx/util/rangebuf.hpp> #include <scwx/util/rangebuf.hpp>
#include <scwx/util/time.hpp> #include <scwx/util/time.hpp>
#include <scwx/common/geographic.hpp>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <set>
#if defined(_MSC_VER) #if defined(_MSC_VER)
# pragma warning(push) # pragma warning(push)
@ -539,5 +541,147 @@ bool Ar2vFile::IndexFile()
return true; return true;
} }
// TODO not good
bool IsRadarDataIncomplete(
const std::shared_ptr<const rda::ElevationScan>& radarData)
{
// Assume the data is incomplete when the delta between the first and last
// angles is greater than 2.5 degrees.
constexpr units::degrees<float> kIncompleteDataAngleThreshold_ {2.5};
const units::degrees<float> firstAngle =
radarData->cbegin()->second->azimuth_angle();
const units::degrees<float> lastAngle =
radarData->crbegin()->second->azimuth_angle();
const units::degrees<float> angleDelta =
common::GetAngleDelta(firstAngle, lastAngle);
return angleDelta > kIncompleteDataAngleThreshold_;
}
Ar2vFile::Ar2vFile(std::shared_ptr<Ar2vFile> current,
std::shared_ptr<Ar2vFile> last) :
Ar2vFile()
{
/*p->vcpData_ = std::make_shared<rda::VolumeCoveragePatternData>(
*current->vcp_data());*/
p->vcpData_ = nullptr; // TODO
/*
use index_ to go through each block type, and elevation.
get the latest time.
if the latest time is not complete, get the previous time (possibly in
last), and merge
*/
if (current == nullptr)
{
return;
}
for (const auto& type : current->p->index_)
{
for (const auto& elevation : type.second)
{
const auto& mostRecent = elevation.second.crbegin();
if (mostRecent == elevation.second.crend())
{
continue;
}
if (IsRadarDataIncomplete(mostRecent->second))
{
std::shared_ptr<rda::ElevationScan> secondMostRecent =
nullptr;
auto maybe = elevation.second.rbegin();
++maybe;
if (maybe == elevation.second.rend())
{
if (last == nullptr)
{
// Nothing to merge with
p->index_[type.first][elevation.first][mostRecent->first] =
mostRecent->second;
continue;
}
auto elevationScan =
std::get<std::shared_ptr<rda::ElevationScan>>(
last->GetElevationScan(type.first, elevation.first, {}));
if (elevationScan == nullptr)
{
// Nothing to merge with
p->index_[type.first][elevation.first][mostRecent->first] =
mostRecent->second;
continue;
}
secondMostRecent = elevationScan;
}
else
{
secondMostRecent = maybe->second;
}
auto newScan = std::make_shared<rda::ElevationScan>();
// Convert old into new coords
logger_->error(
"old {}, new {}",
secondMostRecent->cbegin()->second->azimuth_angle().value(),
mostRecent->second->cbegin()->second->azimuth_angle().value());
// TODO Ordering these correctly
for (const auto& radial : *secondMostRecent)
{
(*newScan)[radial.first] = radial.second;
}
for (const auto& radial : *(mostRecent->second))
{
(*newScan)[radial.first] = radial.second;
}
p->index_[type.first][elevation.first][mostRecent->first] =
newScan;
}
else
{
p->index_[type.first][elevation.first][mostRecent->first] =
mostRecent->second;
}
}
}
// Go though last, adding other elevations TODO
if (last != nullptr)
{
for (const auto& type : last->p->index_)
{
float highestCurrentElevation = -90;
const auto& maybe1 = p->index_.find(type.first);
if (maybe1 != p->index_.cend())
{
const auto& maybe2 = maybe1->second.crbegin();
if (maybe2 != maybe1->second.crend()) {
highestCurrentElevation = maybe2->first + 0.01;
}
}
for (const auto& elevation : type.second)
{
if (elevation.first > highestCurrentElevation)
{
const auto& mostRecent = elevation.second.crbegin();
if (mostRecent == elevation.second.crend())
{
continue;
}
p->index_[type.first][elevation.first][mostRecent->first] =
mostRecent->second;
}
}
}
}
}
} // namespace wsr88d } // namespace wsr88d
} // namespace scwx } // namespace scwx