+ if (f->gps.num)
+ daytime = compute_daytime_ms(clock_time, &f->gps);
+ else
+ daytime = 0;
+ fprintf(detail_file, "%9.2f %9.2f %9.2f %9.2f %02d:%02d:%02d.%03d\n",
+ time, pos, speed, accel,
+ daytime_hour(daytime),
+ daytime_minute(daytime),
+ daytime_second(daytime),
+ daytime_millisecond(daytime));
+ }
+ }
+ if (raw_file) {
+ fprintf(raw_file, "%9s %9s %9s %9s\n",
+ "time", "height", "accel", "daytime");
+ for (i = 0; i < cooked->pres.num; i++) {
+ double time = cooked->pres.data[i].time;
+ double pres = cooked->pres.data[i].value;
+ double accel = cooked->accel.data[i].value;
+ unsigned daytime;
+ if (f->gps.num)
+ daytime = compute_daytime_ms(time, &f->gps);
+ else
+ daytime = 0;
+ fprintf(raw_file, "%9.2f %9.2f %9.2f %02d:%02d:%02d.%03d\n",
+ time, pres, accel,
+ daytime_hour(daytime),
+ daytime_minute(daytime),
+ daytime_second(daytime),
+ daytime_millisecond(daytime));
+ }
+ }
+ if (gps_file || kml_file) {
+ int j = 0, baro_pos;
+ double baro_offset;
+ double baro = 0.0;
+ int state_idx = 0;
+
+ if (gps_file)
+ fprintf(gps_file, "%2s %2s %2s %9s %12s %12s %9s %8s %5s\n",
+ "hr", "mn", "sc",
+ "time", "lat", "lon", "alt", "baro", "nsat");
+ if (kml_file)
+ fprintf(kml_file, kml_placemark_start,
+ state_names[(int)f->state.data[state_idx].value],
+ state_names[(int)f->state.data[state_idx].value]);
+
+ if (f->gps.num)
+ baro_offset = f->gps.data[0].alt;
+ else
+ baro_offset = 0;
+ baro_pos = 0;
+ for (i = 0; i < f->gps.num; i++) {
+ int nsat = 0;
+ int k;
+ while (j < f->gps.numsats - 1) {
+ if (f->gps.sats[j].sat[0].time <= f->gps.data[i].time &&
+ f->gps.data[i].time < f->gps.sats[j+1].sat[0].time)
+ break;
+ j++;
+ }
+ if (cooked) {
+ while (baro_pos < cooked->pres_pos.num) {
+ double baro_time = cooked->accel_accel.start + baro_pos * cooked->accel_accel.step;
+ if (baro_time >= f->gps.data[i].time)
+ break;
+ baro_pos++;
+ }
+ if (baro_pos < cooked->pres_pos.num)
+ baro = cooked->pres_pos.data[baro_pos];
+ }
+ if (gps_file)
+ fprintf(gps_file, "%2d %2d %2d %12.7f %12.7f %12.7f %7.1f %7.1f",
+ f->gps.data[i].hour,
+ f->gps.data[i].minute,
+ f->gps.data[i].second,
+ (f->gps.data[i].time - boost_start) / 100.0,
+ f->gps.data[i].lat,
+ f->gps.data[i].lon,
+ f->gps.data[i].alt,
+ baro + baro_offset);
+
+ nsat = 0;
+ if (f->gps.sats) {
+ for (k = 0; k < f->gps.sats[j].nsat; k++) {
+ if (f->gps.sats[j].sat[k].svid != 0)
+ nsat++;
+ }
+ if (gps_file) {
+ fprintf(gps_file, " %4d", nsat);
+ for (k = 0; k < f->gps.sats[j].nsat; k++) {
+ if (f->gps.sats[j].sat[k].svid != 0) {
+ fprintf (gps_file, " %3d(%4.1f)",
+ f->gps.sats[j].sat[k].svid,
+ (double) f->gps.sats[j].sat[k].c_n);
+ }
+ }
+ fprintf(gps_file, "\n");
+ }
+ }
+
+ if (kml_file) {
+ snprintf(buf, sizeof (buf), kml_coord_fmt,
+ f->gps.data[i].lon,
+ f->gps.data[i].lat,
+ baro + baro_offset,
+ f->gps.data[i].alt,
+ (f->gps.data[i].time - boost_start) / 100.0,
+ nsat);
+ fprintf(kml_file, "%s", buf);
+ if (state_idx + 1 < f->state.num && f->state.data[state_idx + 1].time <= f->gps.data[i].time) {
+ state_idx++;
+ if (f->state.data[state_idx - 1].value != f->state.data[state_idx].value) {
+ fprintf(kml_file, "%s", kml_placemark_end);
+ fprintf(kml_file, kml_placemark_start,
+ state_names[(int)f->state.data[state_idx].value],
+ state_names[(int)f->state.data[state_idx].value]);
+ fprintf(kml_file, "%s", buf);
+ }
+ }
+ }
+