Ignore steps inside the accuracy of both fixes

Indoors, GNSS fixes land 10 to 25 m off with a reported accuracy of
10 to 14 m. A step only has to exceed the new fix's accuracy, so most
of this noise was uploaded. The previous fix can be off as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AuthorKonata <konata@posteo.jp>
Date
Commite6668dcf2281de0be1a0c41aca7192dbb4cfc60a
Parentb82d3cd
2 files changed, 5 insertions(+), 5 deletions(-)
▾Mandroid/app/src/main/java/org/opentracker/SamplingPolicy.kt
@@ -136,8 +136,8 @@ class SamplingPolicy {
(fix.accuracy ?: 0f) > MAX_ACCURACY -> age >= STALE_MS
age >= HEARTBEAT_MS -> true
mode == Mode.STATIONARY -> distance(last, fix) > DEPARTURE_M
// A step inside the fix's own accuracy is noise.
else -> distance(last, fix) >= max(if (mode == Mode.VEHICLE) 20.0 else 10.0, (fix.accuracy ?: 0f).toDouble())
// Both positions can be off by their accuracy. A shorter step is noise.
else -> distance(last, fix) >= max(if (mode == Mode.VEHICLE) 20.0 else 10.0, ((last.accuracy ?: 0f) + (fix.accuracy ?: 0f)).toDouble())
}
if (ok) {
kept.add(i + 1, fix)
▾Mandroid/app/src/test/java/org/opentracker/SamplingPolicyTest.kt
@@ -94,9 +94,9 @@ class SamplingPolicyTest {
val p = SamplingPolicy()
assertTrue(p.onFix(fix(0, speed = 1.5f)))
assertFalse(p.onFix(fix(30_000, 4.0, speed = 1.5f)))
assertTrue(p.onFix(fix(60_000, 40.0, speed = 1.5f)))
assertFalse(p.onFix(fix(90_000, 65.0, speed = 1.5f, acc = 30f)))
assertTrue(p.onFix(fix(120_000, 75.0, speed = 1.5f, acc = 30f)))
assertTrue(p.onFix(fix(60_000, 40.0, speed = 1.5f, acc = 15f)))
assertFalse(p.onFix(fix(90_000, 60.0, speed = 1.5f, acc = 15f)))
assertTrue(p.onFix(fix(120_000, 75.0, speed = 1.5f, acc = 15f)))
}
@Test