mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-10 05:03:06 +02:00
Cleanup: rename TrackStatistics to SegmentStatisticsUpdater.
This commit is contained in:
+6
-6
@@ -39,7 +39,7 @@ import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||
*/
|
||||
//TODO Check that data ranges are valid (not less than zero etc.)
|
||||
//TODO Should be a Java record
|
||||
public class TrackStatistics {
|
||||
public class SegmentStatisticUpdater {
|
||||
|
||||
// The min and max altitude (meters) seen on this track.
|
||||
private final ExtremityMonitor altitudeExtremities = new ExtremityMonitor();
|
||||
@@ -64,7 +64,7 @@ public class TrackStatistics {
|
||||
|
||||
private boolean isIdle;
|
||||
|
||||
public TrackStatistics() {
|
||||
public SegmentStatisticUpdater() {
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class TrackStatistics {
|
||||
*
|
||||
* @param other another statistics data object to copy from
|
||||
*/
|
||||
public TrackStatistics(TrackStatistics other) {
|
||||
public SegmentStatisticUpdater(SegmentStatisticUpdater other) {
|
||||
startTime = other.startTime;
|
||||
stopTime = other.stopTime;
|
||||
totalDistance = other.totalDistance;
|
||||
@@ -89,7 +89,7 @@ public class TrackStatistics {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public TrackStatistics(String startTime, String stopTime, double totalDistance_m, int totalTime_s, int movingTime_s, float maxSpeed_mps, Float totalAltitudeGain_m, Float totalAltitudeLoss_m) {
|
||||
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);
|
||||
this.stopTime = Instant.parse(stopTime);
|
||||
this.totalDistance = Distance.of(totalDistance_m);
|
||||
@@ -107,7 +107,7 @@ public class TrackStatistics {
|
||||
* @param other another statistics data object
|
||||
*/
|
||||
//TODO Should be refactored to append only [mainly due to isIdle] (NOTE: This requires to use a custom value object for AggregatedStatistics; this is anyhow recommended).
|
||||
public void merge(TrackStatistics other) {
|
||||
public void merge(SegmentStatisticUpdater other) {
|
||||
if (startTime == null) {
|
||||
startTime = other.startTime;
|
||||
} else {
|
||||
@@ -407,7 +407,7 @@ public class TrackStatistics {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof TrackStatistics)) return false;
|
||||
if (!(o instanceof SegmentStatisticUpdater)) return false;
|
||||
|
||||
return toString().equals(o.toString());
|
||||
}
|
||||
@@ -29,8 +29,8 @@ import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
||||
|
||||
/**
|
||||
* Updater for {@link TrackStatistics}.
|
||||
* For updating track {@link TrackStatistics} as new {@link TrackPoint}s are added.
|
||||
* Updater for {@link SegmentStatisticUpdater}.
|
||||
* For updating track {@link SegmentStatisticUpdater} as new {@link TrackPoint}s are added.
|
||||
* NOTE: Some of the locations represent pause/resume separator.
|
||||
* NOTE: Has still support for segments (at the moment unused).
|
||||
*
|
||||
@@ -41,7 +41,7 @@ public class TrackStatisticsUpdater {
|
||||
|
||||
private static final String TAG = TrackStatisticsUpdater.class.getSimpleName();
|
||||
|
||||
private final TrackStatistics trackStatistics;
|
||||
private final SegmentStatisticUpdater segmentStatisticUpdater;
|
||||
|
||||
private float averageHeartRateBPM;
|
||||
private Duration totalHeartRateDuration = Duration.ZERO;
|
||||
@@ -49,38 +49,38 @@ public class TrackStatisticsUpdater {
|
||||
private Duration totalPowerDuration = Duration.ZERO;
|
||||
|
||||
// The current segment's statistics
|
||||
private final TrackStatistics currentSegment;
|
||||
private final SegmentStatisticUpdater currentSegment;
|
||||
// Current segment's last trackPoint
|
||||
private TrackPoint lastTrackPoint;
|
||||
|
||||
public TrackStatisticsUpdater() {
|
||||
this(new TrackStatistics());
|
||||
this(new SegmentStatisticUpdater());
|
||||
}
|
||||
|
||||
public TrackStatisticsUpdater(TrackStatistics trackStatistics) {
|
||||
this.trackStatistics = trackStatistics;
|
||||
this.currentSegment = new TrackStatistics();
|
||||
public TrackStatisticsUpdater(SegmentStatisticUpdater segmentStatisticUpdater) {
|
||||
this.segmentStatisticUpdater = segmentStatisticUpdater;
|
||||
this.currentSegment = new SegmentStatisticUpdater();
|
||||
|
||||
resetAverageHeartRate();
|
||||
}
|
||||
|
||||
public TrackStatisticsUpdater(TrackStatisticsUpdater toCopy) {
|
||||
this.currentSegment = new TrackStatistics(toCopy.currentSegment);
|
||||
this.trackStatistics = new TrackStatistics(toCopy.trackStatistics);
|
||||
this.currentSegment = new SegmentStatisticUpdater(toCopy.currentSegment);
|
||||
this.segmentStatisticUpdater = new SegmentStatisticUpdater(toCopy.segmentStatisticUpdater);
|
||||
|
||||
this.lastTrackPoint = toCopy.lastTrackPoint;
|
||||
resetAverageHeartRate();
|
||||
}
|
||||
|
||||
public TrackStatistics getTrackStatistics() {
|
||||
public SegmentStatisticUpdater getTrackStatistics() {
|
||||
// Take a snapshot - we don't want anyone messing with our trackStatistics
|
||||
TrackStatistics stats = new TrackStatistics(trackStatistics);
|
||||
SegmentStatisticUpdater stats = new SegmentStatisticUpdater(segmentStatisticUpdater);
|
||||
stats.merge(currentSegment);
|
||||
return stats;
|
||||
}
|
||||
public TrackStatistics getCurrentSegment() {
|
||||
public SegmentStatisticUpdater getCurrentSegment() {
|
||||
// Take a snapshot - we don't want anyone messing with our currentSegment
|
||||
return new TrackStatistics(currentSegment);
|
||||
return new SegmentStatisticUpdater(currentSegment);
|
||||
}
|
||||
|
||||
public void addTrackPoints(List<TrackPoint> trackPoints) {
|
||||
@@ -182,7 +182,7 @@ public class TrackStatisticsUpdater {
|
||||
|
||||
private void reset(TrackPoint trackPoint) {
|
||||
if (currentSegment.isInitialized()) {
|
||||
trackStatistics.merge(currentSegment);
|
||||
segmentStatisticUpdater.merge(currentSegment);
|
||||
}
|
||||
currentSegment.reset(trackPoint.getTime());
|
||||
|
||||
@@ -209,7 +209,7 @@ public class TrackStatisticsUpdater {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackStatisticsUpdater{" +
|
||||
"trackStatistics=" + trackStatistics +
|
||||
"trackStatistics=" + segmentStatisticUpdater +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user