Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/map
diff options
context:
space:
mode:
authorLev Dragunov <l.dragunov@corp.mail.ru>2015-07-23 20:17:15 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:57:31 +0300
commit4588f7c34d9eb1bb5e8fb72d3c96e3269ba4ac1f (patch)
tree661a980c4d5f0172a4091b9461d51ccc3aef0283 /map
parent05e7c9cb45cde4a5f377c5e086bd9528c847a9d1 (diff)
Get the best router type framework method.
Diffstat (limited to 'map')
-rw-r--r--map/framework.cpp20
-rw-r--r--map/framework.hpp2
2 files changed, 22 insertions, 0 deletions
diff --git a/map/framework.cpp b/map/framework.cpp
index f2fd215edd..7e8434ef32 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -98,6 +98,7 @@ Framework::FixedPosition::FixedPosition()
namespace
{
static const int BM_TOUCH_PIXEL_INCREASE = 20;
+ static const int kKeepPedestrianDistanceMeters = 10000;
}
pair<MwmSet::MwmHandle, MwmSet::RegResult> Framework::RegisterMap(
@@ -2092,6 +2093,8 @@ void Framework::BuildRoute(m2::PointD const & destination, uint32_t timeoutSec)
if (IsRoutingActive())
CloseRouting();
+ SetLastUsedRouter(m_currentRouterType);
+
m_routingSession.BuildRoute(state->Position(), destination,
[this] (Route const & route, IRouter::ResultCode code)
{
@@ -2303,3 +2306,20 @@ string Framework::GetRoutingErrorMessage(IRouter::ResultCode code)
return m_stringsBundle.GetString(messageID);
}
+
+RouterType Framework::GetBestRouterType(m2::PointD const & startPoint, m2::PointD const & finalPoint)
+{
+ if (MercatorBounds::DistanceOnEarth(startPoint, finalPoint) < kKeepPedestrianDistanceMeters)
+ {
+ string routerType;
+ Settings::Get("router", routerType);
+ if (routerType == routing::ToString(RouterType::Pedestrian))
+ return RouterType::Pedestrian;
+ }
+ return RouterType::Vehicle;
+}
+
+void Framework::SetLastUsedRouter(RouterType type)
+{
+ Settings::Set("router", routing::ToString(type));
+}
diff --git a/map/framework.hpp b/map/framework.hpp
index 7748d3a1af..dcab8c1e55 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -569,6 +569,8 @@ public:
void CloseRouting();
void GetRouteFollowingInfo(location::FollowingInfo & info) { m_routingSession.GetRouteFollowingInfo(info); }
m2::PointD GetRouteEndPoint() const { return m_routingSession.GetEndPoint(); }
+ void SetLastUsedRouter(routing::RouterType type);
+ routing::RouterType GetBestRouterType(m2::PointD const & startPoint, m2::PointD const & finalPoint);
// @TODO The three methods below has to be called from jni.
// Sound notifications for turn instructions.
inline void EnableTurnNotifications(bool enable) { m_routingSession.EnableTurnNotifications(enable); }