From bf179a4b6d144b7d606e5c1f346fae4c4d5be05c Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Mon, 6 Mar 2023 14:36:15 +0100 Subject: [PATCH] Filtering out GPX positions when accuracy is less than 10 m --- src/components/gpx-record/GpxRecord.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/gpx-record/GpxRecord.tsx b/src/components/gpx-record/GpxRecord.tsx index 564ae50..6416192 100644 --- a/src/components/gpx-record/GpxRecord.tsx +++ b/src/components/gpx-record/GpxRecord.tsx @@ -42,7 +42,10 @@ const GpxRecord: Component<{}> = (props) => { location.time - globalThis.$lastValidLocationTime }` ); - if (location.time - globalThis.$lastValidLocationTime > 15000) { + if ( + location.accuracy < 10 && + location.time - globalThis.$lastValidLocationTime > 15000 + ) { globalThis.$lastValidLocationTime = location.time; await dispatch({ action: 'appendTrkpt', @@ -62,7 +65,7 @@ const GpxRecord: Component<{}> = (props) => { }, }, }); - setCurrentLocation({lon:location.longitude, lat:location.latitude}); + setCurrentLocation({ lon: location.longitude, lat: location.latitude }); const state = getState(); navigate( `/map/${state.provider}/${location.longitude}/${location.latitude}/${state.zoom}/${state.rotation}` @@ -87,7 +90,7 @@ const GpxRecord: Component<{}> = (props) => { const trkIdObj = getUri('trk', trkId); setTrksegId({ ...trkIdObj, trkseg: 0 }); globalThis.$lastValidLocationTime = 0; - const id = await startBackgroundGeolocation(newLocationHandler, 20); + const id = await startBackgroundGeolocation(newLocationHandler, 10); setWatcherId(id); setState('recording'); setOpen(false); @@ -99,7 +102,7 @@ const GpxRecord: Component<{}> = (props) => { }; const resumeRecordingHandler = async () => { setTrksegId({ ...trksegId()!, trkseg: trksegId()!.trkseg + 1 }); - const id = await startBackgroundGeolocation(newLocationHandler, 20); + const id = await startBackgroundGeolocation(newLocationHandler, 10); setWatcherId(id); setState('recording'); setOpen(false);