diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index dfe0a32004..59bac21c1c 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -476,6 +476,18 @@ IsFoodChecker const & IsFoodChecker::Instance() return instance; } +IsOpentableChecker::IsOpentableChecker() +{ + Classificator const & c = classif(); + m_types.push_back(c.GetTypeByPath({"sponsored", "opentable"})); +} + +IsOpentableChecker const & IsOpentableChecker::Instance() +{ + static IsOpentableChecker const inst; + return inst; +} + uint32_t GetPopulation(FeatureType const & ft) { uint32_t population = ft.GetPopulation(); diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index 17d1e77665..48d1dcfd97 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -184,6 +184,14 @@ public: static IsFoodChecker const & Instance(); }; +class IsOpentableChecker : public BaseChecker +{ + IsOpentableChecker(); + +public: + static IsOpentableChecker const & Instance(); +}; + /// Type of locality (do not change values and order - they have detalization order) /// COUNTRY < STATE < CITY < ... enum Type { NONE = -1, COUNTRY = 0, STATE, CITY, TOWN, VILLAGE, LOCALITY_COUNT }; diff --git a/map/framework.cpp b/map/framework.cpp index 110352c18a..2429def14d 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -789,17 +789,22 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info if (ftypes::IsAddressObjectChecker::Instance()(ft)) info.m_address = GetAddressInfoAtPoint(feature::GetCenter(ft)).FormatHouseAndStreet(); - info.m_isHotel = ftypes::IsHotelChecker::Instance()(ft); if (ftypes::IsBookingChecker::Instance()(ft)) { - info.m_isSponsoredHotel = true; + info.m_sponsoredType = SponsoredType::Booking; string const & baseUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE); - info.m_sponsoredBookingUrl = GetBookingApi().GetBookingUrl(baseUrl); + info.m_sponsoredUrl = GetBookingApi().GetBookingUrl(baseUrl); info.m_sponsoredDescriptionUrl = GetBookingApi().GetDescriptionUrl(baseUrl); } + else if (ftypes::IsOpentableChecker::Instance()(ft)) + { + info.m_sponsoredType = SponsoredType::Opentable; + info.m_sponsoredUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE); + } + info.m_canEditOrAdd = featureStatus != osm::Editor::FeatureStatus::Obsolete && CanEditMap() && - !info.IsSponsoredHotel(); + !info.IsSponsored(); info.m_localizedWifiString = m_stringsBundle.GetString("wifi"); info.m_localizedRatingString = m_stringsBundle.GetString("place_page_booking_rating"); @@ -1979,7 +1984,7 @@ void Framework::ActivateMapSelection(bool needAnimation, df::SelectionShape::ESe CallDrapeFunction(bind(&df::DrapeEngine::SelectObject, _1, selectionType, info.GetMercator(), info.GetID(), needAnimation)); - SetDisplacementMode(DisplacementModeManager::SLOT_MAP_SELECTION, info.IsHotel() /* show */); + SetDisplacementMode(DisplacementModeManager::SLOT_MAP_SELECTION, ftypes::IsHotelChecker::Instance()(info.GetTypes()) /* show */); if (m_activateMapSelectionFn) m_activateMapSelectionFn(info); @@ -2055,7 +2060,7 @@ void Framework::OnTapEvent(TapEvent const & tapEvent) // Older version of statistics used "$GetUserMark" event. alohalytics::Stats::Instance().LogEvent("$SelectMapObject", kv, alohalytics::Location::FromLatLon(ll.lat, ll.lon)); - if (info.IsHotel()) + if (info.m_sponsoredType == SponsoredType::Booking) GetPlatform().SendMarketingEvent("Placepage_Hotel_book", {{"provider", "booking.com"}}); } diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 8e63bc5803..2d5e30b1bf 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -16,8 +16,7 @@ char const * const Info::kPricingSymbol = "$"; bool Info::IsFeature() const { return m_featureID.IsValid(); } bool Info::IsBookmark() const { return m_bac.IsValid(); } bool Info::IsMyPosition() const { return m_isMyPosition; } -bool Info::IsSponsoredHotel() const { return m_isSponsoredHotel; } -bool Info::IsHotel() const { return m_isHotel; } +bool Info::IsSponsored() const { return m_sponsoredType != SponsoredType::None; } bool Info::ShouldShowAddPlace() const { auto const isPointOrBuilding = IsPointType() || IsBuilding(); @@ -116,12 +115,12 @@ BookmarkAndCategory Info::GetBookmarkAndCategory() const { return m_bac; } string Info::GetBookmarkCategoryName() const { return m_bookmarkCategoryName; } string const & Info::GetApiUrl() const { return m_apiUrl; } -string const & Info::GetSponsoredBookingUrl() const { return m_sponsoredBookingUrl; } +string const & Info::GetSponsoredUrl() const { return m_sponsoredUrl; } string const & Info::GetSponsoredDescriptionUrl() const {return m_sponsoredDescriptionUrl; } string Info::GetRatingFormatted() const { - if (!IsSponsoredHotel()) + if (!IsSponsored()) return string(); auto const r = GetMetadata().Get(feature::Metadata::FMD_RATING); @@ -140,7 +139,7 @@ string Info::GetRatingFormatted() const string Info::GetApproximatePricing() const { - if (!IsSponsoredHotel()) + if (!IsSponsored()) return string(); int pricing; diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index 2a150f4b43..29f9bc42be 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -14,6 +14,14 @@ #include "std/string.hpp" +enum class SponsoredType +{ + None, + Booking, + Opentable, + Geochat +}; + namespace place_page { class Info : public osm::MapObject @@ -28,8 +36,7 @@ public: bool IsFeature() const; bool IsBookmark() const; bool IsMyPosition() const; - bool IsSponsoredHotel() const; - bool IsHotel() const; + bool IsSponsored() const; bool ShouldShowAddPlace() const; bool ShouldShowAddBusiness() const; @@ -62,7 +69,7 @@ public: string GetBookmarkCategoryName() const; string const & GetApiUrl() const; - string const & GetSponsoredBookingUrl() const; + string const & GetSponsoredUrl() const; string const & GetSponsoredDescriptionUrl() const; /// @returns formatted rating string for booking object, or empty if it isn't booking object @@ -90,12 +97,11 @@ public: string m_apiUrl; /// Formatted feature address. string m_address; - /// Feature is a hotel. - bool m_isHotel = false; - /// Feature is a sponsored hotel. - bool m_isSponsoredHotel = false; + /// Sponsored type or None. + SponsoredType m_sponsoredType = SponsoredType::None; + /// Sponsored feature urls. - string m_sponsoredBookingUrl; + string m_sponsoredUrl; string m_sponsoredDescriptionUrl; /// Which country this MapObject is in.