X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FSelection.java;h=68654e8ed35d204dc41cf3977e23ba0b67f5a15f;hp=6125eacad76e7b0390daef85fa11e14bd65573fb;hb=326f489e36aa7f235bc19409a57bf4955cd50f24;hpb=8c8868ae29b3252f02e094c02307384cf61ba667 diff --git a/tim/prune/data/Selection.java b/tim/prune/data/Selection.java index 6125eac..68654e8 100644 --- a/tim/prune/data/Selection.java +++ b/tim/prune/data/Selection.java @@ -17,8 +17,8 @@ public class Selection private int _currentPhotoIndex = -1; private int _currentAudioIndex = -1; private AltitudeRange _altitudeRange = null; - private long _totalSeconds = 0L, _movingSeconds = 0L; - private double _angDistance = -1.0, _angMovingDistance = -1.0; + private long _movingSeconds = 0L; + private double _angMovingDistance = -1.0; /** @@ -65,7 +65,8 @@ public class Selection { final int numPoints = _track.getNumPoints(); // Recheck if the number of points has changed - if (numPoints != _prevNumPoints) { + if (numPoints != _prevNumPoints) + { _prevNumPoints = numPoints; check(); } @@ -73,11 +74,10 @@ public class Selection { _altitudeRange = new AltitudeRange(); Altitude altitude = null; - Timestamp time = null, startTime = null, endTime = null; - Timestamp previousTime = null; + Timestamp time = null, previousTime = null; DataPoint lastPoint = null, currPoint = null; - _angDistance = 0.0; _angMovingDistance = 0.0; - _totalSeconds = 0L; _movingSeconds = 0L; + _angMovingDistance = 0.0; + _movingSeconds = 0L; // Loop over points in selection for (int i=_startIndex; i<=_endIndex; i++) { @@ -86,14 +86,17 @@ public class Selection // Ignore waypoints in altitude calculations if (!currPoint.isWaypoint() && altitude.isValid()) { - _altitudeRange.addValue(altitude); + if (currPoint.getSegmentStart()) { + _altitudeRange.ignoreValue(altitude); + } + else { + _altitudeRange.addValue(altitude); + } } - // Store the first and last timestamp in the range + // Compare timestamps within the segments time = currPoint.getTimestamp(); if (time.isValid()) { - if (startTime == null || startTime.isAfter(time)) startTime = time; - if (endTime == null || time.isAfter(endTime)) endTime = time; // add moving time if (!currPoint.getSegmentStart() && previousTime != null && time.isAfter(previousTime)) { _movingSeconds += time.getSecondsSince(previousTime); @@ -106,7 +109,6 @@ public class Selection if (lastPoint != null) { double radians = DataPoint.calculateRadiansBetween(lastPoint, currPoint); - _angDistance += radians; if (!currPoint.getSegmentStart()) { _angMovingDistance += radians; } @@ -114,9 +116,6 @@ public class Selection lastPoint = currPoint; } } - if (endTime != null) { - _totalSeconds = endTime.getSecondsSince(startTime); - } } _valid = true; } @@ -151,15 +150,6 @@ public class Selection } - /** - * @return number of seconds spanned by selection - */ - public long getNumSeconds() - { - if (!_valid) recalculate(); - return _totalSeconds; - } - /** * @return number of seconds spanned by segments within selection */ @@ -169,14 +159,6 @@ public class Selection return _movingSeconds; } - /** - * @return distance of Selection in specified units - */ - public double getDistance() - { - return Distance.convertRadiansToDistance(_angDistance); - } - /** * @return moving distance of Selection in current units */