From 5f56c1ccf47c96e8c47f39e714a62e288359066e Mon Sep 17 00:00:00 2001 From: ExMix Date: Fri, 19 Sep 2014 19:21:20 +0300 Subject: [PATCH] review fixes --- map/routing_session.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/map/routing_session.cpp b/map/routing_session.cpp index affdc80136..ae4ba688c3 100644 --- a/map/routing_session.cpp +++ b/map/routing_session.cpp @@ -61,29 +61,33 @@ RoutingSession::State RoutingSession::OnLocationPositionChanged(m2::PointD const if (m_state == RouteNotReady || m_state == RouteLeft || m_state == RouteFinished) return m_state; - double currentDist = 0.0; - bool isOnDest = IsOnDestPoint(position, errorRadius); - bool isOnTrack = IsOnRoute(position, errorRadius, currentDist); - - if (isOnDest) + if (IsOnDestPoint(position, errorRadius)) m_state = RouteFinished; - else if (isOnTrack) - m_state = OnRoute; else { - if (currentDist > m_lastMinDist) - { - ++m_moveAwayCounter; - m_lastMinDist = currentDist; - } - else + double currentDist = 0.0; + if (IsOnRoute(position, errorRadius, currentDist)) { + m_state = OnRoute; m_moveAwayCounter = 0; m_lastMinDist = 0.0; } + else + { + if (currentDist > m_lastMinDist) + { + ++m_moveAwayCounter; + m_lastMinDist = currentDist; + } + else + { + m_moveAwayCounter = 0; + m_lastMinDist = 0.0; + } - if (m_moveAwayCounter > 10) - m_state = RouteLeft; + if (m_moveAwayCounter > 10) + m_state = RouteLeft; + } } return m_state;