Bugfix: overestimated distance.

A combination of idle trackpoint and stale GPS data, resulted in recording lat=0.0 and lng=0.0; and thus inflating distance as well as GPS-based speed.

Fixes #1898.

Introduced in dfdbc373ff
This commit is contained in:
Dennis Guse
2024-04-25 22:51:51 +02:00
parent 36474e8541
commit e590e4e07e
4 changed files with 57 additions and 6 deletions
@@ -44,7 +44,7 @@ public abstract class Aggregator<Input, Output> {
public Output getValue() {
if (!hasValue()) {
return null;
return null; //TODO Check if this is a good idea!
}
if (isRecent()) {
return value;
@@ -4,7 +4,10 @@ import android.location.Location;
import androidx.annotation.NonNull;
public class AggregatorGPS extends Aggregator<Location, Location> {
import java.util.Optional;
public class AggregatorGPS extends Aggregator<Location, Optional<Location>> {
public AggregatorGPS(String sensorAddress) {
super(sensorAddress);
@@ -12,7 +15,7 @@ public class AggregatorGPS extends Aggregator<Location, Location> {
@Override
protected void computeValue(Raw<Location> current) {
value = current.value();
value = Optional.of(current.value());
}
@Override
@@ -22,7 +25,7 @@ public class AggregatorGPS extends Aggregator<Location, Location> {
@NonNull
@Override
protected Location getNoneValue() {
return new Location("none");
protected Optional<Location> getNoneValue() {
return Optional.empty();
}
}
@@ -152,7 +152,8 @@ public final class SensorDataSet {
public void fillTrackPoint(TrackPoint trackPoint) {
if (gps != null && gps.hasValue()) {
trackPoint.setLocation(gps.getValue());
gps.getValue()
.ifPresent(trackPoint::setLocation);
}
if (getHeartRate() != null) {