Gps - Calculating distance travelled in Android in slow moving traffic

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I am writing a distance calculating app and my approach has been the following.

1. Request location updates every 500ms.
2. Calculate the distance between the previous location and current location using the distanceTo() method in android.location.Location.
3. Update the total distance traveled.

An accuracy check is done to make sure the accuracy is within a given threshold, and only that are accurate enough are taken in for the distance calculation.

This works well and the accuracy has been good. However during slow moving traffic we ve noticed that the distance traveled on the app is more than the actual distance traveled (according to the odometer). I believe this might be because the distance traveled is less than the accuracy given by the phone. Because of this the vehicle might have moved a 2-3 meters but since the accuracy is around 6-8 meters there is an error introduced to the distance calculation.

Has anyone had similar experiences with similar applications ? If so what would be the best approach to resolve this ?

Thanks.

Answers

If the travelled distance between the location updates is comparable to or smaller than the accuracy you can expect that the calculated distance is too large. The locations will zig-zag around the real travelled path and sum of the distances over the zigzag path will be larger then the real (mostly straight path). The opposite behavior may occur if the time between the updates is long and the real travelled path contains a lot of curves. In that case, corners will be cut off and the summed calculated distance will be too short.

A simple solution to your problem may be to reduce the update frequency at low speeds (or request location updates based on minimum travelled distance). A better approach is likely to smooth the path described by the observed locations (i.e. remove the zig-zag) e.g. by using the Douglas-Peucker algorithm.

http://www.i-programmer.info/news/145-mapping-a-gis/9164-gps-always-over-estimates-distances.html http://www.i-programmer.info/news/145-mapping-a-gis/9164-gps-always-over-estimates-distances.html

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/34389971/calculating-distance-travelled-in-android-in-slow-moving-traffic

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils