From d7087d97f3542b8e3dbf46c442a3d20c65b5cb0d Mon Sep 17 00:00:00 2001 From: mvglasow Date: Wed, 15 Aug 2018 23:17:21 +0200 Subject: Add:traffic:Include items in traffic GPX export Signed-off-by: mvglasow --- navit/binding/dbus/binding_dbus.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'navit/binding') diff --git a/navit/binding/dbus/binding_dbus.c b/navit/binding/dbus/binding_dbus.c index 8f7a2ca21..ad9dddd5f 100644 --- a/navit/binding/dbus/binding_dbus.c +++ b/navit/binding/dbus/binding_dbus.c @@ -1221,6 +1221,10 @@ static DBusHandlerResult request_navit_traffic_export_gpx(DBusConnection *connec char * wpt_types[] = {"from", "at", "via", "not_via", "to"}; struct traffic_point * wpts[5]; int i; + struct item ** items; + struct item ** curr_itm; + struct coord c, c_last; + struct coord_geo g; char *header = "\n" " segments (or coherent sequences thereof) */ + for (curr_msg = messages; *curr_msg; curr_msg++) { + items = traffic_message_get_items(*curr_msg); + for (curr_itm = items; *curr_itm; curr_itm++) { + /* + * Don’t blindly copy this code unless you know what you are doing. + * It is based on various assumptions which hold true for traffic map items, but not necessarily for items + * obtained from other maps. + */ + /* TODO output direction as type */ + item_coord_rewind(*curr_itm); + item_coord_get(*curr_itm, &c, 1); + if ((curr_itm == items) || (c.x != c_last.x) || (c.y != c_last.y)) { + /* + * Start a new route for the first item, or if the last point of the previous item does not coincide + * with the first point of the current one. This includes closing the previous route (if any) and + * adding the first point. + */ + if (curr_itm != items) + fprintf(fp, "\n"); + fprintf(fp, "%s\n", (*curr_msg)->id); + transform_to_geo(projection_mg, &c, &g); + fprintf(fp,"\n", g.lng, g.lat); + } + while (item_coord_get(*curr_itm, &c, 1)) { + transform_to_geo(projection_mg, &c, &g); + fprintf(fp,"\n", g.lng, g.lat); + } + c_last.x = c.x; + c_last.y = c.y; + } + if (curr_itm != items) + fprintf(fp, "\n"); + g_free(items); + } fprintf(fp,"%s",trailer); -- cgit v1.2.1