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 c6a5f1d393..7a9cfb1ab4 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -1117,8 +1117,8 @@ public class RouteResultPreparation { if (UNMATCHED_HIGHWAY_TYPE.equals(rr.getObject().getHighway())) { bearingDist = RouteSegmentResult.DIST_BEARING_DETECT_UNMATCHED; } - double mpi = MapUtils.degreesDiff(prev.getBearingEnd(prev.getEndPointIndex(), bearingDist), - rr.getBearingBegin(rr.getStartPointIndex(), bearingDist)); + double mpi = MapUtils.degreesDiff(prev.getBearingEnd(prev.getEndPointIndex(), Math.min(prev.getDistance(), bearingDist)), + rr.getBearingBegin(rr.getStartPointIndex(), Math.min(rr.getDistance(), bearingDist))); if (mpi >= TURN_DEGREE_MIN) { if (mpi < TURN_DEGREE_MIN) { // Slight turn detection here causes many false positives where drivers would expect a "normal" TL. Best use limit-angle=TURN_DEGREE_MIN, this reduces TSL to the turn-lanes cases. diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteSegmentResult.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteSegmentResult.java index c57fdc8f1c..1699b3daf9 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteSegmentResult.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteSegmentResult.java @@ -457,7 +457,7 @@ public class RouteSegmentResult implements StringExternalizable } public float getBearingBegin() { - return getBearingBegin(startPointIndex, DIST_BEARING_DETECT); + return getBearingBegin(startPointIndex, distance > 0 && distance < DIST_BEARING_DETECT ? distance : DIST_BEARING_DETECT); } public float getBearingBegin(int point, float dist) { @@ -465,7 +465,7 @@ public class RouteSegmentResult implements StringExternalizable } public float getBearingEnd() { - return getBearingEnd(endPointIndex, DIST_BEARING_DETECT); + return getBearingEnd(endPointIndex, distance > 0 && distance < DIST_BEARING_DETECT ? distance : DIST_BEARING_DETECT); } public float getBearingEnd(int point, float dist) {