Ignore less acurate updates

This commit is contained in:
Felix Niederwanger 2021-05-28 14:42:59 +02:00
parent 93f4ae4beb
commit 73041e6581
Signed by: phoenix
GPG key ID: 6E77A590E3F6D71C

View file

@ -31,6 +31,16 @@ func mqtt_recv(id string, loc Location) {
if !loc.IsPlausible() { // Ignore stupid locations
return
}
if old, ok := devices[id]; ok { // if we already have a location
if loc.Acc > old.Acc {
// Ignore, if the new location is less precise, and the old one lies within it's accuracy
// This might happen, if there is a provider switch on the phone (e.g. GPX -> coarse location)
distance := old.Distance(loc)
if distance <= loc.Acc {
return
}
}
}
devices[id] = loc
}