[partners_api] taxi engine city restrictions

This commit is contained in:
Arsentiy Milchakov 2017-06-29 17:59:07 +03:00 committed by Ilya Grechuhin
parent bf29a95338
commit 4a37b4a4ae
23 changed files with 504 additions and 94 deletions

View file

@ -58,6 +58,8 @@ set(
routing_manager.hpp
routing_mark.cpp
routing_mark.hpp
taxi_delegate.cpp
taxi_delegate.hpp
track.cpp
track.hpp
traffic_manager.cpp

View file

@ -5,6 +5,7 @@
#include "map/geourl_process.hpp"
#include "map/gps_tracker.hpp"
#include "map/mwm_tree.hpp"
#include "map/taxi_delegate.hpp"
#include "map/user_mark.hpp"
#include "defines.hpp"
@ -354,6 +355,7 @@ void Framework::Migrate(bool keepDownloaded)
m_selectedFeature = FeatureID();
m_searchEngine.reset();
m_infoGetter.reset();
m_taxiEngine.reset();
TCountriesVec existedCountries;
GetStorage().DeleteAllLocalMaps(&existedCountries);
DeregisterAllMaps();
@ -362,6 +364,7 @@ void Framework::Migrate(bool keepDownloaded)
InitCountryInfoGetter();
InitSearchEngine();
RegisterAllMaps();
InitTaxiEngine();
m_trafficManager.SetCurrentDataVersion(GetStorage().GetCurrentDataVersion());
if (m_drapeEngine && m_isRenderingEnabled)
@ -475,6 +478,7 @@ Framework::Framework(FrameworkParams const & params)
InitTransliteration();
LOG(LDEBUG, ("Transliterators initialized"));
InitTaxiEngine();
}
Framework::~Framework()
@ -921,6 +925,10 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info
{
info.m_localAdsStatus = place_page::LocalAdsStatus::NotAvailable;
}
auto const latlon = MercatorBounds::ToLatLon(feature::GetCenter(ft));
ASSERT(m_taxiEngine, ());
info.m_reachableByProviders = m_taxiEngine->GetProvidersAtPos(latlon);
}
void Framework::FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & info) const
@ -3295,3 +3303,15 @@ void Framework::RegisterCountryFilesOnRoute(std::shared_ptr<routing::NumMwmIds>
m_storage.ForEachCountryFile(
[&ptr](platform::CountryFile const & file) { ptr->RegisterFile(file); });
}
void Framework::InitTaxiEngine()
{
ASSERT(!m_taxiEngine, ());
ASSERT(m_infoGetter, ());
ASSERT(m_cityFinder, ());
m_taxiEngine = my::make_unique<taxi::Engine>();
m_taxiEngine->SetDelegate(
my::make_unique<TaxiDelegate>(GetStorage(), *m_infoGetter, *m_cityFinder));
}

View file

@ -181,7 +181,6 @@ protected:
unique_ptr<booking::Api> m_bookingApi = make_unique<booking::Api>();
unique_ptr<viator::Api> m_viatorApi = make_unique<viator::Api>();
unique_ptr<taxi::Engine> m_taxiEngine = make_unique<taxi::Engine>();
df::DrapeApi m_drapeApi;
@ -836,4 +835,10 @@ public:
private:
std::unique_ptr<search::CityFinder> m_cityFinder;
unique_ptr<ads::Engine> m_adsEngine;
// The order matters here: storage::CountryInfoGetter and
// search::CityFinder must be initialized before
// taxi::Engine and, therefore, destroyed after taxi::Engine.
unique_ptr<taxi::Engine> m_taxiEngine;
void InitTaxiEngine();
};

View file

@ -33,6 +33,7 @@ HEADERS += \
reachable_by_taxi_checker.hpp \
routing_manager.hpp \
routing_mark.hpp \
taxi_delegate.hpp \
track.hpp \
traffic_manager.hpp \
user_mark.hpp \
@ -64,6 +65,7 @@ SOURCES += \
reachable_by_taxi_checker.cpp \
routing_manager.cpp \
routing_mark.cpp \
taxi_delegate.cpp \
track.cpp \
traffic_manager.cpp \
user_mark.cpp \

View file

@ -215,9 +215,12 @@ vector<ads::Banner> Info::GetBanners() const
return m_adsEngine->GetBanners(m_types, m_topmostCountryIds, languages::GetCurrentNorm());
}
bool Info::IsReachableByTaxi() const
std::vector<taxi::Provider::Type> Info::ReachableByTaxiProviders() const
{
return IsReachableByTaxiChecker::Instance()(m_types);
if (!IsReachableByTaxiChecker::Instance()(m_types))
return {};
return m_reachableByProviders;
}
void Info::SetMercator(m2::PointD const & mercator) { m_mercator = mercator; }

View file

@ -1,6 +1,9 @@
#pragma once
#include "map/bookmark.hpp"
#include "partners_api/taxi_provider.hpp"
#include "map/routing_mark.hpp"
#include "storage/index.hpp"
@ -102,7 +105,7 @@ public:
bool HasBanner() const;
vector<ads::Banner> GetBanners() const;
bool IsReachableByTaxi() const;
std::vector<taxi::Provider::Type> ReachableByTaxiProviders() const;
void SetMercator(m2::PointD const & mercator);
@ -169,5 +172,7 @@ public:
LocalAdsStatus m_localAdsStatus = LocalAdsStatus::NotAvailable;
string m_localAdsUrl;
std::vector<taxi::Provider::Type> m_reachableByProviders;
};
} // namespace place_page

32
map/taxi_delegate.cpp Normal file
View file

@ -0,0 +1,32 @@
#include "map/taxi_delegate.hpp"
#include "map/city_finder.hpp"
#include "storage/country_info_getter.hpp"
#include "storage/index.hpp"
#include "storage/storage.hpp"
#include "coding/multilang_utf8_string.hpp"
#include "geometry/mercator.hpp"
TaxiDelegate::TaxiDelegate(storage::Storage const & st, storage::CountryInfoGetter const & ig,
CityFinder & cf)
: m_storage(st), m_infoGetter(ig), m_cityFinder(cf)
{
}
storage::TCountriesVec TaxiDelegate::GetCountryIds(ms::LatLon const & latlon)
{
m2::PointD const point = MercatorBounds::FromLatLon(latlon);
auto const countryId = m_infoGetter.GetRegionCountryId(point);
storage::TCountriesVec topmostCountryIds;
m_storage.GetTopmostNodesFor(countryId, topmostCountryIds);
return topmostCountryIds;
}
std::string TaxiDelegate::GetCityName(ms::LatLon const & latlon)
{
m2::PointD const point = MercatorBounds::FromLatLon(latlon);
return m_cityFinder.GetCityName(point, StringUtf8Multilang::kEnglishCode);
}

25
map/taxi_delegate.hpp Normal file
View file

@ -0,0 +1,25 @@
#pragma once
#include "partners_api/taxi_engine.hpp"
namespace storage
{
class Storage;
class CountryInfoGetter;
}
class CityFinder;
class TaxiDelegate : public taxi::Delegate
{
public:
TaxiDelegate(storage::Storage const & st, storage::CountryInfoGetter const & ig, CityFinder & cf);
storage::TCountriesVec GetCountryIds(ms::LatLon const & latlon) override;
std::string GetCityName(ms::LatLon const & latlon) override;
private:
storage::Storage const & m_storage;
storage::CountryInfoGetter const & m_infoGetter;
CityFinder & m_cityFinder;
};

View file

