From debe86bad6065736daac35e391ece4053dbb0590 Mon Sep 17 00:00:00 2001 From: David Martinez <47610359+dvdmrtnz@users.noreply.github.com> Date: Sat, 4 Nov 2023 12:08:59 +0100 Subject: [PATCH] [core] Add Paid/Free indicator to Place Page Signed-off-by: David Martinez <47610359+dvdmrtnz@users.noreply.github.com> --- indexer/feature_utils.cpp | 11 +++++++++++ indexer/feature_utils.hpp | 4 ++++ indexer/ftypes_matcher.cpp | 6 ++++++ indexer/ftypes_matcher.hpp | 8 ++++++++ indexer/map_object.cpp | 5 +++++ indexer/map_object.hpp | 2 ++ map/place_page_info.cpp | 5 +++++ 7 files changed, 41 insertions(+) diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index 89048f4eaa..b3bd659ed4 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -427,4 +427,15 @@ vector GetLocalizedRecyclingTypes(TypesHolder const & types) auto const & isRecyclingType = ftypes::IsRecyclingTypeChecker::Instance(); return GetLocalizedTypes(isRecyclingType, types); } + +string GetLocalizedFeeType(TypesHolder const & types) +{ + auto const & isFeeType = ftypes::IsFeeTypeChecker::Instance(); + auto localized_types = GetLocalizedTypes(isFeeType, types); + ASSERT_LESS_OR_EQUAL ( localized_types.size(), 1, () ); + if (localized_types.empty()) + return ""; + return localized_types[0]; +} + } // namespace feature diff --git a/indexer/feature_utils.hpp b/indexer/feature_utils.hpp index e76ca05762..823caffb58 100644 --- a/indexer/feature_utils.hpp +++ b/indexer/feature_utils.hpp @@ -125,4 +125,8 @@ namespace feature // Returns vector of recycling types localized by platform. std::vector GetLocalizedRecyclingTypes(TypesHolder const & types); + + // Returns fee type localized by platform. + std::string GetLocalizedFeeType(TypesHolder const & types); + } // namespace feature diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index e69473a0be..6473487f4c 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -749,6 +749,12 @@ IsRecyclingTypeChecker::IsRecyclingTypeChecker() : BaseChecker(1 /* level */) m_types.push_back(c.GetTypeByPath({"recycling"})); } +IsFeeTypeChecker::IsFeeTypeChecker() : BaseChecker(1 /* level */) +{ + Classificator const & c = classif(); + m_types.push_back(c.GetTypeByPath({"fee"})); +} + IsCityChecker::IsCityChecker() { m_types.push_back(classif().GetTypeByPath({"place", "city"})); diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index 8c7e6ab00e..52469a168d 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -467,6 +467,14 @@ public: DECLARE_CHECKER_INSTANCE(IsRecyclingTypeChecker); }; +class IsFeeTypeChecker : public BaseChecker +{ + IsFeeTypeChecker(); + +public: + DECLARE_CHECKER_INSTANCE(IsFeeTypeChecker); +}; + class IsCityChecker : public BaseChecker { IsCityChecker(); diff --git a/indexer/map_object.cpp b/indexer/map_object.cpp index 55eec6b273..6bc4d03fa8 100644 --- a/indexer/map_object.cpp +++ b/indexer/map_object.cpp @@ -163,6 +163,11 @@ vector MapObject::GetLocalizedRecyclingTypes() const return feature::GetLocalizedRecyclingTypes(m_types); } +string MapObject::GetLocalizedFeeType() const +{ + return feature::GetLocalizedFeeType(m_types); +} + string MapObject::FormatCuisines() const { return strings::JoinStrings(GetLocalizedCuisines(), kFieldsSeparator); diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index 9113b48e3d..e38da0c592 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -88,6 +88,8 @@ public: std::vector GetRecyclingTypes() const; /// @returns translated recycling type(s). std::vector GetLocalizedRecyclingTypes() const; + /// @returns translated fee type. + std::string GetLocalizedFeeType() const; /// @returns translated and formatted cuisines. std::string FormatCuisines() const; diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 8bb53fd776..acf20bbff4 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -171,6 +171,11 @@ std::string Info::FormatSubtitle(bool withType) const if (GetWheelchairType() == ftraits::WheelchairAvailability::Yes) append(kWheelchairSymbol); + // Fee. + auto const fee = GetLocalizedFeeType(); + if (!fee.empty()) + append(fee); + return result; }