| 146 | } |
| 147 | |
| 148 | void Extrapolator::ExtrapolatedLocationUpdate(uint64_t locationUpdateCounter) |
| 149 | { |
| 150 | location::GpsInfo gpsInfo; |
| 151 | { |
| 152 | lock_guard<mutex> guard(m_mutex); |
| 153 | // Canceling all calls of the method which were activated before |m_locationUpdateMinValid|. |
| 154 | if (locationUpdateCounter < m_locationUpdateMinValid) |
| 155 | return; |
| 156 | |
| 157 | uint64_t const extrapolationTimeMs = kExtrapolationPeriodMs * m_consecutiveRuns; |
| 158 | if (extrapolationTimeMs < kMaxExtrapolationTimeMs && m_lastGpsInfo.IsValid()) |
| 159 | { |
| 160 | if (DoesExtrapolationWork()) |
| 161 | gpsInfo = LinearExtrapolation(m_beforeLastGpsInfo, m_lastGpsInfo, extrapolationTimeMs); |
| 162 | else |
| 163 | gpsInfo = m_lastGpsInfo; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if (gpsInfo.IsValid()) |
| 168 | GetPlatform().RunTask(Platform::Thread::Gui, [this, gpsInfo]() { m_extrapolatedLocationUpdate(gpsInfo); }); |
| 169 | |
| 170 | { |
| 171 | lock_guard<mutex> guard(m_mutex); |
| 172 | if (m_consecutiveRuns != kExtrapolationCounterUndefined) |
| 173 | ++m_consecutiveRuns; |
| 174 | } |
| 175 | |
| 176 | // Calling ExtrapolatedLocationUpdate() in |kExtrapolationPeriodMs| milliseconds. |
| 177 | RunTaskOnBackgroundThread(true /* delayed */); |
| 178 | } |
| 179 | |
| 180 | void Extrapolator::RunTaskOnBackgroundThread(bool delayed) |
| 181 | { |
nothing calls this directly
no test coverage detected