Baseflow / Baseflow/flutter-geolocator

Is distanceFilter working for AppleSettings?

Open
#1,116 15 comments 3 reactions 0 assignees View on GitHub
P2 platform: ios type: bug
Dominant language
Dart
Stars
1.3k
Forks
803
Avg merge
8h 16m
Merged PRs (30d)
1

Description

## 💬 Questions and Help
I have initialized my Geolocator stream for iOS like this

```dart
if (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.macOS) {
locationSettings = AppleSettings(
accuracy: LocationAccuracy.high,
activityType: ActivityType.automotiveNavigation,
distanceFilter: 50,
pauseLocationUpdatesAutomatically: true,
// Only set to true if our app will be started up in the background.
showBackgroundLocationIndicator: false,
);
}

final positionStream = _geolocatorPlatform.getPositionStream(
locationSettings: locationSettings);
```

However, I seem to be receiving updates every second regardless of distance. This is an example of data received

```json
[
{
"timestamp": "2022-08-04 13:10:09",
"distance": 0
},
{
"timestamp": "2022-08-04 13:10:10",
"distance": 7.9757947805834
},
{
"timestamp": "2022-08-04 13:10:11",
"distance": 2.2674748423432
},
{
"timestamp": "2022-08-04 13:10:12",
"distance": 4.141630343381
},
{
"timestamp": "2022-08-04 13:10:13",
"distance": 1.5377582965926
},
{
"timestamp": "2022-08-04 13:10:14",
"distance": 1.1669075782772
},
{
"timestamp": "2022-08-04 13:10:15",
"distance": 0.27485665948729
},
{
"timestamp": "2022-08-04 13:10:16",
"distance": 0.66052748583651
},
{
"timestamp": "2022-08-04 13:10:17",
"distance": 0.34274642153663
},
{
"timestamp": "2022-08-04 13:10:18",
"distance": 0.40991233672361
},
{
"timestamp": "2022-08-04 13:10:19",
"distance": 0.5831300397487
},
{
"timestamp": "2022-08-04 13:10:20",
"distance": 0.00000003401181987862
},
{
"timestamp": "2022-08-04 13:10:32",
"distance": 1.3311573986273
},
{
"timestamp": "2022-08-04 13:10:33",
"distance": 1.2222122786832
},
{
"timestamp": "2022-08-04 13:10:34",
"distance": 0.28793988602762
},
{
"timestamp": "2022-08-04 13:10:35",
"distance": 0.4164630124995
},
{
"timestamp": "2022-08-04 13:10:36",
"distance": 0.30794720696947
},
{
"timestamp": "2022-08-04 13:10:37",
"distance": 3.4094678449345
},
{
"timestamp": "2022-08-04 13:10:38",
"distance": 7.9905255943094
},
{
"timestamp": "2022-08-04 13:10:39",
"distance": 6.5815206312327
},
{
"timestamp": "2022-08-04 13:10:40",
"distance": 11.338309130389
},
{
"timestamp": "2022-08-04 13:10:41",
"distance": 13.215053045416
},
{
"timestamp": "2022-08-04 13:10:42",
"distance": 15.486864727375
},
{
"timestamp": "2022-08-04 13:10:43",
"distance": 16.336293198668
},
{
"timestamp": "2022-08-04 13:10:44",
"distance": 17.58629081234
},
{
"timestamp": "2022-08-04 13:10:45",
"distance": 18.380570582603
},
{
"timestamp": "2022-08-04 13:10:46",
"distance": 19.141020237324
},
{
"timestamp": "2022-08-04 13:10:47",
"distance": 18.563242076721
},
{
"timestamp": "2022-08-04 13:10:48",
"distance": 18.324582857798
},
{
"timestamp": "2022-08-04 13:10:49",
"distance": 19.284692748053
},
{
"timestamp": "2022-08-04 13:10:50",
"distance": 18.381268944416
},
{
"timestamp": "2022-08-04 13:10:51",
"distance": 17.915914755432
},
{
"timestamp": "2022-08-04 13:10:52",
"distance": 18.221607618619
},
{
"timestamp": "2022-08-04 13:10:55",
"distance": 61.908366570742
},
{
"timestamp": "2022-08-04 13:10:56",
"distance": 18.260683415718
},
{
"timestamp": "2022-08-04 13:10:58",
"distance": 19.182044286679
},
{
"timestamp": "2022-08-04 13:10:58",
"distance": 16.727495452973
},
{
"timestamp": "2022-08-04 13:11:22",
"distance": 447.62542741244
},
{
"timestamp": "2022-08-04 13:11:23",
"distance": 19.13914836906
},
{
"timestamp": "2022-08-04 13:11:24",
"distance": 15.278570182625
},
{
"timestamp": "2022-08-04 13:11:25",
"distance": 21.834957704957
},
{
"timestamp": "2022-08-04 13:11:26",
"distance": 19.395564454341
},
{
"timestamp": "2022-08-04 13:11:27",
"distance": 19.93235735733
},
{
"timestamp": "2022-08-04 13:11:28",
"distance": 20.518736611075
},
{
"timestamp": "2022-08-04 13:11:29",
"distance": 20.728230757645
},
{
"timestamp": "2022-08-04 13:11:30",
"distance": 20.40131998597
},
{
"timestamp": "2022-08-04 13:11:31",
"distance": 19.927232099813
},
{
"timestamp": "2022-08-04 13:11:32",
"distance": 19.900167173362
},
{
"timestamp": "2022-08-04 13:11:33",
"distance": 17.142442188899
},
{
"timestamp": "2022-08-04 13:11:34",
"distance": 18.734180067823
}
]
```

For a 64 km drive, this resulted in 3586 updates with an average distance of 17.7 meters. The huge number of updates use processing time and power, and storage. I set my distanceFilter to 50 meters to prevent that many updates, but it seems to be not working. Is there a way to do that?

Contributor guide

Open the contributing guide

Research direction

Start with the iOS AppleSettings configuration and the getPositionStream entry point, reproducing the reported distanceFilter: 50 behavior. Compare emitted updates with the configured threshold and document or test the expected filtering behavior; the issue is done when excessive updates are prevented or the platform limitation is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.