]> git.street.me.uk Git - andy/viking.git/commitdiff
Add some protection against crazy elevation numbers that cause viewing a track's...
authorRob Norris <rw_norris@hotmail.com>
Tue, 9 Oct 2012 19:09:12 +0000 (20:09 +0100)
committerRob Norris <rw_norris@hotmail.com>
Tue, 9 Oct 2012 22:08:52 +0000 (23:08 +0100)
src/viktrack.c

index 00541d3661df881890163c7cd0f5d663d966b7ca..6bbe8bda771be3bb922aac3a8d8456c8d05f7cde 100644 (file)
@@ -414,7 +414,12 @@ gdouble *vik_track_make_elevation_map ( const VikTrack *tr, guint16 num_chunks )
     gboolean okay = FALSE;
     while ( iter )
     {
-      if ( VIK_TRACKPOINT(iter->data)->altitude != VIK_DEFAULT_ALTITUDE ) {
+      // Sometimes a GPS device (or indeed any random file) can have stupid numbers for elevations
+      // Since when is 9.9999e+24 a valid elevation!!
+      // This can happen when a track (with no elevations) is uploaded to a GPS device and then redownloaded (e.g. using a Garmin Legend EtrexHCx)
+      // Some protection against trying to work with crazily massive numbers (otherwise get SIGFPE, Arithmetic exception)
+      if ( VIK_TRACKPOINT(iter->data)->altitude != VIK_DEFAULT_ALTITUDE &&
+          VIK_TRACKPOINT(iter->data)->altitude < 1E9 ) {
         okay = TRUE; break;
       }
       iter = iter->next;