diff options
author | Maxim Pimenov <m@maps.me> | 2017-05-04 13:43:45 +0300 |
---|---|---|
committer | Добрый Ээх <dobriy-eeh@users.noreply.github.com> | 2017-05-04 17:17:52 +0300 |
commit | 9cc17fbc03f9aa249c8d6f3f0661b2c4afd2ee56 (patch) | |
tree | 88c4d7b93a3c2c91f2a26fe227ba5acfb759dc5e | |
parent | 32cff0a2949a28d5e23289699a6bbab3c0376f30 (diff) |
[routing] Removed spontaneous setting of the pedestrian router.beta-791
-rw-r--r-- | map/framework.cpp | 51 | ||||
-rw-r--r-- | map/framework.hpp | 4 |
2 files changed, 17 insertions, 38 deletions
diff --git a/map/framework.cpp b/map/framework.cpp index 010fbcbe81..e108f8d302 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2853,48 +2853,27 @@ void Framework::OnRebuildRouteReady(Route const & route, IRouter::ResultCode cod CallRouteBuilded(code, storage::TCountriesVec()); } -RouterType Framework::GetBestRouter(m2::PointD const & startPoint, m2::PointD const & finalPoint) +RouterType Framework::GetBestRouter(m2::PointD const & startPoint, m2::PointD const & finalPoint) const { - if (MercatorBounds::DistanceOnEarth(startPoint, finalPoint) < kKeepPedestrianDistanceMeters) - { - auto const lastUsedRouter = GetLastUsedRouter(); - switch (lastUsedRouter) - { - case RouterType::Pedestrian: - case RouterType::Bicycle: - return lastUsedRouter; - case RouterType::Taxi: - ASSERT(false, ("GetLastUsedRouter should not return RouterType::Taxi")); - case RouterType::Vehicle: - break; - case RouterType::Count: - CHECK(false, ("Bad router type", lastUsedRouter)); - } - - // Return on a short distance the vehicle router flag only if we are already have routing files. - auto countryFileGetter = [this](m2::PointD const & pt) - { - return m_infoGetter->GetRegionCountryId(pt); - }; - if (!CarRouter::CheckRoutingAbility(startPoint, finalPoint, countryFileGetter, - m_model.GetIndex())) - { - return RouterType::Pedestrian; - } - } - return RouterType::Vehicle; + // todo Implement something more sophisticated here (or delete the method). + return GetLastUsedRouter(); } RouterType Framework::GetLastUsedRouter() const { - string routerType; - settings::Get(kRouterTypeKey, routerType); + string routerTypeStr; + settings::Get(kRouterTypeKey, routerTypeStr); + + auto routerType = routing::FromString(routerTypeStr); - if (routerType == routing::ToString(RouterType::Pedestrian)) - return RouterType::Pedestrian; - if (routerType == routing::ToString(RouterType::Bicycle)) - return RouterType::Bicycle; - return RouterType::Vehicle; + switch (routerType) + { + case RouterType::Pedestrian: + case RouterType::Bicycle: + return routerType; + default: + return RouterType::Vehicle; + } } void Framework::SetLastUsedRouter(RouterType type) diff --git a/map/framework.hpp b/map/framework.hpp index efa73794a6..72ab924b8d 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -774,10 +774,10 @@ public: void CloseRouting(); void GetRouteFollowingInfo(location::FollowingInfo & info) const { m_routingSession.GetRouteFollowingInfo(info); } m2::PointD GetRouteEndPoint() const { return m_routingSession.GetEndPoint(); } + /// Returns the most situable router engine type. + routing::RouterType GetBestRouter(m2::PointD const & startPoint, m2::PointD const & finalPoint) const; routing::RouterType GetLastUsedRouter() const; void SetLastUsedRouter(routing::RouterType type); - /// Returns the most situable router engine type. Bases on distance and the last used router. - routing::RouterType GetBestRouter(m2::PointD const & startPoint, m2::PointD const & finalPoint); // Sound notifications for turn instructions. inline void EnableTurnNotifications(bool enable) { m_routingSession.EnableTurnNotifications(enable); } inline bool AreTurnNotificationsEnabled() const { return m_routingSession.AreTurnNotificationsEnabled(); } |