Hopefully fixes the recent regression which caused incorrect turn
directions to be issued (most likely to occur when entering roundabouts
that have flares).
Actually, the bug was there before but it was being masked by some other
code that recently got removed so the bug then popped to the surface!
Please test.
Mark
diff --git a/src/uk/me/parabola/imgfmt/app/net/RouteNode.java b/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
index 2b8ca79..5a55740 100644
--- a/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
+++ b/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
@@ -339,6 +339,24 @@ public class RouteNode implements ComparableRouteNode {
return false;
}
+ private static boolean rightTurnRequired(int inHeading, int outHeading, int sideHeading) {
+ // decide whether a side road is to the left of the right
+ // given the headings of the incoming, outgoing and side roads
+ int a = sideHeading - (inHeading + 180);
+ while(a -180)
+ a += 360;
+ while(a 180)
+ a -= 360;
+ if(a 0)
+ return false;
+ a = sideHeading - outHeading;
+ while(a -180)
+ a += 360;
+ while(a 180)
+ a -= 360;
+ return a 0;
+ }
+
private static int ATH_OUTGOING = 1;
private static int ATH_INCOMING = 2;
@@ -520,13 +538,13 @@ public class RouteNode implements ComparableRouteNode {
inToOtherDelta += 360;
int newHeading = otherHeading;
- if(outToOtherDelta 0) {
+ if(rightTurnRequired(inHeading, outHeading, otherHeading)) {
// side road to the right
if((mask ATH_OUTGOING) != 0
- outToOtherDelta minDiffBetweenOutgoingAndOtherArcs)
+ Math.abs(outToOtherDelta) minDiffBetweenOutgoingAndOtherArcs)
newHeading = outHeading + minDiffBetweenOutgoingAndOtherArcs;
if((mask ATH_INCOMING) != 0
- inToOtherDelta minDiffBetweenIncomingAndOtherArcs) {
+ Math.abs(inToOtherDelta) minDiffBetweenIncomingAndOtherArcs) {
int nh = inHeading + minDiffBetweenIncomingAndOtherArcs;
if(nh newHeading)
newHeading = nh;
@@ -535,13 +553,13 @@ public class RouteNode implements ComparableRouteNode {
if(newHeading 180)
newHeading -= 360;
}
- else if(outToOtherDelta 0) {
+ else {
// side road to the left
if((mask ATH_OUTGOING) != 0
- outToOtherDelta -minDiffBetweenOutgoingAndOtherArcs)
+ Math.abs(outToOtherDelta) minDiffBetweenOutgoingAndOtherArcs)
newHeading = outHeading - minDiffBetweenOutgoingAndOtherArcs;
if((mask ATH_INCOMING) != 0
- inToOtherDelta -minDiffBetweenIncomingAndOtherArcs) {
+ Math.abs(inToOtherDelta) minDiffBetweenIncomingAndOtherArcs) {
int nh = inHeading - minDiffBetweenIncomingAndOtherArcs;
if(nh newHeading)
newHeading = nh;
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev