From 37bfc0b65be9138bdb4c8e579d03b53b19cd6a90 Mon Sep 17 00:00:00 2001 From: Harry Bond Date: Mon, 5 Feb 2024 10:52:25 +0000 Subject: [PATCH] add local_ref to transport stop titles (better localisation in future pr) Signed-off-by: Harry Bond --- indexer/map_object.cpp | 1 + indexer/map_object.hpp | 3 +++ map/place_page_info.cpp | 41 ++++++++++++++++++++++++++++++++++------- map/place_page_info.hpp | 1 + 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/indexer/map_object.cpp b/indexer/map_object.cpp index 47f86351b6..e55446185f 100644 --- a/indexer/map_object.cpp +++ b/indexer/map_object.cpp @@ -225,5 +225,6 @@ ftraits::WheelchairAvailability MapObject::GetWheelchairType() const bool MapObject::IsPointType() const { return m_geomType == feature::GeomType::Point; } bool MapObject::IsBuilding() const { return ftypes::IsBuildingChecker::Instance()(m_types); } +bool MapObject::IsPublicTransportStop() const { return ftypes::IsPublicTransportStopChecker::Instance()(m_types); } } // namespace osm diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index fac65d2741..15a83b1628 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -119,6 +119,9 @@ public: /// @returns true if object is of building type. bool IsBuilding() const; + /// @returns true if object is a public transport stop type. + bool IsPublicTransportStop() const; + void AssignMetadata(feature::Metadata & dest) const { dest = m_metadata; } protected: diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 795c7423a7..b818e69f20 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -67,12 +67,25 @@ void Info::SetFromFeatureType(FeatureType & ft) m_uiSubtitle = FormatSubtitle(true /* withType */); m_uiAddress = m_address; } - else if (!m_primaryFeatureName.empty()) + else if (IsPublicTransportStop()) { - m_uiTitle = m_primaryFeatureName; - m_uiSecondaryTitle = out.secondary; - m_uiSubtitle = FormatSubtitle(true /* withType */); - m_uiAddress = m_address; + const std::string local_ref = std::string(GetMetadata(feature::Metadata::FMD_LOCAL_REF)); + + if (!local_ref.empty()) // has local ref + { + if (!m_primaryFeatureName.empty()) // has name and local_ref + { + m_uiTitle = m_primaryFeatureName + " (" + local_ref + ")"; + m_uiSubtitle = FormatSubtitle(true /* withType */); + } + else // no name but has local_ref + { + m_uiTitle = GetLocalizedType() + " (" + local_ref + ")"; + m_uiSubtitle = FormatSubtitle(false /* withType */); + } + } + else + SetStandardValues(out); } else if (IsBuilding()) { @@ -80,14 +93,28 @@ void Info::SetFromFeatureType(FeatureType & ft) m_uiTitle = isAddressEmpty ? GetLocalizedType() : m_address; m_uiSubtitle = FormatSubtitle(!isAddressEmpty /* withType */); } + else + SetStandardValues(out); + + // apply to all types after checks + m_hotelType = ftypes::IsHotelChecker::Instance().GetHotelType(ft); +} + +void Info::SetStandardValues(feature::NameParamsOut out) +{ + if (!m_primaryFeatureName.empty()) + { + m_uiTitle = m_primaryFeatureName; + m_uiSecondaryTitle = out.secondary; + m_uiSubtitle = FormatSubtitle(true /* withType */); + m_uiAddress = m_address; + } else { m_uiTitle = GetLocalizedType(); m_uiSubtitle = FormatSubtitle(false /* withType */); m_uiAddress = m_address; } - - m_hotelType = ftypes::IsHotelChecker::Instance().GetHotelType(ft); } void Info::SetMercator(m2::PointD const & mercator) diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index ca8079f084..0500efc2ab 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -209,6 +209,7 @@ public: void SetWikiDescription(std::string && description) { m_description = std::move(description); } void SetMercator(m2::PointD const & mercator); + void SetStandardValues(feature::NameParamsOut out); std::vector GetRawTypes() const { return m_types.ToObjectNames(); } std::optional GetHotelType() const { return m_hotelType; }