flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

Fix issue #1574: Add location accuracy filter to prevent GPS drift

Open Ahmed-Makled opened this issue 7 months ago • 1 comments

Description

This PR addresses issue #1574 by implementing a location accuracy filter to prevent random GPS drift which can cause erratic movement patterns in tracking applications.

Changes

  • Added LocationAccuracyFilter class to filter out location updates with physically implausible movement patterns
  • Implemented filtering based on accuracy, speed, and distance thresholds
  • Added enableAccuracyFilter parameter to AndroidSettings class
  • Added unit tests for different transportation modes and edge cases
  • Updated documentation and CHANGELOG.md

Implementation Details

The filter works by:

  • Detecting locations with very poor accuracy (> 300 meters)
  • Filtering unrealistically high speeds (> 280 m/s or ~1000 km/h)
  • Identifying large position jumps when combined with poor accuracy values
  • Providing a configurable approach that doesn't interfere with legitimate use cases

Testing

The implementation includes comprehensive tests for:

  • Standard walking/driving scenarios (accepted)
  • High-speed transportation like trains (accepted)
  • Unrealistic movements like teleportation (rejected)
  • Different accuracy values and edge cases

This solution is designed to be minimally invasive, with filtering disabled by default to maintain backward compatibility.

Ahmed-Makled avatar May 14 '25 21:05 Ahmed-Makled

Dear @Ahmed-Makled,

This looks very nice. However, this functionality should in our opinion not be the responsibility of the geolocator package. Unfortunately it is also not part of the iOS package. You can always filter out the inaccurate locations by listening to the positionStream and filter out unwanted locations.

Kind regards,

TimHoogstrate avatar May 20 '25 11:05 TimHoogstrate