]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/RangeStats.java
Version 19.2, December 2018
[GpsPrune.git] / tim / prune / data / RangeStats.java
index 0ed8fc7a4588f69e712525ad19cf232b532e1cb2..13ecaade10d4e6a8d0eccc87a383762ae399cc00 100644 (file)
@@ -9,6 +9,7 @@ import tim.prune.config.Config;
  */
 public class RangeStats
 {
+       // MAYBE: Split into basic stats (quick to calculate, for detailsdisplay) and full stats (for other two)
        private boolean _valid = false;
        private int     _numPoints   = 0;
        private int     _startIndex = 0, _endIndex = 0;
@@ -17,9 +18,10 @@ public class RangeStats
        private AltitudeRange _gentleAltitudeRange = null, _steepAltitudeRange = null;
        private Timestamp _earliestTimestamp = null, _latestTimestamp = null;
        private long _movingMilliseconds = 0L;
-       private boolean _timestampsIncomplete = false;
+       private boolean _timesIncomplete = false;
+       private boolean _timesOutOfSequence = false;
        private double _totalDistanceRads = 0.0, _movingDistanceRads = 0.0;
-       // Note, maximum speed is not calculated here, use the SpeedData method instead
+       // Note, maximum speed is not calculated here, use the SpeedData class instead
 
        private static final double STEEP_ANGLE = 0.15; // gradient steeper than 15% counts as steep
 
@@ -48,7 +50,8 @@ public class RangeStats
         */
        private boolean calculateStats(Track inTrack, int inStartIndex, int inEndIndex)
        {
-               _startIndex = inStartIndex;  _endIndex = inEndIndex;
+               _startIndex = inStartIndex;
+               _endIndex = inEndIndex;
                _numPoints = inEndIndex - inStartIndex + 1;
                _totalAltitudeRange  = new AltitudeRange();
                _movingAltitudeRange = new AltitudeRange();
@@ -68,7 +71,9 @@ public class RangeStats
                        // ignore all waypoints
                        if (p.isWaypoint()) continue;
 
-                       if (p.getSegmentStart()) {_numSegments++;}
+                       if (p.getSegmentStart()) {
+                               _numSegments++;
+                       }
                        // Get the distance to the previous track point
                        if (prevPoint != null)
                        {
@@ -123,12 +128,14 @@ public class RangeStats
                                if (!p.getSegmentStart() && prevPoint != null && prevPoint.hasTimestamp())
                                {
                                        long millisLater = p.getTimestamp().getMillisecondsSince(prevPoint.getTimestamp());
-                                       if (millisLater < 0) {_timestampsIncomplete = true;}
-                                       _movingMilliseconds += millisLater;
+                                       if (millisLater < 0) {_timesOutOfSequence = true;}
+                                       else {
+                                               _movingMilliseconds += millisLater;
+                                       }
                                }
                        }
-                       else if (!p.getSegmentStart()) {
-                               _timestampsIncomplete = true;
+                       else {
+                               _timesIncomplete = true;
                        }
 
                        prevPoint = p;
@@ -207,9 +214,14 @@ public class RangeStats
                return _movingMilliseconds / 1000;
        }
 
-       /** @return true if any timestamps are missing or out of sequence */
+       /** @return true if any timestamps are missing */
        public boolean getTimestampsIncomplete() {
-               return _timestampsIncomplete;
+               return _timesIncomplete;
+       }
+
+       /** @return true if any timestamps are out of sequence */
+       public boolean getTimestampsOutOfSequence() {
+               return _timesOutOfSequence;
        }
 
        /** @return total distance in the current distance units (km or mi) */