diff --git a/scwx-qt/source/scwx/qt/ui/settings/alert_palette_settings_widget.cpp b/scwx-qt/source/scwx/qt/ui/settings/alert_palette_settings_widget.cpp index bf0d5970..c4680a62 100644 --- a/scwx-qt/source/scwx/qt/ui/settings/alert_palette_settings_widget.cpp +++ b/scwx-qt/source/scwx/qt/ui/settings/alert_palette_settings_widget.cpp @@ -23,36 +23,6 @@ namespace ui static const std::string logPrefix_ = "scwx::qt::ui::settings::alert_palette_settings_widget"; -struct PhenomenonInfo -{ - bool hasObservedTag_ {false}; - bool hasTornadoPossibleTag_ {false}; - std::vector threatCategories_ { - awips::ThreatCategory::Base}; -}; - -static const boost::unordered_flat_map - phenomenaInfo_ {{awips::Phenomenon::Marine, - PhenomenonInfo {.hasTornadoPossibleTag_ {true}}}, - {awips::Phenomenon::FlashFlood, - PhenomenonInfo {.threatCategories_ { - awips::ThreatCategory::Base, - awips::ThreatCategory::Considerable, - awips::ThreatCategory::Catastrophic}}}, - {awips::Phenomenon::SevereThunderstorm, - PhenomenonInfo {.hasTornadoPossibleTag_ {true}, - .threatCategories_ { - awips::ThreatCategory::Base, - awips::ThreatCategory::Considerable, - awips::ThreatCategory::Destructive}}}, - {awips::Phenomenon::SnowSquall, PhenomenonInfo {}}, - {awips::Phenomenon::Tornado, - PhenomenonInfo {.hasObservedTag_ {true}, - .threatCategories_ { - awips::ThreatCategory::Base, - awips::ThreatCategory::Considerable, - awips::ThreatCategory::Catastrophic}}}}; - class AlertPaletteSettingsWidget::Impl { public: @@ -208,7 +178,7 @@ QWidget* AlertPaletteSettingsWidget::Impl::CreateStackedWidgetPage( QGridLayout* gridLayout = new QGridLayout(self_); page->setLayout(gridLayout); - const auto& phenomenonInfo = phenomenaInfo_.at(phenomenon); + const auto& phenomenonInfo = awips::GetPhenomenonInfo(phenomenon); int row = 0; diff --git a/wxdata/include/scwx/awips/impact_based_warnings.hpp b/wxdata/include/scwx/awips/impact_based_warnings.hpp index a7b22288..7bb07f5a 100644 --- a/wxdata/include/scwx/awips/impact_based_warnings.hpp +++ b/wxdata/include/scwx/awips/impact_based_warnings.hpp @@ -1,6 +1,9 @@ #pragma once +#include + #include +#include namespace scwx { @@ -17,6 +20,15 @@ enum class ThreatCategory : int Unknown }; +struct PhenomenonInfo +{ + bool hasObservedTag_ {false}; + bool hasTornadoPossibleTag_ {false}; + std::vector threatCategories_ {ThreatCategory::Base}; +}; + +const PhenomenonInfo& GetPhenomenonInfo(Phenomenon phenomenon); + ThreatCategory GetThreatCategory(const std::string& name); const std::string& GetThreatCategoryName(ThreatCategory threatCategory); diff --git a/wxdata/source/scwx/awips/impact_based_warnings.cpp b/wxdata/source/scwx/awips/impact_based_warnings.cpp index 75f04d1e..1bf5e321 100644 --- a/wxdata/source/scwx/awips/impact_based_warnings.cpp +++ b/wxdata/source/scwx/awips/impact_based_warnings.cpp @@ -4,6 +4,7 @@ #include #include +#include namespace scwx { @@ -12,6 +13,26 @@ namespace awips static const std::string logPrefix_ = "scwx::awips::impact_based_warnings"; +static const boost::unordered_flat_map + phenomenaInfo_ { + {Phenomenon::Marine, PhenomenonInfo {.hasTornadoPossibleTag_ {true}}}, + {Phenomenon::FlashFlood, + PhenomenonInfo {.threatCategories_ {ThreatCategory::Base, + ThreatCategory::Considerable, + ThreatCategory::Catastrophic}}}, + {Phenomenon::SevereThunderstorm, + PhenomenonInfo {.hasTornadoPossibleTag_ {true}, + .threatCategories_ {ThreatCategory::Base, + ThreatCategory::Considerable, + ThreatCategory::Destructive}}}, + {Phenomenon::SnowSquall, PhenomenonInfo {}}, + {Phenomenon::Tornado, + PhenomenonInfo {.hasObservedTag_ {true}, + .threatCategories_ {ThreatCategory::Base, + ThreatCategory::Considerable, + ThreatCategory::Catastrophic}}}, + {Phenomenon::Unknown, PhenomenonInfo {}}}; + static const std::unordered_map threatCategoryName_ {{ThreatCategory::Base, "Base"}, {ThreatCategory::Significant, "Significant"}, @@ -20,6 +41,16 @@ static const std::unordered_map {ThreatCategory::Catastrophic, "Catastrophic"}, {ThreatCategory::Unknown, "?"}}; +const PhenomenonInfo& GetPhenomenonInfo(Phenomenon phenomenon) +{ + auto it = phenomenaInfo_.find(phenomenon); + if (it != phenomenaInfo_.cend()) + { + return it->second; + } + return phenomenaInfo_.at(Phenomenon::Unknown); +} + SCWX_GET_ENUM(ThreatCategory, GetThreatCategory, threatCategoryName_) const std::string& GetThreatCategoryName(ThreatCategory threatCategory)