Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Ahmed-Makled
Copy link

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 Ahmed-Makled force-pushed the fix_issue_1574_gps_drift branch from 0f3ff93 to ac62031 Compare May 14, 2025 23:06
@TimHoogstrate
Copy link
Contributor

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants