8 typedef std::deque<double> Array;
9 struct VelocityLogItem {
18 VelocityLogItem( const uint32_t timeStamp, const double velocity ) :
19 timeStamp( timeStamp ),
24 typedef std::deque<VelocityLogItem> VelocityyArray;
25 typedef std::deque<double> VelocityLog;
26 const uint32_t k_velocityMeasuringDistance = 5000;
29 VelocityyArray m_velocityArray;
30 VelocityLog m_velocityLog;
44 inline void updateVelocity( const double velocity, const uint32_t timeStamp )
46 m_velocityArray.push_back( VelocityLogItem( timeStamp, velocity ) );
48 removeOldItem( timeStamp );
51 m_velocity = fastestVelocity();;
54 // Google
\90æ
\90¶
\9eH
\82
\81u
\92n
\8b\85\82Ì
\8aO
\8eü
\82Í40,075km
\81v
\81u1
\83m
\83b
\83g
\82Í1.85200km
\81v
55 // 1
\90¢
\8aE
\8dÀ
\95W
\82Í40,075km/16384points
56 //
\8eÀ
\8e\9e\8aÔ1
\95b
\82Å
\83Q
\81[
\83\80\93à0.4
\8e\9e\8aÔ
58 //
\90Ô
\93¹
\94¼
\8ca
\82Í6378.137
\82Æ
\82·
\82é
\82Æ
\8aO
\8eü
\82Í2*M_PI_*6378.137=40075.016685578483111
59 inline double velocityByKnot() const
62 //static const double k_knotFactor = 40075.0 / 16384.0 / 0.4 / 1.85200;
63 static const double k_knotFactor = (2 * M_PI * 6378.137) / 16384.0 / 0.4 / 1.85200;
64 return m_velocity * k_knotFactor;
68 inline double calcVelocityPerSecond()
70 double velocity = 0.0;
72 if ( m_velocityArray.size() < 2 ) {
76 //
\88Ú
\93®
\95½
\8bÏ
\92l
77 for ( VelocityyArray::const_iterator it = m_velocityArray.begin(); it != m_velocityArray.end(); ++it ) {
78 velocity += it->velocity;
80 velocity /= m_velocityArray.size();
84 inline void removeOldItem(const uint32_t timeStamp)
86 VelocityyArray::const_iterator removeMark = m_velocityArray.end();
87 for ( VelocityyArray::const_iterator it = m_velocityArray.begin(); it != m_velocityArray.end(); ++it ) {
88 const uint32_t dt = timeStamp - it->timeStamp;
89 if ( dt <= k_velocityMeasuringDistance ) {
94 if ( removeMark != m_velocityArray.end() ) {
95 m_velocityArray.erase( m_velocityArray.begin(), removeMark );
99 inline void updateVelocityLog()
101 m_velocityLog.push_back( calcVelocityPerSecond() );
102 if ( 3 < m_velocityLog.size() ) {
103 m_velocityLog.pop_front();
107 inline double fastestVelocity() const
109 double fastest = 0.0;
111 VelocityLog::const_iterator it = std::max_element( m_velocityLog.begin(), m_velocityLog.end() );
112 if ( it != m_velocityLog.end() ) {