I'm making an android function that saves the route path that my client travels in while he is logged-in to my app. Kind of like how Uber tracks the ride path.
This works fine most of the time, Like many before me have stated, the GoogleLocationclient API sometimes returns "BAD" locations in its "onLocationChanged" function.
Let me define "BAD" location :- these are location updates that are fetched while the LocationRequest.setPriority = LocationRequest.PRIORITY_HIGH_ACCURACY and the returned Location has a Location.getAccuracy() < 50, but is more than 1000 meters off the actual current location.
So to deal with this issue, I've setup a 3 point queue which caches 3 consecutive location updates and compares them to each other and saves the middle location only if its distance to 1st and 3rd location is lesser than the location between the 1st and 3rd points.
This approach works fine when only one error point pops up between 2 accurate points.
MY PROBLEM
When more then 2 "BAD" locations received consecutively, this logic fails to filter out the incorrect location and no future points get validated. :(
Can anyone suggest :- a) algorithm for optimizing the filtering of location updates
or
b) algorithm to filter out "BAD" locations after collecting all the location points for the trip.
Any help is much appreciated. If this is a duplicate question, kindly forgive my oversight and link me to the original :).
TIA.