static void parse_rmc(struct gps_tpv *tpv, const char **token) { if (is_status_valid(token[1][0])) { parse_time(tpv->time, token[0]); tpv->latitude = parse_angular_distance(token[2], token[3][0]); tpv->longitude = parse_angular_distance(token[4], token[5][0]); tpv->track = parse_track(token[7], 'T'); tpv->speed = parse_speed(token[6], 'N'); parse_date(tpv->time, token[8]); } }
static void parse_track_waypoint(void) { char *str; int column = -1; waypoint *wpt; bind_fields(trkpt_header); wpt = waypt_new(); while ((str = csv_lineparse(NULL, "\t", "", column++))) { int field_no; double x; if (! *str) continue; field_no = header_fields[trkpt_header][column]; switch(field_no) { case 1: parse_coordinates(str, datum_index, grid_index, &wpt->latitude, &wpt->longitude, MYNAME); break; case 2: parse_date_and_time(str, &wpt->creation_time); break; case 3: if (parse_distance(str, &x, 1, MYNAME)) wpt->altitude = x; break; case 4: if (parse_distance(str, &x, 1, MYNAME)) WAYPT_SET(wpt, depth, x); break; case 5: if (parse_temperature(str, &x)) WAYPT_SET(wpt, temperature, x); break; case 8: if (parse_speed(str, &x, 1, MYNAME)) WAYPT_SET(wpt, speed, x); break; case 9: WAYPT_SET(wpt, course, atoi(str)); break; } } track_add_wpt(current_trk, wpt); }
void ProcessWayTags(TagList *tags,int64_t way_id,int mode) { Way way={0}; int oneway=0,area=0; int roundabout=0,lanes=0; char *name=NULL,*ref=NULL,*refname=NULL; way_t id; int i; /* Convert id */ id=(way_t)way_id; logassert((int64_t)id==way_id,"Way ID too large (change way_t to 64-bits?)"); /* check way id can be stored in way_t data type. */ /* Delete */ if(mode==MODE_DELETE || mode==MODE_MODIFY) { way.type=WAY_DELETED; AppendWayList(ways,id,&way,way_nodes,way_nnodes,""); } if(mode==MODE_DELETE) return; /* Sanity check */ if(way_nnodes==0) { logerror("Way %"Pway_t" has no nodes.\n",logerror_way(id)); return; } if(way_nnodes==1) { logerror_node(way_nodes[0]); /* Extra logerror information since way isn't stored */ logerror("Way %"Pway_t" has only one node.\n",logerror_way(id)); return; } /* Parse the tags - just look for highway */ for(i=0;i<tags->ntags;i++) { char *k=tags->k[i]; char *v=tags->v[i]; if(!strcmp(k,"highway")) { way.type=HighwayType(v); if(way.type==Highway_None) logerror("Way %"Pway_t" has an unrecognised highway type '%s' (after tagging rules); ignoring it.\n",logerror_way(id),v); break; } } /* Don't continue if this is not a highway (bypass error logging) */ if(way.type==Highway_None) return; /* Parse the tags - look for the others */ for(i=0;i<tags->ntags;i++) { int recognised=0; char *k=tags->k[i]; char *v=tags->v[i]; switch(*k) { case 'a': if(!strcmp(k,"area")) { if(ISTRUE(v)) area=1; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'area' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'b': if(!strcmp(k,"bicycle")) { if(ISTRUE(v)) way.allow|=Transports_Bicycle; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'bicycle' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } if(!strcmp(k,"bicycleroute")) { if(ISTRUE(v)) way.props|=Properties_BicycleRoute; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'bicycleroute' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } if(!strcmp(k,"bridge")) { if(ISTRUE(v)) way.props|=Properties_Bridge; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'bridge' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'c': if(!strcmp(k,"cycleway")) { if(!strcmp(v,"opposite_lane")) way.props|=Properties_DoubleSens; recognised=1; break; } break; case 'f': if(!strcmp(k,"foot")) { if(ISTRUE(v)) way.allow|=Transports_Foot; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'foot' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } if(!strcmp(k,"footroute")) { if(ISTRUE(v)) way.props|=Properties_FootRoute; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'footroute' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'g': if(!strcmp(k,"goods")) { if(ISTRUE(v)) way.allow|=Transports_Goods; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'goods' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'h': if(!strcmp(k,"highway")) {recognised=1; break;} if(!strcmp(k,"horse")) { if(ISTRUE(v)) way.allow|=Transports_Horse; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'horse' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } if(!strcmp(k,"hgv")) { if(ISTRUE(v)) way.allow|=Transports_HGV; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'hgv' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'i': if(!strcmp(k,"incline")) { /* logerror("Way %"Pway_t" has an 'incline' = '%s' \n",logerror_way(id),v); */ way.incline=pourcent_to_incline(parse_incline(id,k,v)); recognised=1; break; } break; case 'l': if(!strcmp(k,"lanes")) { int en=0; float lanesf; if(sscanf(v,"%f%n",&lanesf,&en)==1 && en && !v[en]) lanes=(int)lanesf; else logerror("Way %"Pway_t" has an unrecognised tag 'lanes' = '%s' (after tagging rules); ignoring it.\n",logerror_way(id),v); recognised=1; break; } break; case 'm': if(!strncmp(k,"max",3)) { if(!strcmp(k+3,"speed")) { way.speed=kph_to_speed(parse_speed(id,k,v)); recognised=1; break; } if(!strcmp(k+3,"weight")) { way.weight=tonnes_to_weight(parse_weight(id,k,v)); recognised=1; break; } if(!strcmp(k+3,"height")) { way.height=metres_to_height(parse_length(id,k,v)); recognised=1; break; } if(!strcmp(k+3,"width")) { way.width=metres_to_height(parse_length(id,k,v)); recognised=1; break; } if(!strcmp(k+3,"length")) { way.length=metres_to_height(parse_length(id,k,v)); recognised=1; break; } } if(!strcmp(k,"moped")) { if(ISTRUE(v)) way.allow|=Transports_Moped; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'moped' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } if(!strcmp(k,"motorcycle")) { if(ISTRUE(v)) way.allow|=Transports_Motorcycle; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'motorcycle' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } if(!strcmp(k,"motorcar")) { if(ISTRUE(v)) way.allow|=Transports_Motorcar; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'motorcar' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } if(!strcmp(k,"multilane")) { if(ISTRUE(v)) way.props|=Properties_Multilane; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'multilane' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'n': if(!strcmp(k,"name")) { name=v; recognised=1; break; } break; case 'o': if(!strcmp(k,"oneway")) { if(ISTRUE(v)) oneway=1; else if(!strcmp(v,"-1")) oneway=-1; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'oneway' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'p': if(!strcmp(k,"paved")) { if(ISTRUE(v)) way.props|=Properties_Paved; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'paved' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } if(!strcmp(k,"psv")) { if(ISTRUE(v)) way.allow|=Transports_PSV; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'psv' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'r': if(!strcmp(k,"ref")) { ref=v; recognised=1; break; } if(!strcmp(k,"roundabout")) { if(ISTRUE(v)) roundabout=1; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'roundabout' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 't': if(!strcmp(k,"tunnel")) { if(ISTRUE(v)) way.props|=Properties_Tunnel; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'tunnel' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; case 'w': if(!strcmp(k,"wheelchair")) { if(ISTRUE(v)) way.allow|=Transports_Wheelchair; else if(!ISFALSE(v)) logerror("Way %"Pway_t" has an unrecognised tag 'wheelchair' = '%s' (after tagging rules); using 'no'.\n",logerror_way(id),v); recognised=1; break; } break; default: break; } if(!recognised) logerror("Way %"Pway_t" has an unrecognised tag '%s' = '%s' (after tagging rules); ignoring it.\n",logerror_way(id),k,v); } /* Create the way */ if(area && oneway) { logerror("Way %"Pway_t" is an area and oneway; ignoring area tagging.\n",logerror_way(id)); area=0; } if(!way.allow) return; if(oneway) { way.type|=Highway_OneWay; if(oneway==-1) for(i=0;i<way_nnodes/2;i++) { node_t temp; temp=way_nodes[i]; way_nodes[i]=way_nodes[way_nnodes-i-1]; way_nodes[way_nnodes-i-1]=temp; } } if(roundabout) way.type|=Highway_Roundabout; if(area) { way.type|=Highway_Area; if(way_nodes[0]!=way_nodes[way_nnodes-1]) logerror("Way %"Pway_t" is an area but not closed.\n",logerror_way(id)); } if(lanes) { if(oneway || (lanes/2)>1) way.props|=Properties_Multilane; if(oneway && lanes==1) way.props&=~Properties_Multilane; } if(ref && name) { refname=(char*)malloc(strlen(ref)+strlen(name)+4); sprintf(refname,"%s (%s)",name,ref); } else if(ref && !name) refname=ref; else if(!ref && name) refname=name; else /* if(!ref && !name) */ refname=""; AppendWayList(ways,id,&way,way_nodes,way_nnodes,refname); if(ref && name) free(refname); }
static void parse_vtg(struct gps_tpv *tpv, const char **token) { tpv->track = parse_track(token[0], token[1][0]); tpv->speed = parse_speed(token[6], token[7][0]); }
static void unicsv_parse_one_line(char *ibuf) { char *s; waypoint *wpt = NULL; int column; int utm_zone = -9999; double utm_easting = 0; double utm_northing = 0; char utm_zc = 'N'; char bng_zone[3] = ""; double bng_easting = 0; double bng_northing = 0; double swiss_easting = unicsv_unknown; double swiss_northing = unicsv_unknown; int checked = 0; time_t date = -1, time = -1; int msec = -1; char is_localtime = 0; garmin_fs_t *gmsd; double d; struct tm ymd; int src_datum = unicsv_datum_idx; int ns = 1; int ew = 1; #ifdef UNICSV_GC_READY geocache_data *gc_data = NULL; #endif wpt = waypt_new(); wpt->latitude = unicsv_unknown; wpt->longitude = unicsv_unknown; memset(&ymd, 0, sizeof(ymd)); column = -1; while ((s = csv_lineparse(ibuf, unicsv_fieldsep, "\"", 0))) { if (column > unicsv_fields_tab_ct) break; /* ignore extra fields on line */ ibuf = NULL; column++; checked++; s = lrtrim(s); if (! *s) continue; /* skip empty columns */ switch(unicsv_fields_tab[column]) { case fld_time: case fld_date: case fld_datetime: /* switch column type if it looks like an iso time string */ if (strchr(s, 'T')) unicsv_fields_tab[column] = fld_iso_time; break; default: ; } switch(unicsv_fields_tab[column]) { case fld_latitude: human_to_dec( s, &wpt->latitude, &wpt->longitude, 1 ); wpt->latitude = wpt->latitude * ns; break; case fld_longitude: human_to_dec( s, &wpt->latitude, &wpt->longitude, 2 ); wpt->longitude = wpt->longitude * ew; break; case fld_shortname: wpt->shortname = xstrdup(s); break; case fld_description: wpt->description = xstrdup(s); break; case fld_notes: wpt->notes = xstrdup(s); break; case fld_url: wpt->url = xstrdup(s); break; case fld_altitude: if (parse_distance(s, &d, unicsv_altscale, MYNAME)) { if (fabs(d) < fabs(unknown_alt)) wpt->altitude = d; } break; case fld_utm_zone: utm_zone = atoi(s); break; case fld_utm_easting: utm_easting = atof(s); break; case fld_utm_northing: utm_northing = atof(s); break; case fld_utm_zone_char: utm_zc = toupper(s[0]); break; case fld_utm: parse_coordinates(s, unicsv_datum_idx, grid_utm, &wpt->latitude, &wpt->longitude, MYNAME); /* coordinates from parse_coordinates are in WGS84 don't convert a second time */ src_datum = DATUM_WGS84; break; case fld_bng: parse_coordinates(s, DATUM_OSGB36, grid_bng, &wpt->latitude, &wpt->longitude, MYNAME); /* coordinates from parse_coordinates are in WGS84 don't convert a second time */ src_datum = DATUM_WGS84; break; case fld_bng_zone: strncpy(bng_zone, s, sizeof(bng_zone)); strupper(bng_zone); break; case fld_bng_northing: bng_northing = atof(s); break; case fld_bng_easting: bng_easting = atof(s); break; case fld_swiss: parse_coordinates(s, DATUM_WGS84, grid_swiss, &wpt->latitude, &wpt->longitude, MYNAME); /* coordinates from parse_coordinates are in WGS84 don't convert a second time */ src_datum = DATUM_WGS84; break; case fld_swiss_easting: swiss_easting = atof(s); break; case fld_swiss_northing: swiss_northing = atof(s); break; case fld_hdop: wpt->hdop = atof(s); if (unicsv_detect) unicsv_data_type = trkdata; break; case fld_pdop: wpt->pdop = atof(s); if (unicsv_detect) unicsv_data_type = trkdata; break; case fld_vdop: wpt->vdop = atof(s); if (unicsv_detect) unicsv_data_type = trkdata; break; case fld_sat: wpt->sat = atoi(s); if (unicsv_detect) unicsv_data_type = trkdata; break; case fld_fix: if (unicsv_detect) unicsv_data_type = trkdata; if (case_ignore_strcmp(s, "none") == 0) wpt->fix = fix_none; else if (case_ignore_strcmp(s, "2d") == 0) wpt->fix = fix_2d; else if (case_ignore_strcmp(s, "3d") == 0) wpt->fix = fix_3d; else if (case_ignore_strcmp(s, "dgps") == 0) wpt->fix = fix_dgps; else if (case_ignore_strcmp(s, "pps") == 0) wpt->fix = fix_pps; else wpt->fix = fix_unknown; break; case fld_utc_date: if ((is_localtime < 2) && (date < 0)) { date = unicsv_parse_date(s, NULL); is_localtime = 0; } break; case fld_utc_time: if ((is_localtime < 2) && (time < 0)) { time = unicsv_parse_time(s, &msec, &date); is_localtime = 0; } break; case fld_speed: if (parse_speed(s, &d, 1.0, MYNAME)) { WAYPT_SET(wpt, speed, d); if (unicsv_detect) unicsv_data_type = trkdata; } break; case fld_course: WAYPT_SET(wpt, course, atof(s)); if (unicsv_detect) unicsv_data_type = trkdata; break; case fld_temperature: d = atof(s); if (fabs(d) < 999999) WAYPT_SET(wpt, temperature, d); break; case fld_temperature_f: d = atof(s); if (fabs(d) < 999999) WAYPT_SET(wpt, temperature, FAHRENHEIT_TO_CELSIUS(d)); break; case fld_heartrate: wpt->heartrate = atoi(s); if (unicsv_detect) unicsv_data_type = trkdata; break; case fld_cadence: wpt->cadence = atoi(s); if (unicsv_detect) unicsv_data_type = trkdata; break; case fld_proximity: if (parse_distance(s, &d, unicsv_proximityscale, MYNAME)) WAYPT_SET(wpt, proximity, d); break; case fld_depth: if (parse_distance(s, &d, unicsv_depthscale, MYNAME)) WAYPT_SET(wpt, depth, d); break; case fld_symbol: wpt->icon_descr = xstrdup(s); wpt->wpt_flags.icon_descr_is_dynamic = 1; break; case fld_iso_time: is_localtime = 2; /* fix result */ wpt->creation_time = xml_parse_time(s, &wpt->microseconds); break; case fld_time: if ((is_localtime < 2) && (time < 0)) { time = unicsv_parse_time(s, &msec, &date); is_localtime = 1; } break; case fld_date: if ((is_localtime < 2) && (date < 0)) { date = unicsv_parse_date(s, NULL); is_localtime = 1; } break; case fld_year: ymd.tm_year = atoi(s); break; case fld_month: ymd.tm_mon = atoi(s); break; case fld_day: ymd.tm_mday = atoi(s); break; case fld_hour: ymd.tm_hour = atoi(s); break; case fld_min: ymd.tm_min = atoi(s); break; case fld_sec: ymd.tm_sec = atoi(s); break; case fld_datetime: if ((is_localtime < 2) && (date < 0) && (time < 0)) { time = unicsv_parse_time(s, &msec, &date); is_localtime = 1; } break; case fld_ns: ns = tolower(s[0]) == 'n' ? 1 : -1; wpt->latitude *= ns; break; case fld_ew: ew = tolower(s[0]) == 'e' ? 1 : -1; wpt->longitude *= ew; break; case fld_garmin_city: case fld_garmin_postal_code: case fld_garmin_state: case fld_garmin_country: case fld_garmin_addr: case fld_garmin_phone_nr: case fld_garmin_phone_nr2: case fld_garmin_fax_nr: case fld_garmin_email: case fld_garmin_facility: gmsd = GMSD_FIND(wpt); if (! gmsd) { gmsd = garmin_fs_alloc(-1); fs_chain_add(&wpt->fs, (format_specific_data *) gmsd); } switch(unicsv_fields_tab[column]) { case fld_garmin_city: GMSD_SETSTR(city, s); break; case fld_garmin_postal_code: GMSD_SETSTR(postal_code, s); break; case fld_garmin_state: GMSD_SETSTR(state, s); break; case fld_garmin_country: GMSD_SETSTR(country, s); break; case fld_garmin_addr: GMSD_SETSTR(addr, s); break; case fld_garmin_phone_nr: GMSD_SETSTR(phone_nr, s); break; case fld_garmin_phone_nr2: GMSD_SETSTR(phone_nr2, s); break; case fld_garmin_fax_nr: GMSD_SETSTR(fax_nr, s); break; case fld_garmin_email: GMSD_SETSTR(email, s); break; case fld_garmin_facility: GMSD_SETSTR(facility, s); break; default: break; } break; #ifdef UNICSV_GC_READY case fld_gc_id: case fld_gc_type: case fld_gc_container: case fld_gc_terr: case fld_gc_diff: case fld_gc_is_archived: case fld_gc_is_available: case fld_gc_exported: case fld_gc_last_found: case fld_gc_placer: case fld_gc_placer_id: case fld_gc_hint: gc_data = waypt_alloc_gc_data(wpt); switch(unicsv_fields_tab[column]) { case fld_gc_id: gc_data->id = atoi(s); if (gc_data->id == 0) gc_data->id = unicsv_parse_gc_id(s); break; case fld_gc_type: gc_data->type = gs_mktype(s); break; case fld_gc_container: gc_data->container = gs_mkcont(s); break; case fld_gc_terr: gc_data->terr = atof(s) * 10; break; case fld_gc_diff: gc_data->diff = atof(s) * 10; break; case fld_gc_is_archived: gc_data->is_archived = unicsv_parse_status(s); break; case fld_gc_is_available: gc_data->is_available = unicsv_parse_status(s); break; case fld_gc_exported: { time_t time, date; int msec; time = unicsv_parse_time(s, &msec, &date); if (date || time) gc_data->exported = unicsv_adjust_time(time, &date); } break; case fld_gc_last_found: { time_t time, date; int msec; time = unicsv_parse_time(s, &msec, &date); if (date || time) gc_data->last_found = unicsv_adjust_time(time, &date); } break; case fld_gc_placer: gc_data->placer = xstrdup(s); break; case fld_gc_placer_id: gc_data->placer_id = atoi(s); break; case fld_gc_hint: gc_data->hint = xstrdup(s); break; default: break; } break; #endif case fld_terminator: /* dummy */ checked--; break; } } if (checked == 0) { waypt_free(wpt); return; } if (is_localtime < 2) { /* not fixed */ if ((time >= 0) && (date >= 0)) { time_t t = date + time; if (is_localtime) { struct tm tm; tm = *gmtime(&t); if (opt_utc) wpt->creation_time = mkgmtime(&tm); else wpt->creation_time = mklocaltime(&tm); } else wpt->creation_time = t; } else if (time >= 0) wpt->creation_time = time; else if (date >= 0) wpt->creation_time = date; else if (ymd.tm_year || ymd.tm_mon || ymd.tm_mday) { if (ymd.tm_year < 100) { if (ymd.tm_year <= 70) ymd.tm_year += 2000; else ymd.tm_year += 1900; } ymd.tm_year -= 1900; if (ymd.tm_mon == 0) ymd.tm_mon = 1; if (ymd.tm_mday == 0) ymd.tm_mday = 1; ymd.tm_mon--; if (opt_utc) wpt->creation_time = mkgmtime(&ymd); else wpt->creation_time = mklocaltime(&ymd); } else if (ymd.tm_hour || ymd.tm_min || ymd.tm_sec) { if (opt_utc) wpt->creation_time = mkgmtime(&ymd); else wpt->creation_time = mklocaltime(&ymd); } if (msec >= 0) wpt->microseconds = msec; if (opt_utc) wpt->creation_time += atoi(opt_utc) * SECONDS_PER_HOUR; } /* utm/bng/swiss can be optional */ if ((wpt->latitude == unicsv_unknown) && (wpt->longitude == unicsv_unknown)) { if (utm_zone != -9999) { GPS_Math_UTM_EN_To_Known_Datum(&wpt->latitude, &wpt->longitude, utm_easting, utm_northing, utm_zone, utm_zc, unicsv_datum_idx); } else if (bng_zone[0]) { if (! GPS_Math_UKOSMap_To_WGS84_M( bng_zone, bng_easting, bng_northing, &wpt->latitude, &wpt->longitude)) fatal(MYNAME ": Unable to convert BNG coordinates (%s %.f %.f)!\n", bng_zone, bng_easting, bng_northing); src_datum = DATUM_WGS84; /* don't convert afterwards */ } else if ((swiss_easting != unicsv_unknown) && (swiss_northing != unicsv_unknown)) { GPS_Math_Swiss_EN_To_WGS84(swiss_easting, swiss_northing, &wpt->latitude, &wpt->longitude); src_datum = DATUM_WGS84; /* don't convert afterwards */ } } if ((src_datum != DATUM_WGS84) && (wpt->latitude != unicsv_unknown) && (wpt->longitude != unicsv_unknown)) { double alt; GPS_Math_Known_Datum_To_WGS84_M(wpt->latitude, wpt->longitude, (double) 0.0, &wpt->latitude, &wpt->longitude, &alt, src_datum); } switch(unicsv_data_type) { case rtedata: if (! unicsv_route) { unicsv_route = route_head_alloc(); route_add_head(unicsv_route); } route_add_wpt(unicsv_route, wpt); break; case trkdata: if (! unicsv_track) { unicsv_track = route_head_alloc(); track_add_head(unicsv_track); } track_add_wpt(unicsv_track, wpt); break; default: waypt_add(wpt); } }