]> git.street.me.uk Git - andy/viking.git/blobdiff - src/gpspoint.c
When manually creating a track, automatically give it a default name.
[andy/viking.git] / src / gpspoint.c
index 7279b2326f3ecf3328313895dbb919f8b56564d2..96d279d1910485f5b195576f588d9d62a090138b 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
+#ifdef HAVE_MATH_H
 #include <math.h>
+#endif
+
 #include "viking.h"
 
 #include <ctype.h>
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif
 
 #include <stdlib.h>
 /* strtod */
@@ -194,11 +202,8 @@ void a_gpspoint_read_file(VikTrwLayer *trw, FILE *f ) {
     if (line_type == GPSPOINT_TYPE_WAYPOINT && line_name)
     {
       VikWaypoint *wp = vik_waypoint_new();
-      gint i = strlen(line_name);
       wp->visible = line_visible;
       wp->altitude = line_altitude;
-      while ( i-- )
-        line_name[i] = toupper(line_name[i]); /* TODO: check for acceptable chars */
 
       vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &line_latlon );
 
@@ -227,16 +232,12 @@ void a_gpspoint_read_file(VikTrwLayer *trw, FILE *f ) {
     else if (line_type == GPSPOINT_TYPE_TRACK && line_name)
     {
       VikTrack *pl = vik_track_new();
-      gint i = strlen(line_name);
 
       /* Thanks to Peter Jones for this Fix */
       if (!line_name) line_name = g_strdup("UNK");
 
       pl->visible = line_visible;
 
-      while ( i-- )
-        line_name[i] = toupper(line_name[i]);
-
       if ( line_comment )
       {
         vik_track_set_comment ( pl, line_comment );
@@ -259,15 +260,11 @@ void a_gpspoint_read_file(VikTrwLayer *trw, FILE *f ) {
       tp->timestamp = line_timestamp;
       tp->altitude = line_altitude;
       if (line_extended) {
-        tp->extended = TRUE;
         tp->speed = line_speed;
         tp->course = line_course;
         tp->nsats = line_sat;
         tp->fix_mode = line_fix;
       }
-      else {
-        tp->extended = FALSE;
-      }
       current_track->trackpoints = g_list_append ( current_track->trackpoints, tp );
     }
 
@@ -385,15 +382,15 @@ static void gpspoint_process_key_and_value ( const gchar *key, gint key_len, con
   }
   else if (key_len == 8 && strncasecmp( key, "latitude", key_len ) == 0 && value != NULL)
   {
-    line_latlon.lat = g_strtod(value, NULL);
+    line_latlon.lat = g_ascii_strtod(value, NULL);
   }
   else if (key_len == 9 && strncasecmp( key, "longitude", key_len ) == 0 && value != NULL)
   {
-    line_latlon.lon = g_strtod(value, NULL);
+    line_latlon.lon = g_ascii_strtod(value, NULL);
   }
   else if (key_len == 8 && strncasecmp( key, "altitude", key_len ) == 0 && value != NULL)
   {
-    line_altitude = g_strtod(value, NULL);
+    line_altitude = g_ascii_strtod(value, NULL);
   }
   else if (key_len == 7 && strncasecmp( key, "visible", key_len ) == 0 && value[0] != 'y' && value[0] != 'Y' && value[0] != 't' && value[0] != 'T')
   {
@@ -405,7 +402,7 @@ static void gpspoint_process_key_and_value ( const gchar *key, gint key_len, con
   }
   else if (key_len == 8 && strncasecmp( key, "unixtime", key_len ) == 0 && value != NULL)
   {
-    line_timestamp = g_strtod(value, NULL);
+    line_timestamp = g_ascii_strtod(value, NULL);
     if ( line_timestamp != 0x80000000 )
       line_has_timestamp = TRUE;
   }
@@ -419,11 +416,11 @@ static void gpspoint_process_key_and_value ( const gchar *key, gint key_len, con
   }
   else if (key_len == 5 && strncasecmp( key, "speed", key_len ) == 0 && value != NULL)
   {
-    line_speed = g_strtod(value, NULL);
+    line_speed = g_ascii_strtod(value, NULL);
   }
   else if (key_len == 6 && strncasecmp( key, "course", key_len ) == 0 && value != NULL)
   {
-    line_course = g_strtod(value, NULL);
+    line_course = g_ascii_strtod(value, NULL);
   }
   else if (key_len == 3 && strncasecmp( key, "sat", key_len ) == 0 && value != NULL)
   {
@@ -496,7 +493,7 @@ static void a_gpspoint_write_trackpoint ( VikTrackpoint *tp, FILE *f )
   if ( tp->newsegment )
     fprintf ( f, " newsegment=\"yes\"" );
 
-  if (tp->extended) {
+  if (!isnan(tp->speed) || !isnan(tp->course) || tp->nsats > 0) {
     fprintf ( f, " extended=\"yes\"" );
     if (!isnan(tp->speed)) {
       gchar *s_speed = a_coords_dtostr(tp->speed);