From d7828b4bf0504f3581a53f388b52c53c2542c708 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 21 Jan 2021 17:55:43 +0100 Subject: [PATCH] fix bug cause roundabout based on circle is completely incorrect --- .../net/osmand/router/RouteResultPreparation.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index d98aa37825..44c48f69ec 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -1187,11 +1187,14 @@ public class RouteResultPreparation { RouteSegmentResult rr) { int exit = 1; RouteSegmentResult last = rr; + RouteSegmentResult firstRoundabout = rr; + RouteSegmentResult lastRoundabout = rr; for (int j = i; j < result.size(); j++) { RouteSegmentResult rnext = result.get(j); last = rnext; if (rnext.getObject().roundabout()) { + lastRoundabout = rnext; boolean plus = rnext.getStartPointIndex() < rnext.getEndPointIndex(); int k = rnext.getStartPointIndex(); if (j == i) { @@ -1213,7 +1216,13 @@ public class RouteResultPreparation { TurnType t = TurnType.getExitTurn(exit, 0, leftSide); // usually covers more than expected float turnAngleBasedOnOutRoads = (float) MapUtils.degreesDiff(last.getBearingBegin(), prev.getBearingEnd()); - t.setTurnAngle(turnAngleBasedOnOutRoads) ; + float turnAngleBasedOnCircle = (float) -MapUtils.degreesDiff(firstRoundabout.getBearingBegin(), lastRoundabout.getBearingEnd() + 180); + if (Math.abs(turnAngleBasedOnOutRoads) > 120) { + // correctly identify if angle is +- 180, so we approach from left or right side + t.setTurnAngle(turnAngleBasedOnCircle) ; + } else { + t.setTurnAngle(turnAngleBasedOnOutRoads) ; + } return t; }