diff --git a/routing/route.hpp b/routing/route.hpp index eb3ca74801..fe3f56f14c 100644 --- a/routing/route.hpp +++ b/routing/route.hpp @@ -60,7 +60,7 @@ public: uint32_t GetTotalTimeSec() const; uint32_t GetCurrentTimeToEndSec() const; - FollowedPolyline const & GetFollowedPolyline() const {return m_poly;} + FollowedPolyline const & GetFollowedPolyline() const { return m_poly; } string const & GetRouterId() const { return m_router; } m2::PolylineD const & GetPoly() const { return m_poly.GetPolyline(); } diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index 66b4054193..60a73af604 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -34,9 +34,9 @@ double constexpr kSpeedCameraMinimalWarningMeters = 200.; // Seconds to warning user before speed camera for driving with current speed. double constexpr kSpeedCameraWarningSeconds = 30; -double constexpr kKmhToMps = 1000. / 3600.; +double constexpr kKmHToMps = 1000. / 3600.; -static double constexpr kInvalidSpeedCameraDistance = -1; +double constexpr kInvalidSpeedCameraDistance = -1; } // namespace namespace routing @@ -44,9 +44,9 @@ namespace routing struct SpeedCameraRestriction { uint32_t m_index; // Index of a polyline point where camera is located. - uint8_t m_maxSpeed; // Maximum speed allowed by the camera. + uint8_t m_maxSpeedKmH; // Maximum speed allowed by the camera. - SpeedCameraRestriction(uint32_t index, uint8_t maxSpeed) : m_index(index), m_maxSpeed(maxSpeed) {} + SpeedCameraRestriction(uint32_t index, uint8_t maxSpeed) : m_index(index), m_maxSpeedKmH(maxSpeed) {} }; RoutingSession::RoutingSession() @@ -54,8 +54,8 @@ RoutingSession::RoutingSession() m_route(string()), m_state(RoutingNotActive), m_endPoint(m2::PointD::Zero()), - m_lastWarnedSpeedCamera(0), - m_lastCheckedCamera(0), + m_lastWarnedSpeedCameraIndex(0), + m_lastCheckedCameraIndex(0), m_speedWarningSignal(false), m_passedDistanceOnRouteMeters(0.0) { @@ -143,8 +143,8 @@ void RoutingSession::Reset() m_turnsSound.Reset(); m_passedDistanceOnRouteMeters = 0.0; - m_lastWarnedSpeedCamera = 0; - m_lastCheckedCamera = 0; + m_lastWarnedSpeedCameraIndex = 0; + m_lastCheckedCameraIndex = 0; m_speedWarningSignal = false; } @@ -189,13 +189,13 @@ RoutingSession::State RoutingSession::OnLocationPositionChanged(m2::PointD const double const warningDistanceM = max(kSpeedCameraMinimalWarningMeters, info.m_speed * kSpeedCameraWarningSeconds); SpeedCameraRestriction cam(0, 0); - double const camDistance = GetCurrentCam(cam, index); + double const camDistance = GetDistanceToCurrentCamM(cam, index); if (kInvalidSpeedCameraDistance != camDistance && camDistance < warningDistanceM) { - if (cam.m_index > m_lastWarnedSpeedCamera && info.m_speed > cam.m_maxSpeed * kKmhToMps) + if (cam.m_index > m_lastWarnedSpeedCameraIndex && info.m_speed > cam.m_maxSpeedKmH * kKmHToMps) { m_speedWarningSignal = true; - m_lastWarnedSpeedCamera = cam.m_index; + m_lastWarnedSpeedCameraIndex = cam.m_index; } } } @@ -352,8 +352,8 @@ void RoutingSession::AssignRoute(Route & route, IRouter::ResultCode e) route.SetRoutingSettings(m_routingSettings); m_route.Swap(route); - m_lastWarnedSpeedCamera = 0; - m_lastCheckedCamera = 0; + m_lastWarnedSpeedCameraIndex = 0; + m_lastCheckedCameraIndex = 0; } void RoutingSession::SetRouter(unique_ptr && router, @@ -433,21 +433,21 @@ string RoutingSession::GetTurnNotificationsLocale() const return m_turnsSound.GetLocale(); } -double RoutingSession::GetCurrentCam(SpeedCameraRestriction & camera, Index const & index) +double RoutingSession::GetDistanceToCurrentCamM(SpeedCameraRestriction & camera, Index const & index) { auto const & m_poly = m_route.GetFollowedPolyline(); - size_t const currentIndex = max(m_poly.GetCurrentIter().m_ind, m_lastCheckedCamera); + size_t const currentIndex = max(m_poly.GetCurrentIter().m_ind, m_lastCheckedCameraIndex); for (size_t i = currentIndex; i < m_poly.GetPolyline().GetSize(); ++i) { uint8_t speed = CheckCameraInPoint(m_poly.GetPolyline().GetPoint(i), index); if (speed != kNoSpeedCamera) { camera = SpeedCameraRestriction(static_cast(i), speed); - m_lastCheckedCamera = i; + m_lastCheckedCameraIndex = i; return m_poly.GetDistanceM(m_poly.GetCurrentIter(), m_poly.GetIterToIndex(i)); } } - m_lastCheckedCamera = m_poly.GetPolyline().GetSize(); + m_lastCheckedCameraIndex = m_poly.GetPolyline().GetSize(); return kInvalidSpeedCameraDistance; } } // namespace routing diff --git a/routing/routing_session.hpp b/routing/routing_session.hpp index 04b3fef8c5..35ed0fe38f 100644 --- a/routing/routing_session.hpp +++ b/routing/routing_session.hpp @@ -120,7 +120,7 @@ private: /// Returns a nearest speed camera record on your way and distance to it. /// Returns kInvalidSpeedCameraDistance if there is no cameras on your way. - double GetCurrentCam(SpeedCameraRestriction & camera, Index const & index); + double GetDistanceToCurrentCamM(SpeedCameraRestriction & camera, Index const & index); /// RemoveRoute removes m_route and resets route attributes (m_state, m_lastDistance, m_moveAwayCounter). void RemoveRoute(); @@ -131,8 +131,8 @@ private: Route m_route; State m_state; m2::PointD m_endPoint; - size_t m_lastWarnedSpeedCamera; - size_t m_lastCheckedCamera; + size_t m_lastWarnedSpeedCameraIndex; + size_t m_lastCheckedCameraIndex; // TODO (ldragunov) Rewrite UI interop to message queue and avoid mutable. /// This field is mutable because it's modified in a constant getter. Note that the notification /// about camera will be sent at most once.