Omit exact duplicates before considering recent displacement.

This commit is contained in:
voussoir 2023-03-26 12:12:42 -07:00
parent fd206249f5
commit 53a1dab2fb
2 changed files with 7 additions and 13 deletions

View file

@ -261,7 +261,12 @@ class TrackerService: Service()
{
// pass
}
else if (! isDifferentEnough(recent_displacement_locations.first(), location, omitRests))
else if (omitRests && recent_displacement_locations.last().latitude == location.latitude && recent_displacement_locations.last().longitude == location.longitude)
{
Log.i("VOUSSOIR", "Omitting due to identical to previous.")
return
}
else if (omitRests && !isDifferentEnough(recent_displacement_locations.first(), location))
{
Log.i("VOUSSOIR", "Omitting due to too close to previous.")
return

View file

@ -146,19 +146,8 @@ fun isAccurateEnough(location: Location, locationAccuracyThreshold: Int): Boolea
}
/* Checks if given location is different enough compared to previous location */
fun isDifferentEnough(previousLocation: Location?, location: Location, omitRests: Boolean): Boolean
fun isDifferentEnough(previousLocation: Location, location: Location): Boolean
{
// check if previous location is (not) available
if (previousLocation == null)
{
return true
}
if (! omitRests)
{
return true
}
// location.accuracy is given as 1 standard deviation, with a 68% chance
// that the true position is within a circle of this radius.
// These formulas determine if the difference between the last point and