diff options
author | Olga Khlopkova <o.khlopkova@corp.mail.ru> | 2020-11-26 12:26:59 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <bykoianko@gmail.com> | 2020-12-01 10:07:36 +0300 |
commit | 6e9d1d9acaad8d549450d89283892fcfc4dcfb8f (patch) | |
tree | 3970501b635e584d9d535dbf5a45ac16ac747e8c /routing | |
parent | e1315400688c95400abc9c33de833d285d9a8f40 (diff) |
[routing][map] Pass AbsentRegionsFinder from RoutingManager to AsyncRouter instead of OnlineAbsentFetcher.
Diffstat (limited to 'routing')
-rw-r--r-- | routing/async_router.cpp | 19 | ||||
-rw-r--r-- | routing/async_router.hpp | 9 | ||||
-rw-r--r-- | routing/routing_session.cpp | 4 | ||||
-rw-r--r-- | routing/routing_session.hpp | 2 |
4 files changed, 18 insertions, 16 deletions
diff --git a/routing/async_router.cpp b/routing/async_router.cpp index adc47afb13..ccdb68bec4 100644 --- a/routing/async_router.cpp +++ b/routing/async_router.cpp @@ -203,14 +203,15 @@ AsyncRouter::~AsyncRouter() m_thread.join(); } -void AsyncRouter::SetRouter(unique_ptr<IRouter> && router, unique_ptr<IOnlineFetcher> && fetcher) +void AsyncRouter::SetRouter(unique_ptr<IRouter> && router, + unique_ptr<AbsentRegionsFinder> && finder) { unique_lock<mutex> ul(m_guard); ResetDelegate(); m_router = move(router); - m_absentFetcher = move(fetcher); + m_absentRegionsFinder = move(finder); } void AsyncRouter::CalculateRoute(Checkpoints const & checkpoints, m2::PointD const & direction, @@ -352,7 +353,7 @@ void AsyncRouter::CalculateRoute() shared_ptr<RouterDelegateProxy> delegateProxy; m2::PointD startDirection; bool adjustToPrevRoute = false; - shared_ptr<IOnlineFetcher> absentFetcher; + shared_ptr<AbsentRegionsFinder> absentRegionsFinder; shared_ptr<IRouter> router; uint64_t routeId = 0; RoutingStatisticsCallback routingStatisticsCallback; @@ -375,7 +376,7 @@ void AsyncRouter::CalculateRoute() adjustToPrevRoute = m_adjustToPrevRoute; delegateProxy = m_delegateProxy; router = m_router; - absentFetcher = m_absentFetcher; + absentRegionsFinder = m_absentRegionsFinder; routeId = ++m_routeCounter; routingStatisticsCallback = m_routingStatisticsCallback; routerName = router->GetName(); @@ -394,8 +395,8 @@ void AsyncRouter::CalculateRoute() LOG(LINFO, ("Calculating the route. checkpoints:", checkpoints, "startDirection:", startDirection, "router name:", router->GetName())); - if (absentFetcher) - absentFetcher->GenerateRequest(checkpoints); + if (absentRegionsFinder) + absentRegionsFinder->GenerateAbsentRegions(checkpoints, delegateProxy->GetDelegate()); // Run basic request. code = router->CalculateRoute(checkpoints, startDirection, adjustToPrevRoute, @@ -439,12 +440,12 @@ void AsyncRouter::CalculateRoute() [delegateProxy, route, code]() { delegateProxy->OnReady(route, code); }); } - bool const needFetchAbsent = (code != RouterResultCode::Cancelled); + bool const needAbsentRegions = (code != RouterResultCode::Cancelled); // Check online response if we have. set<string> absent; - if (absentFetcher && needFetchAbsent) - absentFetcher->GetAbsentCountries(absent); + if (absentRegionsFinder && needAbsentRegions) + absentRegionsFinder->GetAbsentRegions(absent); absent.insert(route->GetAbsentCountries().cbegin(), route->GetAbsentCountries().cend()); if (!absent.empty()) diff --git a/routing/async_router.hpp b/routing/async_router.hpp index 9cf59085c2..6093b90859 100644 --- a/routing/async_router.hpp +++ b/routing/async_router.hpp @@ -1,7 +1,7 @@ #pragma once +#include "routing/absent_regions_finder.hpp" #include "routing/checkpoints.hpp" -#include "routing/online_absent_fetcher.hpp" #include "routing/route.hpp" #include "routing/router.hpp" #include "routing/router_delegate.hpp" @@ -34,8 +34,9 @@ public: /// Sets a synchronous router, current route calculation will be cancelled /// @param router pointer to a router implementation - /// @param fetcher pointer to a online fetcher - void SetRouter(std::unique_ptr<IRouter> && router, std::unique_ptr<IOnlineFetcher> && fetcher); + /// @param finder pointer to a router for generated absent wmwms. + void SetRouter(std::unique_ptr<IRouter> && router, + std::unique_ptr<AbsentRegionsFinder> && finder); /// Main method to calculate new route from startPt to finalPt with start direction /// Processed result will be passed to callback. Callback will be called at the GUI thread. @@ -122,7 +123,7 @@ private: m2::PointD m_startDirection = m2::PointD::Zero(); bool m_adjustToPrevRoute = false; std::shared_ptr<RouterDelegateProxy> m_delegateProxy; - std::shared_ptr<IOnlineFetcher> m_absentFetcher; + std::shared_ptr<AbsentRegionsFinder> m_absentRegionsFinder; std::shared_ptr<IRouter> m_router; RoutingStatisticsCallback const m_routingStatisticsCallback; diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index bc8fc832e5..c6106d4cd7 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -516,12 +516,12 @@ void RoutingSession::AssignRoute(shared_ptr<Route> route, RouterResultCode e) } void RoutingSession::SetRouter(unique_ptr<IRouter> && router, - unique_ptr<OnlineAbsentCountriesFetcher> && fetcher) + unique_ptr<AbsentRegionsFinder> && finder) { CHECK_THREAD_CHECKER(m_threadChecker, ()); ASSERT(m_router != nullptr, ()); Reset(); - m_router->SetRouter(move(router), move(fetcher)); + m_router->SetRouter(move(router), move(finder)); } void RoutingSession::MatchLocationToRoadGraph(location::GpsInfo & location) diff --git a/routing/routing_session.hpp b/routing/routing_session.hpp index e0010e2462..cc65d80507 100644 --- a/routing/routing_session.hpp +++ b/routing/routing_session.hpp @@ -54,7 +54,7 @@ public: PointCheckCallback const & pointCheckCallback); void SetRouter(std::unique_ptr<IRouter> && router, - std::unique_ptr<OnlineAbsentCountriesFetcher> && fetcher); + std::unique_ptr<AbsentRegionsFinder> && finder); /// @param[in] checkpoints in mercator /// @param[in] timeoutSec timeout in seconds, if zero then there is no timeout |