Skip to content

Commit d0505a0

Browse files
committed
Add enableAccuracyFilter option to AndroidSettings class
1 parent 57a6be5 commit d0505a0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

geolocator_android/lib/src/types/android_settings.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class AndroidSettings extends LocationSettings {
99
///
1010
/// The following default values are used:
1111
/// - forceLocationManager: false
12+
/// - enableAccuracyFilter: false
1213
AndroidSettings({
1314
this.forceLocationManager = false,
1415
super.accuracy,
@@ -17,6 +18,7 @@ class AndroidSettings extends LocationSettings {
1718
super.timeLimit,
1819
this.foregroundNotificationConfig,
1920
this.useMSLAltitude = false,
21+
this.enableAccuracyFilter = false,
2022
});
2123

2224
/// Forces the Geolocator plugin to use the legacy LocationManager instead of
@@ -71,6 +73,21 @@ class AndroidSettings extends LocationSettings {
7173
/// Defaults to false
7274
final bool useMSLAltitude;
7375

76+
/// Enables filtering for inaccurate GPS positions that might cause random GPS drift.
77+
///
78+
/// When enabled, the plugin will filter out location updates that are physically implausible
79+
/// based on speed, distance jumps, and accuracy thresholds. This is useful for applications
80+
/// that require smooth location tracking without sudden jumps that can occur due to GPS
81+
/// inaccuracies.
82+
///
83+
/// The filter uses the following criteria to filter out problematic positions:
84+
/// - Locations with very poor accuracy (> 300 meters)
85+
/// - Unrealistically high speeds (> 280 m/s or ~1000 km/h)
86+
/// - Large position jumps combined with poor accuracy
87+
///
88+
/// Defaults to false
89+
final bool enableAccuracyFilter;
90+
7491
@override
7592
Map<String, dynamic> toJson() {
7693
return super.toJson()
@@ -79,6 +96,7 @@ class AndroidSettings extends LocationSettings {
7996
'timeInterval': intervalDuration?.inMilliseconds,
8097
'foregroundNotificationConfig': foregroundNotificationConfig?.toJson(),
8198
'useMSLAltitude': useMSLAltitude,
99+
'enableAccuracyFilter': enableAccuracyFilter,
82100
});
83101
}
84102
}

0 commit comments

Comments
 (0)