From ed00cec4cc81f4e6d1de4270a8b75a3c088b7f8d Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Mon, 9 Sep 2024 08:56:53 -0400 Subject: [PATCH] reverted wfoMap_ to unordered_map and added error checking to getWFOName --- scwx-qt/source/scwx/qt/config/county_database.cpp | 12 +++++++++--- scwx-qt/source/scwx/qt/config/county_database.hpp | 3 +-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scwx-qt/source/scwx/qt/config/county_database.cpp b/scwx-qt/source/scwx/qt/config/county_database.cpp index 289025f3..030225ec 100644 --- a/scwx-qt/source/scwx/qt/config/county_database.cpp +++ b/scwx-qt/source/scwx/qt/config/county_database.cpp @@ -31,7 +31,7 @@ typedef std::unordered_map FormatMap; static bool initialized_ {false}; static FormatMap countyDatabase_; static std::unordered_map stateMap_; -static std::map wfoMap_; +static std::unordered_map wfoMap_; void Initialize() { @@ -264,14 +264,20 @@ const std::unordered_map& GetStates() return stateMap_; } -const std::map& GetWFOs() +const std::unordered_map& GetWFOs() { return wfoMap_; } const std::string& GetWFOName(const std::string& wfoId) { - return wfoMap_.at(wfoId); + auto wfo = wfoMap_.find(wfoId); + if (wfo == wfoMap_.end()) + { + return wfoId; + } + + return wfo->second; } } // namespace CountyDatabase diff --git a/scwx-qt/source/scwx/qt/config/county_database.hpp b/scwx-qt/source/scwx/qt/config/county_database.hpp index e135e7ae..e2d427c6 100644 --- a/scwx-qt/source/scwx/qt/config/county_database.hpp +++ b/scwx-qt/source/scwx/qt/config/county_database.hpp @@ -4,7 +4,6 @@ #include #include #include -#include namespace scwx { @@ -20,7 +19,7 @@ std::string GetCountyName(const std::string& id); std::unordered_map GetCounties(const std::string& state); const std::unordered_map& GetStates(); -const std::map& GetWFOs(); +const std::unordered_map& GetWFOs(); const std::string& GetWFOName(const std::string& wfoId); } // namespace CountyDatabase