From d346795e89a2fee692f9b79a9e382dfd927c3f91 Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Tue, 4 Apr 2017 19:05:58 +0300 Subject: [PATCH] rb countries fix --- map/framework.cpp | 2 ++ map/place_page_info.cpp | 4 ++-- map/place_page_info.hpp | 9 +++++++-- partners_api/ads_engine.cpp | 29 +++++++++++++++++++---------- partners_api/ads_engine.hpp | 4 ++-- partners_api/rb_ads.cpp | 4 ++-- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index 00d0d5be45..cbebdcb309 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2241,6 +2241,7 @@ void Framework::UpdatePlacePageInfoForCurrentSelection() df::SelectionShape::ESelectedObject const obj = OnTapEventImpl(*m_lastTapEvent, info); info.m_countryId = m_infoGetter->GetRegionCountryId(info.GetMercator()); + GetStorage().GetTopmostNodesFor(info.m_countryId, info.m_topmostCountryIds); if (obj != df::SelectionShape::OBJECT_EMPTY) ActivateMapSelection(false, obj, info); } @@ -2295,6 +2296,7 @@ void Framework::OnTapEvent(TapEvent const & tapEvent) if (info.m_countryId.empty()) info.m_countryId = m_infoGetter->GetRegionCountryId(info.GetMercator()); + GetStorage().GetTopmostNodesFor(info.m_countryId, info.m_topmostCountryIds); ActivateMapSelection(true, selection, info); } diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index f53d32553a..ac50114537 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -181,7 +181,7 @@ bool Info::HasBanner() const if (IsMyPosition()) return false; - return m_adsEngine->HasBanner(m_types, m_countryId); + return m_adsEngine->HasBanner(m_types, m_topmostCountryIds); } vector Info::GetBanners() const @@ -189,7 +189,7 @@ vector Info::GetBanners() const if (!m_adsEngine) return {}; - return m_adsEngine->GetBanners(m_types, m_countryId); + return m_adsEngine->GetBanners(m_types, m_topmostCountryIds); } bool Info::IsReachableByTaxi() const diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index 8b0cefe12a..f218cde93c 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -124,9 +124,14 @@ public: string m_sponsoredDescriptionUrl; string m_sponsoredReviewUrl; - /// Which country this MapObject is in. - /// For a country point it will be set to topmost node for country. + /// Which mwm this MapObject is in. + /// Exception: for a country-name point it will be set to the topmost node for the mwm. + /// TODO(@a): use m_topmostCountryIds in exceptional case. storage::TCountryId m_countryId = storage::kInvalidCountryId; + /// The topmost downloader nodes this MapObject is in, i.e. + /// the country name for an object whose mwm represents only + /// one part of the country (or several countries for disputed territories). + storage::TCountriesVec m_topmostCountryIds; bool m_isMyPosition = false; /// True if editing of a selected point is allowed by basic logic. diff --git a/partners_api/ads_engine.cpp b/partners_api/ads_engine.cpp index 6a802a2388..a080733aff 100644 --- a/partners_api/ads_engine.cpp +++ b/partners_api/ads_engine.cpp @@ -18,23 +18,32 @@ Engine::Engine() } bool Engine::HasBanner(feature::TypesHolder const & types, - storage::TCountryId const & countryId) const + storage::TCountriesVec const & countryIds) const { - return std::any_of(m_containers.cbegin(), m_containers.cend(), - [&types, &countryId](ContainerItem const & item) { - return item.m_container->HasBanner(types, countryId); - }); + for (auto const & countryId : countryIds) + { + for (auto const & item : m_containers) + { + if (item.m_container->HasBanner(types, countryId)) + return true; + } + } + + return false; } std::vector Engine::GetBanners(feature::TypesHolder const & types, - storage::TCountryId const & countryId) const + storage::TCountriesVec const & countryIds) const { std::vector banners; - for (auto const & item : m_containers) + for (auto const & countryId : countryIds) { - auto const bannerId = item.m_container->GetBannerId(types, countryId); - if (!bannerId.empty()) - banners.emplace_back(item.m_type, bannerId); + for (auto const & item : m_containers) + { + auto const bannerId = item.m_container->GetBannerId(types, countryId); + if (!bannerId.empty()) + banners.emplace_back(item.m_type, bannerId); + } } return banners; diff --git a/partners_api/ads_engine.hpp b/partners_api/ads_engine.hpp index 0d7f931801..b1c2f4f661 100644 --- a/partners_api/ads_engine.hpp +++ b/partners_api/ads_engine.hpp @@ -19,9 +19,9 @@ class Engine public: Engine(); - bool HasBanner(feature::TypesHolder const & types, storage::TCountryId const & countryId) const; + bool HasBanner(feature::TypesHolder const & types, storage::TCountriesVec const & countryIds) const; std::vector GetBanners(feature::TypesHolder const & types, - storage::TCountryId const & countryId) const; + storage::TCountriesVec const & countryIds) const; private: using ContainerPtr = std::unique_ptr; diff --git a/partners_api/rb_ads.cpp b/partners_api/rb_ads.cpp index bb4db467af..23a7d2d10c 100644 --- a/partners_api/rb_ads.cpp +++ b/partners_api/rb_ads.cpp @@ -17,13 +17,13 @@ auto const kBannerIdForOtherTypes = "14"; std::vector const kSupportedCountries = { - "Azerbaijan", + "Azerbaijan Region", "Armenia", "Belarus", "Kazakhstan", "Kyrgyzstan", "Moldova", - "Russia", + "Russian Federation", "Tajikistan", "Turkmenistan", "Uzbekistan",