mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-08 20:33:06 +02:00
Statistics: used when only the data is needed (instead of passing SegmentStatisticUpdater).
This commit is contained in:
@@ -89,6 +89,7 @@ public class SegmentStatisticUpdater {
|
||||
isIdle = other.isIdle;
|
||||
}
|
||||
|
||||
@Deprecated //TODO Remove
|
||||
@VisibleForTesting
|
||||
public SegmentStatisticUpdater(String startTime, String stopTime, double totalDistance_m, int totalTime_s, int movingTime_s, float maxSpeed_mps, Float totalAltitudeGain_m, Float totalAltitudeLoss_m) {
|
||||
this.startTime = Instant.parse(startTime);
|
||||
@@ -286,10 +287,6 @@ public class SegmentStatisticUpdater {
|
||||
movingTime = movingTime.plus(time);
|
||||
}
|
||||
|
||||
public Duration getStoppedTime() {
|
||||
return totalTime.minus(movingTime);
|
||||
}
|
||||
|
||||
public boolean isIdle() {
|
||||
return isIdle;
|
||||
}
|
||||
@@ -423,6 +420,7 @@ public class SegmentStatisticUpdater {
|
||||
totalAltitudeLoss_m += loss_m;
|
||||
}
|
||||
|
||||
@Deprecated //TODO Remove as it should (a) not be necessary and (b) toString is not complete?
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -37,7 +37,32 @@ public record Statistics(
|
||||
Power avgPower
|
||||
) {
|
||||
|
||||
public Duration getStoppedTime() {
|
||||
return totalTime.minus(movingTime);
|
||||
}
|
||||
|
||||
public Speed getAverageSpeed() {
|
||||
if (totalTime.isZero()) {
|
||||
return Speed.of(0);
|
||||
}
|
||||
return Speed.of(totalDistance, totalTime);
|
||||
}
|
||||
|
||||
public Speed getAverageMovingSpeed() {
|
||||
return Speed.of(totalDistance, movingTime);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
//TODO null should be return (need adjusting ContentPtoviderUtils.createContentValues()
|
||||
public double getMinAltitude() {
|
||||
if (altitudeMin_m == null) return 0;
|
||||
return altitudeMin_m;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
//TODO null should be return (need adjusting ContentPtoviderUtils.createContentValues()
|
||||
public double getMaxAltitude() {
|
||||
if (altitudeMax_m == null) return 0;
|
||||
return altitudeMax_m;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public class TrackStatisticsUpdater {
|
||||
resetAverageHeartRate();
|
||||
}
|
||||
|
||||
//TODO Return Statistic?
|
||||
public SegmentStatisticUpdater getTrackStatistics() {
|
||||
// Take a snapshot - we don't want anyone messing with our trackStatistics
|
||||
SegmentStatisticUpdater stats = new SegmentStatisticUpdater(segmentStatisticUpdater);
|
||||
|
||||
Reference in New Issue
Block a user