mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:30:05 +00:00 
			
		
		
		
	Add alert palette settings widget
This commit is contained in:
		
							parent
							
								
									da79f47416
								
							
						
					
					
						commit
						f8e0ab5b56
					
				
					 5 changed files with 351 additions and 61 deletions
				
			
		|  | @ -309,10 +309,12 @@ set(UI_UI  source/scwx/qt/ui/about_dialog.ui | ||||||
|            source/scwx/qt/ui/serial_port_dialog.ui |            source/scwx/qt/ui/serial_port_dialog.ui | ||||||
|            source/scwx/qt/ui/update_dialog.ui |            source/scwx/qt/ui/update_dialog.ui | ||||||
|            source/scwx/qt/ui/wfo_dialog.ui) |            source/scwx/qt/ui/wfo_dialog.ui) | ||||||
| set(HDR_UI_SETTINGS source/scwx/qt/ui/settings/hotkey_settings_widget.hpp | set(HDR_UI_SETTINGS source/scwx/qt/ui/settings/alert_palette_settings_widget.hpp | ||||||
|  |                     source/scwx/qt/ui/settings/hotkey_settings_widget.hpp | ||||||
|                     source/scwx/qt/ui/settings/settings_page_widget.hpp |                     source/scwx/qt/ui/settings/settings_page_widget.hpp | ||||||
|                     source/scwx/qt/ui/settings/unit_settings_widget.hpp) |                     source/scwx/qt/ui/settings/unit_settings_widget.hpp) | ||||||
| set(SRC_UI_SETTINGS source/scwx/qt/ui/settings/hotkey_settings_widget.cpp | set(SRC_UI_SETTINGS source/scwx/qt/ui/settings/alert_palette_settings_widget.cpp | ||||||
|  |                     source/scwx/qt/ui/settings/hotkey_settings_widget.cpp | ||||||
|                     source/scwx/qt/ui/settings/settings_page_widget.cpp |                     source/scwx/qt/ui/settings/settings_page_widget.cpp | ||||||
|                     source/scwx/qt/ui/settings/unit_settings_widget.cpp) |                     source/scwx/qt/ui/settings/unit_settings_widget.cpp) | ||||||
| set(HDR_UI_SETUP source/scwx/qt/ui/setup/audio_codec_page.hpp | set(HDR_UI_SETUP source/scwx/qt/ui/setup/audio_codec_page.hpp | ||||||
|  |  | ||||||
|  | @ -0,0 +1,239 @@ | ||||||
|  | #include <scwx/qt/ui/settings/alert_palette_settings_widget.hpp> | ||||||
|  | #include <scwx/qt/ui/edit_line_dialog.hpp> | ||||||
|  | #include <scwx/qt/ui/line_label.hpp> | ||||||
|  | #include <scwx/qt/settings/palette_settings.hpp> | ||||||
|  | #include <scwx/awips/impact_based_warnings.hpp> | ||||||
|  | #include <scwx/awips/phenomenon.hpp> | ||||||
|  | 
 | ||||||
|  | #include <boost/unordered/unordered_flat_map.hpp> | ||||||
|  | #include <QGridLayout> | ||||||
|  | #include <QLabel> | ||||||
|  | #include <QListWidget> | ||||||
|  | #include <QStackedWidget> | ||||||
|  | #include <QToolButton> | ||||||
|  | #include <QVBoxLayout> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace qt | ||||||
|  | { | ||||||
|  | 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<awips::ThreatCategory> threatCategories_ { | ||||||
|  |       awips::ThreatCategory::Base}; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | static const boost::unordered_flat_map<awips::Phenomenon, PhenomenonInfo> | ||||||
|  |    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: | ||||||
|  |    explicit Impl(AlertPaletteSettingsWidget* self) : | ||||||
|  |        self_ {self}, | ||||||
|  |        phenomenonPagesWidget_ {new QStackedWidget(self)}, | ||||||
|  |        phenomenonListView_ {new QListWidget(self)}, | ||||||
|  |        editLineDialog_ {new EditLineDialog(self)} | ||||||
|  |    { | ||||||
|  |       SetupUi(); | ||||||
|  |       ConnectSignals(); | ||||||
|  |    } | ||||||
|  |    ~Impl() = default; | ||||||
|  | 
 | ||||||
|  |    void | ||||||
|  |    AddPhenomenonLine(const std::string& name, QGridLayout* layout, int row); | ||||||
|  |    QWidget* CreateStackedWidgetPage(awips::Phenomenon phenomenon); | ||||||
|  |    void     ConnectSignals(); | ||||||
|  |    void     SelectPhenomenon(awips::Phenomenon phenomenon); | ||||||
|  |    void     SetupUi(); | ||||||
|  | 
 | ||||||
|  |    AlertPaletteSettingsWidget* self_; | ||||||
|  | 
 | ||||||
|  |    QStackedWidget* phenomenonPagesWidget_; | ||||||
|  |    QListWidget*    phenomenonListView_; | ||||||
|  | 
 | ||||||
|  |    EditLineDialog* editLineDialog_; | ||||||
|  | 
 | ||||||
|  |    boost::unordered_flat_map<awips::Phenomenon, QWidget*> phenomenonPages_ {}; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | AlertPaletteSettingsWidget::AlertPaletteSettingsWidget(QWidget* parent) : | ||||||
|  |     SettingsPageWidget(parent), p {std::make_shared<Impl>(this)} | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | AlertPaletteSettingsWidget::~AlertPaletteSettingsWidget() = default; | ||||||
|  | 
 | ||||||
|  | void AlertPaletteSettingsWidget::Impl::SetupUi() | ||||||
|  | { | ||||||
|  |    // Setup primary widget layout
 | ||||||
|  |    QGridLayout* gridLayout = new QGridLayout(self_); | ||||||
|  |    gridLayout->setContentsMargins(0, 0, 0, 0); | ||||||
|  |    self_->setLayout(gridLayout); | ||||||
|  | 
 | ||||||
|  |    QWidget* phenomenonIndexPane = new QWidget(self_); | ||||||
|  |    phenomenonPagesWidget_->setSizePolicy(QSizePolicy::Policy::Expanding, | ||||||
|  |                                          QSizePolicy::Policy::Preferred); | ||||||
|  | 
 | ||||||
|  |    gridLayout->addWidget(phenomenonIndexPane, 0, 0); | ||||||
|  |    gridLayout->addWidget(phenomenonPagesWidget_, 0, 1); | ||||||
|  | 
 | ||||||
|  |    QSpacerItem* spacer = | ||||||
|  |       new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); | ||||||
|  |    gridLayout->addItem(spacer, 1, 0); | ||||||
|  | 
 | ||||||
|  |    // Setup phenomenon index pane
 | ||||||
|  |    QVBoxLayout* phenomenonIndexLayout = new QVBoxLayout(self_); | ||||||
|  |    phenomenonIndexPane->setLayout(phenomenonIndexLayout); | ||||||
|  | 
 | ||||||
|  |    QLabel* phenomenonLabel = new QLabel(tr("Phenomenon:"), self_); | ||||||
|  |    phenomenonListView_->setSizePolicy(QSizePolicy::Policy::Minimum, | ||||||
|  |                                       QSizePolicy::Policy::Expanding); | ||||||
|  | 
 | ||||||
|  |    phenomenonIndexLayout->addWidget(phenomenonLabel); | ||||||
|  |    phenomenonIndexLayout->addWidget(phenomenonListView_); | ||||||
|  | 
 | ||||||
|  |    // Setup stacked widget
 | ||||||
|  |    auto& paletteSettings = settings::PaletteSettings::Instance(); | ||||||
|  |    Q_UNUSED(paletteSettings); | ||||||
|  | 
 | ||||||
|  |    for (auto& phenomenon : settings::PaletteSettings::alert_phenomena()) | ||||||
|  |    { | ||||||
|  |       QWidget* phenomenonWidget = CreateStackedWidgetPage(phenomenon); | ||||||
|  |       phenomenonPagesWidget_->addWidget(phenomenonWidget); | ||||||
|  | 
 | ||||||
|  |       phenomenonPages_.insert_or_assign(phenomenon, phenomenonWidget); | ||||||
|  | 
 | ||||||
|  |       phenomenonListView_->addItem( | ||||||
|  |          QString::fromStdString(awips::GetPhenomenonText(phenomenon))); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    phenomenonListView_->setCurrentRow(0); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void AlertPaletteSettingsWidget::Impl::ConnectSignals() | ||||||
|  | { | ||||||
|  |    QObject::connect( | ||||||
|  |       phenomenonListView_->selectionModel(), | ||||||
|  |       &QItemSelectionModel::selectionChanged, | ||||||
|  |       self_, | ||||||
|  |       [this](const QItemSelection& selected, const QItemSelection& deselected) | ||||||
|  |       { | ||||||
|  |          if (selected.size() == 0 && deselected.size() == 0) | ||||||
|  |          { | ||||||
|  |             // Items which stay selected but change their index are not
 | ||||||
|  |             // included in selected and deselected. Thus, this signal might
 | ||||||
|  |             // be emitted with both selected and deselected empty, if only
 | ||||||
|  |             // the indices of selected items change.
 | ||||||
|  |             return; | ||||||
|  |          } | ||||||
|  | 
 | ||||||
|  |          if (selected.size() > 0) | ||||||
|  |          { | ||||||
|  |             QModelIndex selectedIndex = selected[0].indexes()[0]; | ||||||
|  |             QVariant    variantData = | ||||||
|  |                phenomenonListView_->model()->data(selectedIndex); | ||||||
|  |             if (variantData.typeId() == QMetaType::QString) | ||||||
|  |             { | ||||||
|  |                awips::Phenomenon phenomenon = awips::GetPhenomenonFromText( | ||||||
|  |                   variantData.toString().toStdString()); | ||||||
|  |                SelectPhenomenon(phenomenon); | ||||||
|  |             } | ||||||
|  |          } | ||||||
|  |       }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void AlertPaletteSettingsWidget::Impl::SelectPhenomenon( | ||||||
|  |    awips::Phenomenon phenomenon) | ||||||
|  | { | ||||||
|  |    auto it = phenomenonPages_.find(phenomenon); | ||||||
|  |    if (it != phenomenonPages_.cend()) | ||||||
|  |    { | ||||||
|  |       phenomenonPagesWidget_->setCurrentWidget(it->second); | ||||||
|  |    } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | QWidget* AlertPaletteSettingsWidget::Impl::CreateStackedWidgetPage( | ||||||
|  |    awips::Phenomenon phenomenon) | ||||||
|  | { | ||||||
|  |    QWidget*     page       = new QWidget(self_); | ||||||
|  |    QGridLayout* gridLayout = new QGridLayout(self_); | ||||||
|  |    page->setLayout(gridLayout); | ||||||
|  | 
 | ||||||
|  |    const auto& phenomenonInfo = phenomenaInfo_.at(phenomenon); | ||||||
|  | 
 | ||||||
|  |    int row = 0; | ||||||
|  | 
 | ||||||
|  |    // Add a blank label to align left and right widgets
 | ||||||
|  |    gridLayout->addWidget(new QLabel(self_), row++, 0); | ||||||
|  | 
 | ||||||
|  |    AddPhenomenonLine("Active", gridLayout, row++); | ||||||
|  | 
 | ||||||
|  |    if (phenomenonInfo.hasObservedTag_) | ||||||
|  |    { | ||||||
|  |       AddPhenomenonLine("Observed", gridLayout, row++); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    if (phenomenonInfo.hasTornadoPossibleTag_) | ||||||
|  |    { | ||||||
|  |       AddPhenomenonLine("Tornado Possible", gridLayout, row++); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    for (auto& category : phenomenonInfo.threatCategories_) | ||||||
|  |    { | ||||||
|  |       if (category == awips::ThreatCategory::Base) | ||||||
|  |       { | ||||||
|  |          continue; | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       AddPhenomenonLine( | ||||||
|  |          awips::GetThreatCategoryName(category), gridLayout, row++); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    AddPhenomenonLine("Inactive", gridLayout, row++); | ||||||
|  | 
 | ||||||
|  |    QSpacerItem* spacer = | ||||||
|  |       new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); | ||||||
|  |    gridLayout->addItem(spacer, row, 0); | ||||||
|  | 
 | ||||||
|  |    return page; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void AlertPaletteSettingsWidget::Impl::AddPhenomenonLine( | ||||||
|  |    const std::string& name, QGridLayout* layout, int row) | ||||||
|  | { | ||||||
|  |    layout->addWidget(new QLabel(tr(name.c_str()), self_), row, 0); | ||||||
|  |    layout->addWidget(new LineLabel(self_), row, 1); | ||||||
|  |    layout->addWidget(new QToolButton(self_), row, 2); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // namespace ui
 | ||||||
|  | } // namespace qt
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | @ -0,0 +1,29 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <scwx/qt/ui/settings/settings_page_widget.hpp> | ||||||
|  | 
 | ||||||
|  | #include <QWidget> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace qt | ||||||
|  | { | ||||||
|  | namespace ui | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | class AlertPaletteSettingsWidget : public SettingsPageWidget | ||||||
|  | { | ||||||
|  |    Q_OBJECT | ||||||
|  | 
 | ||||||
|  | public: | ||||||
|  |    explicit AlertPaletteSettingsWidget(QWidget* parent = nullptr); | ||||||
|  |    ~AlertPaletteSettingsWidget(); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |    class Impl; | ||||||
|  |    std::shared_ptr<Impl> p; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | } // namespace ui
 | ||||||
|  | } // namespace qt
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | @ -69,6 +69,7 @@ enum class Phenomenon | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Phenomenon         GetPhenomenon(const std::string& code); | Phenomenon         GetPhenomenon(const std::string& code); | ||||||
|  | Phenomenon         GetPhenomenonFromText(const std::string& text); | ||||||
| const std::string& GetPhenomenonCode(Phenomenon phenomenon); | const std::string& GetPhenomenonCode(Phenomenon phenomenon); | ||||||
| const std::string& GetPhenomenonText(Phenomenon phenomenon); | const std::string& GetPhenomenonText(Phenomenon phenomenon); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -77,64 +77,65 @@ static const PhenomenonCodesBimap phenomenonCodes_ = | ||||||
|    (Phenomenon::FreezingSpray, "ZY")                      //
 |    (Phenomenon::FreezingSpray, "ZY")                      //
 | ||||||
|    (Phenomenon::Unknown, "??"); |    (Phenomenon::Unknown, "??"); | ||||||
| 
 | 
 | ||||||
| static const std::unordered_map<Phenomenon, std::string> phenomenonText_ { | static const PhenomenonCodesBimap phenomenonText_ = | ||||||
|    {Phenomenon::AshfallLand, "Ashfall (land)"},              //
 |    boost::assign::list_of<PhenomenonCodesBimap::relation>   //
 | ||||||
|    {Phenomenon::AirStagnation, "Air Stagnation"},            //
 |    (Phenomenon::AshfallLand, "Ashfall (land)")              //
 | ||||||
|    {Phenomenon::BeachHazard, "Beach Hazard"},                //
 |    (Phenomenon::AirStagnation, "Air Stagnation")            //
 | ||||||
|    {Phenomenon::BriskWind, "Brisk Wind"},                    //
 |    (Phenomenon::BeachHazard, "Beach Hazard")                //
 | ||||||
|    {Phenomenon::Blizzard, "Blizzard"},                       //
 |    (Phenomenon::BriskWind, "Brisk Wind")                    //
 | ||||||
|    {Phenomenon::CoastalFlood, "Coastal Flood"},              //
 |    (Phenomenon::Blizzard, "Blizzard")                       //
 | ||||||
|    {Phenomenon::DebrisFlow, "Debris Flow"},                  //
 |    (Phenomenon::CoastalFlood, "Coastal Flood")              //
 | ||||||
|    {Phenomenon::DustStorm, "Dust Storm"},                    //
 |    (Phenomenon::DebrisFlow, "Debris Flow")                  //
 | ||||||
|    {Phenomenon::BlowingDust, "Blowing Dust"},                //
 |    (Phenomenon::DustStorm, "Dust Storm")                    //
 | ||||||
|    {Phenomenon::ExtremeCold, "Extreme Cold"},                //
 |    (Phenomenon::BlowingDust, "Blowing Dust")                //
 | ||||||
|    {Phenomenon::ExcessiveHeat, "Excessive Heat"},            //
 |    (Phenomenon::ExtremeCold, "Extreme Cold")                //
 | ||||||
|    {Phenomenon::ExtremeWind, "Extreme Wind"},                //
 |    (Phenomenon::ExcessiveHeat, "Excessive Heat")            //
 | ||||||
|    {Phenomenon::Flood, "Flood"},                             //
 |    (Phenomenon::ExtremeWind, "Extreme Wind")                //
 | ||||||
|    {Phenomenon::FlashFlood, "Flash Flood"},                  //
 |    (Phenomenon::Flood, "Flood")                             //
 | ||||||
|    {Phenomenon::DenseFogLand, "Dense Fog (land)"},           //
 |    (Phenomenon::FlashFlood, "Flash Flood")                  //
 | ||||||
|    {Phenomenon::Flood, "Flood (Forecast Points)"},           //
 |    (Phenomenon::DenseFogLand, "Dense Fog (land)")           //
 | ||||||
|    {Phenomenon::Frost, "Frost"},                             //
 |    (Phenomenon::Flood, "Flood (Forecast Points)")           //
 | ||||||
|    {Phenomenon::FireWeather, "Fire Weather"},                //
 |    (Phenomenon::Frost, "Frost")                             //
 | ||||||
|    {Phenomenon::Freeze, "Freeze"},                           //
 |    (Phenomenon::FireWeather, "Fire Weather")                //
 | ||||||
|    {Phenomenon::Gale, "Gale"},                               //
 |    (Phenomenon::Freeze, "Freeze")                           //
 | ||||||
|    {Phenomenon::HurricaneForceWind, "Hurricane Force Wind"}, //
 |    (Phenomenon::Gale, "Gale")                               //
 | ||||||
|    {Phenomenon::Heat, "Heat"},                               //
 |    (Phenomenon::HurricaneForceWind, "Hurricane Force Wind") //
 | ||||||
|    {Phenomenon::Hurricane, "Hurricane"},                     //
 |    (Phenomenon::Heat, "Heat")                               //
 | ||||||
|    {Phenomenon::HighWind, "High Wind"},                      //
 |    (Phenomenon::Hurricane, "Hurricane")                     //
 | ||||||
|    {Phenomenon::Hydrologic, "Hydrologic"},                   //
 |    (Phenomenon::HighWind, "High Wind")                      //
 | ||||||
|    {Phenomenon::HardFreeze, "Hard Freeze"},                  //
 |    (Phenomenon::Hydrologic, "Hydrologic")                   //
 | ||||||
|    {Phenomenon::IceStorm, "Ice Storm"},                      //
 |    (Phenomenon::HardFreeze, "Hard Freeze")                  //
 | ||||||
|    {Phenomenon::LakeEffectSnow, "Lake Effect Snow"},         //
 |    (Phenomenon::IceStorm, "Ice Storm")                      //
 | ||||||
|    {Phenomenon::LowWater, "Low Water"},                      //
 |    (Phenomenon::LakeEffectSnow, "Lake Effect Snow")         //
 | ||||||
|    {Phenomenon::LakeshoreFlood, "Lakeshore Flood"},          //
 |    (Phenomenon::LowWater, "Low Water")                      //
 | ||||||
|    {Phenomenon::LakeWind, "Lake Wind"},                      //
 |    (Phenomenon::LakeshoreFlood, "Lakeshore Flood")          //
 | ||||||
|    {Phenomenon::Marine, "Marine"},                           //
 |    (Phenomenon::LakeWind, "Lake Wind")                      //
 | ||||||
|    {Phenomenon::DenseFogMarine, "Dense Fog (marine)"},       //
 |    (Phenomenon::Marine, "Marine")                           //
 | ||||||
|    {Phenomenon::AshfallMarine, "Ashfall (marine)"},          //
 |    (Phenomenon::DenseFogMarine, "Dense Fog (marine)")       //
 | ||||||
|    {Phenomenon::DenseSmokeMarine, "Dense Smoke (marine)"},   //
 |    (Phenomenon::AshfallMarine, "Ashfall (marine)")          //
 | ||||||
|    {Phenomenon::RipCurrentRisk, "Rip Current Risk"},         //
 |    (Phenomenon::DenseSmokeMarine, "Dense Smoke (marine)")   //
 | ||||||
|    {Phenomenon::SmallCraft, "Small Craft"},                  //
 |    (Phenomenon::RipCurrentRisk, "Rip Current Risk")         //
 | ||||||
|    {Phenomenon::HazardousSeas, "Hazardous Seas"},            //
 |    (Phenomenon::SmallCraft, "Small Craft")                  //
 | ||||||
|    {Phenomenon::DenseSmokeLand, "Dense Smoke (land)"},       //
 |    (Phenomenon::HazardousSeas, "Hazardous Seas")            //
 | ||||||
|    {Phenomenon::Storm, "Storm"},                             //
 |    (Phenomenon::DenseSmokeLand, "Dense Smoke (land)")       //
 | ||||||
|    {Phenomenon::StormSurge, "Storm Surge"},                  //
 |    (Phenomenon::Storm, "Storm")                             //
 | ||||||
|    {Phenomenon::SnowSquall, "Snow Squall"},                  //
 |    (Phenomenon::StormSurge, "Storm Surge")                  //
 | ||||||
|    {Phenomenon::HighSurf, "High Surf"},                      //
 |    (Phenomenon::SnowSquall, "Snow Squall")                  //
 | ||||||
|    {Phenomenon::SevereThunderstorm, "Severe Thunderstorm"},  //
 |    (Phenomenon::HighSurf, "High Surf")                      //
 | ||||||
|    {Phenomenon::Tornado, "Tornado"},                         //
 |    (Phenomenon::SevereThunderstorm, "Severe Thunderstorm")  //
 | ||||||
|    {Phenomenon::TropicalStorm, "Tropical Storm"},            //
 |    (Phenomenon::Tornado, "Tornado")                         //
 | ||||||
|    {Phenomenon::Tsunami, "Tsunami"},                         //
 |    (Phenomenon::TropicalStorm, "Tropical Storm")            //
 | ||||||
|    {Phenomenon::Typhoon, "Typhoon"},                         //
 |    (Phenomenon::Tsunami, "Tsunami")                         //
 | ||||||
|    {Phenomenon::HeavyFreezingSpray, "Heavy Freezing Spray"}, //
 |    (Phenomenon::Typhoon, "Typhoon")                         //
 | ||||||
|    {Phenomenon::WindChill, "Wind Chill"},                    //
 |    (Phenomenon::HeavyFreezingSpray, "Heavy Freezing Spray") //
 | ||||||
|    {Phenomenon::Wind, "Wind"},                               //
 |    (Phenomenon::WindChill, "Wind Chill")                    //
 | ||||||
|    {Phenomenon::WinterStorm, "Winter Storm"},                //
 |    (Phenomenon::Wind, "Wind")                               //
 | ||||||
|    {Phenomenon::WinterWeather, "Winter Weather"},            //
 |    (Phenomenon::WinterStorm, "Winter Storm")                //
 | ||||||
|    {Phenomenon::FreezingFog, "Freezing Fog"},                //
 |    (Phenomenon::WinterWeather, "Winter Weather")            //
 | ||||||
|    {Phenomenon::FreezingRain, "Freezing Rain"},              //
 |    (Phenomenon::FreezingFog, "Freezing Fog")                //
 | ||||||
|    {Phenomenon::FreezingSpray, "Freezing Spray"},            //
 |    (Phenomenon::FreezingRain, "Freezing Rain")              //
 | ||||||
|    {Phenomenon::Unknown, "Unknown"}}; |    (Phenomenon::FreezingSpray, "Freezing Spray")            //
 | ||||||
|  |    (Phenomenon::Unknown, "Unknown"); | ||||||
| 
 | 
 | ||||||
| Phenomenon GetPhenomenon(const std::string& code) | Phenomenon GetPhenomenon(const std::string& code) | ||||||
| { | { | ||||||
|  | @ -154,6 +155,24 @@ Phenomenon GetPhenomenon(const std::string& code) | ||||||
|    return phenomenon; |    return phenomenon; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | Phenomenon GetPhenomenonFromText(const std::string& text) | ||||||
|  | { | ||||||
|  |    Phenomenon phenomenon; | ||||||
|  | 
 | ||||||
|  |    if (phenomenonText_.right.find(text) != phenomenonText_.right.end()) | ||||||
|  |    { | ||||||
|  |       phenomenon = phenomenonText_.right.at(text); | ||||||
|  |    } | ||||||
|  |    else | ||||||
|  |    { | ||||||
|  |       phenomenon = Phenomenon::Unknown; | ||||||
|  | 
 | ||||||
|  |       logger_->debug("Unrecognized code: \"{}\"", text); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return phenomenon; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| const std::string& GetPhenomenonCode(Phenomenon phenomenon) | const std::string& GetPhenomenonCode(Phenomenon phenomenon) | ||||||
| { | { | ||||||
|    return phenomenonCodes_.left.at(phenomenon); |    return phenomenonCodes_.left.at(phenomenon); | ||||||
|  | @ -161,7 +180,7 @@ const std::string& GetPhenomenonCode(Phenomenon phenomenon) | ||||||
| 
 | 
 | ||||||
| const std::string& GetPhenomenonText(Phenomenon phenomenon) | const std::string& GetPhenomenonText(Phenomenon phenomenon) | ||||||
| { | { | ||||||
|    return phenomenonText_.at(phenomenon); |    return phenomenonText_.left.at(phenomenon); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace awips
 | } // namespace awips
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat