From 9a8a5b1a68aa79c78998ddd095594a4f12f02d95 Mon Sep 17 00:00:00 2001 From: "Dr. Johann Pfefferl" Date: Thu, 17 Jun 2010 11:50:22 +0200 Subject: [PATCH] Improved the detection when a fix is really usable --- debian/changelog | 6 ++++++ gps-tracker.c | 28 +++++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index 28f9118..b06a067 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +gps-tracker (1.0-12) unstable; urgency=low + + * Improved the detection when a fix is really usable + + -- Dr. Johann Pfefferl Thu, 17 Jun 2010 11:49:12 +0200 + gps-tracker (1.0-11) unstable; urgency=low * Show the climb rate more precisely diff --git a/gps-tracker.c b/gps-tracker.c index 0e39111..392ff79 100644 --- a/gps-tracker.c +++ b/gps-tracker.c @@ -22,7 +22,7 @@ typedef struct { //GtkWidget *wp_label; GtkButton *wp_set_btn; GString *wp_marker_str; - gboolean tracking_is_on; + gboolean tracking_is_on, has_fix; FILE *outf_p; guint points_recorded_in_current_segment; LocationGPSDeviceStatus last_device_status; @@ -163,9 +163,21 @@ static void on_gps_device_changed (LocationGPSDevice *device, gpointer data) if (!device) return; - if (device->fix) { + /* if there is no fix, or we are recording (fp != NULL), but the fix is so + * bad that it is a 2D fix only, with no time set then do not + * record any longer */ + if ((device->status == LOCATION_GPS_DEVICE_STATUS_NO_FIX) || + (device->fix && fp && + (! device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) && + (device->fix->mode == LOCATION_GPS_DEVICE_MODE_2D))) { + app_data->has_fix = FALSE; + hildon_banner_show_information(GTK_WIDGET(app_data->window), NULL, "WARNING: Lost fix"); + app_data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX; + } + else if (device->fix) { //g_print("mode=%d stat=%d\n", device->fix->mode, device->status); if (device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) { + app_data->has_fix = TRUE; /* fix found again */ //g_print ("lat = %f, long = %f\n", device->fix->latitude, device->fix->longitude); CHANGE_LABEL(app_data->lat_val_label, "% 9.6f", device->fix->latitude); CHANGE_LABEL(app_data->lon_val_label, "% 9.6f", device->fix->longitude); @@ -259,8 +271,6 @@ static void on_gps_device_changed (LocationGPSDevice *device, gpointer data) } } } - else - g_print("device->fix=%p\n", device->fix); //g_print ("Satellites in view: %d\n", device->satellites_in_view); //g_print ("Satellites in use: %d\n", device->satellites_in_use); @@ -275,7 +285,11 @@ static void on_gps_device_changed (LocationGPSDevice *device, gpointer data) // g_print ("Mobile Coutry Code WCDMA: %d\n", device->cell_info->wcdma_cell_info.mcc); //} - if(device->status == LOCATION_GPS_DEVICE_STATUS_NO_FIX) { + if(app_data->has_fix) { + hildon_gtk_window_set_progress_indicator(GTK_WINDOW(app_data->window), 0); + gtk_widget_set_sensitive(GTK_WIDGET(app_data->start_stop_button), TRUE); + } + else { hildon_gtk_window_set_progress_indicator(GTK_WINDOW(app_data->window), 1); CHANGE_LABEL(app_data->lat_val_label, " ?", NULL); CHANGE_LABEL(app_data->lon_val_label, " ?", NULL); @@ -283,10 +297,6 @@ static void on_gps_device_changed (LocationGPSDevice *device, gpointer data) CHANGE_LABEL(app_data->speed_val_label, " ?", NULL); CHANGE_LABEL(app_data->track_val_label, " ?", NULL); } - else { - hildon_gtk_window_set_progress_indicator(GTK_WINDOW(app_data->window), 0); - gtk_widget_set_sensitive(GTK_WIDGET(app_data->start_stop_button), TRUE); - } } static void -- 1.7.9.5