mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-13 22:33:07 +02:00
Update elevation min,max and speed min,max after buffer is full
This commit is contained in:
@@ -231,7 +231,7 @@ public class TripStatisticsUpdater {
|
|||||||
speedBuffer.reset();
|
speedBuffer.reset();
|
||||||
} else if (isValidSpeed(time, speed, lastLocationTime, lastLocationSpeed)) {
|
} else if (isValidSpeed(time, speed, lastLocationTime, lastLocationSpeed)) {
|
||||||
speedBuffer.setNext(speed);
|
speedBuffer.setNext(speed);
|
||||||
if (speed > currentSegment.getMaxSpeed()) {
|
if (speedBuffer.isFull() && speed > currentSegment.getMaxSpeed()) {
|
||||||
currentSegment.setMaxSpeed(speed);
|
currentSegment.setMaxSpeed(speed);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -246,13 +246,12 @@ public class TripStatisticsUpdater {
|
|||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void updateElevation(double elevation) {
|
void updateElevation(double elevation) {
|
||||||
currentSegment.updateElevationExtremities(elevation);
|
// Update elevation using the smoothed average after the buffer is full
|
||||||
|
|
||||||
// update elevation gain
|
|
||||||
double oldAverage = elevationBuffer.getAverage();
|
double oldAverage = elevationBuffer.getAverage();
|
||||||
elevationBuffer.setNext(elevation);
|
elevationBuffer.setNext(elevation);
|
||||||
double newAverage = elevationBuffer.getAverage();
|
double newAverage = elevationBuffer.getAverage();
|
||||||
if (elevationBuffer.isFull()) {
|
if (elevationBuffer.isFull()) {
|
||||||
|
currentSegment.updateElevationExtremities(newAverage);
|
||||||
double difference = newAverage - oldAverage;
|
double difference = newAverage - oldAverage;
|
||||||
if (difference > 0) {
|
if (difference > 0) {
|
||||||
currentSegment.addTotalElevationGain(difference);
|
currentSegment.addTotalElevationGain(difference);
|
||||||
@@ -337,11 +336,12 @@ public class TripStatisticsUpdater {
|
|||||||
* 10X the smoothed average and the speed difference doesn't imply 2g
|
* 10X the smoothed average and the speed difference doesn't imply 2g
|
||||||
* acceleration.
|
* acceleration.
|
||||||
*/
|
*/
|
||||||
if (!speedBuffer.isFull()) {
|
if (speedBuffer.isFull()) {
|
||||||
|
double average = speedBuffer.getAverage();
|
||||||
|
double diff = Math.abs(average - speed);
|
||||||
|
return (speed < average * 10) && (diff < MAX_ACCELERATION * timeDifference);
|
||||||
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
double average = speedBuffer.getAverage();
|
|
||||||
double diff = Math.abs(average - speed);
|
|
||||||
return (speed < average * 10) && (diff < MAX_ACCELERATION * timeDifference);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user