mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:40:05 +00:00
Initial clang format/tidy fixes for level_2_chunks
This commit is contained in:
parent
0bda6296c0
commit
0f95439b61
9 changed files with 108 additions and 103 deletions
|
|
@ -272,7 +272,8 @@ public:
|
||||||
common::Level3ProductCategoryMap availableCategoryMap_ {};
|
common::Level3ProductCategoryMap availableCategoryMap_ {};
|
||||||
std::shared_mutex availableCategoryMutex_ {};
|
std::shared_mutex availableCategoryMutex_ {};
|
||||||
|
|
||||||
float incomingLevel2Elevation_ {-90};
|
float incomingLevel2Elevation_ {
|
||||||
|
provider::AwsLevel2ChunksDataProvider::INVALID_ELEVATION};
|
||||||
|
|
||||||
std::unordered_map<boost::uuids::uuid,
|
std::unordered_map<boost::uuids::uuid,
|
||||||
std::shared_ptr<ProviderManager>,
|
std::shared_ptr<ProviderManager>,
|
||||||
|
|
@ -654,7 +655,7 @@ void RadarProductManager::EnableRefresh(common::RadarProductGroup group,
|
||||||
{
|
{
|
||||||
if (group == common::RadarProductGroup::Level2)
|
if (group == common::RadarProductGroup::Level2)
|
||||||
{
|
{
|
||||||
//p->EnableRefresh(uuid, p->level2ProviderManager_, enabled);
|
// p->EnableRefresh(uuid, p->level2ProviderManager_, enabled);
|
||||||
p->EnableRefresh(uuid, p->level2ChunksProviderManager_, enabled);
|
p->EnableRefresh(uuid, p->level2ChunksProviderManager_, enabled);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1431,7 +1432,7 @@ std::shared_ptr<types::RadarProductRecord>
|
||||||
RadarProductManagerImpl::StoreRadarProductRecord(
|
RadarProductManagerImpl::StoreRadarProductRecord(
|
||||||
std::shared_ptr<types::RadarProductRecord> record)
|
std::shared_ptr<types::RadarProductRecord> record)
|
||||||
{
|
{
|
||||||
//logger_->debug("StoreRadarProductRecord()");
|
// logger_->debug("StoreRadarProductRecord()");
|
||||||
|
|
||||||
std::shared_ptr<types::RadarProductRecord> storedRecord = nullptr;
|
std::shared_ptr<types::RadarProductRecord> storedRecord = nullptr;
|
||||||
|
|
||||||
|
|
@ -1571,9 +1572,10 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
|
||||||
|
|
||||||
if (record != nullptr)
|
if (record != nullptr)
|
||||||
{
|
{
|
||||||
std::shared_ptr<wsr88d::rda::ElevationScan> recordRadarData = nullptr;
|
std::shared_ptr<wsr88d::rda::ElevationScan> recordRadarData =
|
||||||
float recordElevationCut = 0.0f;
|
nullptr;
|
||||||
std::vector<float> recordElevationCuts;
|
float recordElevationCut = 0.0f;
|
||||||
|
std::vector<float> recordElevationCuts;
|
||||||
|
|
||||||
std::tie(recordRadarData, recordElevationCut, recordElevationCuts) =
|
std::tie(recordRadarData, recordElevationCut, recordElevationCuts) =
|
||||||
record->level2_file()->GetElevationScan(
|
record->level2_file()->GetElevationScan(
|
||||||
|
|
@ -1595,10 +1597,14 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
|
||||||
elevationCuts = std::move(recordElevationCuts);
|
elevationCuts = std::move(recordElevationCuts);
|
||||||
foundTime = collectionTime;
|
foundTime = collectionTime;
|
||||||
|
|
||||||
if (p->incomingLevel2Elevation_ != -90)
|
if (p->incomingLevel2Elevation_ !=
|
||||||
|
provider::AwsLevel2ChunksDataProvider::INVALID_ELEVATION)
|
||||||
{
|
{
|
||||||
p->incomingLevel2Elevation_ = -90;
|
p->incomingLevel2Elevation_ = provider::
|
||||||
Q_EMIT IncomingLevel2ElevationChanged(-90);
|
AwsLevel2ChunksDataProvider::INVALID_ELEVATION;
|
||||||
|
Q_EMIT IncomingLevel2ElevationChanged(
|
||||||
|
provider::AwsLevel2ChunksDataProvider::
|
||||||
|
INVALID_ELEVATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -661,7 +661,6 @@ float MapWidget::GetIncomingLevel2Elevation() const
|
||||||
return p->radarProductManager_->incoming_level_2_elevation();
|
return p->radarProductManager_->incoming_level_2_elevation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
common::Level2Product
|
common::Level2Product
|
||||||
MapWidgetImpl::GetLevel2ProductOrDefault(const std::string& productName) const
|
MapWidgetImpl::GetLevel2ProductOrDefault(const std::string& productName) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ void RadarProductLayer::UpdateSweep()
|
||||||
std::try_to_lock);
|
std::try_to_lock);
|
||||||
if (!sweepLock.owns_lock())
|
if (!sweepLock.owns_lock())
|
||||||
{
|
{
|
||||||
//logger_->debug("Sweep locked, deferring update");
|
// logger_->debug("Sweep locked, deferring update");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger_->debug("UpdateSweep()");
|
logger_->debug("UpdateSweep()");
|
||||||
|
|
|
||||||
|
|
@ -30,15 +30,10 @@ public:
|
||||||
explicit Level2SettingsWidgetImpl(Level2SettingsWidget* self) :
|
explicit Level2SettingsWidgetImpl(Level2SettingsWidget* self) :
|
||||||
self_ {self},
|
self_ {self},
|
||||||
layout_ {new QVBoxLayout(self)},
|
layout_ {new QVBoxLayout(self)},
|
||||||
elevationGroupBox_ {},
|
|
||||||
incomingElevationLabel_ {},
|
|
||||||
elevationButtons_ {},
|
elevationButtons_ {},
|
||||||
elevationCuts_ {},
|
elevationCuts_ {}
|
||||||
elevationButtonsChanged_ {false},
|
|
||||||
resizeElevationButtons_ {false},
|
|
||||||
settingsGroupBox_ {},
|
|
||||||
declutterCheckBox_ {}
|
|
||||||
{
|
{
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-owning-memory) Qt takes care of this
|
||||||
layout_->setContentsMargins(0, 0, 0, 0);
|
layout_->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
incomingElevationLabel_ = new QLabel("", self);
|
incomingElevationLabel_ = new QLabel("", self);
|
||||||
|
|
@ -48,7 +43,6 @@ public:
|
||||||
new ui::FlowLayout(elevationGroupBox_);
|
new ui::FlowLayout(elevationGroupBox_);
|
||||||
layout_->addWidget(elevationGroupBox_);
|
layout_->addWidget(elevationGroupBox_);
|
||||||
|
|
||||||
|
|
||||||
settingsGroupBox_ = new QGroupBox(tr("Settings"), self);
|
settingsGroupBox_ = new QGroupBox(tr("Settings"), self);
|
||||||
QLayout* settingsLayout = new QVBoxLayout(settingsGroupBox_);
|
QLayout* settingsLayout = new QVBoxLayout(settingsGroupBox_);
|
||||||
layout_->addWidget(settingsGroupBox_);
|
layout_->addWidget(settingsGroupBox_);
|
||||||
|
|
@ -57,6 +51,7 @@ public:
|
||||||
settingsLayout->addWidget(declutterCheckBox_);
|
settingsLayout->addWidget(declutterCheckBox_);
|
||||||
|
|
||||||
settingsGroupBox_->setVisible(false);
|
settingsGroupBox_->setVisible(false);
|
||||||
|
// NOLINTEND(cppcoreguidelines-owning-memory) Qt takes care of this
|
||||||
|
|
||||||
QObject::connect(hotkeyManager_.get(),
|
QObject::connect(hotkeyManager_.get(),
|
||||||
&manager::HotkeyManager::HotkeyPressed,
|
&manager::HotkeyManager::HotkeyPressed,
|
||||||
|
|
@ -72,15 +67,15 @@ public:
|
||||||
Level2SettingsWidget* self_;
|
Level2SettingsWidget* self_;
|
||||||
QLayout* layout_;
|
QLayout* layout_;
|
||||||
|
|
||||||
QGroupBox* elevationGroupBox_;
|
QGroupBox* elevationGroupBox_ {};
|
||||||
QLabel* incomingElevationLabel_;
|
QLabel* incomingElevationLabel_ {};
|
||||||
std::list<QToolButton*> elevationButtons_;
|
std::list<QToolButton*> elevationButtons_;
|
||||||
std::vector<float> elevationCuts_;
|
std::vector<float> elevationCuts_;
|
||||||
bool elevationButtonsChanged_;
|
bool elevationButtonsChanged_ {};
|
||||||
bool resizeElevationButtons_;
|
bool resizeElevationButtons_ {};
|
||||||
|
|
||||||
QGroupBox* settingsGroupBox_;
|
QGroupBox* settingsGroupBox_ {};
|
||||||
QCheckBox* declutterCheckBox_;
|
QCheckBox* declutterCheckBox_ {};
|
||||||
|
|
||||||
float currentElevation_ {};
|
float currentElevation_ {};
|
||||||
QToolButton* currentElevationButton_ {nullptr};
|
QToolButton* currentElevationButton_ {nullptr};
|
||||||
|
|
@ -249,8 +244,9 @@ void Level2SettingsWidget::UpdateElevationSelection(float elevation)
|
||||||
|
|
||||||
void Level2SettingsWidget::UpdateIncomingElevation(float incomingElevation)
|
void Level2SettingsWidget::UpdateIncomingElevation(float incomingElevation)
|
||||||
{
|
{
|
||||||
p->incomingElevationLabel_->setText("Incoming Elevation: " +
|
p->incomingElevationLabel_->setText(
|
||||||
QString::number(incomingElevation, 'f', 1) + common::Characters::DEGREE);
|
"Incoming Elevation: " + QString::number(incomingElevation, 'f', 1) +
|
||||||
|
common::Characters::DEGREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level2SettingsWidget::UpdateSettings(map::MapWidget* activeMap)
|
void Level2SettingsWidget::UpdateSettings(map::MapWidget* activeMap)
|
||||||
|
|
@ -258,8 +254,8 @@ void Level2SettingsWidget::UpdateSettings(map::MapWidget* activeMap)
|
||||||
std::optional<float> currentElevationOption = activeMap->GetElevation();
|
std::optional<float> currentElevationOption = activeMap->GetElevation();
|
||||||
const float currentElevation =
|
const float currentElevation =
|
||||||
currentElevationOption.has_value() ? *currentElevationOption : 0.0f;
|
currentElevationOption.has_value() ? *currentElevationOption : 0.0f;
|
||||||
std::vector<float> elevationCuts = activeMap->GetElevationCuts();
|
std::vector<float> elevationCuts = activeMap->GetElevationCuts();
|
||||||
float incomingElevation = activeMap->GetIncomingLevel2Elevation();
|
const float incomingElevation = activeMap->GetIncomingLevel2Elevation();
|
||||||
|
|
||||||
if (p->elevationCuts_ != elevationCuts)
|
if (p->elevationCuts_ != elevationCuts)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace scwx::provider
|
||||||
class AwsLevel2ChunksDataProvider : public NexradDataProvider
|
class AwsLevel2ChunksDataProvider : public NexradDataProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
constexpr static const float INVALID_ELEVATION = -90.0;
|
||||||
explicit AwsLevel2ChunksDataProvider(const std::string& radarSite);
|
explicit AwsLevel2ChunksDataProvider(const std::string& radarSite);
|
||||||
explicit AwsLevel2ChunksDataProvider(const std::string& radarSite,
|
explicit AwsLevel2ChunksDataProvider(const std::string& radarSite,
|
||||||
const std::string& bucketName,
|
const std::string& bucketName,
|
||||||
|
|
|
||||||
|
|
@ -103,17 +103,14 @@ public:
|
||||||
*
|
*
|
||||||
* @return NEXRAD data
|
* @return NEXRAD data
|
||||||
*/
|
*/
|
||||||
virtual std::shared_ptr<wsr88d::NexradFile>
|
virtual std::shared_ptr<wsr88d::NexradFile> LoadLatestObject() = 0;
|
||||||
LoadLatestObject() = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the second NEXRAD file object
|
* Loads the second NEXRAD file object
|
||||||
*
|
*
|
||||||
* @return NEXRAD data
|
* @return NEXRAD data
|
||||||
*/
|
*/
|
||||||
virtual std::shared_ptr<wsr88d::NexradFile>
|
virtual std::shared_ptr<wsr88d::NexradFile> LoadSecondLatestObject() = 0;
|
||||||
LoadSecondLatestObject() = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists NEXRAD objects for the current date, and adds them to the cache. If
|
* Lists NEXRAD objects for the current date, and adds them to the cache. If
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ public:
|
||||||
currentScan_ {"", false},
|
currentScan_ {"", false},
|
||||||
scansMutex_ {},
|
scansMutex_ {},
|
||||||
lastTimeListed_ {},
|
lastTimeListed_ {},
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) about average
|
||||||
updatePeriod_ {7},
|
updatePeriod_ {7},
|
||||||
self_ {self}
|
self_ {self}
|
||||||
{
|
{
|
||||||
|
|
@ -80,10 +81,11 @@ public:
|
||||||
util::SetEnvironment("AWS_EC2_METADATA_DISABLED", "true");
|
util::SetEnvironment("AWS_EC2_METADATA_DISABLED", "true");
|
||||||
|
|
||||||
// Use anonymous credentials
|
// Use anonymous credentials
|
||||||
Aws::Auth::AWSCredentials credentials {};
|
const Aws::Auth::AWSCredentials credentials {};
|
||||||
|
|
||||||
Aws::Client::ClientConfiguration config;
|
Aws::Client::ClientConfiguration config;
|
||||||
config.region = region_;
|
config.region = region_;
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) arbitrary
|
||||||
config.connectTimeoutMs = 10000;
|
config.connectTimeoutMs = 10000;
|
||||||
|
|
||||||
client_ = std::make_shared<Aws::S3::S3Client>(
|
client_ = std::make_shared<Aws::S3::S3Client>(
|
||||||
|
|
@ -104,10 +106,9 @@ public:
|
||||||
const std::chrono::system_clock::time_point& time,
|
const std::chrono::system_clock::time_point& time,
|
||||||
int last);
|
int last);
|
||||||
|
|
||||||
bool LoadScan(Impl::ScanRecord& scanRecord);
|
bool LoadScan(Impl::ScanRecord& scanRecord);
|
||||||
std::tuple<bool, size_t, size_t> ListObjects();
|
std::tuple<bool, size_t, size_t> ListObjects();
|
||||||
|
|
||||||
|
|
||||||
std::string radarSite_;
|
std::string radarSite_;
|
||||||
std::string bucketName_;
|
std::string bucketName_;
|
||||||
std::string region_;
|
std::string region_;
|
||||||
|
|
@ -190,6 +191,7 @@ size_t AwsLevel2ChunksDataProvider::cache_size() const
|
||||||
std::chrono::system_clock::time_point
|
std::chrono::system_clock::time_point
|
||||||
AwsLevel2ChunksDataProvider::last_modified() const
|
AwsLevel2ChunksDataProvider::last_modified() const
|
||||||
{
|
{
|
||||||
|
const std::shared_lock lock(p->scansMutex_);
|
||||||
if (p->currentScan_.valid_ && p->currentScan_.lastModified_ !=
|
if (p->currentScan_.valid_ && p->currentScan_.lastModified_ !=
|
||||||
std::chrono::system_clock::time_point {})
|
std::chrono::system_clock::time_point {})
|
||||||
{
|
{
|
||||||
|
|
@ -207,7 +209,7 @@ AwsLevel2ChunksDataProvider::last_modified() const
|
||||||
}
|
}
|
||||||
std::chrono::seconds AwsLevel2ChunksDataProvider::update_period() const
|
std::chrono::seconds AwsLevel2ChunksDataProvider::update_period() const
|
||||||
{
|
{
|
||||||
std::shared_lock lock(p->scansMutex_);
|
const std::shared_lock lock(p->scansMutex_);
|
||||||
// Add an extra second of delay
|
// Add an extra second of delay
|
||||||
static const auto extra = std::chrono::seconds(2);
|
static const auto extra = std::chrono::seconds(2);
|
||||||
// get update period from time between chunks
|
// get update period from time between chunks
|
||||||
|
|
@ -233,7 +235,7 @@ AwsLevel2ChunksDataProvider::FindKey(std::chrono::system_clock::time_point time)
|
||||||
{
|
{
|
||||||
logger_->debug("FindKey: {}", util::TimeString(time));
|
logger_->debug("FindKey: {}", util::TimeString(time));
|
||||||
|
|
||||||
std::shared_lock lock(p->scansMutex_);
|
const std::shared_lock lock(p->scansMutex_);
|
||||||
if (p->currentScan_.valid_ && time >= p->currentScan_.time_)
|
if (p->currentScan_.valid_ && time >= p->currentScan_.time_)
|
||||||
{
|
{
|
||||||
return p->currentScan_.prefix_;
|
return p->currentScan_.prefix_;
|
||||||
|
|
@ -248,7 +250,7 @@ AwsLevel2ChunksDataProvider::FindKey(std::chrono::system_clock::time_point time)
|
||||||
|
|
||||||
std::string AwsLevel2ChunksDataProvider::FindLatestKey()
|
std::string AwsLevel2ChunksDataProvider::FindLatestKey()
|
||||||
{
|
{
|
||||||
std::shared_lock lock(p->scansMutex_);
|
const std::shared_lock lock(p->scansMutex_);
|
||||||
if (!p->currentScan_.valid_)
|
if (!p->currentScan_.valid_)
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
|
|
@ -260,7 +262,7 @@ std::string AwsLevel2ChunksDataProvider::FindLatestKey()
|
||||||
std::chrono::system_clock::time_point
|
std::chrono::system_clock::time_point
|
||||||
AwsLevel2ChunksDataProvider::FindLatestTime()
|
AwsLevel2ChunksDataProvider::FindLatestTime()
|
||||||
{
|
{
|
||||||
std::shared_lock lock(p->scansMutex_);
|
const std::shared_lock lock(p->scansMutex_);
|
||||||
if (!p->currentScan_.valid_)
|
if (!p->currentScan_.valid_)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -325,10 +327,11 @@ std::string AwsLevel2ChunksDataProvider::Impl::GetScanKey(
|
||||||
std::tuple<bool, size_t, size_t>
|
std::tuple<bool, size_t, size_t>
|
||||||
AwsLevel2ChunksDataProvider::Impl::ListObjects()
|
AwsLevel2ChunksDataProvider::Impl::ListObjects()
|
||||||
{
|
{
|
||||||
size_t newObjects = 0;
|
size_t newObjects = 0;
|
||||||
size_t totalObjects = 0;
|
const size_t totalObjects = 0;
|
||||||
|
|
||||||
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
const std::chrono::system_clock::time_point now =
|
||||||
|
std::chrono::system_clock::now();
|
||||||
|
|
||||||
if (currentScan_.valid_ && !currentScan_.hasAllFiles_ &&
|
if (currentScan_.valid_ && !currentScan_.hasAllFiles_ &&
|
||||||
lastTimeListed_ + std::chrono::minutes(2) > now)
|
lastTimeListed_ + std::chrono::minutes(2) > now)
|
||||||
|
|
@ -366,8 +369,8 @@ AwsLevel2ChunksDataProvider::Impl::ListObjects()
|
||||||
|
|
||||||
int lastScanNumber = -1;
|
int lastScanNumber = -1;
|
||||||
// Start with last scan
|
// Start with last scan
|
||||||
int previousScanNumber = scanNumberMap.crbegin()->first;
|
int previousScanNumber = scanNumberMap.crbegin()->first;
|
||||||
const int firstScanNumber = scanNumberMap.cbegin()->first;
|
const int firstScanNumber = scanNumberMap.cbegin()->first;
|
||||||
|
|
||||||
// Look for a gap in scan numbers. This indicates that is the latest
|
// Look for a gap in scan numbers. This indicates that is the latest
|
||||||
// scan.
|
// scan.
|
||||||
|
|
@ -383,7 +386,7 @@ AwsLevel2ChunksDataProvider::Impl::ListObjects()
|
||||||
{
|
{
|
||||||
// Have already checked scan with highest number, so skip first
|
// Have already checked scan with highest number, so skip first
|
||||||
previousScanNumber = firstScanNumber;
|
previousScanNumber = firstScanNumber;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (const auto& scan : scanNumberMap)
|
for (const auto& scan : scanNumberMap)
|
||||||
{
|
{
|
||||||
if (first)
|
if (first)
|
||||||
|
|
@ -415,15 +418,16 @@ AwsLevel2ChunksDataProvider::Impl::ListObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string& lastScanPrefix = scanNumberMap.at(lastScanNumber);
|
const std::string& lastScanPrefix = scanNumberMap.at(lastScanNumber);
|
||||||
int secondLastScanNumber =
|
const int secondLastScanNumber =
|
||||||
|
// 999 is the last file possible
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
||||||
lastScanNumber == 1 ? 999 : lastScanNumber - 1;
|
lastScanNumber == 1 ? 999 : lastScanNumber - 1;
|
||||||
|
|
||||||
const auto& secondLastScanPrefix =
|
const auto& secondLastScanPrefix =
|
||||||
scanNumberMap.find(secondLastScanNumber);
|
scanNumberMap.find(secondLastScanNumber);
|
||||||
|
|
||||||
if (!currentScan_.valid_ ||
|
if (!currentScan_.valid_ || currentScan_.prefix_ != lastScanPrefix)
|
||||||
currentScan_.prefix_ != lastScanPrefix)
|
|
||||||
{
|
{
|
||||||
if (currentScan_.valid_ &&
|
if (currentScan_.valid_ &&
|
||||||
(secondLastScanPrefix == scanNumberMap.cend() ||
|
(secondLastScanPrefix == scanNumberMap.cend() ||
|
||||||
|
|
@ -445,9 +449,9 @@ AwsLevel2ChunksDataProvider::Impl::ListObjects()
|
||||||
newObjects += 1;
|
newObjects += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentScan_.valid_ = true;
|
currentScan_.valid_ = true;
|
||||||
currentScan_.prefix_ = lastScanPrefix;
|
currentScan_.prefix_ = lastScanPrefix;
|
||||||
currentScan_.nexradFile_ = nullptr;
|
currentScan_.nexradFile_ = nullptr;
|
||||||
currentScan_.time_ = GetScanTime(lastScanPrefix);
|
currentScan_.time_ = GetScanTime(lastScanPrefix);
|
||||||
currentScan_.lastModified_ = {};
|
currentScan_.lastModified_ = {};
|
||||||
currentScan_.secondLastModified_ = {};
|
currentScan_.secondLastModified_ = {};
|
||||||
|
|
@ -502,7 +506,7 @@ bool AwsLevel2ChunksDataProvider::Impl::LoadScan(Impl::ScanRecord& scanRecord)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasNew = false;
|
bool hasNew = false;
|
||||||
auto& chunks = listOutcome.GetResult().GetContents();
|
auto& chunks = listOutcome.GetResult().GetContents();
|
||||||
logger_->debug("Found {} new chunks.", chunks.size());
|
logger_->debug("Found {} new chunks.", chunks.size());
|
||||||
for (const auto& chunk : chunks)
|
for (const auto& chunk : chunks)
|
||||||
|
|
@ -511,27 +515,26 @@ bool AwsLevel2ChunksDataProvider::Impl::LoadScan(Impl::ScanRecord& scanRecord)
|
||||||
|
|
||||||
// KIND/585/20250324-134727-001-S
|
// KIND/585/20250324-134727-001-S
|
||||||
// KIND/5/20250324-134727-001-S
|
// KIND/5/20250324-134727-001-S
|
||||||
static const size_t firstSlash = std::string("KIND/").size();
|
static const size_t firstSlash = std::string("KIND/").size();
|
||||||
const size_t secondSlash = key.find('/', firstSlash);
|
const size_t secondSlash = key.find('/', firstSlash);
|
||||||
static const size_t startNumberPosOffset =
|
static const size_t startNumberPosOffset =
|
||||||
std::string("/20250324-134727-").size();
|
std::string("/20250324-134727-").size();
|
||||||
const size_t startNumberPos =
|
const size_t startNumberPos = secondSlash + startNumberPosOffset;
|
||||||
secondSlash + startNumberPosOffset;
|
const std::string& keyNumberStr = key.substr(startNumberPos, 3);
|
||||||
const std::string& keyNumberStr = key.substr(startNumberPos, 3);
|
const int keyNumber = std::stoi(keyNumberStr);
|
||||||
const int keyNumber = std::stoi(keyNumberStr);
|
// As far as order goes, only the first one matters. This may cause some
|
||||||
if (keyNumber != scanRecord.nextFile_)
|
// issues if keys come in out of order, but usually they just skip chunks
|
||||||
|
if (scanRecord.nextFile_ == 1 && keyNumber != scanRecord.nextFile_)
|
||||||
{
|
{
|
||||||
logger_->warn("Chunk found that was not in order {} {} {}",
|
logger_->warn("Chunk found that was not in order {} {}",
|
||||||
key,
|
scanRecord.lastKey_,
|
||||||
scanRecord.nextFile_,
|
key);
|
||||||
keyNumber);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we want the ending char
|
// Now we want the ending char
|
||||||
// KIND/585/20250324-134727-001-S
|
// KIND/585/20250324-134727-001-S
|
||||||
static const size_t charPos =
|
static const size_t charPos = std::string("/20250324-134727-001-").size();
|
||||||
std::string("/20250324-134727-001-").size();
|
|
||||||
if (secondSlash + charPos >= key.size())
|
if (secondSlash + charPos >= key.size())
|
||||||
{
|
{
|
||||||
logger_->warn("Chunk key was not long enough");
|
logger_->warn("Chunk key was not long enough");
|
||||||
|
|
@ -591,15 +594,16 @@ bool AwsLevel2ChunksDataProvider::Impl::LoadScan(Impl::ScanRecord& scanRecord)
|
||||||
}
|
}
|
||||||
hasNew = true;
|
hasNew = true;
|
||||||
|
|
||||||
std::chrono::seconds lastModifiedSeconds {
|
const std::chrono::seconds lastModifiedSeconds {
|
||||||
outcome.GetResult().GetLastModified().Seconds()};
|
outcome.GetResult().GetLastModified().Seconds()};
|
||||||
std::chrono::system_clock::time_point lastModified {lastModifiedSeconds};
|
const std::chrono::system_clock::time_point lastModified {
|
||||||
|
lastModifiedSeconds};
|
||||||
|
|
||||||
scanRecord.secondLastModified_ = scanRecord.lastModified_;
|
scanRecord.secondLastModified_ = scanRecord.lastModified_;
|
||||||
scanRecord.lastModified_ = lastModified;
|
scanRecord.lastModified_ = lastModified;
|
||||||
|
|
||||||
scanRecord.nextFile_ += 1;
|
scanRecord.nextFile_ = keyNumber + 1;
|
||||||
scanRecord.lastKey_ = key;
|
scanRecord.lastKey_ = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanRecord.nexradFile_ == nullptr)
|
if (scanRecord.nexradFile_ == nullptr)
|
||||||
|
|
@ -618,7 +622,7 @@ std::shared_ptr<wsr88d::NexradFile>
|
||||||
AwsLevel2ChunksDataProvider::LoadObjectByTime(
|
AwsLevel2ChunksDataProvider::LoadObjectByTime(
|
||||||
std::chrono::system_clock::time_point time)
|
std::chrono::system_clock::time_point time)
|
||||||
{
|
{
|
||||||
std::unique_lock lock(p->scansMutex_);
|
const std::unique_lock lock(p->scansMutex_);
|
||||||
static const std::chrono::system_clock::time_point epoch {};
|
static const std::chrono::system_clock::time_point epoch {};
|
||||||
|
|
||||||
if (p->currentScan_.valid_ &&
|
if (p->currentScan_.valid_ &&
|
||||||
|
|
@ -640,10 +644,10 @@ AwsLevel2ChunksDataProvider::LoadObjectByTime(
|
||||||
std::shared_ptr<wsr88d::NexradFile>
|
std::shared_ptr<wsr88d::NexradFile>
|
||||||
AwsLevel2ChunksDataProvider::LoadLatestObject()
|
AwsLevel2ChunksDataProvider::LoadLatestObject()
|
||||||
{
|
{
|
||||||
std::unique_lock lock(p->scansMutex_);
|
const std::unique_lock lock(p->scansMutex_);
|
||||||
return std::make_shared<wsr88d::Ar2vFile>(p->currentScan_.nexradFile_,
|
return std::make_shared<wsr88d::Ar2vFile>(p->currentScan_.nexradFile_,
|
||||||
p->lastScan_.nexradFile_);
|
p->lastScan_.nexradFile_);
|
||||||
//return p->currentScan_.nexradFile_;
|
// return p->currentScan_.nexradFile_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<wsr88d::NexradFile>
|
std::shared_ptr<wsr88d::NexradFile>
|
||||||
|
|
@ -667,8 +671,8 @@ std::pair<size_t, size_t> AwsLevel2ChunksDataProvider::Refresh()
|
||||||
boost::timer::cpu_timer timer {};
|
boost::timer::cpu_timer timer {};
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
std::unique_lock lock(p->refreshMutex_);
|
const std::unique_lock lock(p->refreshMutex_);
|
||||||
std::unique_lock scanLock(p->scansMutex_);
|
const std::unique_lock scanLock(p->scansMutex_);
|
||||||
|
|
||||||
auto [success, newObjects, totalObjects] = p->ListObjects();
|
auto [success, newObjects, totalObjects] = p->ListObjects();
|
||||||
|
|
||||||
|
|
@ -682,6 +686,8 @@ std::pair<size_t, size_t> AwsLevel2ChunksDataProvider::Refresh()
|
||||||
}
|
}
|
||||||
if (p->lastScan_.valid_)
|
if (p->lastScan_.valid_)
|
||||||
{
|
{
|
||||||
|
// TODO this is slow when initially loading data. If possible, loading
|
||||||
|
// this from the archive may speed it up a lot.
|
||||||
if (p->LoadScan(p->lastScan_))
|
if (p->LoadScan(p->lastScan_))
|
||||||
{
|
{
|
||||||
newObjects += 1;
|
newObjects += 1;
|
||||||
|
|
@ -690,6 +696,7 @@ std::pair<size_t, size_t> AwsLevel2ChunksDataProvider::Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) format to 6 digits
|
||||||
logger_->debug("Refresh() in {}", timer.format(6, "%ws"));
|
logger_->debug("Refresh() in {}", timer.format(6, "%ws"));
|
||||||
return std::make_pair(newObjects, totalObjects);
|
return std::make_pair(newObjects, totalObjects);
|
||||||
}
|
}
|
||||||
|
|
@ -710,8 +717,7 @@ float AwsLevel2ChunksDataProvider::GetCurrentElevation()
|
||||||
if (!p->currentScan_.valid_ || p->currentScan_.nexradFile_ == nullptr)
|
if (!p->currentScan_.valid_ || p->currentScan_.nexradFile_ == nullptr)
|
||||||
{
|
{
|
||||||
// Does not have any scan elevation. -90 is beyond what is possible
|
// Does not have any scan elevation. -90 is beyond what is possible
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
return INVALID_ELEVATION;
|
||||||
return -90;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vcpData = p->currentScan_.nexradFile_->vcp_data();
|
auto vcpData = p->currentScan_.nexradFile_->vcp_data();
|
||||||
|
|
@ -719,18 +725,17 @@ float AwsLevel2ChunksDataProvider::GetCurrentElevation()
|
||||||
if (radarData.size() == 0)
|
if (radarData.size() == 0)
|
||||||
{
|
{
|
||||||
// Does not have any scan elevation. -90 is beyond what is possible
|
// Does not have any scan elevation. -90 is beyond what is possible
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
return INVALID_ELEVATION;
|
||||||
return -90;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& lastElevation = radarData.crbegin();
|
const auto& lastElevation = radarData.crbegin();
|
||||||
std::shared_ptr<wsr88d::rda::DigitalRadarData> digitalRadarData0 =
|
const std::shared_ptr<wsr88d::rda::DigitalRadarData> digitalRadarData0 =
|
||||||
std::dynamic_pointer_cast<wsr88d::rda::DigitalRadarData>(
|
std::dynamic_pointer_cast<wsr88d::rda::DigitalRadarData>(
|
||||||
lastElevation->second->cbegin()->second);
|
lastElevation->second->cbegin()->second);
|
||||||
|
|
||||||
if (vcpData != nullptr)
|
if (vcpData != nullptr)
|
||||||
{
|
{
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-narrowing-conversions) Float is plenty
|
// NOLINTNEXTLINE(*-narrowing-conversions) Float is plenty
|
||||||
return vcpData->elevation_angle(lastElevation->first);
|
return vcpData->elevation_angle(lastElevation->first);
|
||||||
}
|
}
|
||||||
else if (digitalRadarData0 != nullptr)
|
else if (digitalRadarData0 != nullptr)
|
||||||
|
|
@ -738,9 +743,7 @@ float AwsLevel2ChunksDataProvider::GetCurrentElevation()
|
||||||
return digitalRadarData0->elevation_angle().value();
|
return digitalRadarData0->elevation_angle().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does not have any scan elevation. -90 is beyond what is possible
|
return INVALID_ELEVATION;
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
|
||||||
return -90;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace scwx::provider
|
} // namespace scwx::provider
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ Ar2vFile::GetElevationScan(rda::DataBlockType dataBlockType,
|
||||||
float elevation,
|
float elevation,
|
||||||
std::chrono::system_clock::time_point time) const
|
std::chrono::system_clock::time_point time) const
|
||||||
{
|
{
|
||||||
//logger_->debug("GetElevationScan: {} degrees", elevation);
|
// logger_->debug("GetElevationScan: {} degrees", elevation);
|
||||||
|
|
||||||
std::shared_ptr<rda::ElevationScan> elevationScan = nullptr;
|
std::shared_ptr<rda::ElevationScan> elevationScan = nullptr;
|
||||||
float elevationCut = 0.0f;
|
float elevationCut = 0.0f;
|
||||||
|
|
@ -273,7 +273,7 @@ bool Ar2vFile::LoadData(std::istream& is)
|
||||||
|
|
||||||
std::size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is)
|
std::size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is)
|
||||||
{
|
{
|
||||||
//logger_->debug("Decompressing LDM Records");
|
// logger_->debug("Decompressing LDM Records");
|
||||||
|
|
||||||
std::size_t numRecords = 0;
|
std::size_t numRecords = 0;
|
||||||
|
|
||||||
|
|
@ -321,22 +321,22 @@ std::size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is)
|
||||||
++numRecords;
|
++numRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
//logger_->debug("Decompressed {} LDM Records", numRecords);
|
// logger_->debug("Decompressed {} LDM Records", numRecords);
|
||||||
|
|
||||||
return numRecords;
|
return numRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ar2vFileImpl::ParseLDMRecords()
|
void Ar2vFileImpl::ParseLDMRecords()
|
||||||
{
|
{
|
||||||
//logger_->debug("Parsing LDM Records");
|
// logger_->debug("Parsing LDM Records");
|
||||||
|
|
||||||
//std::size_t count = 0;
|
// std::size_t count = 0;
|
||||||
|
|
||||||
for (auto it = rawRecords_.begin(); it != rawRecords_.end(); it++)
|
for (auto it = rawRecords_.begin(); it != rawRecords_.end(); it++)
|
||||||
{
|
{
|
||||||
std::stringstream& ss = *it;
|
std::stringstream& ss = *it;
|
||||||
|
|
||||||
//logger_->trace("Record {}", count++);
|
// logger_->trace("Record {}", count++);
|
||||||
|
|
||||||
ParseLDMRecord(ss);
|
ParseLDMRecord(ss);
|
||||||
}
|
}
|
||||||
|
|
@ -445,7 +445,7 @@ void Ar2vFileImpl::ProcessRadarData(
|
||||||
|
|
||||||
void Ar2vFileImpl::IndexFile()
|
void Ar2vFileImpl::IndexFile()
|
||||||
{
|
{
|
||||||
//logger_->debug("Indexing file");
|
// logger_->debug("Indexing file");
|
||||||
|
|
||||||
for (auto& elevationCut : radarData_)
|
for (auto& elevationCut : radarData_)
|
||||||
{
|
{
|
||||||
|
|
@ -465,6 +465,7 @@ void Ar2vFileImpl::IndexFile()
|
||||||
|
|
||||||
if (vcpData_ != nullptr)
|
if (vcpData_ != nullptr)
|
||||||
{
|
{
|
||||||
|
// NOLINTNEXTLINE(*-narrowing-conversions) Float is plenty
|
||||||
elevationAngle = vcpData_->elevation_angle(elevationCut.first);
|
elevationAngle = vcpData_->elevation_angle(elevationCut.first);
|
||||||
waveformType = vcpData_->waveform_type(elevationCut.first);
|
waveformType = vcpData_->waveform_type(elevationCut.first);
|
||||||
}
|
}
|
||||||
|
|
@ -500,15 +501,15 @@ void Ar2vFileImpl::IndexFile()
|
||||||
auto time = util::TimePoint(radial0->modified_julian_date(),
|
auto time = util::TimePoint(radial0->modified_julian_date(),
|
||||||
radial0->collection_time());
|
radial0->collection_time());
|
||||||
|
|
||||||
index_[dataBlockType][elevationAngle][time] =
|
index_[dataBlockType][elevationAngle][time] = elevationCut.second;
|
||||||
elevationCut.second;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Ar2vFile::LoadLDMRecords(std::istream& is) {
|
bool Ar2vFile::LoadLDMRecords(std::istream& is)
|
||||||
size_t decompressedRecords = p->DecompressLDMRecords(is);
|
{
|
||||||
|
const size_t decompressedRecords = p->DecompressLDMRecords(is);
|
||||||
if (decompressedRecords == 0)
|
if (decompressedRecords == 0)
|
||||||
{
|
{
|
||||||
p->ParseLDMRecord(is);
|
p->ParseLDMRecord(is);
|
||||||
|
|
@ -528,6 +529,7 @@ bool Ar2vFile::IndexFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO not good
|
// TODO not good
|
||||||
|
// NOLINTNEXTLINE
|
||||||
bool IsRadarDataIncomplete(
|
bool IsRadarDataIncomplete(
|
||||||
const std::shared_ptr<const rda::ElevationScan>& radarData)
|
const std::shared_ptr<const rda::ElevationScan>& radarData)
|
||||||
{
|
{
|
||||||
|
|
@ -695,12 +697,13 @@ Ar2vFile::Ar2vFile(const std::shared_ptr<Ar2vFile>& current,
|
||||||
// Find the highest elevation this type has for the current scan
|
// Find the highest elevation this type has for the current scan
|
||||||
// Start below any reasonable elevation
|
// Start below any reasonable elevation
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
||||||
float highestCurrentElevation = -90;
|
float highestCurrentElevation = -90;
|
||||||
const auto& maybe1 = p->index_.find(type.first);
|
const auto& maybe1 = p->index_.find(type.first);
|
||||||
if (maybe1 != p->index_.cend())
|
if (maybe1 != p->index_.cend())
|
||||||
{
|
{
|
||||||
const auto& maybe2 = maybe1->second.crbegin();
|
const auto& maybe2 = maybe1->second.crbegin();
|
||||||
if (maybe2 != maybe1->second.crend()) {
|
if (maybe2 != maybe1->second.crend())
|
||||||
|
{
|
||||||
// Add a slight offset to ensure good floating point compare.
|
// Add a slight offset to ensure good floating point compare.
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
||||||
highestCurrentElevation = maybe2->first + 0.01f;
|
highestCurrentElevation = maybe2->first + 0.01f;
|
||||||
|
|
|
||||||
|
|
@ -221,8 +221,8 @@ uint16_t VolumeCoveragePatternData::number_of_base_tilts() const
|
||||||
double VolumeCoveragePatternData::elevation_angle(uint16_t e) const
|
double VolumeCoveragePatternData::elevation_angle(uint16_t e) const
|
||||||
{
|
{
|
||||||
|
|
||||||
// NOLINTNEXTLINE This conversion is accurate
|
|
||||||
float elevationAngleConverted =
|
float elevationAngleConverted =
|
||||||
|
// NOLINTNEXTLINE This conversion is accurate
|
||||||
p->elevationCuts_[e].elevationAngle_ * ANGLE_DATA_SCALE;
|
p->elevationCuts_[e].elevationAngle_ * ANGLE_DATA_SCALE;
|
||||||
// Any elevation above 90 degrees should be interpreted as a
|
// Any elevation above 90 degrees should be interpreted as a
|
||||||
// negative angle
|
// negative angle
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue