X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fdata%2FRangeStats.java;h=b32f12fa987344a04f2a419e8cb68e7cfd210975;hb=ce911cf3be599e69d8f0a98f8e33e94f4e7fa6dd;hp=1f5762618640a9df97bb63fd50ea0877efb0dc5a;hpb=f08ce2f01d168894308cc09f317c78b23477e5b7;p=GpsPrune.git diff --git a/src/tim/prune/data/RangeStats.java b/src/tim/prune/data/RangeStats.java index 1f57626..b32f12f 100644 --- a/src/tim/prune/data/RangeStats.java +++ b/src/tim/prune/data/RangeStats.java @@ -11,7 +11,7 @@ public class RangeStats private boolean _foundTrackPoint = false; protected AltitudeRange _totalAltitudeRange = new AltitudeRange(); protected AltitudeRange _movingAltitudeRange = new AltitudeRange(); - private Timestamp _earliestTimestamp = null, _latestTimestamp = null; + private Timestamp _earliestTimestamp = null, _latestTimestamp = null, _movingTimestamp = null; private long _movingMilliseconds = 0L; private boolean _timesIncomplete = false; private boolean _timesOutOfSequence = false; @@ -75,16 +75,26 @@ public class RangeStats } // timestamps + if (inPoint.getSegmentStart()) + { + // reset movingTimestamp for moving time at the start + // of each segment + _movingTimestamp = null; + } if (inPoint.hasTimestamp()) { Timestamp currTstamp = inPoint.getTimestamp(); if (_earliestTimestamp == null || currTstamp.isBefore(_earliestTimestamp)) { _earliestTimestamp = currTstamp; } + if (_latestTimestamp == null || currTstamp.isAfter(_latestTimestamp)) { + _latestTimestamp = currTstamp; + } + // Work out duration without segment gaps - if (!inPoint.getSegmentStart() && _latestTimestamp != null) + if (_movingTimestamp != null) { - long millisLater = currTstamp.getMillisecondsSince(_latestTimestamp); + long millisLater = currTstamp.getMillisecondsSince(_movingTimestamp); if (millisLater < 0) { _timesOutOfSequence = true; } @@ -92,9 +102,7 @@ public class RangeStats _movingMilliseconds += millisLater; } } - if (_latestTimestamp == null || currTstamp.isAfter(_latestTimestamp)) { - _latestTimestamp = currTstamp; - } + _movingTimestamp = currTstamp; } else { _timesIncomplete = true;