diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2019-05-21 20:19:28 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2019-05-22 21:13:05 +0300 |
commit | fa59cb2a6a97839d035f33127aff5e38d334a85a (patch) | |
tree | 663d403874b8ac0a7f7273cc1ef90d355e11d7b7 /map | |
parent | 98045752e4c87c0714c2a6619591eee9e069c0a2 (diff) |
[core] cross reference api + tests + framework integration
Diffstat (limited to 'map')
-rw-r--r-- | map/CMakeLists.txt | 2 | ||||
-rw-r--r-- | map/cross_reference_delegate.cpp | 31 | ||||
-rw-r--r-- | map/cross_reference_delegate.hpp | 26 | ||||
-rw-r--r-- | map/framework.cpp | 19 | ||||
-rw-r--r-- | map/framework.hpp | 3 | ||||
-rw-r--r-- | map/place_page_info.hpp | 3 |
6 files changed, 83 insertions, 1 deletions
diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt index e89a3f48e7..29b8a66f78 100644 --- a/map/CMakeLists.txt +++ b/map/CMakeLists.txt @@ -16,6 +16,8 @@ set( benchmark_tools.cpp booking_availability_filter.cpp booking_availability_filter.hpp + cross_reference_delegate.cpp + cross_reference_delegate.hpp booking_filter.hpp booking_filter_cache.cpp booking_filter_cache.hpp diff --git a/map/cross_reference_delegate.cpp b/map/cross_reference_delegate.cpp new file mode 100644 index 0000000000..2f259dc615 --- /dev/null +++ b/map/cross_reference_delegate.cpp @@ -0,0 +1,31 @@ +#include "map/cross_reference_delegate.hpp" + +#include "search/city_finder.hpp" + +#include "indexer/data_source.hpp" +#include "indexer/ftypes_sponsored.hpp" + +CrossReferenceDelegate::CrossReferenceDelegate(DataSource const & dataSource, + search::CityFinder & cityFinder) + : m_dataSource(dataSource) + , m_cityFinder(cityFinder) +{ +} + +std::string CrossReferenceDelegate::GetCityOsmId(m2::PointD const & point) +{ + auto const featureId = m_cityFinder.GetCityFeatureID(point); + + if (!featureId.IsValid()) + return {}; + + FeaturesLoaderGuard guard(m_dataSource, featureId.m_mwmId); + auto feature = guard.GetOriginalFeatureByIndex(featureId.m_index); + if (!feature) + return {}; + + if (ftypes::IsCrossReferenceCityChecker::Instance()(*feature)) + return feature->GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID); + + return {}; +} diff --git a/map/cross_reference_delegate.hpp b/map/cross_reference_delegate.hpp new file mode 100644 index 0000000000..48a6fa766c --- /dev/null +++ b/map/cross_reference_delegate.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "partners_api/cross_reference_api.hpp" + +#include "geometry/point2d.hpp" + +#include <string> + +class DataSource; + +namespace search +{ + class CityFinder; +} + +class CrossReferenceDelegate : public cross_reference::Api::Delegate +{ +public: + CrossReferenceDelegate(DataSource const & dataSource, search::CityFinder & cityFinder); + + std::string GetCityOsmId(m2::PointD const & point) override; + +private: + DataSource const & m_dataSource; + search::CityFinder & m_cityFinder; +}; diff --git a/map/framework.cpp b/map/framework.cpp index bcf4c25c75..e4d390cce0 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1,6 +1,7 @@ #include "map/framework.hpp" #include "map/benchmark_tools.hpp" #include "map/chart_generator.hpp" +#include "map/cross_reference_delegate.hpp" #include "map/displayed_categories_modifiers.hpp" #include "map/everywhere_search_params.hpp" #include "map/ge0_parser.hpp" @@ -575,6 +576,9 @@ Framework::Framework(FrameworkParams const & params) GetPowerManager().Subscribe(this); GetPowerManager().Load(); + + m_crossReferenceApi->SetDelegate(make_unique<CrossReferenceDelegate>(m_model.GetDataSource(), + *m_cityFinder)); } Framework::~Framework() @@ -639,6 +643,15 @@ locals::Api * Framework::GetLocalsApi(platform::NetworkPolicy const & policy) return nullptr; } +cross_reference::Api * Framework::GetCrossReferenceApi(platform::NetworkPolicy const & policy) const +{ + ASSERT(m_crossReferenceApi, ()); + if (policy.CanUse()) + return m_crossReferenceApi.get(); + + return nullptr; +} + void Framework::ShowNode(storage::CountryId const & countryId) { StopLocationFollow(); @@ -955,6 +968,10 @@ void Framework::FillInfoFromFeatureType(FeatureType & ft, place_page::Info & inf { info.SetSponsoredType(place_page::SponsoredType::Holiday); } + else if (ftypes::IsCrossReferenceCityChecker::Instance()(ft)) + { + info.SetSponsoredType(SponsoredType::CrossReference); + } FillLocalExperts(ft, info); FillDescription(ft, info); @@ -1481,6 +1498,8 @@ void Framework::EnterForeground() m_trafficManager.OnEnterForeground(); m_routingManager.SetAllowSendingPoints(true); + + m_crossReferenceApi->OnEnterForeground(); } void Framework::InitCountryInfoGetter() diff --git a/map/framework.hpp b/map/framework.hpp index d4a135a53d..7f66e9fe5f 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -62,6 +62,7 @@ #include "partners_api/banner.hpp" #include "partners_api/booking_api.hpp" +#include "partners_api/cross_reference_api.hpp" #include "partners_api/locals_api.hpp" #include "partners_api/taxi_engine.hpp" @@ -229,6 +230,7 @@ protected: unique_ptr<booking::Api> m_bookingApi = make_unique<booking::Api>(); unique_ptr<locals::Api> m_localsApi = make_unique<locals::Api>(); + unique_ptr<cross_reference::Api> m_crossReferenceApi = make_unique<cross_reference::Api>(); df::DrapeApi m_drapeApi; @@ -276,6 +278,7 @@ public: booking::Api const * GetBookingApi(platform::NetworkPolicy const & policy) const; taxi::Engine * GetTaxiEngine(platform::NetworkPolicy const & policy); locals::Api * GetLocalsApi(platform::NetworkPolicy const & policy); + cross_reference::Api * GetCrossReferenceApi(platform::NetworkPolicy const & policy) const; ugc::Api * GetUGCApi() { return m_ugcApi.get(); } ugc::Api const * GetUGCApi() const { return m_ugcApi.get(); } diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index b747b0a605..3394d2fb65 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -45,7 +45,8 @@ enum class SponsoredType Booking, Opentable, Partner, - Holiday + Holiday, + CrossReference, }; enum class LocalAdsStatus |