"method extraction" refactoring for ComputeMoveSpeed.

This commit is contained in:
rachytski 2012-10-19 17:51:26 +03:00 committed by Alex Zolotarev
parent 5080d7ccfe
commit 2bd6a35aeb
2 changed files with 15 additions and 2 deletions

View file

@ -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<MoveScreenTask> const & t = m_framework->GetAnimator().MoveScreen(startPt, endPt, speed);

View file

@ -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