]> git.street.me.uk Git - andy/viking.git/commitdiff
Fix vik_track_get_length_to_trackpoint() so with the first track point it returns...
authorRob Norris <rw_norris@hotmail.com>
Sun, 3 Nov 2013 21:03:48 +0000 (21:03 +0000)
committerRob Norris <rw_norris@hotmail.com>
Sat, 16 Nov 2013 23:04:34 +0000 (23:04 +0000)
src/viktrack.c

index 04e75f0260515d69e485ff0592e60a7086f117ac..fface590ad4a370d37b8b49f7a743faf7df074bf 100644 (file)
@@ -272,6 +272,10 @@ gdouble vik_track_get_length_to_trackpoint (const VikTrack *tr, const VikTrackpo
   gdouble len = 0.0;
   if ( tr->trackpoints )
   {
+    // Is it the very first track point?
+    if ( VIK_TRACKPOINT(tr->trackpoints->data) == tp )
+      return len;
+
     GList *iter = tr->trackpoints->next;
     while (iter)
     {
@@ -282,7 +286,7 @@ gdouble vik_track_get_length_to_trackpoint (const VikTrack *tr, const VikTrackpo
 
       // Exit when we reach the desired point
       if ( tp1 == tp )
-       break;
+        break;
 
       iter = iter->next;
     }