diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index d0b294be5b..7ba86bf400 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -7,6 +7,7 @@ #include "indexer/scales.hpp" #include "platform/localization.hpp" +#include "platform/distance.hpp" #include "coding/string_utf8_multilang.hpp" #include "coding/transliteration.hpp" @@ -316,6 +317,7 @@ FeatureEstimator const & GetFeatureEstimator() } // namespace static constexpr std::string_view kStarSymbol = "★"; +static constexpr std::string_view kMountainSymbol= "▲"; NameParamsIn::NameParamsIn(StringUtf8Multilang const & src_, RegionData const & regionData_, std::string_view deviceLang_, bool allowTranslit_) @@ -482,4 +484,17 @@ string FormatStars(uint8_t starsCount) return stars; } +string FormatElevation(string_view elevation) +{ + if (!elevation.empty()) + { + double value; + if (strings::to_double(elevation, value)) + return std::string{kMountainSymbol} + platform::Distance::FormatAltitude(value); + else + LOG(LWARNING, ("Invalid elevation metadata:", elevation)); + } + return {}; +} + } // namespace feature diff --git a/indexer/feature_utils.hpp b/indexer/feature_utils.hpp index 7c47c25787..c62bae61ff 100644 --- a/indexer/feature_utils.hpp +++ b/indexer/feature_utils.hpp @@ -144,4 +144,7 @@ namespace feature /// @returns starsCount of ★ symbol. std::string FormatStars(uint8_t starsCount); + /// @returns formatted elevation with ▲ symbol and units. + std::string FormatElevation(std::string_view elevation); + } // namespace feature diff --git a/indexer/map_object.cpp b/indexer/map_object.cpp index c4462c4fb0..dc7d48ebd8 100644 --- a/indexer/map_object.cpp +++ b/indexer/map_object.cpp @@ -203,20 +203,6 @@ int MapObject::GetStars() const return count; } -string MapObject::GetElevationFormatted() const -{ - auto const sv = m_metadata.Get(MetadataID::FMD_ELE); - if (!sv.empty()) - { - double value; - if (strings::to_double(sv, value)) - return platform::Distance::FormatAltitude(value); - else - LOG(LWARNING, ("Invalid elevation metadata:", sv)); - } - return {}; -} - ftraits::WheelchairAvailability MapObject::GetWheelchairType() const { auto const opt = ftraits::Wheelchair::GetValue(m_types); diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index 7ed6070dd3..5778f24360 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -104,9 +104,6 @@ public: /// @returns true if feature has Toilets type. bool HasToilets() const; - - /// @returns formatted elevation in feet or meters, or empty string. - std::string GetElevationFormatted() const; /// @} bool IsPointType() const; diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 4d75e5749d..4fdeab5090 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -19,7 +19,6 @@ namespace place_page { -static constexpr std::string_view kMountainSymbol= "▲"; static constexpr std::string_view kWheelchairSymbol = "♿️"; static constexpr std::string_view kAtmSymbol = "💳"; @@ -172,9 +171,9 @@ std::string Info::FormatSubtitle(bool withType) const } // Elevation. - auto const eleStr = GetElevationFormatted(); + auto const eleStr = feature::FormatElevation(GetMetadata(MetadataID::FMD_ELE)); if (!eleStr.empty()) - append(std::string{kMountainSymbol} + eleStr); + append(eleStr); // ATM if (HasAtm())