Filtering out GPX positions when accuracy is less than 10 m

This commit is contained in:
Eric van der Vlist 2023-03-06 14:36:15 +01:00
parent 5404a6e5ad
commit bf179a4b6d
1 changed files with 7 additions and 4 deletions

View File

@ -42,7 +42,10 @@ const GpxRecord: Component<{}> = (props) => {
location.time - globalThis.$lastValidLocationTime location.time - globalThis.$lastValidLocationTime
}` }`
); );
if (location.time - globalThis.$lastValidLocationTime > 15000) { if (
location.accuracy < 10 &&
location.time - globalThis.$lastValidLocationTime > 15000
) {
globalThis.$lastValidLocationTime = location.time; globalThis.$lastValidLocationTime = location.time;
await dispatch({ await dispatch({
action: 'appendTrkpt', action: 'appendTrkpt',
@ -87,7 +90,7 @@ const GpxRecord: Component<{}> = (props) => {
const trkIdObj = getUri('trk', trkId); const trkIdObj = getUri('trk', trkId);
setTrksegId({ ...trkIdObj, trkseg: 0 }); setTrksegId({ ...trkIdObj, trkseg: 0 });
globalThis.$lastValidLocationTime = 0; globalThis.$lastValidLocationTime = 0;
const id = await startBackgroundGeolocation(newLocationHandler, 20); const id = await startBackgroundGeolocation(newLocationHandler, 10);
setWatcherId(id); setWatcherId(id);
setState('recording'); setState('recording');
setOpen(false); setOpen(false);
@ -99,7 +102,7 @@ const GpxRecord: Component<{}> = (props) => {
}; };
const resumeRecordingHandler = async () => { const resumeRecordingHandler = async () => {
setTrksegId({ ...trksegId()!, trkseg: trksegId()!.trkseg + 1 }); setTrksegId({ ...trksegId()!, trkseg: trksegId()!.trkseg + 1 });
const id = await startBackgroundGeolocation(newLocationHandler, 20); const id = await startBackgroundGeolocation(newLocationHandler, 10);
setWatcherId(id); setWatcherId(id);
setState('recording'); setState('recording');
setOpen(false); setOpen(false);