]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/SpeedCalculator.java
Version 19.1, August 2018
[GpsPrune.git] / tim / prune / data / SpeedCalculator.java
index 49fd05665a90e8788e3806e5f740d773f7c4cc0f..6f81d5a32187d60b43d0a686deb6e8a3e59571ba 100644 (file)
@@ -16,7 +16,10 @@ public abstract class SpeedCalculator
         */
        public static void calculateSpeed(Track inTrack, int inIndex, SpeedValue inValue)
        {
-               inValue.setInvalid();
+               if (inValue != null)
+               {
+                       inValue.setInvalid();
+               }
                if (inTrack == null || inIndex < 0 || inValue == null)
                {
                        System.err.println("Cannot calculate speed for index " + inIndex);
@@ -79,7 +82,7 @@ public abstract class SpeedCalculator
                                        lateStamp = p.getTimestamp();
                                }
 
-                               stop = (p == null) || p.getSegmentStart() || hasSufficientTimeDifference(point,  p);
+                               stop = (p == null) || p.getSegmentStart() || hasSufficientTimeDifference(point, p);
                                index++;
                                if (p != null && !p.isWaypoint()) {
                                        q = p;
@@ -153,7 +156,7 @@ public abstract class SpeedCalculator
                                                if (p.hasAltitude()) firstAlt = p.getAltitude();
                                        }
 
-                                       stop = (p == null) || p.getSegmentStart() || hasSufficientTimeDifference(p,  point);
+                                       stop = (p == null) || p.getSegmentStart() || hasSufficientTimeDifference(p, point);
                                        index--;
                                }
                                while (!stop);
@@ -173,7 +176,7 @@ public abstract class SpeedCalculator
                                        if (p.hasAltitude()) lastAlt = p.getAltitude();
                                }
 
-                               stop = (p == null) || p.getSegmentStart() || hasSufficientTimeDifference(point,  p);
+                               stop = (p == null) || p.getSegmentStart() || hasSufficientTimeDifference(point, p);
                                index++;
                        }
                        while (!stop);