static void lowranceusr_parse_routes(void) { char buff[MAXUSRSTRINGSIZE + 1]; short int num_routes, num_legs; int i,j; int text_len; waypoint *wpt_tmp; num_routes = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " parse_routes: Num Routes = %d\n", num_routes); for (i=0; i < num_routes; i++) { rte_head = route_head_alloc(); route_add_head(rte_head); rte_head->rte_num = i+1; /* route name */ text_len = lowranceusr_readstr(&buff[0], MAXUSRSTRINGSIZE, file_in); if (text_len) { buff[text_len] = '\0'; rte_head->rte_name = xstrdup(buff); } rte_head->rte_desc = '\0'; /* ???????? */ /* num Legs */ num_legs = gbfgetint16(file_in); /* route reversed */ (void) gbfread(&buff[0], 1, 1, file_in); /* waypoints */ for (j=0; j < num_legs; j++) { wpt_tmp = waypt_new(); lowranceusr_parse_waypt(wpt_tmp); route_add_wpt(rte_head, wpt_tmp); } } }
static void data_read(void) { short int NumWaypoints, MajorVersion, MinorVersion, object_num; int i; MajorVersion = gbfgetint16(file_in); reading_version = MajorVersion; MinorVersion = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " data_read: Major Version %d Minor Version %d\n", MajorVersion, MinorVersion); if (MajorVersion < 2) { fatal(MYNAME ": input file is from an old version of the USR file and is not supported\n"); } NumWaypoints = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " data_read: Num waypoints %d\n", NumWaypoints); for (i = 0; i < NumWaypoints; i++) { waypoint *wpt_tmp; wpt_tmp = waypt_new(); /* Object num */ object_num = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " data_read: object_num = %d\n", object_num); /* waypoint */ lowranceusr_parse_waypt(wpt_tmp); waypt_add(wpt_tmp); } lowranceusr_parse_routes(); lowranceusr_parse_icons(); lowranceusr_parse_trails(); }
/* * Icons are automatically converted to waypoints unless * option of ignoreicons is used */ static void lowranceusr_parse_icons(void) { char buff[MAXUSRSTRINGSIZE + 1]; short int num_icons; int i; num_icons = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " parse_icons: num Icons = %d\n", num_icons); for (i=0; i < num_icons; i++) { if (ignoreicons) { /* position coord lat & long */ (void) gbfread(&buff[0], 4, 2, file_in); /* symbol */ (void) gbfread(&buff[0], 4, 1, file_in); } else { waypoint *wpt_tmp; wpt_tmp = waypt_new(); /* position coord lat & long */ wpt_tmp->latitude = lat_mm_to_deg(gbfgetint32(file_in)); wpt_tmp->longitude = lon_mm_to_deg(gbfgetint32(file_in)); wpt_tmp->altitude = 0; snprintf(buff, sizeof(buff), "Icon %d", i+1); wpt_tmp->shortname = xstrdup(buff); /* symbol */ wpt_tmp->icon_descr = lowranceusr_find_desc_from_icon_number(gbfgetint32(file_in)); waypt_add(wpt_tmp); } } }
static void xol_shape(const char *args, const char **attrv) { const char **avp = &attrv[0]; while (*avp) { if (strcmp(avp[0], "type") == 0) { if (strcmp(avp[1], "waypoint") == 0) { wpt = waypt_new(); } else if (strcmp(avp[1], "polyline") == 0) { trk = route_head_alloc(); track_add_head(trk); } } else if (strcmp(avp[0], "name") == 0) { if (wpt) wpt->shortname = xstrdup(avp[1]); else if (trk) trk->rte_name = xstrdup(avp[1]); } else if (strcmp(avp[0], "comment") == 0) { if (wpt) wpt->notes = xstrdup(avp[1]); } else if (strcmp(avp[0], "alt") == 0) { if (wpt) wpt->altitude = atof(avp[1]); } else if (strcmp(avp[0], "timestamp") == 0) { if (wpt) wpt->creation_time = xml_parse_time(avp[1], &wpt->microseconds); } else if (strcmp(avp[0], "icon") == 0) { if (wpt) { wpt->icon_descr = xstrdup(avp[1]); wpt->wpt_flags.icon_descr_is_dynamic = 1; } } avp+=2; } }
void trk_coord(const char *args, const char **attrv) { int consumed = 0; double lat, lon, alt; waypoint *trkpt; route_head *trk_head = route_head_alloc(); if (wpt_tmp->shortname) { trk_head->rte_name = xstrdup(wpt_tmp->shortname); } track_add_head(trk_head); while (3 == sscanf(args, "%lf,%lf,%lf %n", &lon, &lat, &alt, &consumed)){ trkpt = waypt_new(); trkpt->latitude = lat; trkpt->longitude = lon; trkpt->altitude = alt; track_add_wpt(trk_head, trkpt); args += consumed; } }
static void mmo_read_CObjTrack(mmo_data_t *data) { #ifdef MMO_DBG const char *sobj = "CObjTrack"; #endif int tp, ctp; route_head *trk; DBG((sobj, ":-----------------------------------------------------\n")); DBG((sobj, "name = \"%s\" [ visible=%s, id=0x%04X ]\n", data->name, data->visible ? "yes" : "NO", data->objid)); trk = route_head_alloc(); trk->rte_name = xstrdup(data->name); track_add_head(trk); tp = gbfgetint16(fin); DBG((sobj, "track has %d point(s)\n", tp)); for (ctp = 0; ctp < tp; ctp++) { waypoint *wpt; char unk; wpt = waypt_new(); wpt->latitude = gbfgetdbl(fin); wpt->longitude = gbfgetdbl(fin); unk = gbfgetc(fin); wpt->creation_time = gbfgetint32(fin); wpt->altitude = gbfgetflt(fin); if (unk != 0) { gbuint16 ux; ux = gbfgetuint16(fin); DBG((sobj, "u16 = %04X (%d)\n", ux, ux)); if (unk > 1) { gbuint16 ux; ux = gbfgetuint16(fin); DBG((sobj, "u16 = %04X (%d)\n", ux, ux)); } } track_add_wpt(trk, wpt); } if (mmo_version > 0) { gbuint32 u32; u32 = gbfgetuint32(fin); /* Min. update interval */ DBG((sobj, "min. update interval = %d\n", u32)); u32 = gbfgetuint32(fin); /* unknown */ // DBG((sobj, "unknown value = 0x%8X (%d)\n", u32, u32)); u32 = gbfgetuint32(fin); /* unknown */ // DBG((sobj, "unknown value = 0x%8X (%d)\n", u32, u32)); u32 = gbfgetuint32(fin); /* unknown */ DBG((sobj, "min. update distance = %d\n", u32)); u32 = gbfgetuint32(fin); /* unknown */ DBG((sobj, "track partition interval = %d\n", u32 / 60)); u32 = gbfgetuint32(fin); /* unknown */ // DBG((sobj, "unknown value = 0x%8X (%d)\n", u32, u32)); u32 = gbfgetuint32(fin); /* unknown */ DBG((sobj, "tick interval = %d\n", u32 / 60)); trk->line_color.bbggrr = gbfgetuint32(fin); /* rgb color */ trk->line_color.opacity = 255; DBG((sobj, "color = 0x%06X\n", trk->line_color.bbggrr)); } if (mmo_version >= 0x12) { char u8; u8 = gbfgetc(fin); DBG((sobj, "line width = %d - (since 0x12)\n", u8)); u8 = gbfgetc(fin); DBG((sobj, "line style = %d - (since 0x12)\n", u8)); u8 = gbfgetc(fin); DBG((sobj, "transparency = %d - (since 0x12)\n", u8)); trk->line_color.opacity = 255 - (u8 * 51); if (mmo_version >= 0x16) { char u8; gbuint16 u16; u8 = gbfgetc(fin); // DBG((sobj, "u8 = 0x%X (since 0x16)\n", u8)); u16 = gbfgetuint16(fin); // DBG((sobj, "u16 = 0x%X (since 0x16)\n", u16)); u16 = gbfgetuint16(fin); // DBG((sobj, "u16 = 0x%X (since 0x16)\n", u16)); } } if (trk->rte_waypt_ct == 0) { track_del_head(trk); data->data = NULL; } }
static void mmo_read_CObjWaypoint(mmo_data_t *data) { #ifdef MMO_DBG const char *sobj = "CObjWaypoint"; #endif waypoint *wpt; time_t time; int rtelinks; mmo_data_t **rtelink = NULL; char *str; char buf[16]; int i, ux; DBG((sobj, ":-----------------------------------------------------\n")); DBG((sobj, "name = \"%s\" [ visible=%s, id=0x%04X ]\n", data->name, data->visible ? "yes" : "NO", data->objid)); wpt = waypt_new(); wpt->shortname = xstrdup(data->name); time = data->mtime; if (! time) time = data->ctime; if (time > 0) wpt->creation_time = time; wpt->latitude = gbfgetdbl(fin); wpt->longitude = gbfgetdbl(fin); DBG((sobj, "coordinates = %f / %f\n", wpt->latitude, wpt->longitude)); rtelinks = gbfgetuint16(fin); if (rtelinks > 0) { rtelink = xcalloc(sizeof(*rtelink), rtelinks); DBG((sobj, "rtelinks = %d\n", rtelinks)); for (i = 0; i < rtelinks; i++) { mmo_data_t *tmp; int objid; DBG((sobj, "read rtelink number %d\n", i + 1)); objid = gbfgetuint16(fin); gbfseek(fin, -2, SEEK_CUR); rtelink[i] = tmp = mmo_read_object(wpt); if ((objid < 0x8000) && (tmp != NULL) && (tmp->type == rtedata)) { route_head *rte = tmp->data; tmp->left--; route_add_wpt(rte, waypt_dupe(wpt)); DBG((sobj, "\"%s\" Added to route \"%s\"\n", wpt->shortname, rte->rte_name)); } } } str = mmo_readstr(); /* descr + url */ if (strncmp(str, "_FILE_ ", 7) == 0) { char *cx, *cend; cx = lrtrim(str + 7); cend = strchr(cx, '\n'); if (cend == NULL) cend = cx + strlen(cx); cx = lrtrim(xstrndup(cx, cend - cx)); if (*cx) wpt->url = cx; else xfree(cx); if (*cend++) wpt->notes = xstrdup(cend); if (wpt->url) DBG((sobj, "url = \"%s\"\n", wpt->url)); } else if (*str) wpt->notes = xstrdup(str); xfree(str); if (wpt->notes) DBG((sobj, "notes = \"%s\"\n", wpt->notes)); mmo_fillbuf(buf, 12, 1); i = le_read32(&buf[8]); /* icon */ if (i != -1) { char key[16]; char *name; snprintf(key, sizeof(key), "%d", i); if (avltree_find(icons, key, (void *)&name)) { wpt->icon_descr = xstrdup(name); wpt->wpt_flags.icon_descr_is_dynamic = 1; DBG((sobj, "icon = \"%s\"\n", wpt->icon_descr)); } } wpt->proximity = le_read_float(&buf[4]); if (wpt->proximity) { wpt->wpt_flags.proximity = 1; DBG((sobj, "proximity = %f\n", wpt->proximity)); } str = mmo_readstr(); /* name on gps ??? option ??? */ if (*str) { wpt->description = wpt->shortname; wpt->shortname = str; DBG((sobj, "name on gps = %s\n", str)); } else xfree(str); ux = gbfgetuint32(fin); DBG((sobj, "proximity type = %d\n", ux)); if (rtelinks) { int i; for (i = 0; i < rtelinks; i++) { int j; route_head *rte = rtelink[i]->data; for (j = 0; j < rtelinks; j++) { if ((i != j) && (rtelink[i] == rtelink[j])) { rtelink[i]->loop = 1; break; } } rtelink[i]->done++; if ((rtelink[i]->left == 0) && (rtelink[i]->done == rte->rte_waypt_ct)) { if (mmo_version <= 0x11) mmo_end_of_route(rtelink[i]); } } } if (rtelink) { xfree(rtelink); waypt_free(wpt); data->data = NULL; } else waypt_add(wpt); }
static void parse_waypoint(void) { char *str; int column = -1; waypoint *wpt; garmin_fs_p gmsd = NULL; bind_fields(waypt_header); wpt = waypt_new(); gmsd = garmin_fs_alloc(-1); fs_chain_add(&wpt->fs, (format_specific_data *) gmsd); while ((str = csv_lineparse(NULL, "\t", "", column++))) { int i, dynamic; double d; int field_no = header_fields[waypt_header][column]; switch(field_no) { case 1: wpt->shortname = DUPSTR(str); break; case 2: wpt->notes = DUPSTR(str); break; case 3: for (i = 0; i <= gt_waypt_class_map_line; i++) { if (case_ignore_strcmp(str, gt_waypt_class_names[i]) == 0) { GMSD_SET(wpt_class, i); break; } } break; case 4: parse_coordinates(str, datum_index, grid_index, &wpt->latitude, &wpt->longitude, MYNAME); break; case 5: if (parse_distance(str, &d, 1, MYNAME)) wpt->altitude = d; break; case 6: if (parse_distance(str, &d, 1, MYNAME)) WAYPT_SET(wpt, depth, d); break; case 7: if (parse_distance(str, &d, 1, MYNAME)) WAYPT_SET(wpt, proximity, d); break; case 8: if (parse_temperature(str, &d)) WAYPT_SET(wpt, temperature, d); break; case 9: if (parse_display(str, &i)) GMSD_SET(display, i); break; case 10: break; /* skip color */ case 11: i = gt_find_icon_number_from_desc(str, GDB); GMSD_SET(icon, i); wpt->icon_descr = gt_find_desc_from_icon_number(i, GDB, &dynamic); wpt->wpt_flags.icon_descr_is_dynamic = dynamic; break; case 12: GMSD_SETSTR(facility, str); break; case 13: GMSD_SETSTR(city, str); break; case 14: GMSD_SETSTR(state, str); break; case 15: GMSD_SETSTR(country, str); GMSD_SETSTR(cc, gt_get_icao_cc(str, wpt->shortname)); break; case 16: parse_date_and_time(str, &wpt->creation_time); break; case 17: wpt->url = DUPSTR(str); break; case 18: GMSD_SET(category, parse_categories(str)); break; default: break; } } waypt_add(wpt); }
static void format_garmin_xt_proc_atrk(void) { gbuint16 block=0, uu=0; gbuint32 Lat=0, Lon=0; gbuint32 Tim=0; double LatF = 0, LonF = 0, AltF = 0; waypoint *wpt; int method = 0; unsigned char buf[3]; gbint32 num_trackpoints; // get the option for the processing the track name if ( opt_trk_header ) { method = atoi(opt_trk_header); } if (! track) { track = route_head_alloc(); // header option was not set to ignore if ( method !=1 ) { track->rte_name = xstrdup("ATRK XT"); } track_add_head(track); } // We think the word at offset 0xc is the trackpoint count. gbfseek(fin, 12, SEEK_SET); num_trackpoints = gbfgetuint32(fin); while (num_trackpoints--) { block = gbfgetuint16(fin); if (block != 0x0c) break; gbfread(&buf, 3, DATABLOCKSIZE, fin); //1. Lat Lat = buf[0] | (buf[1] << 8) | (buf[2] << 16); gbfread(&buf, 3, DATABLOCKSIZE, fin); //2. Lon Lon = buf[0] | (buf[1] << 8) | (buf[2] << 16); uu = gbfgetuint16(fin); Tim = gbfgetuint32(fin); Tim += 631065600; // adjustment to UnixTime LatF = Lat; if (LatF>8388608) {LatF -= 16777216;}; LonF = Lon; if (LonF>8388608) {LonF -= 16777216;}; AltF = (double)uu * GARMIN_XT_ELE - 1500; //create new waypoint wpt = waypt_new(); //populate wpt; wpt->latitude = LatF*180/16777216; /* Degrees */ wpt->longitude = LonF*360/16777216; /* Degrees */ wpt->altitude = AltF; /* Meters. */ wpt->creation_time = Tim; /* Unix Time adjusted to Garmin time */ track_add_wpt(track, wpt); } }
static void nav_start(void *data, const XML_Char *xml_el, const XML_Char **xml_attr) { const char *el; const char **attr; el = xml_convert_to_char_string(xml_el); attr = xml_convert_attrs_to_char_string(xml_attr); if (0 == strcmp(el, "CacheDetails")) { const char **ap; geocache_data *gc_data; wpt_tmp = waypt_new(); gc_data = waypt_alloc_gc_data(wpt_tmp); for (ap = attr; *ap; ap+=2) { if (0 == strcmp(ap[0], "cache_id")) { wpt_tmp->shortname = xstrdup(ap[1]); } else if (0 == strcmp(ap[0], "name")) { wpt_tmp->description = xstrdup(ap[1]); } else if (0 == strcmp(ap[0], "latitude")) { sscanf(ap[1], "%lf", &wpt_tmp->latitude); } else if (0 == strcmp(ap[0], "longitude")) { sscanf(ap[1], "%lf", &wpt_tmp->longitude); } else if (0 == strcmp(ap[0], "longitude")) { sscanf(ap[1], "%lf", &wpt_tmp->longitude); } else if (0 == strcmp(ap[0], "difficulty")) { float x; sscanf(ap[1], "%f", &x); gc_data->diff = x * 10; } else if (0 == strcmp(ap[0], "terrain")) { float x; sscanf(ap[1], "%f", &x); gc_data->terr = x * 10; } else if (0 == strcmp(ap[0], "cache_type")) { static char buf[512]; gc_data->type = nc_mktype(ap[1]); if (!strcmp(ap[1], "normal")) wpt_tmp->icon_descr = "Geocache-regular"; else if (!strcmp(ap[1], "multi-part")) wpt_tmp->icon_descr = "Geocache-multi"; else if (!strcmp(ap[1], "moving_travelling")) wpt_tmp->icon_descr = "Geocache-moving"; else { sprintf(buf, "Geocache-%-.20s", ap[1]); wpt_tmp->icon_descr = xstrdup(buf); } } else if (0 == strcmp(ap[0], "hidden_date")) { struct tm tm; sscanf(ap[1], "%d-%d-%d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday); tm.tm_mon -= 1; tm.tm_year -= 1900; tm.tm_isdst = 0; tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; wpt_tmp->creation_time = mktime(&tm); } else if (0 == strcmp(ap[0], "retired")) { if (!strcmp(ap[1], "yes") && noretired) { xfree(wpt_tmp); return; } } else if (0 == strcmp(ap[0], "cache_size")) { gc_data->container = nc_mkcont(ap[1]); } else if (0 == strcmp(ap[0], "description")) { gc_data->desc_long.is_html = 1; gc_data->desc_long.utfstring = xstrdup(ap[1]); } else if (0 == strcmp(ap[0], "comments")) { gc_data->desc_short.is_html = 1; gc_data->desc_short.utfstring = xstrdup(ap[1]); } } waypt_add(wpt_tmp); } xml_free_converted_attrs(attr); xml_free_converted_string(el); }
static waypoint* parse_wpt(char *buff) { int col = -1; char *c, *cx; waypoint *wpt = waypt_new(); struct tm tm; memset(&tm, 0, sizeof(tm)); int has_time = 0; c = strstr(buff, "A "); if (c == buff) col++; c = csv_lineparse(buff, " ", "", col++); while (c != NULL) { c = lrtrim(c); if (*c != '\0') { #if 0 printf(MYNAME "_read_wpt: col(%d)=%s\n", col, c); #endif switch(col) { case 0: cx = c + strlen(c) - 1; /* trim trailing underscores */ while ((cx >= c) && (*cx == '_')) *cx-- = '\0'; if (*c != '\0') wpt->shortname = xstrdup(c); break; case 2: human_to_dec(c, &wpt->latitude, NULL, 1); break; case 3: human_to_dec(c, NULL, &wpt->longitude, 2); break; // Older compegps used a dumb constant. // Report are that 2010-era writes a sensible // value here. /* always "27-MAR-62 00:00:00" */ case 4: if (strcmp(c, "27-MAR-62")) { has_time = 1; compegps_parse_date(c, &tm); } break; case 5: if (has_time) { compegps_parse_time(c, &tm); wpt->creation_time = mkgmtime(&tm); } case 6: wpt->altitude = atof(c); break; case 7: wpt->description = xstrdup(c); break; default: if (col > 7) { wpt->description = xstrappend(wpt->description, " "); wpt->description = xstrappend(wpt->description, c); } } } c = csv_lineparse(NULL, " ", "", col++); } fix_datum(&wpt->latitude, &wpt->longitude); return wpt; }
static void geoniche_read_asc(void) { pdbrec_t *pdb_rec; /* Process record 0 */ pdb_rec = file_in->rec_list; if (strcmp((char *) pdb_rec->data, Rec0Magic)) fatal(MYNAME ": Bad record 0, not a GeoNiche file.\n"); pdb_rec = pdb_rec->next; /* Process the rest of the records */ for (; pdb_rec; pdb_rec = pdb_rec->next) { waypoint *wpt; char *vdata; int vlen; char *p; int id; int route_id; char *title; char *category; double lat, lon, alt; char *datestr, *timestr; int icon; char *notes; char gid[6+1]; struct tm tm; memset(&tm, 0, sizeof(tm)); wpt = waypt_new(); if (!wpt) fatal(MYNAME ": Couldn't allocate waypoint.\n"); vdata = (char *) pdb_rec->data; vlen = pdb_rec->size; /* Field 1: Target */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 1 (target).\n"); if (strcmp(p, "Route") == 0) fatal(MYNAME ": Route record type is not implemented.\n"); if (strcmp(p, "Target")) fatal(MYNAME ": Unknown record type '%s'.\n", p); xfree(p); /* Field 2: Import ID number */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 2 (ID).\n"); id = atoi(p); xfree(p); /* Field 3: Title */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 3 (Title).\n"); title = p; /* Field 4: Route ID number */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 4 (Route ID).\n"); route_id = atoi(p); xfree(p); /* Field 5: Category */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 5 (Category).\n"); category = p; /* Field 6: Latitude */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 6 (Latitude).\n"); lat = atof(p); xfree(p); /* Field 7: Longitude */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 7 (Longitude).\n"); lon = atof(p); xfree(p); /* Field 8: Altitude */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 8 (Altitude).\n"); alt = atof(p); xfree(p); /* Field 9: Creation date */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 9 (Creation date).\n"); datestr = p; /* Field 10: Creation time */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 10 (Creation time).\n"); timestr = p; /* Field 11: Visited date */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 11 (Visited date).\n"); xfree(p); /* Field 12: Visited time */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 12 (Visited time).\n"); xfree(p); /* Field 13: Icon color (R G B) */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 13 (Icon color).\n"); xfree(p); /* Field 14: icon number */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 14 (Icon number).\n"); icon = atoi(p); xfree(p); /* Field 15: unused */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 15 (unused1).\n"); xfree(p); /* Field 16: unused */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 16 (unused2).\n"); xfree(p); /* Field 17: unused */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 17 (unused3).\n"); xfree(p); /* Field 18: Notes */ p = field(&vdata, &vlen); if (!p) fatal(MYNAME ": Premature EOD processing field 18 (Notes).\n"); notes = p; sscanf(datestr, "%d/%d/%d", &tm.tm_mon, &tm.tm_mday, &tm.tm_year); tm.tm_mon -= 1; tm.tm_year -= 1900; sscanf(timestr, "%d:%d:%d", &tm.tm_hour, &tm.tm_min, &tm.tm_sec); if (tm.tm_year >= 1970) { wpt->creation_time = mktime(&tm); } xfree(datestr); xfree(timestr); id2gid(gid, id); wpt->latitude = lat; wpt->longitude = lon; wpt->altitude = alt; wpt->icon_descr = category; wpt->wpt_flags.icon_descr_is_dynamic = 1; if (gid[0]) { wpt->shortname = xstrdup(gid); wpt->description = title; wpt->notes = notes; } else { wpt->shortname = xstrdup(title); wpt->description = title; wpt->notes = notes; } waypt_add(wpt); } }
static void humminbird_read_track(gbfile* fin) { humminbird_trk_header_t th; humminbird_trk_point_t* points; route_head* trk; waypoint* first_wpt; int i; int max_points = 0; gbint32 accum_east; gbint32 accum_north; double g_lat; if (! gbfread(&th, 1, sizeof(th), fin)) fatal(MYNAME ": Unexpected end of file reading header!\n"); th.trk_num = be_read16(&th.trk_num); th.num_points = be_read16(&th.num_points); th.time = be_read32(&th.time); th.start_east = be_read32(&th.start_east); th.start_north = be_read32(&th.start_north); th.end_east = be_read32(&th.end_east); th.end_north = be_read32(&th.end_north); th.sw_east = be_read32(&th.sw_east); th.sw_north = be_read32(&th.sw_north); th.ne_east = be_read32(&th.ne_east); th.ne_north = be_read32(&th.ne_north); max_points = (131080 - sizeof(gbuint32) - sizeof(th)) / sizeof(humminbird_trk_point_t); if (th.num_points > max_points) fatal(MYNAME ": Too many track points! (%d)\n", th.num_points); /* num_points is actually one too big, because it includes the value in the header. But we want the extra point at the end because the freak-value filter below looks at points[i+1] */ points = xcalloc(th.num_points, sizeof(humminbird_trk_point_t)); if (! gbfread(points, sizeof(humminbird_trk_point_t), th.num_points-1, fin)) fatal(MYNAME ": Unexpected end of file reading points!\n"); accum_east = th.start_east; accum_north = th.start_north; trk = route_head_alloc(); track_add_head(trk); trk->rte_name = xstrndup(th.name, sizeof(th.name)); trk->rte_num = th.trk_num; /* We create one wpt for the info in the header */ first_wpt = waypt_new(); g_lat = gudermannian_i1924(accum_north); first_wpt->latitude = geocentric_to_geodetic_hwr(g_lat); first_wpt->longitude = accum_east/EAST_SCALE * 180.0; first_wpt->altitude = 0.0; /* No depth info in the header. */ track_add_wpt(trk, first_wpt); for(i=0 ; i<th.num_points-1 ; i++) { waypoint *wpt = waypt_new(); gbint16 next_deltaeast, next_deltanorth; double guder; points[i].depth = be_read16(&points[i].depth); points[i].deltaeast = be_read16(&points[i].deltaeast); points[i].deltanorth = be_read16(&points[i].deltanorth); /* Every once in a while the delta values are 32767 followed by -32768. Filter that. */ next_deltaeast = be_read16(&points[i+1].deltaeast); if (points[ i ].deltaeast == 32767 && next_deltaeast == -32768) { points[ i ].deltaeast = -1; points[i+1].deltaeast = 0; /* BE 0 == LE 0 */ } next_deltanorth = be_read16(&points[i+1].deltanorth); if (points[ i ].deltanorth == 32767 && next_deltanorth == -32768) { points[ i ].deltanorth = -1; points[i+1].deltanorth = 0; } accum_east += points[i].deltaeast; accum_north += points[i].deltanorth; guder = gudermannian_i1924(accum_north); wpt->latitude = geocentric_to_geodetic_hwr(guder); wpt->longitude = accum_east/EAST_SCALE * 180.0; wpt->altitude = 0.0; if (points[i].depth != 0) WAYPT_SET(wpt,depth,(double)points[i].depth / 100.0); if (i == th.num_points-2 && th.time != 0) { /* Last point. Add the date from the header. */ /* Unless it's zero. Sometimes happens, possibly if the gps didn't have a lock when the track was saved. */ wpt->creation_time = th.time; } track_add_wpt(trk, wpt); } xfree(points); }
static int ppdb_read_wpt(route_head *head, int isRoute) { char *data, *str; double altfeet; struct tm tm; while (pdb_read_rec(file_in, NULL, NULL, NULL, (void *)&data) >= 0) { waypoint *wpt_tmp = waypt_new(); int line = 0; char *tmp = data; /* Print the whole input record. All input records are printed before processing. */ if (global_opts.debug_level >= 5) { DBG(("\n\ --- BEGIN Input data record -----------------------------------------------\n\ %s\n\ --- END Input data record -------------------------------------------------\n",data)); } while ((str = csv_lineparse(tmp, ",", "\"", line++))) { tmp = NULL; switch(line) { case 1: /* latitude */ wpt_tmp->latitude = ppdb_decode_coord(str); break; case 2: /* longitude */ wpt_tmp->longitude = ppdb_decode_coord(str); break; case 3: /* altitude */ if (*str != '\0') { CHECK_INP(1, sscanf(str, "%lf", &altfeet), "altitude", str); if (altfeet != -9999) wpt_tmp->altitude = FEET_TO_METERS(altfeet); } break; case 4: /* time and date (optional) */ memset(&tm, 0, sizeof(tm)); if (ppdb_decode_tm(str, &tm)) { tm.tm_year -= 1900; tm.tm_mon--; wpt_tmp->creation_time = mkgmtime(&tm); } break; case 5: /* name */ if (*str != '\0') wpt_tmp->shortname = xstrdup(str); break; case 6: /* icon */ if (*str != '\0') wpt_tmp->icon_descr = xstrdup(str); wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1; break; case 7: /* notes */ if (*str != '\0') wpt_tmp->notes = xstrdup(str); break; } } /* Print the whole input record, should a warning be triggered. * Use warning() here instead of DBG() to print the data record * right after the warning is issued. */ if (warn_ && (global_opts.debug_level > 1) && (global_opts.debug_level < 5)) { warning("Faulty input data record : %s\n",data); warn_ = 0; } if (head && isRoute ) route_add_wpt(head, wpt_tmp); else if (head) track_add_wpt(head, wpt_tmp); else waypt_add(wpt_tmp); }
static void lowranceusr_parse_trails(void) { char buff[MAXUSRSTRINGSIZE + 1]; short int num_trails, num_trail_points, num_section_points; int i,j, trk_num, itmp; int text_len; waypoint *wpt_tmp; route_head *trk_tmp; /* num trails */ num_trails = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " parse_trails: num trails = %d\n", num_trails); for (i=trk_num=0; i < num_trails; i++) { trk_head = route_head_alloc(); trk_head->rte_num = ++trk_num; track_add_head(trk_head); /* trail name */ text_len = lowranceusr_readstr(&buff[0], MAXUSRSTRINGSIZE, file_in); if (global_opts.debug_level >= 1) printf(MYNAME " parse_trails: name text len = %d\n", text_len); if (text_len) { buff[text_len] = '\0'; trk_head->rte_name = xstrdup(buff); } trk_head->rte_desc = '\0'; if (global_opts.debug_level >= 1) printf(MYNAME " parse_trails: trail name = %s\n", trk_head->rte_name); /* visible */ (void) gbfread(&buff[0], 1, 1, file_in); /* num trail points */ num_trail_points = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " parse_trails: num trail points = %d\n", num_trail_points); /* max trail size */ itmp = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " parse_trails: max trail size = %d\n", itmp); if (num_trail_points) { while (num_trail_points) { /* num section points */ num_section_points = gbfgetint16(file_in); if (global_opts.debug_level >= 1) printf(MYNAME " parse_trails: num section points = %d\n", num_section_points); for (j=0; j < num_section_points; j++, num_trail_points--) { wpt_tmp = waypt_new(); wpt_tmp->latitude = lat_mm_to_deg(gbfgetint32(file_in)); wpt_tmp->longitude = lon_mm_to_deg(gbfgetint32(file_in)); /* continuous */ (void) gbfread(&buff[0], 1, 1, file_in); if (!buff[0] && seg_break && j) { trk_tmp = route_head_alloc(); trk_tmp->rte_num = ++trk_num; trk_tmp->rte_name = xstrdup(trk_head->rte_name); trk_tmp->rte_desc = '\0'; track_add_head(trk_tmp); trk_head = trk_tmp; } track_add_wpt(trk_head, wpt_tmp); if (global_opts.debug_level >= 1) printf(MYNAME " parse_trails: Trail pt lat %f lon %f\n", wpt_tmp->latitude, wpt_tmp->longitude); } } } /* remove the trail since it's empty */ else track_del_head(trk_head); } }
void wpt_s(const char *args, const char **unused) { wpt_tmp = waypt_new(); wpt_tmp_queued = 0; }
static void gtm_read(void) { route_head *first_trk_head = NULL; route_head *trk_head = NULL; route_head *rte_head = NULL; waypoint *wpt; int real_tr_count = 0; char *route_name; unsigned int icon; int i; /* Image information */ for (i = 0; i != im_count; i++) { fread_string_discard(file_in); fread_string_discard(file_in); fread_discard(file_in, 30); } /* Waypoints */ for (i = 0; i != wp_count; i++) { wpt = waypt_new(); wpt->latitude = fread_double(file_in); wpt->longitude = fread_double(file_in); convert_datum(&wpt->latitude, &wpt->longitude); wpt->shortname = fread_fixedstring(file_in, 10); wpt->description = fread_string(file_in); icon = fread_integer(file_in); if (icon < sizeof(icon_descr)/sizeof(char*)) wpt->icon_descr = icon_descr[icon]; fread_discard(file_in, 1); wpt->creation_time = fread_long(file_in); if (wpt->creation_time) wpt->creation_time += EPOCH89DIFF; fread_discard(file_in, 2); wpt->altitude = fread_single(file_in); if (wpt->altitude == unknown_alt_gtm) wpt->altitude = unknown_alt; fread_discard(file_in, 2); waypt_add(wpt); } /* Waypoint Styles */ if (wp_count) { for (i = 0; i != ws_count; i++) { fread_discard(file_in, 4); fread_string_discard(file_in); fread_discard(file_in, 24); } } /* Tracklogs */ for (i = 0; i != tr_count; i++) { wpt = waypt_new(); wpt->latitude = fread_double(file_in); wpt->longitude = fread_double(file_in); convert_datum(&wpt->latitude, &wpt->longitude); wpt->creation_time = fread_long(file_in); if (wpt->creation_time) wpt->creation_time += EPOCH89DIFF; start_new = fread_byte(file_in); wpt->altitude = fread_single(file_in); if (wpt->altitude == unknown_alt_gtm) wpt->altitude = unknown_alt; if (start_new || !trk_head) { trk_head = route_head_alloc(); track_add_head(trk_head); real_tr_count++; if (!first_trk_head) first_trk_head = trk_head; } track_add_wpt(trk_head, wpt); } /* Tracklog styles */ trk_head = first_trk_head; for (i = 0; i != ts_count && i != real_tr_count; i++) { trk_head->rte_name = fread_string(file_in); fread_discard(file_in, 12); trk_head = (route_head *)QUEUE_NEXT(&trk_head->Q); } /* Routes */ for (i = 0; i != rt_count; i++) { wpt = waypt_new(); wpt->latitude = fread_double(file_in); wpt->longitude = fread_double(file_in); convert_datum(&wpt->latitude, &wpt->longitude); wpt->shortname = fread_fixedstring(file_in, 10); wpt->description = fread_string(file_in); route_name = fread_string(file_in); icon = fread_integer(file_in); if (icon < sizeof(icon_descr)/sizeof(char*)) wpt->icon_descr = icon_descr[icon]; fread_discard(file_in, 1); start_new = fread_byte(file_in); fread_discard(file_in, 6); wpt->altitude = fread_single(file_in); if (wpt->altitude == unknown_alt_gtm) wpt->altitude = unknown_alt; fread_discard(file_in, 2); if (start_new || !rte_head) { rte_head = route_head_alloc(); rte_head->rte_name = route_name; route_add_head(rte_head); } else { xfree(route_name); } route_add_wpt(rte_head, wpt); } }
void gtc_trk_pnt_s(const char *unused, const char **attrv) { wpt_tmp = waypt_new(); }
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); } }
static void humminbird_read_track_old(gbfile* fin) { humminbird_trk_header_old_t th; humminbird_trk_point_old_t* points; route_head* trk; waypoint* first_wpt; int i; int max_points = 0; gbint32 accum_east; gbint32 accum_north; double g_lat; const int file_len = 8048; char namebuf[TRK_NAME_LEN]; if (! gbfread(&th, 1, sizeof(th), fin)) fatal(MYNAME ": Unexpected end of file reading header!\n"); th.trk_num = be_read16(&th.trk_num); th.num_points = be_read16(&th.num_points); th.time = be_read32(&th.time); th.start_east = be_read32(&th.start_east); th.start_north = be_read32(&th.start_north); th.end_east = be_read32(&th.end_east); th.end_north = be_read32(&th.end_north); // These files are always 8048 bytes long. Note that that's the value // of the second 16-bit word in the signature. max_points = (file_len - (sizeof(th) + sizeof (gbuint32) + TRK_NAME_LEN)) / sizeof(humminbird_trk_point_old_t); if (th.num_points > max_points) fatal(MYNAME ": Too many track points! (%d)\n", th.num_points); /* num_points is actually one too big, because it includes the value in the header. But we want the extra point at the end because the freak-value filter below looks at points[i+1] */ points = xcalloc(th.num_points, sizeof(humminbird_trk_point_old_t)); if (! gbfread(points, sizeof(humminbird_trk_point_old_t), th.num_points-1, fin)) fatal(MYNAME ": Unexpected end of file reading points!\n"); accum_east = th.start_east; accum_north = th.start_north; trk = route_head_alloc(); track_add_head(trk); /* The name is not in the header, but at the end of the file. (The last 20 bytes.) */ gbfseek(fin, file_len-TRK_NAME_LEN, SEEK_SET); gbfread(&namebuf, 1, TRK_NAME_LEN, fin); trk->rte_name = xstrndup(namebuf, sizeof(namebuf)); trk->rte_num = th.trk_num; /* We create one wpt for the info in the header */ first_wpt = waypt_new(); g_lat = gudermannian_i1924(accum_north); first_wpt->latitude = geocentric_to_geodetic_hwr(g_lat); first_wpt->longitude = accum_east/EAST_SCALE * 180.0; first_wpt->altitude = 0.0; track_add_wpt(trk, first_wpt); for(i=0 ; i<th.num_points-1 ; i++) { waypoint *wpt = waypt_new(); // gbint16 next_deltaeast, next_deltanorth; double guder; points[i].deltaeast = be_read16(&points[i].deltaeast); points[i].deltanorth = be_read16(&points[i].deltanorth); // I've commented this out, don't know if it happens in this // format. It happens in the newer version though. // /* Every once in a while the delta values are // 32767 followed by -32768. Filter that. */ // // next_deltaeast = be_read16(&points[i+1].deltaeast); // if (points[ i ].deltaeast == 32767 && // next_deltaeast == -32768) { // points[ i ].deltaeast = -1; // points[i+1].deltaeast = 0; /* BE 0 == LE 0 */ // } // next_deltanorth = be_read16(&points[i+1].deltanorth); // if (points[ i ].deltanorth == 32767 && // next_deltanorth == -32768) { // points[ i ].deltanorth = -1; // points[i+1].deltanorth = 0; // } // accum_east += points[i].deltaeast; accum_north += points[i].deltanorth; guder = gudermannian_i1924(accum_north); wpt->latitude = geocentric_to_geodetic_hwr(guder); wpt->longitude = accum_east/EAST_SCALE * 180.0; wpt->altitude = 0.0; if (i == th.num_points-2 && th.time != 0) { /* Last point. Add the date from the header. */ /* Unless it's zero. Sometimes happens, possibly if the gps didn't have a lock when the track was saved. */ wpt->creation_time = th.time; } track_add_wpt(trk, wpt); } xfree(points); }
static void gopal_read(void) { char *buff; char *str, *c; int column; long line; double hmsd,speed; int fix, hms; route_head *route; waypoint *wpt, *lastwpt=NULL; double long_old,lat_old; char tbuffer[64]; long_old=0;lat_old=0; strftime(routename,sizeof(routename),"Tracklog %c",localtime(&tx)); route = route_head_alloc(); route->rte_name=xstrdup(routename); route_add_head(route); line=0; while ((buff = gbfgetstr(fin))) { if ((line == 0) && fin->unicode) cet_convert_init(CET_CHARSET_UTF8, 1); str = buff = lrtrim(buff); if (*buff == '\0') continue; if (gopal_check_line(buff)!=8)continue; wpt = waypt_new(); column = -1; // the format of gopal is quite simple. Unfortunately the developers forgot the date as the first element... //TICK; TIME; LONG; LAT; HEIGHT; SPEED; Fix; HDOP; SAT //3801444, 080558, 2.944362, 43.262117, 295.28, 0.12964, 2, 2.900000, 3 c = csv_lineparse(str, ",", "", column++); while (c != NULL) { switch(column) { case 0: /* "-" */ /* unknown fields for the moment */ //sscanf(c, "%llu", &wpt->microseconds); break; case 1: /* Time UTC */ sscanf(c,"%lf",&hmsd); hms = (int) hmsd; tm.tm_sec = hms % 100; hms = hms / 100; tm.tm_min = hms % 100; hms = hms / 100; tm.tm_hour = hms % 100; tm.tm_year=trackdate.tm_year; tm.tm_mon=trackdate.tm_mon; tm.tm_mday=trackdate.tm_mday; wpt->creation_time = tx+((((time_t)tm.tm_hour * 60) + tm.tm_min) * 60) + tm.tm_sec; if (global_opts.debug_level > 1){ strftime(tbuffer, sizeof(tbuffer), "%c", gmtime(&wpt->creation_time)); printf("parsed timestamp: %s\n",tbuffer); } break; case 2: /* longitude */ sscanf(c, "%lf", &wpt->longitude); break; case 3: /* latitude */ sscanf(c, "%lf", &wpt->latitude); break; case 4: /* altitude */ sscanf(c, "%lf", &wpt->altitude); break; case 5: /* speed */ //sscanf(c, "%lf", &wpt->speed); wpt->speed=atof(c); if (global_opts.debug_level > 1){ printf("parsed speed: %8.5f\n",wpt->speed); } break; case 6: /* type of fix */ sscanf(c, "%d", &fix); //my device shows only 0 or 2 //should i guess from no of sats if 2d or 3d? switch (fix) { case 0: wpt->fix = fix_none;break; case 2: wpt->fix = fix_2d;break; //case 3: wpt->fix = fix_3d;break; //case 4: wpt->fix = fix_dgps;break; /* 2D_diff */ //case 5: wpt->fix = fix_dgps;break; /* 3D_diff */ default: wpt->fix = fix_unknown; break; } break; case 7: /* hdop */ wpt->hdop = atof(c); //sscanf(c, "%lf", &wpt->hdop); does not work ??? //wpt->vdop=0;wpt->hdop=0; break; case 8: /* number of sats */ sscanf(c, "%d", &wpt->sat); break; } c = csv_lineparse(NULL, ",", "", column++); } line++; if ((wpt->fix != fix_none)&&(lat_old==0)){ //first-time init lat_old=wpt->latitude; long_old=wpt->longitude; //route_add_wpt(route, wpt); lastwpt=wpt; } //calculate the speed to reach this waypoint from the last. This way I try to sort out invalid waypoints speed=0; if (lastwpt !=NULL) { speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) / abs(wpt->creation_time - lastwpt->creation_time); //printf("speed line %d %lf \n",line,speed); } /* Error handling: in the tracklog of my device sometimes "jump" waypoints ;-) */ if ((optclean) && (((wpt->longitude==0.0)|| (wpt->latitude==0.0)||(abs(wpt->latitude)>90)||(abs(wpt->longitude)>180))|| ((speed>maxspeed)||(speed<minspeed))) ) { if (global_opts.debug_level > 1) fprintf(stderr,"Problem in or around line %5lu: \"%s\" %lf km/h\n",line,buff,speed); } else { if (global_opts.debug_level > 1) fprintf(stderr,"valid line %5lu: \"%s\" %lf km/h\n",line,buff,speed); lastwpt=wpt; long_old=wpt->longitude; lat_old=wpt->latitude; route_add_wpt(route,wpt); waypt_add(waypt_dupe( wpt)); } } }
static void geoniche_read_bin(void) { pdbrec_t *pdb_rec; /* Process records */ for (pdb_rec = file_in->rec_list; pdb_rec != NULL; pdb_rec = pdb_rec->next) { char *vdata = (char *) pdb_rec->data; struct tm created, visited; int icon_nr, selected; int latdeg, londeg; double lat, lon, altitude; waypoint *waypt; memset(&visited, 0, sizeof(visited)); memset(&created, 0, sizeof(created)); latdeg = be_read16(vdata + 0); lat = be_read32(vdata + 2); londeg = be_read16(vdata + 6); lon = be_read32(vdata + 8); altitude = (float) be_read32(vdata + 12); selected = vdata[16]; created.tm_min = be_read16(vdata + 20); created.tm_hour = be_read16(vdata + 22); created.tm_mday = be_read16(vdata + 24); created.tm_mon = be_read16(vdata + 26); created.tm_year = be_read16(vdata + 28); visited.tm_min = be_read16(vdata + 34); visited.tm_hour = be_read16(vdata + 36); visited.tm_mday = be_read16(vdata + 38); visited.tm_mon = be_read16(vdata + 40); visited.tm_year = be_read16(vdata + 42); #ifdef GEONICHE_DBG printf(MYNAME "-date: %04d/%02d/%02d, %02d:%02d (%04d/%02d/%02d, %02d:%02d)\n", created.tm_year, created.tm_mon, created.tm_mday, created.tm_hour, created.tm_min, visited.tm_year, visited.tm_mon, visited.tm_mday, visited.tm_hour, visited.tm_min); #endif icon_nr = vdata[62]; latdeg = 89 - latdeg; lat = lat * (double) 0.0000006; if (latdeg >= 0) lat = (double) 60.0 - lat; else latdeg++; lon = lon * (double) 0.0000006; while (londeg >= 360) londeg-=360; if (londeg > 180) { lon = (double) 60.0 - lon; londeg = londeg - 359; } created.tm_year-=1900; created.tm_mon--; waypt = waypt_new(); waypt->shortname = xstrdup(vdata + 63); waypt->altitude = altitude; waypt->creation_time = mkgmtime(&created); GPS_Math_DegMin_To_Deg(latdeg, lat, &waypt->latitude); GPS_Math_DegMin_To_Deg(londeg, lon, &waypt->longitude); waypt->icon_descr = geoniche_icon_to_descr(icon_nr); if (waypt->icon_descr != NULL) waypt->wpt_flags.icon_descr_is_dynamic = 1; waypt_add(waypt); } }
static void data_read(void) { char *buff; char *s; char *holder; waypoint *wpt_tmp; int i; int linecount = 0; while ((buff = gbfgetstr(file_in))) { if ((linecount++ == 0) && file_in->unicode) cet_convert_init(CET_CHARSET_UTF8, 1); /* skip the line if it contains "sHyperLink" as it is a header (I hope :) */ if ((strlen(buff)) && (strstr(buff, "sHyperLink") == NULL)) { wpt_tmp = waypt_new(); /* data delimited by tabs, not enclosed in quotes. */ s = buff; s = csv_lineparse(s, "\t", "", linecount); i = 0; while (s) { switch (i) { /* Group sID sDescription fLat fLong fEasting fNorthing fAlt iColour iSymbol sHyperLink */ /* 0 1 2 3 4 5 6 7 8 9 10 */ case 0: /* ignore: group */ break; case 1: wpt_tmp->shortname = csv_stringtrim(s, "", 0); break; case 2: /* Description is not a TopoMapPro format requirement. If we assign "" then .loc/.gpx will generate empty XML tags :( */ holder = csv_stringtrim(s, "", 0); if (strlen(holder)) wpt_tmp->description = holder; else xfree(holder); break; case 3: wpt_tmp->latitude = atof(s); break; case 4: wpt_tmp->longitude = atof(s); break; case 5: /* ignore: NZMapGrid Easting */ break; case 6: /* ignore: NZMapGrid Northing */ break; case 7: wpt_tmp->altitude = atof(s); break; case 8: /* ignore: color */ break; case 9: /* ignore: symbol (non standard) */ break; case 10: /* URL is not a TopoMapPro format requirement. You can store file links etc, we will discard anything that is not http (as URLs in TMPro must start "http:") as other GPS formats probably can't use the TopoMapLinks links. (plus discards length 0 strings (so no empty XML tags)) */ holder = csv_stringtrim(s, "", 0); if (strstr(holder, "http:") != NULL) wpt_tmp->url = holder; else xfree(holder); break; default: /* whoa! nelly */ warning(MYNAME ": Warning: data fields on line %d exceed specification.\n", linecount); break; } i++; s = csv_lineparse(NULL, "\t", "\"", linecount); } if (i != 11) { xfree(wpt_tmp); warning(MYNAME ": WARNING - extracted %d fields from line %d. \nData on line ignored.\n", i, linecount); } else { waypt_add(wpt_tmp); } } else { /* empty line */ } } }
static void nmn4_read_data(void) { char *buff; char *str, *c; int column; int line = 0; char *zip1, *zip2, *city, *street, *number; route_head *route; waypoint *wpt; route = route_head_alloc(); route_add_head(route); while ((buff = gbfgetstr(fin))) { if ((line++ == 0) && fin->unicode) cet_convert_init(CET_CHARSET_UTF8, 1); str = buff = lrtrim(buff); if (*buff == '\0') continue; nmn4_check_line(buff); /* for a quiet compiler */ zip1 = zip2 = city = street = number = NULL; wpt = waypt_new(); column = -1; c = csv_lineparse(str, "|", "", column++); while (c != NULL) { switch(column) { case 0: /* "-" */ /* unknown fields for the moment */ case 1: /* "-" */ case 2: /* "-" */ case 3: /* "-" */ case 9: /* "-" */ case 10: /* "-" */ case 13: /* "-" */ case 14: /* "-" */ case 15: /* "" */ break; case 4: /* ZIP Code */ if (*c != '-') zip1 = xstrdup(c); else zip1 = xstrdup(""); break; case 5: /* City */ if (*c != '-') city = xstrdup(c); else city = xstrdup(""); break; case 6: /* ZIP Code -2- */ if (*c != '-') zip2 = xstrdup(c); else zip2 = xstrdup(""); break; case 7: /* Street */ if (*c != '-') street = xstrdup(c); else street = xstrdup(""); break; case 8: /* Number */ if (*c != '-') number = xstrdup(c); else number = xstrdup(""); /* This is our final index All stuff for generating names or comments is hold locally. We don't have fields for street, city or zip-code. Instead we construct a description from that. */ if (strcmp(zip1, zip2) == 0) *zip2 = '\0'; if (*city != '\0') { /* if any field following city has a value, add a comma to city */ if ((*street != '\0') || (*number != '\0') || (*zip2 != '\0')) city = xstrappend(city, ","); } /* concats all fields to one string and release */ wpt->description = nmn4_concat(zip1, city, street, number, zip2, NULL); break; case 11: /* longitude */ sscanf(c, "%lf", &wpt->longitude); break; case 12: /* latitude */ sscanf(c, "%lf", &wpt->latitude); break; } c = csv_lineparse(NULL, "|", "", column++); } route_add_wpt(route, wpt); } }
static void magpdb_read_data(const char *data, const size_t data_len) { route_head *route; char *cin = (char *)data; char *cend = cin + data_len; route = route_head_alloc(); route_add_head(route); while (cin < cend) { char *lend; int len; lend = strchr(cin, '\x0A'); if (lend == NULL) break; len = (lend - cin); if (len > 0) { double distance; int hour, min; *lend = '\0'; if (case_ignore_strncmp(cin, "Wegname=", 8) == 0) /* This only works with the german release */ { /* test-data created with other releases are welcome */ cin += 8; if (*cin != '\0') route->rte_name = xstrdup(cin); } else if (case_ignore_strncmp(cin, "Fahrzeit=", 9) == 0) { } else if (case_ignore_strncmp(cin, "Kosten=", 7) == 0) { } else if (case_ignore_strncmp(cin, "Entfernung=", 11) == 0) { } /* check, if line starts with time and distance */ else if (3 == sscanf(cin, "%d:%d %lf", &hour, &min, &distance)) { char *buff, *comma; /* detect time-format settings, 12,0 or 12.0 */ comma = strchr(cin, '.'); buff = strchr(cin, ','); if (comma == NULL) comma = buff; else if ((buff != NULL) && (buff < comma)) comma = buff; if (comma != NULL) { char separator = *comma; /* now we are looking for a sequence like 0,1 NE (123456,654321) */ buff = xmalloc(strlen(cin) + 1); /* safe target space for sscanf( ... */ comma = cin; while ((comma = strchr(comma, separator))) { int i, xlat, xlon; waypoint *wpt; char *cx; comma++; if (isdigit(*comma) == 0) continue; if (isdigit(*(comma - 2)) == 0) continue; if (4 != sscanf(comma, "%d %s (%d,%d)", &i, buff, &xlon, &xlat)) continue; if (strchr("NESW", *buff) == NULL) continue; /* north, east, ... */ cx = comma - 2; /* go left over delta distance */ while (isdigit(*cx) != 0) *cx-- = '\0'; cin = lrtrim(cin); for (i = 0; i < 2; i++) /* skip time and distance at start of line */ { cin = strchr(cin, ' '); cin = lrtrim(cin); } wpt = waypt_new(); wpt->latitude = magpdb_to_degree(xlat); wpt->longitude = magpdb_to_degree(xlon); wpt->description = xstrdup(cin); cx = strchr(comma, ')'); /* find tailing notes after the coordinates */ if (cx != NULL) { char *tail = lrtrim(++cx); if (*tail != '\0') { wpt->notes = xstrdup(tail); } } /* generate some waypoints from our route-only format */ if ((*cin != '-') && (case_ignore_strncmp(cin, "bei ", 4) != 0)) waypt_add(waypt_dupe(wpt)); route_add_wpt(route, wpt); break; } xfree(buff); } } } cin = lend + 1; } }
static void psp_read(void) { char buff[MAXPSPSTRINGSIZE + 1]; double radians; double lat, lon; waypoint *wpt_tmp; short int pincount; short int pindex; char gridbyte = 0x00; char *tmp; /* 32 bytes - file header */ psp_fread(&buff[0], 1, 32, psp_file_in); if (valid_psp_header(buff) != 0) { fatal(MYNAME ": input file does not appear to be a valid .PSP file.\n"); } pincount = le_read16(&buff[12]); while (pincount--) { wpt_tmp = waypt_new(); wpt_tmp->altitude = unknown_alt; /* offset 0x20 - 0x21 pin index */ psp_fread(&pindex, 1, 2, psp_file_in); /* offset 0x22 - 0x23 */ psp_fread(&buff[0], 1, 2, psp_file_in); /* offset 0x24 */ /* 1 byte, the grid byte - needed for sign corrections later*/ psp_fread(&gridbyte, 1, 1, psp_file_in); /* 8 bytes - latitude in radians */ radians = psp_fread_double(psp_file_in); lat = DEG(radians); /* 8 bytes - longitude in radians */ radians = psp_fread_double(psp_file_in); lon = DEG(radians); /* since we don't know the origin of this PSP file, we use */ /* the grid byte adjust longitude, if necessary, mimicing */ /* the behavior of pocketstreets correcting the data. This */ /* does not correct the fact that points in eastern US are */ /* written with the wrong coordinates by S&T. (MS bug) */ decode_psp_coordinates(&lat, &lon, gridbyte); wpt_tmp->latitude = lat; wpt_tmp->longitude = lon; /* 1 byte - pin display properties */ psp_fread(&buff[0], 1, 1, psp_file_in); /* 3 bytes - unknown */ psp_fread(&buff[0], 1, 3, psp_file_in); /* 1 bytes - icon (values: 0x00 - 0x27) */ psp_fread(&buff[0], 1, 1, psp_file_in); /* 3 bytes - unknown */ psp_fread(&buff[0], 1, 3, psp_file_in); wpt_tmp->shortname = psp_read_str(psp_file_in); wpt_tmp->description = psp_read_str(psp_file_in); tmp = psp_read_str(psp_file_in); /* (address?) */ if (tmp) xfree(tmp); waypt_add(wpt_tmp); } }
/* * Main Function to process Saved tracks file */ static void format_garmin_xt_proc_strk(void) { int Count = 0; // Used to obtain number of read bytes int NumberOfTracks = 0, TracksCompleted = 0; // Number of tracks in the file and number of processed tracks gbuint16 trackbytes = 0; // Bytes in track gbuint8 TrackBlock[STRK_BLOCK_SIZE]; // File Block gbuint8 ii; // temp variable double Lat = 0, Lon = 0; // wpt data double PrevLat = 0, PrevLon = 0, PrevEle = 0; // wpt data gbuint32 Time = 0, PrevTime =0; // wpt data int FirstCoo; gbuint8 trk_color = 0xff; // Skip 12 bytes from the BOF gbfseek(fin, 12, SEEK_SET); // read # of tracks NumberOfTracks = gbfgetuint16(fin); // Skip 2 bytes gbfseek(fin, 2, SEEK_CUR); // Process all tracks one by one while ((TracksCompleted < NumberOfTracks) && (!gbfeof( fin ) ) ) { route_head *tmp_track; waypoint *wpt; char *trk_name; trk_name = xmalloc(30); // Generate Track Header trackbytes = format_garmin_xt_rd_st_attrs(trk_name, &trk_color) - 50; tmp_track = route_head_alloc(); // update track color tmp_track->line_color.bbggrr = colors[trk_color]; tmp_track->line_color.opacity = 255; // update track name tmp_track->rte_name = trk_name; track_add_head(tmp_track); // This is the 1st coordinate of the track FirstCoo = TRUE; while (trackbytes>0) { if (trackbytes>=STRK_BLOCK_SIZE) { Count = gbfread(&TrackBlock, DATABLOCKSIZE, STRK_BLOCK_SIZE, fin); trackbytes -= STRK_BLOCK_SIZE; } else { Count = gbfread(&TrackBlock, DATABLOCKSIZE, trackbytes, fin); trackbytes = 0; } // decrypt loaded track block (Count - size of loaded TrackBlock) format_garmin_xt_decrypt_trk_blk(Count, TrackBlock); // process each track point in the loaded TrackBlock for (ii=1; ii <= ((Count-1) / 12); ii++) { // decompose loaded track block part (track point) format_garmin_xt_decomp_trk_blk(ii, TrackBlock, &PrevEle, &Lat, &Lon, &Time); // Add point to the track if not the first point if (!FirstCoo) { //create new waypoint wpt = waypt_new(); //populate wpt; wpt->latitude = PrevLat; /* Degrees */ wpt->longitude = PrevLon; /* Degrees */ wpt->altitude = PrevEle; /* Meters. */ wpt->creation_time = Time; /* Unix Time adjusted to Garmin time */ // add way point to the track track_add_wpt(tmp_track, wpt); } else { FirstCoo = FALSE; } PrevLat = Lat; PrevLon = Lon; PrevTime = Time; } } // decompose elevation for the last point if (Count > 12) { Count--; } format_garmin_xt_decomp_last_ele(Count, &PrevEle, TrackBlock); //create new waypoint wpt = waypt_new(); //populate wpt; wpt->latitude = PrevLat; /* Degrees */ wpt->longitude = PrevLon; /* Degrees */ wpt->altitude = PrevEle; /* Meters. */ wpt->creation_time = Time; /* Unix Time adjusted to Garmin time */ // add way point to the track track_add_wpt(tmp_track, wpt); // update completed tracks counter TracksCompleted++; } }