Adding impact based warnings to ibw namespace

This commit is contained in:
Dan Paulat 2024-09-16 21:13:45 -05:00
parent 38a2831779
commit 7101cdf183
6 changed files with 29 additions and 23 deletions

View file

@ -10,7 +10,6 @@
#include <scwx/util/strings.hpp> #include <scwx/util/strings.hpp>
#include <scwx/util/time.hpp> #include <scwx/util/time.hpp>
#include <format> #include <format>
#include <QApplication> #include <QApplication>
@ -38,7 +37,7 @@ public:
~AlertModelImpl() = default; ~AlertModelImpl() = default;
bool GetObserved(const types::TextEventKey& key); bool GetObserved(const types::TextEventKey& key);
awips::ThreatCategory GetThreatCategory(const types::TextEventKey& key); awips::ibw::ThreatCategory GetThreatCategory(const types::TextEventKey& key);
bool GetTornadoPossible(const types::TextEventKey& key); bool GetTornadoPossible(const types::TextEventKey& key);
static std::string GetCounties(const types::TextEventKey& key); static std::string GetCounties(const types::TextEventKey& key);
@ -61,7 +60,7 @@ public:
types::TextEventHash<types::TextEventKey>> types::TextEventHash<types::TextEventKey>>
observedMap_; observedMap_;
std::unordered_map<types::TextEventKey, std::unordered_map<types::TextEventKey,
awips::ThreatCategory, awips::ibw::ThreatCategory,
types::TextEventHash<types::TextEventKey>> types::TextEventHash<types::TextEventKey>>
threatCategoryMap_; threatCategoryMap_;
std::unordered_map<types::TextEventKey, std::unordered_map<types::TextEventKey,
@ -158,7 +157,7 @@ QVariant AlertModel::data(const QModelIndex& index, int role) const
case static_cast<int>(Column::ThreatCategory): case static_cast<int>(Column::ThreatCategory):
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
{ {
return QString::fromStdString(awips::GetThreatCategoryName( return QString::fromStdString(awips::ibw::GetThreatCategoryName(
p->GetThreatCategory(textEventKey))); p->GetThreatCategory(textEventKey)));
} }
else else
@ -439,10 +438,10 @@ bool AlertModelImpl::GetObserved(const types::TextEventKey& key)
return observed; return observed;
} }
awips::ThreatCategory awips::ibw::ThreatCategory
AlertModelImpl::GetThreatCategory(const types::TextEventKey& key) AlertModelImpl::GetThreatCategory(const types::TextEventKey& key)
{ {
awips::ThreatCategory threatCategory = awips::ThreatCategory::Base; awips::ibw::ThreatCategory threatCategory = awips::ibw::ThreatCategory::Base;
auto it = threatCategoryMap_.find(key); auto it = threatCategoryMap_.find(key);
if (it != threatCategoryMap_.cend()) if (it != threatCategoryMap_.cend())

View file

@ -179,7 +179,7 @@ QWidget* AlertPaletteSettingsWidget::Impl::CreateStackedWidgetPage(
page->setLayout(gridLayout); page->setLayout(gridLayout);
const auto& impactBasedWarningInfo = const auto& impactBasedWarningInfo =
awips::GetImpactBasedWarningInfo(phenomenon); awips::ibw::GetImpactBasedWarningInfo(phenomenon);
int row = 0; int row = 0;
@ -200,13 +200,13 @@ QWidget* AlertPaletteSettingsWidget::Impl::CreateStackedWidgetPage(
for (auto& category : impactBasedWarningInfo.threatCategories_) for (auto& category : impactBasedWarningInfo.threatCategories_)
{ {
if (category == awips::ThreatCategory::Base) if (category == awips::ibw::ThreatCategory::Base)
{ {
continue; continue;
} }
AddPhenomenonLine( AddPhenomenonLine(
awips::GetThreatCategoryName(category), gridLayout, row++); awips::ibw::GetThreatCategoryName(category), gridLayout, row++);
} }
AddPhenomenonLine("Inactive", gridLayout, row++); AddPhenomenonLine("Inactive", gridLayout, row++);

View file

@ -9,6 +9,8 @@ namespace scwx
{ {
namespace awips namespace awips
{ {
namespace ibw
{
enum class ThreatCategory : int enum class ThreatCategory : int
{ {
@ -32,5 +34,6 @@ const ImpactBasedWarningInfo& GetImpactBasedWarningInfo(Phenomenon phenomenon);
ThreatCategory GetThreatCategory(const std::string& name); ThreatCategory GetThreatCategory(const std::string& name);
const std::string& GetThreatCategoryName(ThreatCategory threatCategory); const std::string& GetThreatCategoryName(ThreatCategory threatCategory);
} // namespace ibw
} // namespace awips } // namespace awips
} // namespace scwx } // namespace scwx

View file

@ -65,7 +65,7 @@ struct Segment
std::optional<CodedTimeMotionLocation> codedMotion_ {}; std::optional<CodedTimeMotionLocation> codedMotion_ {};
bool observed_ {false}; bool observed_ {false};
ThreatCategory threatCategory_ {ThreatCategory::Base}; ibw::ThreatCategory threatCategory_ {ibw::ThreatCategory::Base};
bool tornadoPossible_ {false}; bool tornadoPossible_ {false};
Segment() = default; Segment() = default;

View file

@ -10,8 +10,10 @@ namespace scwx
{ {
namespace awips namespace awips
{ {
namespace ibw
{
static const std::string logPrefix_ = "scwx::awips::impact_based_warnings"; static const std::string logPrefix_ = "scwx::awips::ibw::impact_based_warnings";
static const boost::unordered_flat_map<Phenomenon, ImpactBasedWarningInfo> static const boost::unordered_flat_map<Phenomenon, ImpactBasedWarningInfo>
impactBasedWarningInfo_ { impactBasedWarningInfo_ {
@ -62,5 +64,6 @@ const std::string& GetThreatCategoryName(ThreatCategory threatCategory)
return threatCategoryName_.at(threatCategory); return threatCategoryName_.at(threatCategory);
} }
} // namespace ibw
} // namespace awips } // namespace awips
} // namespace scwx } // namespace scwx

View file

@ -378,7 +378,7 @@ void ParseCodedInformation(std::shared_ptr<Segment> segment,
segment->tornadoPossible_ = true; segment->tornadoPossible_ = true;
} }
else if (segment->threatCategory_ == ThreatCategory::Base && else if (segment->threatCategory_ == ibw::ThreatCategory::Base &&
(threatTagIt = std::find_if(kThreatCategoryTags.cbegin(), (threatTagIt = std::find_if(kThreatCategoryTags.cbegin(),
kThreatCategoryTags.cend(), kThreatCategoryTags.cend(),
[&it](const std::string& tag) { [&it](const std::string& tag) {
@ -389,18 +389,19 @@ void ParseCodedInformation(std::shared_ptr<Segment> segment,
const std::string threatCategoryName = const std::string threatCategoryName =
it->substr(threatTagIt->length()); it->substr(threatTagIt->length());
ThreatCategory threatCategory = GetThreatCategory(threatCategoryName); ibw::ThreatCategory threatCategory =
ibw::GetThreatCategory(threatCategoryName);
switch (threatCategory) switch (threatCategory)
{ {
case ThreatCategory::Significant: case ibw::ThreatCategory::Significant:
// "Significant" is no longer an official tag, and has largely been // "Significant" is no longer an official tag, and has largely been
// replaced with "Considerable". // replaced with "Considerable".
threatCategory = ThreatCategory::Considerable; threatCategory = ibw::ThreatCategory::Considerable;
break; break;
case ThreatCategory::Unknown: case ibw::ThreatCategory::Unknown:
threatCategory = ThreatCategory::Base; threatCategory = ibw::ThreatCategory::Base;
break; break;
default: default: