forked from upstream-mirrors/OpenTracks
TrackRecordingManager: do not store altitude changes twice (previous …
…TrackPoint's storage was delayed). Fixes #969.
This commit is contained in:
@@ -349,9 +349,15 @@ public class TrackPoint {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackPoint minusSensorDistance(@NonNull TrackPoint lastTrackPoint) {
|
||||
public TrackPoint minusCumulativeSensorData(@NonNull TrackPoint lastTrackPoint) {
|
||||
if (hasSensorDistance() && lastTrackPoint.hasSensorDistance()) {
|
||||
setSensorDistance(getSensorDistance().minus(lastTrackPoint.getSensorDistance()));
|
||||
sensorDistance = sensorDistance.minus(lastTrackPoint.getSensorDistance());
|
||||
}
|
||||
if (hasAltitudeGain() && lastTrackPoint.hasAltitudeGain()) {
|
||||
altitudeGain_m -= lastTrackPoint.altitudeGain_m;
|
||||
}
|
||||
if (hasAltitudeLoss() && lastTrackPoint.hasAltitudeLoss()) {
|
||||
altitudeLoss_m -= lastTrackPoint.altitudeLoss_m;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ class TrackRecordingManager {
|
||||
} else {
|
||||
insertTrackPointHelper(trackId, lastTrackPoint);
|
||||
// Remove the sensorDistance from trackPoint that is already going be stored with lastTrackPoint.
|
||||
trackPoint.minusSensorDistance(lastTrackPoint);
|
||||
trackPoint.minusCumulativeSensorData(lastTrackPoint);
|
||||
}
|
||||
lastTrackPoint = null;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,19 @@ public class AltitudeSumManager implements SensorEventListener {
|
||||
return isConnected ? altitudeGain_m : null;
|
||||
}
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
public void addAltitudeGain_m(float altitudeGain_m) {
|
||||
this.altitudeGain_m = this.altitudeGain_m == null ? 0f : this.altitudeGain_m;
|
||||
this.altitudeGain_m += altitudeGain_m ;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void addAltitudeLoss_m(Float altitudeLoss_m) {
|
||||
this.altitudeLoss_m = this.altitudeLoss_m == null ? 0f : this.altitudeLoss_m;
|
||||
this.altitudeLoss_m += altitudeLoss_m ;
|
||||
}
|
||||
|
||||
public @Nullable
|
||||
Float getAltitudeLoss_m() {
|
||||
return isConnected ? altitudeLoss_m : null;
|
||||
|
||||
@@ -77,7 +77,8 @@ public class PressureSensorUtils {
|
||||
* https://de.wikipedia.org/wiki/Barometrische_H%C3%B6henformel#Internationale_H%C3%B6henformel
|
||||
* {\color{White} p(h)} = p_0 \cdot \left( 1 - \frac{0{,}0065 \frac{\mathrm K}{\mathrm m} \cdot h}{T_0\ } \right)^{5{,}255}
|
||||
*/
|
||||
private static float getBarometricPressure(float altitude_m) {
|
||||
@VisibleForTesting
|
||||
public static float getBarometricPressure(float altitude_m) {
|
||||
return (float) (p0 * Math.pow(1.0 - 0.0065 * altitude_m / 288.15, 5.255f));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user