diff --git a/map/framework.cpp b/map/framework.cpp index cd42c2778e..5e499a0925 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2173,14 +2173,13 @@ void Framework::SetRouter(RouterType type) if (type == RouterType::Pedestrian) { router = CreatePedestrianAStarBidirectionalRouter(m_model.GetIndex(), routingVisualizerFn); - m_routingSession.SetRoutingSettings(routing::RoutingSettings(false /* m_matchBearing */, - 20. /* m_matchingThresholdM */)); + m_routingSession.SetRoutingSettings(routing::GetPedestrianRoutingSettings()); } else { router.reset(new OsrmRouter(&m_model.GetIndex(), countryFileGetter, routingVisualizerFn)); fetcher.reset(new OnlineAbsentCountriesFetcher(countryFileGetter, localFileGetter)); - m_routingSession.SetRoutingSettings(routing::RoutingSettings()); + m_routingSession.SetRoutingSettings(routing::GetCarRoutingSettings()); } m_routingSession.SetRouter(move(router), move(fetcher), routingStatisticsFn); diff --git a/routing/route.cpp b/routing/route.cpp index 53d409dd27..62b724a6e5 100644 --- a/routing/route.cpp +++ b/routing/route.cpp @@ -22,7 +22,7 @@ static double const LOCATION_TIME_THRESHOLD = 60.0*1.0; static double const ON_END_TOLERANCE_M = 10.0; Route::Route(string const & router, vector const & points, string const & name) - : m_router(router), m_poly(points), m_name(name) + : m_router(router), m_routingSettings(GetCarRoutingSettings()), m_poly(points), m_name(name) { Update(); } @@ -201,10 +201,10 @@ void Route::MatchLocationToRoute(location::GpsInfo & location, location::RouteMa { if (m_current.IsValid()) { - const m2::PointD locationMerc(MercatorBounds::LonToX(location.m_longitude), + m2::PointD const locationMerc(MercatorBounds::LonToX(location.m_longitude), MercatorBounds::LatToY(location.m_latitude)); - const double distFromRoute = MercatorBounds::DistanceOnEarth(m_current.m_pt, locationMerc); - if (distFromRoute < m_routingSettings.m_matchingThresholdM) + double const distFromRouteM = MercatorBounds::DistanceOnEarth(m_current.m_pt, locationMerc); + if (distFromRouteM < m_routingSettings.m_matchingThresholdM) { location.m_latitude = MercatorBounds::YToLat(m_current.m_pt.y); location.m_longitude = MercatorBounds::XToLon(m_current.m_pt.x); diff --git a/routing/route.hpp b/routing/route.hpp index 34ac0b2caa..66bf08862d 100644 --- a/routing/route.hpp +++ b/routing/route.hpp @@ -26,11 +26,12 @@ public: typedef pair TTimeItem; typedef vector TTimes; - explicit Route(string const & router) : m_router(router) {} + explicit Route(string const & router) + : m_router(router), m_routingSettings(GetCarRoutingSettings()) {} template Route(string const & router, IterT beg, IterT end) - : m_router(router), m_poly(beg, end) + : m_router(router), m_routingSettings(GetCarRoutingSettings()), m_poly(beg, end) { Update(); } diff --git a/routing/routing_settings.hpp b/routing/routing_settings.hpp index f9c62e3f21..1eb6ecdff5 100644 --- a/routing/routing_settings.hpp +++ b/routing/routing_settings.hpp @@ -10,13 +10,6 @@ namespace routing /// For example, route matching properties, rerouting properties and so on. struct RoutingSettings { - RoutingSettings() : m_matchBearing(true), m_matchingThresholdM(50.) {} - RoutingSettings(bool routeMatchingBearing, double halfRouteMatchingPassageMeters) - : m_matchBearing(routeMatchingBearing), - m_matchingThresholdM(halfRouteMatchingPassageMeters) - { - } - /// \brief if m_matchBearing is equal to true the bearing follows the /// route direction if the current position is matched to the route. /// If m_matchBearing is equal to false GPS bearing is used while @@ -29,4 +22,14 @@ struct RoutingSettings /// the closest point to the route. double m_matchingThresholdM; }; + +inline RoutingSettings GetPedestrianRoutingSettings() +{ + return RoutingSettings({ false /* m_matchBearing */, 20. /* m_matchingThresholdM */ }); +} + +inline RoutingSettings GetCarRoutingSettings() +{ + return RoutingSettings({ true /* m_matchBearing */, 50. /* m_matchingThresholdM */ }); +} } // namespace routing