Renaming PhenomenonInfo to ImpactBasedWarningInfo

This commit is contained in:
Dan Paulat 2024-09-16 21:05:07 -05:00
parent 829d8a3152
commit 38a2831779
3 changed files with 31 additions and 26 deletions

View file

@ -178,7 +178,8 @@ QWidget* AlertPaletteSettingsWidget::Impl::CreateStackedWidgetPage(
QGridLayout* gridLayout = new QGridLayout(self_); QGridLayout* gridLayout = new QGridLayout(self_);
page->setLayout(gridLayout); page->setLayout(gridLayout);
const auto& phenomenonInfo = awips::GetPhenomenonInfo(phenomenon); const auto& impactBasedWarningInfo =
awips::GetImpactBasedWarningInfo(phenomenon);
int row = 0; int row = 0;
@ -187,17 +188,17 @@ QWidget* AlertPaletteSettingsWidget::Impl::CreateStackedWidgetPage(
AddPhenomenonLine("Active", gridLayout, row++); AddPhenomenonLine("Active", gridLayout, row++);
if (phenomenonInfo.hasObservedTag_) if (impactBasedWarningInfo.hasObservedTag_)
{ {
AddPhenomenonLine("Observed", gridLayout, row++); AddPhenomenonLine("Observed", gridLayout, row++);
} }
if (phenomenonInfo.hasTornadoPossibleTag_) if (impactBasedWarningInfo.hasTornadoPossibleTag_)
{ {
AddPhenomenonLine("Tornado Possible", gridLayout, row++); AddPhenomenonLine("Tornado Possible", gridLayout, row++);
} }
for (auto& category : phenomenonInfo.threatCategories_) for (auto& category : impactBasedWarningInfo.threatCategories_)
{ {
if (category == awips::ThreatCategory::Base) if (category == awips::ThreatCategory::Base)
{ {

View file

@ -20,14 +20,14 @@ enum class ThreatCategory : int
Unknown Unknown
}; };
struct PhenomenonInfo struct ImpactBasedWarningInfo
{ {
bool hasObservedTag_ {false}; bool hasObservedTag_ {false};
bool hasTornadoPossibleTag_ {false}; bool hasTornadoPossibleTag_ {false};
std::vector<ThreatCategory> threatCategories_ {ThreatCategory::Base}; std::vector<ThreatCategory> threatCategories_ {ThreatCategory::Base};
}; };
const PhenomenonInfo& GetPhenomenonInfo(Phenomenon phenomenon); 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);

View file

@ -13,25 +13,29 @@ namespace awips
static const std::string logPrefix_ = "scwx::awips::impact_based_warnings"; static const std::string logPrefix_ = "scwx::awips::impact_based_warnings";
static const boost::unordered_flat_map<Phenomenon, PhenomenonInfo> static const boost::unordered_flat_map<Phenomenon, ImpactBasedWarningInfo>
phenomenaInfo_ { impactBasedWarningInfo_ {
{Phenomenon::Marine, PhenomenonInfo {.hasTornadoPossibleTag_ {true}}}, {Phenomenon::Marine,
ImpactBasedWarningInfo {.hasTornadoPossibleTag_ {true}}},
{Phenomenon::FlashFlood, {Phenomenon::FlashFlood,
PhenomenonInfo {.threatCategories_ {ThreatCategory::Base, ImpactBasedWarningInfo {
ThreatCategory::Considerable, .threatCategories_ {ThreatCategory::Base,
ThreatCategory::Catastrophic}}}, ThreatCategory::Considerable,
ThreatCategory::Catastrophic}}},
{Phenomenon::SevereThunderstorm, {Phenomenon::SevereThunderstorm,
PhenomenonInfo {.hasTornadoPossibleTag_ {true}, ImpactBasedWarningInfo {
.threatCategories_ {ThreatCategory::Base, .hasTornadoPossibleTag_ {true},
ThreatCategory::Considerable, .threatCategories_ {ThreatCategory::Base,
ThreatCategory::Destructive}}}, ThreatCategory::Considerable,
{Phenomenon::SnowSquall, PhenomenonInfo {}}, ThreatCategory::Destructive}}},
{Phenomenon::SnowSquall, ImpactBasedWarningInfo {}},
{Phenomenon::Tornado, {Phenomenon::Tornado,
PhenomenonInfo {.hasObservedTag_ {true}, ImpactBasedWarningInfo {
.threatCategories_ {ThreatCategory::Base, .hasObservedTag_ {true},
ThreatCategory::Considerable, .threatCategories_ {ThreatCategory::Base,
ThreatCategory::Catastrophic}}}, ThreatCategory::Considerable,
{Phenomenon::Unknown, PhenomenonInfo {}}}; ThreatCategory::Catastrophic}}},
{Phenomenon::Unknown, ImpactBasedWarningInfo {}}};
static const std::unordered_map<ThreatCategory, std::string> static const std::unordered_map<ThreatCategory, std::string>
threatCategoryName_ {{ThreatCategory::Base, "Base"}, threatCategoryName_ {{ThreatCategory::Base, "Base"},
@ -41,14 +45,14 @@ static const std::unordered_map<ThreatCategory, std::string>
{ThreatCategory::Catastrophic, "Catastrophic"}, {ThreatCategory::Catastrophic, "Catastrophic"},
{ThreatCategory::Unknown, "?"}}; {ThreatCategory::Unknown, "?"}};
const PhenomenonInfo& GetPhenomenonInfo(Phenomenon phenomenon) const ImpactBasedWarningInfo& GetImpactBasedWarningInfo(Phenomenon phenomenon)
{ {
auto it = phenomenaInfo_.find(phenomenon); auto it = impactBasedWarningInfo_.find(phenomenon);
if (it != phenomenaInfo_.cend()) if (it != impactBasedWarningInfo_.cend())
{ {
return it->second; return it->second;
} }
return phenomenaInfo_.at(Phenomenon::Unknown); return impactBasedWarningInfo_.at(Phenomenon::Unknown);
} }
SCWX_GET_ENUM(ThreatCategory, GetThreatCategory, threatCategoryName_) SCWX_GET_ENUM(ThreatCategory, GetThreatCategory, threatCategoryName_)