Update radar site text

This commit is contained in:
Dan Paulat 2022-05-28 22:45:30 -05:00
parent f6262bba65
commit f71391e3b9
6 changed files with 70 additions and 7 deletions

View file

@ -3,6 +3,7 @@
#include <scwx/common/sites.hpp>
#include <scwx/util/logger.hpp>
#include <format>
#include <unordered_map>
namespace scwx
@ -90,6 +91,29 @@ std::string RadarSite::place() const
return p->place_;
}
std::string RadarSite::location_name() const
{
std::string locationName;
if (p->country_ == "USA")
{
locationName = std::format("{}, {}", p->place_, p->state_);
}
else if (std::all_of(p->state_.cbegin(),
p->state_.cend(),
[](char c) { return std::isdigit(c); }))
{
locationName = std::format("{}, {}", p->place_, p->country_);
}
else
{
locationName =
std::format("{}, {}, {}", p->place_, p->state_, p->country_);
}
return locationName;
}
std::shared_ptr<RadarSite> RadarSite::Get(const std::string& id)
{
std::shared_ptr<RadarSite> radarSite = nullptr;

View file

@ -31,6 +31,7 @@ public:
std::string country() const;
std::string state() const;
std::string place() const;
std::string location_name() const;
static std::shared_ptr<RadarSite> Get(const std::string& id);