@ -19,9 +19,13 @@ set(
opentable_api.hpp
rb_ads.cpp
rb_ads.hpp
taxi_base.cpp
taxi_base.hpp
taxi_countries.cpp
taxi_countries.hpp
taxi_engine.cpp
taxi_engine.hpp
taxi_places.hpp
taxi_provider.hpp
uber_api.cpp
uber_api.hpp

View file

@ -16,6 +16,8 @@ SOURCES += \
mopub_ads.cpp \
opentable_api.cpp \
rb_ads.cpp \
taxi_base.cpp \
taxi_countries.cpp \
taxi_engine.cpp \
uber_api.cpp \
viator_api.cpp \
@ -31,7 +33,9 @@ HEADERS += \
opentable_api.hpp \
rb_ads.hpp \
taxi_base.hpp \
taxi_countries.hpp \
taxi_engine.hpp \
taxi_places.hpp \
taxi_provider.hpp \
uber_api.hpp \
viator_api.cpp \

View file

@ -6,10 +6,18 @@
#include "geometry/latlon.hpp"
#include "base/scope_guard.hpp"
#include "base/stl_add.hpp"
namespace
{
class TaxiDelegateForTrsting : public taxi::Delegate
{
public:
storage::TCountriesVec GetCountryIds(ms::LatLon const & latlon) override { return {"Belarus"}; }
std::string GetCityName(ms::LatLon const & latlon) override { return "Minsk"; }
};
std::vector<taxi::Product> GetUberSynchronous(ms::LatLon const & from, ms::LatLon const & to,
std::string const & url)
{
@ -46,13 +54,24 @@ std::vector<taxi::Product> GetYandexSynchronous(ms::LatLon const & from, ms::Lat
return yandexProducts;
}
taxi::ProvidersContainer GetProvidersSynchronous(ms::LatLon const & from, ms::LatLon const & to,
taxi::ProvidersContainer GetProvidersSynchronous(taxi::Engine const & engine,
ms::LatLon const & from, ms::LatLon const & to,
std::string const & url)
{
taxi::ProvidersContainer providers;
providers.emplace_back(taxi::Provider::Type::Uber, GetUberSynchronous(from, to, url));
providers.emplace_back(taxi::Provider::Type::Yandex, GetYandexSynchronous(from, to, url));
for (auto const provider : engine.GetProvidersAtPos(from))
{
switch (provider)
{
case taxi::Provider::Type::Uber:
providers.emplace_back(taxi::Provider::Type::Uber, GetUberSynchronous(from, to, url));
break;
case taxi::Provider::Type::Yandex:
providers.emplace_back(taxi::Provider::Type::Yandex, GetYandexSynchronous(from, to, url));
break;
}
}
return providers;
}
@ -236,33 +255,36 @@ UNIT_TEST(TaxiEngine_Smoke)
testing::StopEventLoop();
};
taxi::ProvidersContainer const synchronousProviders = GetProvidersSynchronous(from, to, kTesturl);
taxi::Engine engine(
{{taxi::Provider::Type::Uber, kTesturl}, {taxi::Provider::Type::Yandex, kTesturl}});
engine.SetDelegate(my::make_unique<TaxiDelegateForTrsting>());
taxi::ProvidersContainer const synchronousProviders =
GetProvidersSynchronous(engine, from, to, kTesturl);
{
taxi::Engine engine(
{{taxi::Provider::Type::Uber, kTesturl}, {taxi::Provider::Type::Yandex, kTesturl}});
{
lock_guard<mutex> lock(resultsMutex);
reqId = engine.GetAvailableProducts(
ms::LatLon(55.753960, 37.624513), ms::LatLon(55.765866, 37.661270),
{"Brazil", "Russian Federation"}, standardCallback, errorPossibleCallback);
reqId = engine.GetAvailableProducts(ms::LatLon(55.753960, 37.624513),
ms::LatLon(55.765866, 37.661270), standardCallback,
errorPossibleCallback);
}
{
lock_guard<mutex> lock(resultsMutex);
reqId = engine.GetAvailableProducts(
ms::LatLon(59.922445, 30.367201), ms::LatLon(59.943675, 30.361123),
{"Brazil", "Russian Federation"}, standardCallback, errorPossibleCallback);
reqId = engine.GetAvailableProducts(ms::LatLon(59.922445, 30.367201),
ms::LatLon(59.943675, 30.361123), standardCallback,
errorPossibleCallback);
}
{
lock_guard<mutex> lock(resultsMutex);
reqId = engine.GetAvailableProducts(
ms::LatLon(52.509621, 13.450067), ms::LatLon(52.510811, 13.409490),
{"Brazil", "Russian Federation"}, standardCallback, errorPossibleCallback);
reqId = engine.GetAvailableProducts(ms::LatLon(52.509621, 13.450067),
ms::LatLon(52.510811, 13.409490), standardCallback,
errorPossibleCallback);
}
{
lock_guard<mutex> lock(resultsMutex);
reqId = engine.GetAvailableProducts(from, to, {"Brazil", "Russian Federation"}, lastCallback,
errorCallback);
reqId = engine.GetAvailableProducts(from, to, lastCallback, errorCallback);
}
}

View file

@ -0,0 +1,32 @@
#include "partners_api/taxi_base.hpp"
namespace taxi
{
bool ApiItem::AreAllCountriesDisabled(storage::TCountriesVec const & countryIds,
std::string const & city) const
{
if (m_disabledCountries.IsEmpty())
return false;
bool isCountryDisabled = true;
for (auto const & countryId : countryIds)
isCountryDisabled = isCountryDisabled && m_disabledCountries.Has(countryId, city);
return isCountryDisabled;
}
bool ApiItem::IsAnyCountryEnabled(storage::TCountriesVec const & countryIds,
std::string const & city) const
{
if (m_enabledCountries.IsEmpty())
return true;
for (auto const & countryId : countryIds)
{
if (m_enabledCountries.Has(countryId, city))
return true;
}
return false;
}
} // namespace taxi

View file

@ -1,5 +1,6 @@
#pragma once
#include "partners_api/taxi_countries.hpp"
#include "partners_api/taxi_provider.hpp"
#include <functional>
@ -29,6 +30,7 @@ struct RideRequestLinks
class ApiBase
{
public:
ApiBase(std::string const & baseUrl) : m_baseUrl(baseUrl) {}
virtual ~ApiBase() = default;
/// Requests list of available products. Returns request identificator immediately.
@ -41,7 +43,31 @@ public:
ms::LatLon const & from,
ms::LatLon const & to) const = 0;
private:
protected:
std::string const m_baseUrl;
};
using ApiPtr = std::unique_ptr<ApiBase>;
struct ApiItem
{
ApiItem(Provider::Type type, ApiPtr && api, Countries const & enabled, Countries const & disabled)
: m_type(type)
, m_api(std::move(api))
, m_enabledCountries(enabled)
, m_disabledCountries(disabled)
{
}
bool AreAllCountriesDisabled(storage::TCountriesVec const & countryIds,
std::string const & city) const;
bool IsAnyCountryEnabled(storage::TCountriesVec const & countryIds,
std::string const & city) const;
Provider::Type m_type;
ApiPtr m_api;
Countries m_enabledCountries;
Countries m_disabledCountries;
};
} // namespace taxi

View file

@ -0,0 +1,30 @@
#include "partners_api/taxi_countries.hpp"
#include <algorithm>
namespace taxi
{
Countries::Countries(std::vector<Country> const & countries) : m_countries(countries) {}
bool Countries::IsEmpty() const { return m_countries.empty(); }
bool Countries::Has(storage::TCountryId id, std::string const & city) const
{
auto const countryIt =
std::find_if(m_countries.cbegin(), m_countries.cend(),
[&id](Country const & country) { return country.m_id == id; });
if (countryIt == m_countries.cend())
return false;
auto const & cities = countryIt->m_cities;
if (cities.empty())
return true;
auto const cityIt = std::find_if(cities.cbegin(), cities.cend(),
[&city](std::string const & c) { return c == city; });
return cityIt != cities.cend();
}
} // namespace taxi

View file

@ -0,0 +1,27 @@
#pragma once
#include "storage/index.hpp"
#include <string>
#include <vector>
namespace taxi
{
class Countries
{
public:
struct Country
{
storage::TCountryId m_id;
std::vector<std::string> m_cities;
};
Countries(std::vector<Country> const & countries);
bool IsEmpty() const;
bool Has(storage::TCountryId id, std::string const & city) const;
private:
std::vector<Country> m_countries;
};
} // namespace taxi

View file

@ -1,4 +1,5 @@
#include "partners_api/taxi_engine.hpp"
#include "partners_api/taxi_places.hpp"
#include "partners_api/uber_api.hpp"
#include "partners_api/yandex_api.hpp"
@ -8,6 +9,7 @@
#include <algorithm>
#include <initializer_list>
#include <iterator>
#include <utility>
namespace
{
@ -109,21 +111,20 @@ void ResultMaker::DecrementRequestCount()
// Engine -----------------------------------------------------------------------------------------
Engine::Engine(std::vector<ProviderUrl> urls /* = {} */)
{
m_enabledCountries = {{Provider::Type::Yandex, {"Russian Federation"}}};
m_disabledCountries = {{Provider::Type::Uber, {"Russian Federation"}}};
AddApi<yandex::Api>(urls, Provider::Type::Yandex);
AddApi<uber::Api>(urls, Provider::Type::Uber);
AddApi<yandex::Api>(urls, Provider::Type::Yandex, places::kPlaces, {{{}}});
AddApi<uber::Api>(urls, Provider::Type::Uber, {{{}}}, places::kPlaces);
}
void Engine::SetDelegate(std::unique_ptr<Delegate> delegate) { m_delegate = std::move(delegate); }
/// Requests list of available products. Returns request identificator immediately.
uint64_t Engine::GetAvailableProducts(ms::LatLon const & from, ms::LatLon const & to,
storage::TCountriesVec const & countryIds,
SuccessCallback const & successFn,
ErrorCallback const & errorFn)
{
ASSERT(successFn, ());
ASSERT(errorFn, ());
ASSERT(m_delegate, ());
auto const reqId = ++m_requestId;
auto const maker = m_maker;
@ -133,7 +134,7 @@ uint64_t Engine::GetAvailableProducts(ms::LatLon const & from, ms::LatLon const
{
auto type = api.m_type;
if (AreAllCountriesDisabled(type, countryIds) || !IsAnyCountryEnabled(type, countryIds))
if (!IsAvailableAtPos(type, from))
{
maker->DecrementRequestCount(reqId);
maker->MakeResult(reqId);
@ -169,50 +170,51 @@ RideRequestLinks Engine::GetRideRequestLinks(Provider::Type type, std::string co
return it->m_api->GetRideRequestLinks(productId, from, to);
}
bool Engine::AreAllCountriesDisabled(Provider::Type type,
storage::TCountriesVec const & countryIds) const
std::vector<Provider::Type> Engine::GetProvidersAtPos(ms::LatLon const & pos) const
{
auto const it =
FindByProviderType(type, m_disabledCountries.cbegin(), m_disabledCountries.cend());
std::vector<Provider::Type> result;
if (it == m_disabledCountries.end())
return false;
auto const & disabledCountries = it->m_countries;
bool isCountryDisabled = true;
for (auto const & countryId : countryIds)
for (auto const & api : m_apis)
{
auto const countryIt =
std::find(disabledCountries.cbegin(), disabledCountries.cend(), countryId);
isCountryDisabled = isCountryDisabled && countryIt != disabledCountries.cend();
if (IsAvailableAtPos(api.m_type, pos))
result.push_back(api.m_type);
}
return isCountryDisabled;
return result;
}
bool Engine::IsAnyCountryEnabled(Provider::Type type,
storage::TCountriesVec const & countryIds) const
bool Engine::IsAvailableAtPos(Provider::Type type, ms::LatLon const & pos) const
{
auto const it = FindByProviderType(type, m_enabledCountries.cbegin(), m_enabledCountries.cend());
return !AreAllCountriesDisabled(type, pos) && IsAnyCountryEnabled(type, pos);
}
if (it == m_enabledCountries.end())
return true;
bool Engine::AreAllCountriesDisabled(Provider::Type type, ms::LatLon const & latlon) const
{
auto const it = FindByProviderType(type, m_apis.cbegin(), m_apis.cend());
auto const & enabledCountries = it->m_countries;
for (auto const & countryId : countryIds)
{
auto const countryIt = std::find(enabledCountries.cbegin(), enabledCountries.cend(), countryId);
CHECK(it != m_apis.cend(), ());
if (countryIt != enabledCountries.cend())
return true;
}
auto const countryIds = m_delegate->GetCountryIds(latlon);
auto const city = m_delegate->GetCityName(latlon);
return false;
return it->AreAllCountriesDisabled(countryIds, city);
}
bool Engine::IsAnyCountryEnabled(Provider::Type type, ms::LatLon const & latlon) const
{
auto const it = FindByProviderType(type, m_apis.cbegin(), m_apis.cend());
CHECK(it != m_apis.cend(), ());
auto const countryIds = m_delegate->GetCountryIds(latlon);
auto const city = m_delegate->GetCityName(latlon);
return it->IsAnyCountryEnabled(countryIds, city);
}
template <typename ApiType>
void Engine::AddApi(std::vector<ProviderUrl> const & urls, Provider::Type type)
void Engine::AddApi(std::vector<ProviderUrl> const & urls, Provider::Type type,
Countries const & enabled, Countries const & disabled)
{
auto const it = std::find_if(urls.cbegin(), urls.cend(), [type](ProviderUrl const & item)
{
@ -220,8 +222,8 @@ void Engine::AddApi(std::vector<ProviderUrl> const & urls, Provider::Type type)
});
if (it != urls.cend())
m_apis.emplace_back(type, my::make_unique<ApiType>(it->m_url));
m_apis.emplace_back(type, my::make_unique<ApiType>(it->m_url), enabled, disabled);
else
m_apis.emplace_back(type, my::make_unique<ApiType>());
m_apis.emplace_back(type, my::make_unique<ApiType>(), enabled, disabled);
}
} // namespace taxi

View file

@ -1,7 +1,5 @@
#pragma once
#include "storage/index.hpp"
#include "partners_api/taxi_base.hpp"
#include <cstdint>
@ -16,6 +14,15 @@ using SuccessCallback =
using ErrorCallback = std::function<void(ErrorsContainer const & errors, uint64_t const requestId)>;
class Delegate
{
public:
virtual ~Delegate() = default;
virtual storage::TCountriesVec GetCountryIds(ms::LatLon const & latlon) = 0;
virtual std::string GetCityName(ms::LatLon const & latlon) = 0;
};
/// This class is used to collect replies from all taxi apis and to call callback when all replies
/// are collected. The methods are called in callbacks on different threads, so synchronization is
/// required.
@ -60,48 +67,35 @@ class Engine final
public:
explicit Engine(std::vector<ProviderUrl> urls = {});
void SetDelegate(std::unique_ptr<Delegate> delegate);
/// Requests list of available products. Returns request identificator immediately.
uint64_t GetAvailableProducts(ms::LatLon const & from, ms::LatLon const & to,
storage::TCountriesVec const & countryIds,
SuccessCallback const & successFn, ErrorCallback const & errorFn);
/// Returns link which allows you to launch some taxi app.
RideRequestLinks GetRideRequestLinks(Provider::Type type, std::string const & productId,
ms::LatLon const & from, ms::LatLon const & to) const;
std::vector<Provider::Type> GetProvidersAtPos(ms::LatLon const & pos) const;
private:
bool AreAllCountriesDisabled(Provider::Type type,
storage::TCountriesVec const & countryIds) const;
bool IsAnyCountryEnabled(Provider::Type type, storage::TCountriesVec const & countryIds) const;
bool IsAvailableAtPos(Provider::Type type, ms::LatLon const & pos) const;
bool AreAllCountriesDisabled(Provider::Type type, ms::LatLon const & latlon) const;
bool IsAnyCountryEnabled(Provider::Type type, ms::LatLon const & latlon) const;
template <typename ApiType>
void AddApi(std::vector<ProviderUrl> const & urls, Provider::Type type);
void AddApi(std::vector<ProviderUrl> const & urls, Provider::Type type, Countries const & enabled,
Countries const & disabled);
using ApiPtr = std::unique_ptr<ApiBase>;
struct ApiContainerItem
{
ApiContainerItem(Provider::Type type, ApiPtr && api) : m_type(type), m_api(std::move(api)) {}
Provider::Type m_type;
ApiPtr m_api;
};
struct SupportedCountriesItem
{
Provider::Type m_type;
storage::TCountriesVec m_countries;
};
std::vector<ApiContainerItem> m_apis;
std::vector<SupportedCountriesItem> m_enabledCountries;
std::vector<SupportedCountriesItem> m_disabledCountries;
std::vector<ApiItem> m_apis;
// Id for currently processed request.
uint64_t m_requestId = 0;
// Use single instance of maker for all requests, for this reason,
// all outdated requests will be ignored.
std::shared_ptr<ResultMaker> m_maker = std::make_shared<ResultMaker>();
std::unique_ptr<Delegate> m_delegate;
};
} // namespace taxi

View file

@ -0,0 +1,149 @@
#pragma once
#include "partners_api/taxi_countries.hpp"
namespace taxi
{
namespace places
{
// Places which are supported by yandex taxi and in the same time are not supported by uber taxi.
Countries const kPlaces = {
{{"Armenia", {"Yerevan"}},
{"Belarus", {"Minsk"}},
{"Georgia Region", {"Tbilisi"}},
{"Kazakhstan", {"Almaty", "Astana", "Karaganda", "Pavlodar", "Shymkent"}},
{"Russian Federation",
{"Almetyevsk",
"Anapa",
"Aprelevka",
"Arzamas",
"Arkhangelsk",
"Astrakhan",
"Balakovo",
"Balashikha",
"Barnaul",
"Belgorod",
"Blagoveshchensk",
"Bryansk",
"Vidnoye",
"Vladivostok",
"Vladikavkaz",
"Vladimir",
"Volgograd",
"Volgodonsk",
"Vologda",
"Voronezh",
"Gelendzhik",
"Golitsyno",
"Dedovsk",
"Dzerzhinsky",
"Dmitrov",
"Dolgoprudny",
"Domodedovo",
"Dubna",
"Yekaterinburg",
"Zheleznodorozhny",
"Zhukovsky",
"Zelenograd",
"Ivanovo",
"Ivanteyevka",
"Izhevsk",
"Irkutsk",
"Yoshkar-Ola",
"Kazan",
"Kaliningrad",
"Kaluga",
"Kamensk-Uralsky",
"Kashira",
"Kemerovo",
"Kirov",
"Kislovodsk",
"Kolomna",
"Komsomolsk-on-Amur",
"Korolyov",
"Kotelniki",
"Krasnogorsk",
"Krasnodar",
"Krasnoznamensk",
"Krasnoyarsk",
"Kurgan",
"Kursk",
"Lipetsk",
"Lobnya",
"Lytkarino",
"Lyubertsy",
"Magnitogorsk",
"Makhachkala",
"Mozhaisk",
"Moscow",
"Murmansk",
"Mytishchi",
"Naberezhnye Chelny",
"Naro-Fominsk",
"Nakhabino",
"Nizhnekamsk",
"Nizhny Novgorod",
"Nizhny Tagil",
"Novokuznetsk",
"Novorossiysk",
"Novosibirsk",
"Novy Urengoy",
"Noginsk",
"Noyabrsk",
"Obninsk",
"Odintsovo",
"Ozyory",
"Omsk",
"Oryol",
"Orenburg",
"Orsk",
"Penza",
"Perm",
"Petrozavodsk",
"Podolsk",
"Pushkino",
"Ramenskoye",
"Reutov",
"Rostov-on-Don",
"Ryazan",
"Samara",
"Saint Petersburg",
"Saransk",
"Saratov",
"Sergiyev Posad",
"Serpukhov",
"Smolensk",
"Sochi",
"Stavropol",
"Staraya Kupavna",
"Sterlitamak",
"Stupino",
"Surgut",
"Syzran",
"Syktyvkar",
"Taganrog",
"Tambov",
"Tver",
"Tolyatti",
"Tomsk",
"Troitsk",
"Tula",
"Tyumen",
"Ulan-Ude",
"Ulyanovsk",
"Ufa",
"Fryazino",
"Khabarovsk",
"Khimki",
"Cheboksary",
"Chelyabinsk",
"Cherepovets",
"Chekhov",
"Chita",
"Shchyolkovo",
"Elektrostal",
"Elektrougli",
"Yakutsk",
"Yaroslavl"}}}};
} // namespace places
} // namespace taxi

View file

@ -71,7 +71,7 @@ private:
class Api : public ApiBase
{
public:
explicit Api(std::string const & baseUrl = kEstimatesUrl) : m_baseUrl(baseUrl) {}
explicit Api(std::string const & baseUrl = kEstimatesUrl) : ApiBase(baseUrl) {}
// ApiBase overrides:
/// Requests list of available products from Uber.
void GetAvailableProducts(ms::LatLon const & from, ms::LatLon const & to,
@ -85,7 +85,6 @@ public:
private:
shared_ptr<ProductMaker> m_maker = make_shared<ProductMaker>();
uint64_t m_requestId = 0;
string const m_baseUrl;
};
void SetUberUrlForTesting(string const & url);

View file

@ -49,6 +49,8 @@ namespace taxi
{
namespace yandex
{
Countries const kEnabledCountries = {{{}}};
bool RawApi::GetTaxiInfo(ms::LatLon const & from, ms::LatLon const & to, std::string & result,
std::string const & baseUrl /* = kTaxiInfoUrl */)
{

View file

@ -26,7 +26,7 @@ public:
class Api : public ApiBase
{
public:
explicit Api(std::string const & baseUrl = kTaxiInfoUrl) : m_baseUrl(baseUrl) {}
explicit Api(std::string const & baseUrl = kTaxiInfoUrl) : ApiBase(baseUrl) {}
// ApiBase overrides:
/// Requests list of available products from Yandex.
void GetAvailableProducts(ms::LatLon const & from, ms::LatLon const & to,
@ -36,9 +36,6 @@ public:
/// Returns link which allows you to launch the Yandex app.
RideRequestLinks GetRideRequestLinks(std::string const & productId, ms::LatLon const & from,
ms::LatLon const & to) const override;
private:
std::string const m_baseUrl;
};
void MakeFromJson(std::string const & src, std::vector<taxi::Product> & products);

View file

@ -20,6 +20,9 @@
34921F661BFA0A6900737D6E /* api_mark_point.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 34921F611BFA0A6900737D6E /* api_mark_point.hpp */; };
34DDA1811DBE5DF40088A609 /* libpartners_api.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 34DDA17F1DBE5DF40088A609 /* libpartners_api.a */; };
34DDA1821DBE5DF40088A609 /* libtracking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 34DDA1801DBE5DF40088A609 /* libtracking.a */; };
3D47B2931F054BC5000828D2 /* taxi_delegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D47B2901F054BC5000828D2 /* taxi_delegate.cpp */; };
3D47B2941F054BC5000828D2 /* taxi_delegate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D47B2911F054BC5000828D2 /* taxi_delegate.hpp */; };
3D47B2951F054BC5000828D2 /* city_finder.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D47B2921F054BC5000828D2 /* city_finder.hpp */; };
3D74ABBE1EA76F1D0063A898 /* local_ads_supported_types.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D74ABBD1EA76F1D0063A898 /* local_ads_supported_types.cpp */; };
45201E931CE4AC90008A4842 /* api_mark_point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45201E921CE4AC90008A4842 /* api_mark_point.cpp */; };
45580ABE1E2CBD5E00CD535D /* benchmark_tools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45580ABC1E2CBD5E00CD535D /* benchmark_tools.cpp */; };
@ -143,6 +146,9 @@
34AF87EA1DBE5AD000E5E7DC /* common-release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "common-release.xcconfig"; path = "../common-release.xcconfig"; sourceTree = "<group>"; };
34DDA17F1DBE5DF40088A609 /* libpartners_api.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpartners_api.a; path = "/Users/igrechuhin/Repo/omim/xcode/partners_api/../../../omim-xcode-build/Debug/libpartners_api.a"; sourceTree = "<absolute>"; };
34DDA1801DBE5DF40088A609 /* libtracking.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtracking.a; path = "/Users/igrechuhin/Repo/omim/xcode/tracking/../../../omim-xcode-build/Debug/libtracking.a"; sourceTree = "<absolute>"; };
3D47B2901F054BC5000828D2 /* taxi_delegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = taxi_delegate.cpp; sourceTree = "<group>"; };
3D47B2911F054BC5000828D2 /* taxi_delegate.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = taxi_delegate.hpp; sourceTree = "<group>"; };
3D47B2921F054BC5000828D2 /* city_finder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = city_finder.hpp; sourceTree = "<group>"; };
3D74ABBD1EA76F1D0063A898 /* local_ads_supported_types.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = local_ads_supported_types.cpp; sourceTree = "<group>"; };
45201E921CE4AC90008A4842 /* api_mark_point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = api_mark_point.cpp; sourceTree = "<group>"; };
45580ABC1E2CBD5E00CD535D /* benchmark_tools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = benchmark_tools.cpp; sourceTree = "<group>"; };
@ -419,6 +425,9 @@
675345BD1A4054AD00A0A8C3 /* map */ = {
isa = PBXGroup;
children = (
3D47B2901F054BC5000828D2 /* taxi_delegate.cpp */,
3D47B2911F054BC5000828D2 /* taxi_delegate.hpp */,
3D47B2921F054BC5000828D2 /* city_finder.hpp */,
3D74ABBD1EA76F1D0063A898 /* local_ads_supported_types.cpp */,
56B6EAF61EA4BAF00037D963 /* mwm_tree.cpp */,
56B6EAF71EA4BAF00037D963 /* mwm_tree.hpp */,
@ -489,6 +498,7 @@
56B6EAF91EA4BAF00037D963 /* mwm_tree.hpp in Headers */,
347B60771DD9926D0050FA24 /* traffic_manager.hpp in Headers */,
6753466B1A4054E800A0A8C3 /* geourl_process.hpp in Headers */,
3D47B2951F054BC5000828D2 /* city_finder.hpp in Headers */,
F6B283081C1B03320081957A /* gps_track_storage.hpp in Headers */,
675346671A4054E800A0A8C3 /* ge0_parser.hpp in Headers */,
675346A21A4054E800A0A8C3 /* user_mark.hpp in Headers */,
@ -497,6 +507,7 @@
34921F661BFA0A6900737D6E /* api_mark_point.hpp in Headers */,
675346751A4054E800A0A8C3 /* mwm_url.hpp in Headers */,
6753464B1A4054E800A0A8C3 /* bookmark.hpp in Headers */,
3D47B2941F054BC5000828D2 /* taxi_delegate.hpp in Headers */,
348AB57D1D7EE0C6009F8301 /* chart_generator.hpp in Headers */,
F63421F91DF9BF9100A96868 /* reachable_by_taxi_checker.hpp in Headers */,
6753469E1A4054E800A0A8C3 /* user_mark_container.hpp in Headers */,
@ -616,6 +627,7 @@
files = (
F6B283051C1B03320081957A /* gps_track_filter.cpp in Sources */,
675346481A4054E800A0A8C3 /* bookmark_manager.cpp in Sources */,
3D47B2931F054BC5000828D2 /* taxi_delegate.cpp in Sources */,
675346741A4054E800A0A8C3 /* mwm_url.cpp in Sources */,
347B60761DD9926D0050FA24 /* traffic_manager.cpp in Sources */,
F6B283091C1B03320081957A /* gps_track.cpp in Sources */,

View file

@ -20,6 +20,10 @@
3488B0381E9D11890068AFD8 /* rb_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 346E889E1E9D088200D4CE9B /* rb_tests.cpp */; };
3488B0391E9D118D0068AFD8 /* facebook_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DBC1C501E4B14810016897F /* facebook_tests.cpp */; };
3D47B2811F00F94D000828D2 /* mopub_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D47B2801F00F94D000828D2 /* mopub_tests.cpp */; };
3D47B29A1F054C89000828D2 /* taxi_base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D47B2961F054C89000828D2 /* taxi_base.cpp */; };
3D47B29B1F054C89000828D2 /* taxi_countries.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D47B2971F054C89000828D2 /* taxi_countries.cpp */; };
3D47B29C1F054C89000828D2 /* taxi_countries.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D47B2981F054C89000828D2 /* taxi_countries.hpp */; };
3D47B29D1F054C89000828D2 /* taxi_places.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D47B2991F054C89000828D2 /* taxi_places.hpp */; };
3DBC1C541E4B14920016897F /* facebook_ads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DBC1C521E4B14920016897F /* facebook_ads.cpp */; };
3DBC1C551E4B14920016897F /* facebook_ads.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3DBC1C531E4B14920016897F /* facebook_ads.hpp */; };
3DFEBF851EF82BEA00317D5C /* viator_api.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DFEBF831EF82BEA00317D5C /* viator_api.cpp */; };
@ -68,6 +72,10 @@
3475E0E11DBF581B004C7E69 /* common-debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "common-debug.xcconfig"; path = "../common-debug.xcconfig"; sourceTree = "<group>"; };
3475E0E21DBF581B004C7E69 /* common-release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "common-release.xcconfig"; path = "../common-release.xcconfig"; sourceTree = "<group>"; };
3D47B2801F00F94D000828D2 /* mopub_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mopub_tests.cpp; sourceTree = "<group>"; };
3D47B2961F054C89000828D2 /* taxi_base.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = taxi_base.cpp; sourceTree = "<group>"; };
3D47B2971F054C89000828D2 /* taxi_countries.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = taxi_countries.cpp; sourceTree = "<group>"; };
3D47B2981F054C89000828D2 /* taxi_countries.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = taxi_countries.hpp; sourceTree = "<group>"; };
3D47B2991F054C89000828D2 /* taxi_places.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = taxi_places.hpp; sourceTree = "<group>"; };
3DBC1C501E4B14810016897F /* facebook_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = facebook_tests.cpp; sourceTree = "<group>"; };
3DBC1C521E4B14920016897F /* facebook_ads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = facebook_ads.cpp; sourceTree = "<group>"; };
3DBC1C531E4B14920016897F /* facebook_ads.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = facebook_ads.hpp; sourceTree = "<group>"; };
@ -154,6 +162,10 @@
F6B5363B1DA520B20067EEA5 /* partners_api */ = {
isa = PBXGroup;
children = (
3D47B2961F054C89000828D2 /* taxi_base.cpp */,
3D47B2971F054C89000828D2 /* taxi_countries.cpp */,
3D47B2981F054C89000828D2 /* taxi_countries.hpp */,
3D47B2991F054C89000828D2 /* taxi_places.hpp */,
3DFEBF831EF82BEA00317D5C /* viator_api.cpp */,
3DFEBF841EF82BEA00317D5C /* viator_api.hpp */,
3DFEBF941EFBFC1500317D5C /* taxi_base.hpp */,
@ -232,7 +244,9 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
3D47B29C1F054C89000828D2 /* taxi_countries.hpp in Headers */,
346E88971E9D087400D4CE9B /* ads_base.hpp in Headers */,
3D47B29D1F054C89000828D2 /* taxi_places.hpp in Headers */,
F67E75261DB8F06F00D6741F /* opentable_api.hpp in Headers */,
F6B536411DA520E40067EEA5 /* booking_api.hpp in Headers */,
3430643D1E9FBCF500DC7665 /* mopub_ads.hpp in Headers */,
@ -351,9 +365,11 @@
346E889B1E9D087400D4CE9B /* rb_ads.cpp in Sources */,
3DBC1C541E4B14920016897F /* facebook_ads.cpp in Sources */,
346E88981E9D087400D4CE9B /* ads_engine.cpp in Sources */,
3D47B29B1F054C89000828D2 /* taxi_countries.cpp in Sources */,
F67E75251DB8F06F00D6741F /* opentable_api.cpp in Sources */,
3DFEBFA31EFBFC2300317D5C /* taxi_engine_tests.cpp in Sources */,
F6B536401DA520E40067EEA5 /* booking_api.cpp in Sources */,
3D47B29A1F054C89000828D2 /* taxi_base.cpp in Sources */,
3DFEBF9E1EFBFC1500317D5C /* yandex_api.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;