Fix walking direction heading for real this time
This commit is contained in:
parent
fff25e0a24
commit
aea4f3e799
@ -237,6 +237,7 @@ int dijkstra_search_route_to_geojson(struct dijkstra_search *search,
|
||||
struct dijkstra_node *node_last = NULL;
|
||||
float heading = -1.0;
|
||||
float last_heading = 0;
|
||||
float heading_diff;
|
||||
char *relative_direction_str = NULL;
|
||||
char *format_str = NULL;
|
||||
int offset = 0;
|
||||
@ -249,9 +250,14 @@ int dijkstra_search_route_to_geojson(struct dijkstra_search *search,
|
||||
node = (struct dijkstra_node*) l->data;
|
||||
if (node_last) {
|
||||
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) {
|
||||
if (heading < 0.0)
|
||||
heading += 360;
|
||||
heading_diff = last_heading - heading;
|
||||
if (fabsf(heading_diff) > 180)
|
||||
heading_diff = heading - last_heading;
|
||||
if (heading_diff > 25) {
|
||||
relative_direction_str = "right";
|
||||
} else if (last_heading - heading < -25) {
|
||||
} else if (heading_diff < -25) {
|
||||
relative_direction_str = "left";
|
||||
} else {
|
||||
relative_direction_str = "straight";
|
||||
|
Loading…
Reference in New Issue
Block a user