/* Output something interesing when we can for route and trackpoints */ static void kml_output_description(const waypoint *pt) { char *alt_units; double alt; if (!trackdata) { return; } alt = fmt_distance(pt->altitude, &alt_units); kml_write_xml(1, "<description><![CDATA[\n"); kml_write_xml(1, "<table>\n"); TD("Longitude: %f", pt->longitude); TD("Latitude: %f", pt->latitude); if (pt->altitude != unknown_alt) TD2("Altitude: %.3f %s", alt, alt_units); if (pt->heartrate) TD("Heart rate: %d", pt->heartrate); if (pt->cadence) TD("Cadence: %d", pt->cadence); /* Which unit is this temp in? C? F? K? */ if WAYPT_HAS(pt, temperature) TD("Temperature: %.1f", pt->temperature); if WAYPT_HAS(pt, depth) { char *depth_units; double depth = fmt_distance(pt->depth, &depth_units); TD2("Depth: %.1f %s", depth, depth_units); }
void garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt) { char *phone, *addr; garmin_fs_t *gmsd = GMSD_FIND(waypt); if (gmsd == NULL) return; /* Find out if there is at least one field set */ addr = GMSD_GET(addr, ""); if (! *addr) addr = GMSD_GET(city, ""); if (! *addr) addr = GMSD_GET(country, ""); if (! *addr) addr = GMSD_GET(postal_code, ""); if (! *addr) addr = GMSD_GET(state, ""); phone = GMSD_GET(phone_nr, ""); if (*addr || *phone || (gmsd->flags.category && gmsd->category) || WAYPT_HAS(waypt, depth) || WAYPT_HAS(waypt, proximity) || WAYPT_HAS(waypt, temperature) || gmsd->flags.display) { int space = 1; gbfprintf(ofd, "%*s<extensions>\n", space++ * 2, ""); gbfprintf(ofd, "%*s<gpxx:WaypointExtension %s\">\n", space++ * 2, "", GARMIN_GPX_EXT_REFERENCE); if WAYPT_HAS(waypt, proximity) gbfprintf(ofd, "%*s<gpxx:Proximity>%.6f</gpxx:Proximity>\n", space * 2, "", waypt->proximity); if WAYPT_HAS(waypt, temperature) gbfprintf(ofd, "%*s<gpxx:Temperature>%.6f</gpxx:Temperature>\n", space * 2, "", waypt->temperature); if WAYPT_HAS(waypt, depth) gbfprintf(ofd, "%*s<gpxx:Depth>%.6f</gpxx:Depth>\n", space * 2, "", waypt->depth); if (gmsd->flags.display) { char *cx; switch(gmsd->display) { case gt_display_mode_symbol: cx = "SymbolOnly"; break; case gt_display_mode_symbol_and_comment: cx = "SymbolAndDescription"; break; default: cx = "SymbolAndName"; break; } gbfprintf(ofd, "%*s<gpxx:DisplayMode>%s</gpxx:DisplayMode>\n", space * 2, "", cx); } if (gmsd->flags.category && gmsd->category) { int i; gbuint16 cx = gmsd->category; gbfprintf(ofd, "%*s<gpxx:Categories>\n", space++ * 2, ""); for (i = 0; i < 16; i++) { if (cx & 1) gbfprintf(ofd, "%*s<gpxx:Category>Category %d</gpxx:Category>\n", space*2, "", i+1); cx = cx >> 1; } gbfprintf(ofd, "%*s</gpxx:Categories>\n", --space * 2, ""); }
static void mmo_write_wpt_cb(const waypoint *wpt) { char *str, *cx; int objid; time_t time; int icon = 0; time = wpt->creation_time; if (time < 0) time = 0; if (mmo_datatype == trkdata) { gbfputdbl(wpt->latitude, fout); gbfputdbl(wpt->longitude, fout); gbfputc(0, fout); gbfputuint32(time, fout); if (wpt->altitude != unknown_alt) gbfputflt(wpt->altitude, fout); else gbfputflt(0, fout); return; } objid = mmo_write_obj_head("CObjWaypoint", (wpt->shortname && *wpt->shortname) ? wpt->shortname : "Mark", time, wptdata); mmo_register_object(objid, wpt, wptdata); mmo_write_category("CCategory", (mmo_datatype == rtedata) ? "Waypoints" : "Marks"); gbfputdbl(wpt->latitude, fout); gbfputdbl(wpt->longitude, fout); if (mmo_datatype == rtedata) { int i = mmo_get_objid(mmo_rte); gbfputuint16(1, fout); /* two extra bytes */ gbfputuint16(i & 0x7FFF, fout); } else gbfputuint16(0, fout); /* extra bytes */ if (wpt->url && *wpt->url) { str = xstrdup("_FILE_ "); str = xstrappend(str, wpt->url); str = xstrappend(str, "\n"); } else str = xstrdup(""); cx = wpt->notes; if (cx == NULL) cx = wpt->description; if (cx != NULL) { char *kml = NULL; if (strcmp(wpt->session->name, "kml") == 0) { utf_string tmp; tmp.utfstring = cx; tmp.is_html = 1; cx = kml = strip_html(&tmp); } str = xstrappend(str, cx); if (kml) xfree(kml); } mmo_writestr(str); xfree(str); gbfputuint32(0x01, fout); if WAYPT_HAS(wpt, proximity) gbfputflt((int) wpt->proximity, fout); else gbfputflt(0, fout);
static void unicsv_waypt_disp_cb(const waypoint *wpt) { double lat, lon, alt; char *cout = NULL; const char *shortname; garmin_fs_t *gmsd; #ifdef UNICSV_GC_READY const geocache_data *gc_data = NULL; #endif unicsv_waypt_ct++; shortname = (wpt->shortname) ? wpt->shortname : ""; gmsd = GMSD_FIND(wpt); if (unicsv_datum_idx == DATUM_WGS84) { lat = wpt->latitude; lon = wpt->longitude; alt = wpt->altitude; } else { GPS_Math_WGS84_To_Known_Datum_M(wpt->latitude, wpt->longitude, 0.0, &lat, &lon, &alt, unicsv_datum_idx); } gbfprintf(fout, "%d%s", unicsv_waypt_ct, unicsv_fieldsep); switch(unicsv_grid_idx) { case grid_lat_lon_ddd: cout = pretty_deg_format(lat, lon, 'd', unicsv_fieldsep, 0); gbfputs(cout, fout); break; case grid_lat_lon_dmm: cout = pretty_deg_format(lat, lon, 'm', unicsv_fieldsep, 0); gbfputs(cout, fout); break; case grid_lat_lon_dms: { char *sep, *tmp; cout = pretty_deg_format(lat, lon, 's', unicsv_fieldsep, 0); sep = strchr(cout, ','); *sep = '\0'; tmp = strenquote(cout, UNICSV_QUOT_CHAR); gbfprintf(fout, "%s%s", tmp, unicsv_fieldsep); xfree(tmp); tmp = strenquote(sep+1, UNICSV_QUOT_CHAR); gbfputs(tmp, fout); xfree(tmp); } break; case grid_bng: { char map[3]; double north, east; if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map)) unicsv_fatal_outside(wpt); gbfprintf(fout, "%s%s%5.0f%s%5.0f", map, unicsv_fieldsep, east, unicsv_fieldsep, north); break; } case grid_utm: { int zone; char zonec; double north, east; if (! GPS_Math_Known_Datum_To_UTM_EN(lat, lon, &east, &north, &zone, &zonec, unicsv_datum_idx)) unicsv_fatal_outside(wpt); gbfprintf(fout, "%02d%s%c%s%.0f%s%.0f", zone, unicsv_fieldsep, zonec, unicsv_fieldsep, east, unicsv_fieldsep, north); break; } case grid_swiss: { double north, east; if (! GPS_Math_WGS84_To_Swiss_EN(wpt->latitude, wpt->longitude, &east, &north)) unicsv_fatal_outside(wpt); gbfprintf(fout, "%.f%s%.f", east, unicsv_fieldsep, north); break; } default: gbfprintf(fout, "%.*f%s%.*f", llprec, lat, unicsv_fieldsep, llprec, lon); break; } if (cout) xfree(cout); if FIELD_USED(fld_shortname) unicsv_print_str(shortname); if FIELD_USED(fld_altitude) { if (wpt->altitude != unknown_alt) gbfprintf(fout, "%s%.1f", unicsv_fieldsep, wpt->altitude); else gbfputs(unicsv_fieldsep, fout); } if FIELD_USED(fld_description) unicsv_print_str(wpt->description); if FIELD_USED(fld_notes) unicsv_print_str(wpt->notes); if FIELD_USED(fld_symbol) unicsv_print_str((wpt->icon_descr != NULL) ? wpt->icon_descr : "Waypoint"); if FIELD_USED(fld_depth) { if WAYPT_HAS(wpt, depth) gbfprintf(fout, "%s%.3f", unicsv_fieldsep, wpt->depth); else gbfputs(unicsv_fieldsep, fout); }
static void unicsv_waypt_enum_cb(const waypoint *wpt) { const char *shortname; garmin_fs_t *gmsd; shortname = (wpt->shortname) ? wpt->shortname : ""; gmsd = GMSD_FIND(wpt); if (*shortname) gb_setbit(&unicsv_outp_flags, fld_shortname); if (wpt->altitude != unknown_alt) gb_setbit(&unicsv_outp_flags, fld_altitude); if (wpt->icon_descr && *wpt->icon_descr) gb_setbit(&unicsv_outp_flags, fld_symbol); if (wpt->description && *wpt->description && (strcmp(shortname, wpt->description) != 0)) gb_setbit(&unicsv_outp_flags, fld_description); if (wpt->notes && *wpt->notes && (strcmp(shortname, wpt->notes) != 0)) { if ((! wpt->description) || (strcmp(wpt->description, wpt->notes) != 0)) gb_setbit(&unicsv_outp_flags, fld_notes); } if (wpt->url && *wpt->url) gb_setbit(&unicsv_outp_flags, fld_url); if (wpt->creation_time != 0) { gb_setbit(&unicsv_outp_flags, fld_time); if (wpt->creation_time >= SECONDS_PER_DAY) gb_setbit(&unicsv_outp_flags, fld_date); } if (wpt->fix != fix_unknown) gb_setbit(&unicsv_outp_flags, fld_fix); if (wpt->vdop > 0) gb_setbit(&unicsv_outp_flags, fld_vdop); if (wpt->hdop > 0) gb_setbit(&unicsv_outp_flags, fld_hdop); if (wpt->pdop > 0) gb_setbit(&unicsv_outp_flags, fld_pdop); if (wpt->sat > 0) gb_setbit(&unicsv_outp_flags, fld_sat); if (wpt->heartrate != 0) gb_setbit(&unicsv_outp_flags, fld_heartrate); if (wpt->cadence != 0) gb_setbit(&unicsv_outp_flags, fld_cadence); /* "flagged" waypoint members */ if WAYPT_HAS(wpt, course) gb_setbit(&unicsv_outp_flags, fld_course); if WAYPT_HAS(wpt, depth) gb_setbit(&unicsv_outp_flags, fld_depth); if WAYPT_HAS(wpt, speed) gb_setbit(&unicsv_outp_flags, fld_speed); if WAYPT_HAS(wpt, proximity) gb_setbit(&unicsv_outp_flags, fld_proximity); if WAYPT_HAS(wpt, temperature) gb_setbit(&unicsv_outp_flags, fld_temperature); if (gmsd) { if GMSD_HAS(addr) gb_setbit(&unicsv_outp_flags, fld_garmin_addr); if GMSD_HAS(city) gb_setbit(&unicsv_outp_flags, fld_garmin_city); if GMSD_HAS(country) gb_setbit(&unicsv_outp_flags, fld_garmin_country); if GMSD_HAS(phone_nr) gb_setbit(&unicsv_outp_flags, fld_garmin_phone_nr); if GMSD_HAS(phone_nr2) gb_setbit(&unicsv_outp_flags, fld_garmin_phone_nr2); if GMSD_HAS(fax_nr) gb_setbit(&unicsv_outp_flags, fld_garmin_fax_nr); if GMSD_HAS(email) gb_setbit(&unicsv_outp_flags, fld_garmin_email); if GMSD_HAS(postal_code) gb_setbit(&unicsv_outp_flags, fld_garmin_postal_code); if GMSD_HAS(state) gb_setbit(&unicsv_outp_flags, fld_garmin_state); if GMSD_HAS(facility) gb_setbit(&unicsv_outp_flags, fld_garmin_facility); } #ifdef UNICSV_GC_READY if (! waypt_empty_gc_data(wpt)) { const geocache_data *gc_data = wpt->gc_data; if (gc_data->id) gb_setbit(&unicsv_outp_flags, fld_gc_id); if (gc_data->type) gb_setbit(&unicsv_outp_flags, fld_gc_type); if (gc_data->container) gb_setbit(&unicsv_outp_flags, fld_gc_container); if (gc_data->terr) gb_setbit(&unicsv_outp_flags, fld_gc_terr); if (gc_data->diff) gb_setbit(&unicsv_outp_flags, fld_gc_diff); if (gc_data->is_archived) gb_setbit(&unicsv_outp_flags, fld_gc_is_archived); if (gc_data->is_available) gb_setbit(&unicsv_outp_flags, fld_gc_is_available); if (gc_data->exported) gb_setbit(&unicsv_outp_flags, fld_gc_exported); if (gc_data->last_found) gb_setbit(&unicsv_outp_flags, fld_gc_last_found); if (gc_data->placer && *gc_data->placer) gb_setbit(&unicsv_outp_flags, fld_gc_placer); if (gc_data->placer_id) gb_setbit(&unicsv_outp_flags, fld_gc_placer_id); if (gc_data->hint && *gc_data->hint) gb_setbit(&unicsv_outp_flags, fld_gc_hint); } #endif }
static void lowranceusr_waypt_disp(const waypoint *wpt) { int text_len, Lat, Lon, Time, SymbolId; short int WayptType; char *name; char *comment; int alt = METERS_TO_FEET(wpt->altitude); if (wpt->altitude == unknown_alt) { alt = UNKNOWN_USR_ALTITUDE; } Lat = lat_deg_to_mm(wpt->latitude); Lon = lon_deg_to_mm(wpt->longitude); gbfputint32(Lat, file_out); gbfputint32(Lon, file_out); gbfputint32(alt, file_out); if (writing_version >= 3) { float depth = WAYPT_HAS(wpt, depth) ? METERS_TO_FEET(wpt->depth) : -99999.0; gbfputflt(depth, file_out); } if (global_opts.debug_level >= 1) { /* print lat/lon/alt on one easily greppable line */ printf(MYNAME " waypt_disp: Lat = %d Lon = %d Alt = %d\n",Lat, Lon, alt); } /* Try and make sure we have a name */ if ((! wpt->shortname) || global_opts.synthesize_shortnames) { if (wpt->description && global_opts.synthesize_shortnames) { name = mkshort_from_wpt(mkshort_handle, wpt); } else if (wpt->shortname) { name = xstrdup(wpt->shortname); } else if (wpt->description) { name = xstrdup(wpt->description); } else { name = xstrdup(""); } } else { name = xstrdup(wpt->shortname); } text_len = strlen(name); if (text_len > MAXUSRSTRINGSIZE) text_len = MAXUSRSTRINGSIZE; gbfputint32(text_len, file_out); gbfwrite(name, 1, text_len, file_out); if (global_opts.debug_level >= 1) printf(MYNAME " waypt_disp: Waypt name = %s\n",name); xfree(name); /** * Comments are now used by the iFinder (Expedition C supports them) */ if (wpt->description && strcmp(wpt->description, wpt->shortname) != 0) { comment = xstrdup(wpt->description); text_len = strlen(comment); if (text_len > MAXUSRSTRINGSIZE) text_len = MAXUSRSTRINGSIZE; gbfputint32(text_len, file_out); gbfwrite(comment, 1, text_len, file_out); xfree(comment); } else { text_len = 0; gbfputint32(text_len, file_out); } if (wpt->creation_time > base_time_secs) { Time = wpt->creation_time - base_time_secs; } else { Time = 0; } if (global_opts.debug_level >= 2) { time_t wpt_time = Time; printf(MYNAME " waypt_disp: base_time : %d\n", (int)base_time_secs); printf(MYNAME " waypt_disp: creation time : %d\n", (int)wpt->creation_time); printf(MYNAME " waypt_disp: waypt time : %d\n", (int)wpt_time); printf(MYNAME " waypt_disp: waypt time (local): %s\n", ctime(&wpt_time)); } gbfputint32(Time, file_out); if (get_cache_icon(wpt) && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)) { SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt)); } else { SymbolId = lowranceusr_find_icon_number_from_desc(wpt->icon_descr); } /* If the waypoint is archived or disabled, use a "disabled" icon instead. */ if ( (wpt->gc_data->is_archived==status_true) || (wpt->gc_data->is_available==status_false) ) { SymbolId = lowranceusr_find_icon_number_from_desc("Disabled Cache"); } gbfputint32(SymbolId, file_out); /* USER waypoint type */ WayptType = 0; gbfputint16(WayptType, file_out); }