From 0fbbd374a7e3919da0fcb8969aa6571b8c27cb98 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Wed, 6 May 2020 14:13:04 +0200 Subject: [PATCH] Fix walking direction heading --- src/dijkstrasearch.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/dijkstrasearch.c b/src/dijkstrasearch.c index 3ec75e0..3afccf5 100644 --- a/src/dijkstrasearch.c +++ b/src/dijkstrasearch.c @@ -248,11 +248,10 @@ int dijkstra_search_route_to_geojson(struct dijkstra_search *search, for (l = route; l != NULL; l = l->next) { node = (struct dijkstra_node*) l->data; if (node_last) { - heading = atanf((node->position.y - node_last->position.y) / (node->position.x - node_last->position.x)) / (M_PI * 2) * 360; - heading = atanf((node->position.y - node_last->position.y) / (node->position.x - node_last->position.x)) / (M_PI * 2) * 360; - if (last_heading - heading > 10) { + heading = atan2f((node->position.y - node_last->position.y), (node->position.x - node_last->position.x)) / (M_PI * 2) * 360; + if (last_heading - heading > 25) { relative_direction_str = "right"; - } else if (last_heading - heading < -10) { + } else if (last_heading - heading < -25) { relative_direction_str = "left"; } else { relative_direction_str = "straight";