Look up product code when unavailable

This commit is contained in:
Dan Paulat 2022-09-05 19:00:01 -05:00
parent 822e523400
commit 0ca1ec2269
3 changed files with 31 additions and 0 deletions

View file

@ -54,6 +54,11 @@ std::shared_ptr<RadarProductView> RadarProductViewFactory::Create(
} }
else if (productGroup == common::RadarProductGroup::Level3) else if (productGroup == common::RadarProductGroup::Level3)
{ {
if (productCode == 0)
{
productCode = common::GetLevel3ProductCodeByAwipsId(productName);
}
if (level3RadialProducts_.contains(productCode)) if (level3RadialProducts_.contains(productCode))
{ {
view = Level3RadialView::Create(productName, radarProductManager); view = Level3RadialView::Create(productName, radarProductManager);

View file

@ -72,6 +72,8 @@ const std::string& GetLevel3Palette(int16_t productCode);
std::string GetLevel3ProductByAwipsId(const std::string& awipsId); std::string GetLevel3ProductByAwipsId(const std::string& awipsId);
const std::string& GetLevel3ProductDescription(const std::string& productName); const std::string& GetLevel3ProductDescription(const std::string& productName);
int16_t GetLevel3ProductCodeByAwipsId(const std::string& awipsId);
int16_t GetLevel3ProductCodeByProduct(const std::string& productName);
const std::vector<std::string>& const std::vector<std::string>&
GetLevel3ProductsByCategory(Level3ProductCategory category); GetLevel3ProductsByCategory(Level3ProductCategory category);
const std::vector<std::string>& const std::vector<std::string>&

View file

@ -329,6 +329,30 @@ const std::string& GetLevel3ProductDescription(const std::string& productName)
} }
} }
int16_t GetLevel3ProductCodeByAwipsId(const std::string& awipsId)
{
const std::string& productName {GetLevel3ProductByAwipsId(awipsId)};
const int16_t productCode {GetLevel3ProductCodeByProduct(productName)};
return productCode;
}
int16_t GetLevel3ProductCodeByProduct(const std::string& productName)
{
auto it = std::find_if(level3ProductCodeMap_.cbegin(),
level3ProductCodeMap_.cend(),
[&](auto&& p) { return p.second == productName; });
if (it != level3ProductCodeMap_.cend())
{
return static_cast<int16_t>(it->first);
}
else
{
return 0;
}
}
const std::vector<std::string>& const std::vector<std::string>&
GetLevel3ProductsByCategory(Level3ProductCategory category) GetLevel3ProductsByCategory(Level3ProductCategory category)
{ {