diff --git a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java index 89a6c4ead0..2d935bb105 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java @@ -516,7 +516,7 @@ public class RouteResultPreparation { kl = true; int lns = attached.getObject().getLanes(); if(attached.getObject().getOneway() == 0) { - lns = (lns + 1) / 2; + lns = countLines(attached, lns); } if (lns > 0) { right += lns; @@ -526,7 +526,7 @@ public class RouteResultPreparation { kr = true; int lns = attached.getObject().getLanes(); if(attached.getObject().getOneway() == 0) { - lns = (lns + 1) / 2; + lns = countLines(attached, lns); } if (lns > 0) { left += lns; @@ -542,8 +542,9 @@ public class RouteResultPreparation { right = 1; } int current = currentSegm.getObject().getLanes(); - if(currentSegm.getObject().getOneway() == 0) { - current = (current + 1) / 2; + // attachedRoutes covers all allowed outbound routes at that point except currentSegm. + if (currentSegm.getObject().getOneway() == 0) { + current = countLines(currentSegm, current); } if (current <= 0) { current = 1; @@ -579,6 +580,19 @@ public class RouteResultPreparation { } return t; } + + protected int countLines(RouteSegmentResult attached, int lns) { + try { + if (attached.isForwardDirection() && attached.getObject().getValue("lanes:forward") != null) { + return Integer.parseInt(attached.getObject().getValue("lanes:forward")); + } else if (!attached.isForwardDirection() && attached.getObject().getValue("lanes:backward") != null) { + return Integer.parseInt(attached.getObject().getValue("lanes:backward")); + } + } catch (NumberFormatException e) { + e.printStackTrace(); + } + return (lns + 1) / 2; + } private boolean isMotorway(RouteSegmentResult s){ String h = s.getObject().getHighway();