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:
+1
@@ -492,6 +492,7 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
.setSensorDistance(Distance.of(2)),
|
.setSensorDistance(Distance.of(2)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, null)
|
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, null)
|
||||||
.setSensorDistance(Distance.of(11))
|
.setSensorDistance(Distance.of(11))
|
||||||
|
.setSpeed(Speed.of(5))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f)
|
.setAltitudeLoss(0f)
|
||||||
.setSensorDistance(Distance.of(2))
|
.setSensorDistance(Distance.of(2))
|
||||||
|
|||||||
@@ -349,6 +349,13 @@ public class TrackPoint {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TrackPoint minusSensorDistance(@NonNull TrackPoint lastTrackPoint) {
|
||||||
|
if (hasSensorDistance() && lastTrackPoint.hasSensorDistance()) {
|
||||||
|
setSensorDistance(getSensorDistance().minus(lastTrackPoint.getSensorDistance()));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasSensorData() {
|
public boolean hasSensorData() {
|
||||||
return hasHeartRate() || hasCyclingCadence() || hasPower();
|
return hasHeartRate() || hasCyclingCadence() || hasPower();
|
||||||
}
|
}
|
||||||
@@ -396,10 +403,9 @@ public class TrackPoint {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String result = "time=" + getTime() + " (type=" + getType() + ")";
|
String result = "time=" + getTime() + " (type=" + getType() + ")";
|
||||||
if (!hasLocation()) {
|
if (hasLocation()) {
|
||||||
return result;
|
result += ": lat=" + getLatitude() + " lng=" + getLongitude();
|
||||||
}
|
}
|
||||||
result += ": lat=" + getLatitude() + " lng=" + getLongitude();
|
|
||||||
if (hasHorizontalAccuracy()) {
|
if (hasHorizontalAccuracy()) {
|
||||||
result += " acc=" + getHorizontalAccuracy();
|
result += " acc=" + getHorizontalAccuracy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ public final class SensorDataSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cyclingDistanceSpeed != null && cyclingDistanceSpeed.hasValue()) {
|
if (cyclingDistanceSpeed != null && cyclingDistanceSpeed.hasValue()) {
|
||||||
trackPoint.setSensorDistance(cyclingDistanceSpeed.getValue().getDistanceOverall());
|
trackPoint.setSensorDistance(cyclingDistanceSpeed.getValue().getDistanceOverall())
|
||||||
trackPoint.setSpeed(cyclingDistanceSpeed.getValue().getSpeed());
|
.setSpeed(cyclingDistanceSpeed.getValue().getSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cyclingPower != null && cyclingPower.hasValue()) {
|
if (cyclingPower != null && cyclingPower.hasValue()) {
|
||||||
@@ -82,9 +82,9 @@ public final class SensorDataSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (runningDistanceSpeedCadence != null && runningDistanceSpeedCadence.hasValue()) {
|
if (runningDistanceSpeedCadence != null && runningDistanceSpeedCadence.hasValue()) {
|
||||||
trackPoint.setSensorDistance(runningDistanceSpeedCadence.getValue().getDistance());
|
trackPoint.setSensorDistance(runningDistanceSpeedCadence.getValue().getDistance())
|
||||||
trackPoint.setSpeed(runningDistanceSpeedCadence.getValue().getSpeed());
|
.setSpeed(runningDistanceSpeedCadence.getValue().getSpeed())
|
||||||
trackPoint.setCyclingCadence_rpm(runningDistanceSpeedCadence.getValue().getCadence());
|
.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.");
|
Log.w(TAG, "Ignore insertTrackPoint. trackPoint time same as last valid trackId point time.");
|
||||||
} else {
|
} else {
|
||||||
insertTrackPointHelper(trackId, lastTrackPoint);
|
insertTrackPointHelper(trackId, lastTrackPoint);
|
||||||
|
// Remove the sensorDistance from trackPoint that is already going be stored with lastTrackPoint.
|
||||||
|
trackPoint.minusSensorDistance(lastTrackPoint);
|
||||||
}
|
}
|
||||||
lastTrackPoint = null;
|
lastTrackPoint = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user