gpx2yaml

GPX to YAML converter
Log | Files | Refs | README | LICENSE

commit d4a102ab079edf239a095bdd3564be3cac193971
parent 69bdf1e0a07ed37961a6c75e6145dc8f98d68322
Author: Nikolay Korotkiy <sikmir@gmail.com>
Date:   Thu, 19 Aug 2021 22:30:57 +0300

add distance property

Diffstat:
Mgpx2yaml.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gpx2yaml.c b/gpx2yaml.c @@ -10,7 +10,7 @@ struct pos { }; static XMLParser parser; /* XML parser state */ -static char curelement[16]; +static char curelement[32]; static char curgpxelement[16]; static struct pos pos; static int linkindex; @@ -47,7 +47,8 @@ xml_handler_start_element(XMLParser *p, const char *tag, size_t taglen) trksegindex = 1; printf("- type: Feature\n"); printf(" properties:\n"); - } else if (istag(tag, "name") || istag(tag, "desc") || istag(tag, "type") || istag(tag, "text")) { + } else if (istag(tag, "name") || istag(tag, "desc") || istag(tag, "type") || + istag(tag, "text") || istag(tag, "gpxtrkx:Distance")) { strlcpy(curelement, tag, sizeof(curelement)); } else if (istag(tag, "trkseg")) { if (trksegindex == 1) { @@ -73,7 +74,8 @@ xml_handler_end_element(XMLParser *p, const char *tag, size_t taglen, int isshor printf(" - %s\n", pos.lat); } else if (istag(tag, "trk")) { curgpxelement[0] = '\0'; - } else if (istag(tag, "name") || istag(tag, "desc") || istag(tag, "type") || istag(tag, "text")) { + } else if (istag(tag, "name") || istag(tag, "desc") || istag(tag, "type") || + istag(tag, "text") || istag(tag, "gpxtrkx:Distance")) { curelement[0] = '\0'; } else if (istag(tag, "link")) { linkindex++; @@ -117,6 +119,8 @@ xml_handler_data(XMLParser *p, const char *data, size_t datalen) printf(" type: \"%s\"\n", data); } else if (strcmp(curelement, "text") == 0) { printf(" link%d_text: \"%s\"\n", linkindex, data); + } else if (strcmp(curelement, "gpxtrkx:Distance") == 0) { + printf(" distance: %s\n", data); } }