forked from upstream-mirrors/OpenTracks
TrackRecordingManager: do not store sensor distance twice (previous TrackPoint's storage was delayed).
Fixes #969.
This commit is contained in:
@@ -349,6 +349,13 @@ public class TrackPoint {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackPoint minusSensorDistance(@NonNull TrackPoint lastTrackPoint) {
|
||||
if (hasSensorDistance() && lastTrackPoint.hasSensorDistance()) {
|
||||
setSensorDistance(getSensorDistance().minus(lastTrackPoint.getSensorDistance()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasSensorData() {
|
||||
return hasHeartRate() || hasCyclingCadence() || hasPower();
|
||||
}
|
||||
@@ -396,10 +403,9 @@ public class TrackPoint {
|
||||
@Override
|
||||
public String toString() {
|
||||
String result = "time=" + getTime() + " (type=" + getType() + ")";
|
||||
if (!hasLocation()) {
|
||||
return result;
|
||||
if (hasLocation()) {
|
||||
result += ": lat=" + getLatitude() + " lng=" + getLongitude();
|
||||
}
|
||||
result += ": lat=" + getLatitude() + " lng=" + getLongitude();
|
||||
if (hasHorizontalAccuracy()) {
|
||||
result += " acc=" + getHorizontalAccuracy();
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ public final class SensorDataSet {
|
||||
}
|
||||
|
||||
if (cyclingDistanceSpeed != null && cyclingDistanceSpeed.hasValue()) {
|
||||
trackPoint.setSensorDistance(cyclingDistanceSpeed.getValue().getDistanceOverall());
|
||||
trackPoint.setSpeed(cyclingDistanceSpeed.getValue().getSpeed());
|
||||
trackPoint.setSensorDistance(cyclingDistanceSpeed.getValue().getDistanceOverall())
|
||||
.setSpeed(cyclingDistanceSpeed.getValue().getSpeed());
|
||||
}
|
||||
|
||||
if (cyclingPower != null && cyclingPower.hasValue()) {
|
||||
@@ -82,9 +82,9 @@ public final class SensorDataSet {
|
||||
}
|
||||
|
||||
if (runningDistanceSpeedCadence != null && runningDistanceSpeedCadence.hasValue()) {
|
||||
trackPoint.setSensorDistance(runningDistanceSpeedCadence.getValue().getDistance());
|
||||
trackPoint.setSpeed(runningDistanceSpeedCadence.getValue().getSpeed());
|
||||
trackPoint.setCyclingCadence_rpm(runningDistanceSpeedCadence.getValue().getCadence());
|
||||
trackPoint.setSensorDistance(runningDistanceSpeedCadence.getValue().getDistance())
|
||||
.setSpeed(runningDistanceSpeedCadence.getValue().getSpeed())
|
||||
.setCyclingCadence_rpm(runningDistanceSpeedCadence.getValue().getCadence());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,6 +207,8 @@ class TrackRecordingManager {
|
||||
Log.w(TAG, "Ignore insertTrackPoint. trackPoint time same as last valid trackId point time.");
|
||||
} else {
|
||||
insertTrackPointHelper(trackId, lastTrackPoint);
|
||||
// Remove the sensorDistance from trackPoint that is already going be stored with lastTrackPoint.
|
||||
trackPoint.minusSensorDistance(lastTrackPoint);
|
||||
}
|
||||
lastTrackPoint = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user