INSIDE_PATH_POINT_ELE,
INSIDE_PATH_POINT_TIME,
INSIDE_PATH_POINT_DESC,
+ INSIDE_PATH_POINT_NAME,
FINISH,
UNKNOWN,
ERROR,
data->prev_state = data->state; \
data->state = UNKNOWN; \
data->unknown_depth = 1; \
-}
+ g_debug("GPX: unknown tag"); }
static void
gpx_start_element(SaxData * data, const xmlChar * name, const xmlChar ** attrs)
{
-
+ g_debug("GPX-START: %s", name);
switch (data->state) {
case ERROR:
break;
data->state = INSIDE_PATH_POINT_ELE;
else if (!strcmp((gchar *) name, "desc"))
data->state = INSIDE_PATH_POINT_DESC;
-
+ else if (!strcmp((gchar *) name, "name"))
+ data->state = INSIDE_PATH_POINT_NAME;
else
MACRO_SET_UNKNOWN();
break;
static void
gpx_end_element(SaxData * data, const xmlChar * name)
{
+ g_debug("GPX-END: %s", name);
switch (data->state) {
case ERROR:
- break;
+
+ break;
case START:
data->state = ERROR;
- break;
+ break;
case INSIDE_GPX:
if (!strcmp((gchar *) name, "gpx"))
data->state = FINISH;
else
data->state = ERROR;
- break;
+ break;
case INSIDE_PATH:
if (!strcmp((gchar *) name, "trk"))
data->state = INSIDE_GPX;
else
data->state = ERROR;
- break;
+ break;
case INSIDE_PATH_SEGMENT:
if (!strcmp((gchar *) name, "trkseg")) {
if (data->at_least_one_trkpt) {
data->state = INSIDE_PATH;
} else
data->state = ERROR;
- break;
+ break;
case INSIDE_PATH_POINT:
if (!strcmp((gchar *) name, "trkpt")) {
data->state = INSIDE_PATH_SEGMENT;
data->at_least_one_trkpt = TRUE;
} else
data->state = ERROR;
- break;
+ break;
case INSIDE_PATH_POINT_ELE:
if (!strcmp((gchar *) name, "ele")) {
gchar *error_check;
data->chars = g_string_new("");
} else
data->state = ERROR;
- break;
+ break;
case INSIDE_PATH_POINT_TIME:
if (!strcmp((gchar *) name, "time")) {
struct tm time;
gchar *ptr;
- if (NULL == (ptr = strptime(data->chars->str,
- XML_DATE_FORMAT, &time)))
+ if (NULL == (ptr = strptime(data->chars->str, XML_DATE_FORMAT, &time)))
/* Failed to parse dateTime format. */
data->state = ERROR;
else {
data->path.tail->time = (mktime(&time));
/* Now, skip inconsequential characters */
- while (*ptr && *ptr != 'Z' && *ptr != '-'
- && *ptr != '+')
+ while (*ptr && *ptr != 'Z' && *ptr != '-' && *ptr != '+')
ptr++;
/* Check if we ran to the end of the string. */
if (*ptr) {
/* Next character is either 'Z', '-', or '+' */
if (*ptr == 'Z')
- /* Zulu (UTC) time. Undo the local time zone's
- * offset. */
+ /* Zulu (UTC) time. Undo the local time zone's offset. */
data->path.tail->time += time.tm_gmtoff;
else {
/* Not Zulu (UTC). Must parse hours and minutes. */
- gint offhours =
- strtol(ptr, &error_check,
- 10);
- if (error_check != ptr
- && *(ptr =
- error_check) == ':') {
+ gint offhours = strtol(ptr, &error_check, 10);
+ if (error_check != ptr && *(ptr = error_check) == ':') {
/* Parse of hours worked. Check minutes. */
- gint offmins =
- strtol(ptr + 1,
- &error_check,
- 10);
- if (error_check !=
- (ptr + 1)) {
+ gint offmins = strtol(ptr + 1, &error_check, 10);
+ if (error_check != (ptr + 1)) {
/* Parse of minutes worked. Calculate. */
- data->path.tail->time +=
- (time.tm_gmtoff -
- (offhours * 60 * 60 + offmins * 60));
+ data->path.tail->time += (time.tm_gmtoff - (offhours * 60 * 60 + offmins * 60));
}
}
}
data->chars = g_string_new("");
} else
data->state = ERROR;
- break;
+ break;
case INSIDE_PATH_POINT_DESC:
/* only parse description for routes */
if (!strcmp((gchar *) name, "desc")) {
MACRO_PATH_INCREMENT_WTAIL(data->path);
data->path.wtail->point = data->path.tail;
- data->path.wtail->desc
- = g_string_free(data->chars, FALSE);
+ data->path.wtail->desc = g_string_free(data->chars, FALSE);
data->chars = g_string_new("");
data->state = INSIDE_PATH_POINT;
} else
data->state = ERROR;
- break;
+ break;
+ case INSIDE_PATH_POINT_NAME:
+
+ break;
case UNKNOWN:
if (!--data->unknown_depth)
data->state = data->prev_state;
else
data->state = ERROR;
- break;
+ break;
default:
;
}
case INSIDE_PATH_POINT_ELE:
case INSIDE_PATH_POINT_TIME:
case INSIDE_PATH_POINT_DESC:
+ case INSIDE_PATH_POINT_NAME:
for (i = 0; i < len; i++)
data->chars = g_string_append_c(data->chars, ch[i]);
- vprintf("%s\n", data->chars->str);
+ g_debug("GPXC: %s", data->chars->str);
break;
default:
break;
* plus room for more route data. */
path_resize(dest, num_dest_points + num_src_points);
- memcpy(dest->tail + 1, src_first,
- num_src_points * sizeof(Point));
+ memcpy(dest->tail + 1, src_first, num_src_points * sizeof(Point));
dest->tail += num_src_points;
/* Append waypoints from src to dest->. */
- path_wresize(dest, (dest->wtail - dest->whead)
- + (src->wtail - src->whead) + 2);
+ path_wresize(dest, (dest->wtail - dest->whead) + (src->wtail - src->whead) + 2);
for (curr = src->whead - 1; curr++ != src->wtail;) {
- (++(dest->wtail))->point =
- dest->head + num_dest_points +
- (curr->point - src_first);
+ (++(dest->wtail))->point = dest->head + num_dest_points + (curr->point - src_first);
dest->wtail->desc = curr->desc;
}