The recorded waypoints are put at the end of the gpx file release-1.1-1
authorDr. Johann Pfefferl <pfefferl@gmx.net>
Tue, 22 Jun 2010 15:41:25 +0000 (17:41 +0200)
committerDr. Johann Pfefferl <pfefferl@gmx.net>
Tue, 22 Jun 2010 15:41:25 +0000 (17:41 +0200)
debian/changelog
gps-tracker.c

index 0d5a665..ccf7036 100644 (file)
@@ -1,3 +1,9 @@
+gps-tracker (1.1-1) unstable; urgency=low
+
+  * The recorded waypoints are put at the end of the gpx file
+
+ -- Dr. Johann Pfefferl <pfefferl@gmx.net>  Tue, 22 Jun 2010 17:40:02 +0200
+
 gps-tracker (1.0-14) unstable; urgency=low
 
   * Reset the climb value to unknown if no fix is detected
index 57e8f3b..252cd84 100644 (file)
@@ -21,7 +21,7 @@ typedef struct {
     GtkWidget *speed_val_label, *track_val_label, *climb_val_label;
     //GtkWidget *wp_label;
     GtkButton *wp_set_btn;
-    GString *wp_marker_str;
+    GString *wp_marker_str, *waypoint_block_str;
     gboolean tracking_is_on, has_fix;
     FILE *outf_p;
     guint points_recorded_in_current_segment;
@@ -54,8 +54,9 @@ static gchar * interface_file_chooser (AppData * appdata, GtkFileChooserAction a
     return filename;
 }
 
-static void write_gpx_header(FILE *fp)
+static void write_gpx_header(AppData *app_data)
 {
+  FILE *fp = app_data->outf_p;
   g_return_if_fail(fp);
   g_fprintf(fp,
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
@@ -71,10 +72,14 @@ static void write_gpx_header(FILE *fp)
       );
 }
 
-static void write_gpx_footer(FILE *fp)
+static void write_gpx_footer(AppData *app_data)
 {
+  FILE *fp = app_data->outf_p;
   g_return_if_fail(fp);
-  g_fprintf(fp, "</trkseg>\n</trk>\n</gpx>\n");
+  g_fprintf(fp, "</trkseg>\n</trk>\n");
+  g_fprintf(fp, app_data->waypoint_block_str->str);
+  g_fprintf(fp, "</gpx>\n");
+  g_string_truncate(app_data->waypoint_block_str, 0);
 }
 
 static void cb_wp_set_btn (GtkWidget * w, AppData * data)
@@ -99,7 +104,7 @@ static void cb_start_stop (GtkWidget * w, AppData * data)
     data->outf_p = fopen(data->intermediate_gpx_data_filename, "w");
     data->points_recorded_in_current_segment = 0;
     data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX;
-    write_gpx_header(data->outf_p);
+    write_gpx_header(data);
     //hildon_banner_show_information(GTK_WIDGET(data->window), NULL, "Tracking started");
     gtk_button_set_label (data->start_stop_button, "Stop");
     gtk_widget_set_sensitive(GTK_WIDGET(data->save_button), FALSE);
@@ -109,7 +114,7 @@ static void cb_start_stop (GtkWidget * w, AppData * data)
     data->points_recorded_in_current_segment = 0;
     data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX;
     if(data->outf_p) {
-      write_gpx_footer(data->outf_p);
+      write_gpx_footer(data);
       fclose(data->outf_p);
       data->outf_p = NULL;
     }
@@ -193,6 +198,8 @@ static void on_gps_device_changed (LocationGPSDevice *device, gpointer data)
         if(app_data->wp_marker_str->len) {
           g_fprintf(fp, "<name>%s</name>\n", app_data->wp_marker_str->str);
           hildon_banner_show_information(GTK_WIDGET(app_data->window), NULL, app_data->wp_marker_str->str);
+          g_string_append_printf(app_data->waypoint_block_str, "<wpt lat=\"%s\" lon=\"%s\"><name>%s</name></wpt>\n",
+              sbuf1, sbuf2, app_data->wp_marker_str->str);
           g_string_truncate(app_data->wp_marker_str, 0);
         }
       }
@@ -342,6 +349,7 @@ int main (int argc, char **argv)
        hildon_program_add_window (data->program, HILDON_WINDOW (data->window));
 
   data->wp_marker_str = g_string_sized_new(64);
+  data->waypoint_block_str = g_string_sized_new(32<<10);
   data->main_vbox = (gpointer)gtk_vbox_new(FALSE, 0);
   data->loc_hbox = (gpointer)gtk_hbox_new(FALSE, 0);
   data->loc_gps_data_table = (gpointer)gtk_table_new(4, 2, FALSE);
@@ -482,6 +490,7 @@ int main (int argc, char **argv)
   g_free(data->working_dir);
   g_free(data->intermediate_gpx_data_filename);
   g_string_free(data->wp_marker_str, TRUE);
+  g_string_free(data->waypoint_block_str, TRUE);
   g_free(data);
        g_object_unref (device);
        g_object_unref (control);