diff --git a/map/location_state.cpp b/map/location_state.cpp index 62f5f54508..4a14b9a224 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -65,6 +65,13 @@ namespace location setIsVisible(false); } + double State::ComputeMoveSpeed(m2::PointD const & globalPt0, + m2::PointD const & globalPt1, + ScreenBase const & s) + { + return max(0.1, min(0.5, 0.5 * s.GtoP(globalPt0).Length(s.GtoP(globalPt1)) / 50.0)); + } + bool State::HasPosition() const { return m_hasPosition; @@ -507,7 +514,7 @@ namespace location m2::PointD endPt = Position(); ScreenBase const & s = m_framework->GetNavigator().Screen(); - double speed = min(0.5, 0.5 * s.GtoP(startPt).Length(s.GtoP(endPt)) / 50.0); + double speed = ComputeMoveSpeed(startPt, endPt, s); m_framework->GetAnimator().MoveScreen(startPt, endPt, speed); @@ -523,7 +530,8 @@ namespace location m2::PointD startPt = m_framework->GetNavigator().Screen().GetOrg(); m2::PointD endPt = Position(); ScreenBase const & s = m_framework->GetNavigator().Screen(); - double speed = min(0.5,0.5 * s.GtoP(startPt).Length(s.GtoP(endPt)) / 50.0); + + double speed = ComputeMoveSpeed(startPt, endPt, s); shared_ptr const & t = m_framework->GetAnimator().MoveScreen(startPt, endPt, speed); diff --git a/map/location_state.hpp b/map/location_state.hpp index 069aea46d5..dd521e5104 100644 --- a/map/location_state.hpp +++ b/map/location_state.hpp @@ -5,6 +5,7 @@ #include "../platform/location.hpp" #include "../geometry/point2d.hpp" +#include "../geometry/screenbase.hpp" #include "../std/shared_ptr.hpp" #include "../std/map.hpp" @@ -113,6 +114,10 @@ namespace location void CallCompassStatusListeners(ECompassProcessMode mode); + double ComputeMoveSpeed(m2::PointD const & globalPt0, + m2::PointD const & globalPt1, + ScreenBase const & s); + public: struct Params : base_t::Params