From 3505918e548bad4ccfb1e66dd89c7733c613f44d Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Mon, 22 Feb 2016 21:37:40 +0100 Subject: [PATCH] solidify GPX output --- storage.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/storage.c b/storage.c index a32b048..f7076bc 100644 --- a/storage.c +++ b/storage.c @@ -1018,28 +1018,19 @@ char *gpx_string(JsonNode *location_array) // json_foreach(one, location_array) { - double lat = 0.0, lon = 0.0; - char *isotst = ""; - JsonNode *j; + JsonNode *jlat, *jlon, *jisotst, *j; - if ((j = json_find_member(one, "lat")) != NULL) { - lat = j->number_; - } + if ((jlat = json_find_member(one, "lat")) && + (jlon = json_find_member(one, "lon")) && + (jisotst = json_find_member(one, "isotst"))) { - if ((j = json_find_member(one, "lon")) != NULL) { - lon = j->number_; - } - - if ((j = json_find_member(one, "isotst")) != NULL) { - isotst = j->string_; - } - - utstring_printf(xml, " \n", lat, lon); - utstring_printf(xml, "\t\n", isotst); - if ((j = json_find_member(one, "alt")) != NULL) { - utstring_printf(xml, "\t%.2f\n", j->number_); + utstring_printf(xml, " \n", jlat->number_, jlon->number_); + utstring_printf(xml, "\t\n", jisotst->string_); + if ((j = json_find_member(one, "alt")) != NULL) { + utstring_printf(xml, "\t%.2f\n", j->number_); + } + utstring_printf(xml, "\t\n"); } - utstring_printf(xml, "\t\n"); } utstring_printf(xml, "%s", " \n\n\n");