forked from upstream-mirrors/OpenTracks
Removed altitude smoothing completely: now it will just be the plain GPS-reported value.
Was only used for statistics in exports. Follow-up to #1241.
This commit is contained in:
@@ -86,7 +86,7 @@ public class TrackStatisticsUpdaterTest {
|
||||
assertEquals(Duration.ofSeconds(9), statistics.getMovingTime());
|
||||
|
||||
assertEquals(2.5, statistics.getMinAltitude(), 0.01);
|
||||
assertEquals(28.75, statistics.getMaxAltitude(), 0.01);
|
||||
assertEquals(32.5, statistics.getMaxAltitude(), 0.01);
|
||||
assertEquals(36, statistics.getTotalAltitudeGain(), 0.01);
|
||||
assertEquals(36, statistics.getTotalAltitudeLoss(), 0.01);
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package de.dennisguse.opentracks.stats;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import de.dennisguse.opentracks.data.models.Altitude;
|
||||
|
||||
public class AltitudeRingBuffer extends RingBuffer<Altitude> {
|
||||
|
||||
private Altitude firstAltitude;
|
||||
|
||||
AltitudeRingBuffer(int size) {
|
||||
super(size);
|
||||
}
|
||||
|
||||
AltitudeRingBuffer(RingBuffer<Altitude> toCopy) {
|
||||
super(toCopy);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected Number from(Altitude object) {
|
||||
if (firstAltitude == null) {
|
||||
firstAltitude = object;
|
||||
}
|
||||
return object.toM();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Altitude to(double object) {
|
||||
return firstAltitude.replace(object);
|
||||
}
|
||||
}
|
||||
@@ -41,12 +41,6 @@ import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||
*/
|
||||
public class TrackStatisticsUpdater {
|
||||
|
||||
/**
|
||||
* The number of altitude readings to smooth to get a somewhat accurate signal.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
private static final int ALTITUDE_SMOOTHING_FACTOR = 25;
|
||||
|
||||
/**
|
||||
* The number of speed reading to smooth to get a somewhat accurate signal.
|
||||
*/
|
||||
@@ -63,7 +57,6 @@ public class TrackStatisticsUpdater {
|
||||
|
||||
private final TrackStatistics trackStatistics;
|
||||
|
||||
private final AltitudeRingBuffer altitudeBuffer;
|
||||
private final SpeedRingBuffer speedBuffer;
|
||||
private float averageHeartRateBPM;
|
||||
private Duration totalHeartRateDuration = Duration.ZERO;
|
||||
@@ -86,7 +79,6 @@ public class TrackStatisticsUpdater {
|
||||
this.trackStatistics = trackStatistics;
|
||||
this.currentSegment = new TrackStatistics();
|
||||
|
||||
altitudeBuffer = new AltitudeRingBuffer(ALTITUDE_SMOOTHING_FACTOR);
|
||||
speedBuffer = new SpeedRingBuffer(SPEED_SMOOTHING_FACTOR);
|
||||
resetAverageHeartRate();
|
||||
}
|
||||
@@ -95,7 +87,6 @@ public class TrackStatisticsUpdater {
|
||||
this.currentSegment = new TrackStatistics(toCopy.currentSegment);
|
||||
this.trackStatistics = new TrackStatistics(toCopy.trackStatistics);
|
||||
|
||||
this.altitudeBuffer = new AltitudeRingBuffer(toCopy.altitudeBuffer);
|
||||
this.speedBuffer = new SpeedRingBuffer(toCopy.speedBuffer);
|
||||
|
||||
this.lastTrackPoint = toCopy.lastTrackPoint;
|
||||
@@ -140,11 +131,7 @@ public class TrackStatisticsUpdater {
|
||||
|
||||
//Update absolute (GPS-based) altitude
|
||||
if (trackPoint.hasAltitude()) {
|
||||
// Update altitude using the smoothed average
|
||||
altitudeBuffer.setNext(trackPoint.getAltitude());
|
||||
Altitude newAverage = altitudeBuffer.getAverage();
|
||||
|
||||
currentSegment.updateAltitudeExtremities(newAverage);
|
||||
currentSegment.updateAltitudeExtremities(trackPoint.getAltitude());
|
||||
}
|
||||
|
||||
// Update heart rate
|
||||
@@ -198,7 +185,6 @@ public class TrackStatisticsUpdater {
|
||||
currentSegment.reset(trackPoint.getTime());
|
||||
|
||||
lastTrackPoint = null;
|
||||
altitudeBuffer.reset();
|
||||
speedBuffer.reset();
|
||||
resetAverageHeartRate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user