static void print_gpx_footer(void) { if (intrack) print_gpx_trk_end(); (void)fprintf(logfile,"</gpx>\n"); (void)fclose(logfile); }
static void conditionally_log_fix(struct gps_data_t *gpsdata) { static double int_time, old_int_time; static double old_lat, old_lon; static bool first = true; int_time = gpsdata->fix.time; if ((int_time == old_int_time) || gpsdata->fix.mode < MODE_2D) return; /* may not be worth logging if we've moved only a very short distance */ if (minmove>0 && !first && earth_distance( gpsdata->fix.latitude, gpsdata->fix.longitude, old_lat, old_lon) < minmove) return; /* * Make new track if the jump in time is above * timeout. Handle jumps both forward and * backwards in time. The clock sometimes jumps * backward when gpsd is submitting junk on the * dbus. */ /*@-type@*/ if (fabs(int_time - old_int_time) > timeout && !first) { print_gpx_trk_end(); intrack = false; } /*@+type@*/ if (!intrack) { print_gpx_trk_start(); intrack = true; if (first) first = false; } old_int_time = int_time; if (minmove > 0) { old_lat = gpsdata->fix.latitude; old_lon = gpsdata->fix.longitude; } print_fix(gpsdata, int_time); }
static DBusHandlerResult handle_gps_fix (DBusMessage* message) { DBusError error; double temp_time; dbus_error_init (&error); dbus_message_get_args (message, &error, DBUS_TYPE_DOUBLE, &temp_time, DBUS_TYPE_INT32, &gpsfix.mode, DBUS_TYPE_DOUBLE, &gpsfix.ept, DBUS_TYPE_DOUBLE, &gpsfix.latitude, DBUS_TYPE_DOUBLE, &gpsfix.longitude, DBUS_TYPE_DOUBLE, &gpsfix.eph, DBUS_TYPE_DOUBLE, &gpsfix.altitude, DBUS_TYPE_DOUBLE, &gpsfix.epv, DBUS_TYPE_DOUBLE, &gpsfix.track, DBUS_TYPE_DOUBLE, &gpsfix.epd, DBUS_TYPE_DOUBLE, &gpsfix.speed, DBUS_TYPE_DOUBLE, &gpsfix.eps, DBUS_TYPE_DOUBLE, &gpsfix.climb, DBUS_TYPE_DOUBLE, &gpsfix.epc, DBUS_TYPE_INVALID); gpsfix.time = floor(temp_time); /* * we have a fix there - log the point */ if ((gpsfix.time!=gpsfix.old_time)&&gpsfix.mode>1) { struct tm time; /* Make new track if the jump in time is above * tracklimit. Handle jumps both forward and * backwards in time. The clock sometimes jump * backward when gpsd is submitting junk on the * dbus. */ if (fabs(gpsfix.time - gpsfix.old_time) > tracklimit && !first) { print_gpx_trk_end(); intrack = 0; } if (!intrack) { print_gpx_trk_start(); intrack = 1; if (first) first = 0; } gpsfix.old_time = gpsfix.time; fprintf (stdout, " <trkpt lat=\"%f\" lon=\"%f\">\n", gpsfix.latitude, gpsfix.longitude); fprintf (stdout, " <ele>%f</ele>\n", gpsfix.altitude); gmtime_r (&(gpsfix.time), &time); fprintf (stdout, " <time>%04d-%02d-%02dT%02d:%02d:%02dZ</time>\n", time.tm_year+1900, time.tm_mon+1, time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec); if (gpsfix.mode==1) fprintf (stdout, " <fix>none</fix>\n"); else fprintf (stdout, " <fix>%dd</fix>\n", gpsfix.mode); fprintf (stdout, " </trkpt>\n"); fflush (stdout); } return DBUS_HANDLER_RESULT_HANDLED; }
static void print_gpx_footer (void) { if (intrack) print_gpx_trk_end(); fprintf (stdout, "</gpx>\n"); fclose (stdout); }