diff options
author | Lev Dragunov <l.dragunov@corp.mail.ru> | 2015-07-28 18:11:24 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:58:39 +0300 |
commit | 1f36eb605532726e00ee75f582bb20df40b8b9b3 (patch) | |
tree | d9edf04d0e3f2921c45de55b9339e3840b055bab /map/framework.cpp | |
parent | 6a6cb45df2c342d821e704cc568f3aa3c4752473 (diff) |
Async router tests.
Diffstat (limited to 'map/framework.cpp')
-rw-r--r-- | map/framework.cpp | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/map/framework.cpp b/map/framework.cpp index 37882bb357..265eb6fb40 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2099,33 +2099,40 @@ void Framework::BuildRoute(m2::PointD const & destination, uint32_t timeoutSec) SetLastUsedRouter(m_currentRouterType); - m_routingSession.BuildRoute(state->Position(), destination, - [this] (Route const & route, IRouter::ResultCode code) + auto fn = [this](Route const & route, IRouter::ResultCode code) + { + vector<storage::TIndex> absentCountries; + vector<storage::TIndex> absentRoutingIndexes; + if (code == IRouter::NoError) { - vector<storage::TIndex> absentCountries; - vector<storage::TIndex> absentRoutingIndexes; - if (code == IRouter::NoError) + InsertRoute(route); + GetLocationState()->RouteBuilded(); + ShowRectExVisibleScale(route.GetPoly().GetLimitRect()); + } + else + { + for (string const & name : route.GetAbsentCountries()) { - InsertRoute(route); - GetLocationState()->RouteBuilded(); - ShowRectExVisibleScale(route.GetPoly().GetLimitRect()); + storage::TIndex fileIndex = m_storage.FindIndexByFile(name); + if (m_storage.GetLatestLocalFile(fileIndex)) + absentRoutingIndexes.push_back(fileIndex); + else + absentCountries.push_back(fileIndex); } - else - { - for (string const & name : route.GetAbsentCountries()) - { - storage::TIndex fileIndex = m_storage.FindIndexByFile(name); - if (m_storage.GetLatestLocalFile(fileIndex)) - absentRoutingIndexes.push_back(fileIndex); - else - absentCountries.push_back(fileIndex); - } - if (code != IRouter::NeedMoreMaps) - RemoveRoute(); - } - CallRouteBuilded(code, absentCountries, absentRoutingIndexes); - }, m_progressCallback, timeoutSec); + if (code != IRouter::NeedMoreMaps) + RemoveRoute(); + } + CallRouteBuilded(code, absentCountries, absentRoutingIndexes); + LOG(LINFO, ("Inside callback!")); + }; + + m_routingSession.BuildRoute(state->Position(), destination, + [fn](Route const & route, IRouter::ResultCode code) + { + GetPlatform().RunOnGuiThread(bind(fn, route, code)); + }, + m_progressCallback, timeoutSec); } void Framework::SetRouter(RouterType type) |