Even Priority_high_accuracy Gives Very Low Accuracy Location Updates
Solution 1:
Sometimes it happens. Moreover, erroneous location fixes can arrive for 5 minutes in a row. To try to filter such coordinates, I used the method described in Location Strategies article (see section Maintaining a current best Estimate).
privatestaticfinalintTWO_MINUTES=1000 * 60 * 2;
/** Determines whether one Location reading is better than the current Location fix
* @param location The new Location that you want to evaluate
* @param currentBestLocation The current Location fix, to which you want to compare the new one
*/protectedbooleanisBetterLocation(Location location, Location currentBestLocation) {
if (currentBestLocation == null) {
// A new location is always better than no locationreturntrue;
}
// Check whether the new location fix is newer or olderlongtimeDelta= location.getTime() - currentBestLocation.getTime();
booleanisSignificantlyNewer= timeDelta > TWO_MINUTES;
booleanisSignificantlyOlder= timeDelta < -TWO_MINUTES;
booleanisNewer= timeDelta > 0;
// If it's been more than two minutes since the current location, use the new location// because the user has likely movedif (isSignificantlyNewer) {
returntrue;
// If the new location is more than two minutes older, it must be worse
} elseif (isSignificantlyOlder) {
returnfalse;
}
// Check whether the new location fix is more or less accurateintaccuracyDelta= (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
booleanisLessAccurate= accuracyDelta > 0;
booleanisMoreAccurate= accuracyDelta < 0;
booleanisSignificantlyLessAccurate= accuracyDelta > 200;
// Check if the old and new location are from the same providerbooleanisFromSameProvider= isSameProvider(location.getProvider(),
currentBestLocation.getProvider());
// Determine location quality using a combination of timeliness and accuracyif (isMoreAccurate) {
returntrue;
} elseif (isNewer && !isLessAccurate) {
returntrue;
} elseif (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
returntrue;
}
returnfalse;
}
/** Checks whether two providers are the same */privatebooleanisSameProvider(String provider1, String provider2) {
if (provider1 == null) {
returnprovider2== null;
}
return provider1.equals(provider2);
}
It was designed for the use with a standard Android Location API, but it works. I just made a few corrections to it, because all fixes have the same provider. It allows me to filter about 30% of "bad" location fixes.
Solution 2:
Distance measurement on raw GPS data will always be noisy, because the underlying data is often inaccurate. These jumps are due to inaccurate location measurements. To achieve, accurate distance measurements, you can need to filter the noise in the data.
Some useful filtering techniques that you can explore are:
- Smoothening location data using Kalman filters - see tutorial
- Snapping to road with Google maps snap-to-roads API, or OSRM match service.
If you are looking for an end-to-end solution that gives accurate location data and distance measurements, you can also try the HyperTrack SDK for Android or iOS. You can read about how they filter locations to improve accuracy on their blog.
Post a Comment for "Even Priority_high_accuracy Gives Very Low Accuracy Location Updates"