patch for left/right confusion

Line
2===================================================================
5@@ -933,6 +933,47 @@
6 }
7
8 /**
9+ * @brief Returns if it possible to turn into a way that is the other direction or more straight than the route turn.
10+ *
11+ *
12+ * @param from The navigation item which should form the start
13+ * @param to The navigation item which should form the end
14+ * @param angle_of_route angle is < 0 if route turns to the left and > 0 for turns to the right
15+ * @return The number of possibilities to turn or -1 on error
16+ */
17+static int
19+{
20+       int count_left = 0, count_right = 0;
22+
23+       if (!nav_itm) {
24+               return -1;
25+       }
26+
27+       w = nav_itm->way.next;
28+       while (w) {
29+          if (!way->flags || ((w->flags & nav->vehicleprofile->flags) == nav->vehicleprofile->flags)) {
30+                       // If a way is generally allowed for the vehicle take it into account. It's important
31+                       // to consider for announcing, even if it is a one-way in the reverse direction, for instance.
32+                       if (angle_delta(nav_itm->prev->angle_end, w->angle2) < angle_of_route) {
33+                               count_left++; // one more possibility to turn left or less right that the route.
34+                       } else {
35+                               count_right++; // one more possibility to turn right or less left that the route.
36+                       }
37+               }
38+               w = w->next;
39+       }
40+
41+       if (angle_of_route >= 0) { // turn of route is right. Possible to turn left or drive straighter than the route?
42+               return (count_left > 0);
43+       } else {
44+               return (count_right > 0);
45+       }
46+}
47+
48+
49+/**
50  * @brief Calculates distance and time to the destination
51  *
52  * This function calculates the distance and the time to the destination of a
53@@ -1538,9 +1579,20 @@
54        }
55
56        if (delta < 0) {
57-               /* TRANSLATORS: left, as in 'Turn left' */
58-               dir=_("left");
59+               // if there is a Y-junction and the right way also turn turns left, don't say 'left', but right.
60+               if (is_opposite_turn_possible(nav, cmd->itm, delta) > 0) {
61+                       // TRANSLATORS: left, as in 'Turn left'
62+                       dir=_("left");
63+               }
64                delta=-delta;
65+       } else {
66+               // This is turn 'right' as default, but also check a possible Y-junction, in which the left way
67+               // keeps also slightly right. In this case if the street is really right or going just left on the map,
68+               // but is the 'most left' possibility.
69+               if (is_opposite_turn_possible(nav, cmd->itm, delta) == 0) {
70+                       // TRANSLATORS: left, as in 'Turn left'
71+                       dir=_("left");
72+               }
73        }
74
75        if (strength_needed) {