From 2cdb3eb3d347c41a0853d04790d10a52ade9ddbc Mon Sep 17 00:00:00 2001 From: sonora Date: Sun, 29 Oct 2017 17:29:41 +0100 Subject: [PATCH 1/2] fix for STOP distance analysis --- .../src/net/osmand/binary/RouteDataObject.java | 9 ++++----- .../src/net/osmand/plus/helpers/WaypointHelper.java | 11 ++++++----- .../osmand/plus/routing/RouteCalculationResult.java | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java index 01986dea8b..c3a39c2cfd 100644 --- a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java @@ -685,7 +685,7 @@ public class RouteDataObject { return direction; } - public boolean isStopApplicable(boolean direction, int intId) { + public boolean isStopApplicable(boolean direction, int intId, int startPointInd, int endPointInd) { int[] pt = getPointTypes(intId); int sz = pt.length; for (int i = 0; i < sz; i++) { @@ -705,10 +705,9 @@ public class RouteDataObject { //} } // Experimental: Distance analysis for STOP with no recognized directional tagging (but exclude those mapped on intersection node) - double d1 = distance(0, intId); - double d2 = distance(intId, getPointsLength() - 1); - if (((direction == true) && (d1 < d2) && (d1 != 0)) - || ((direction == false) && (d1 > d2) && (d2 != 0))) { + double d2Start = distance(startPointInd, intId); + double d2End = distance(intId, endPointInd); + if ((d2Start < d2End) && d2Start != 0 && d2End != 0) { return false; } // No directional info detected diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index 1817810c27..d5a88e2950 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -273,11 +273,12 @@ public class WaypointHelper { AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, 0, loc); // For STOP first check if it has directional info - if (info != null && info.getType() != null && info.getType() == AlarmInfoType.STOP) { - if (!ro.isStopApplicable(ro.bearingVsRouteDirection(loc), i)) { - info = null; - } - } + // Looks like has no effect here + //if (info != null && info.getType() != null && info.getType() == AlarmInfoType.STOP) { + // if (!ro.isStopApplicable(ro.bearingVsRouteDirection(loc), i)) { + // info = null; + // } + //} if (info != null) { if (info.getType() != AlarmInfoType.SPEED_CAMERA || showCameras) { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 510fcb8057..8c8f424969 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -191,7 +191,7 @@ public class RouteCalculationResult { loc.setLongitude(MapUtils.get31LongitudeX(x31)); AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, locInd, loc); // For STOP first check if it has directional info - if ((info != null) && !((info.getType() == AlarmInfoType.STOP) && !res.getObject().isStopApplicable(res.isForwardDirection(), intId))) { + if ((info != null) && !((info.getType() == AlarmInfoType.STOP) && !res.getObject().isStopApplicable(res.isForwardDirection(), intId, res.getStartPointIndex(), res.getEndPointIndex()))) { alarms.add(info); } } From 508054cfec1cc4c43d87aa475b9932433c734694 Mon Sep 17 00:00:00 2001 From: sonora Date: Sun, 29 Oct 2017 18:18:17 +0100 Subject: [PATCH 2/2] 50m limit for heuritic STOP masking --- OsmAnd-java/src/net/osmand/binary/RouteDataObject.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java index c3a39c2cfd..6bf172ad4a 100644 --- a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java @@ -704,10 +704,11 @@ public class RouteDataObject { // return true; //} } - // Experimental: Distance analysis for STOP with no recognized directional tagging (but exclude those mapped on intersection node) + // Heuristic fallback: Distance analysis for STOP with no recognized directional tagging: + // Mask STOPs closer to the start than to the end of the routing segment if it is within 50m of start, but do not mask STOPs mapped directly on start/end (likely intersection node) double d2Start = distance(startPointInd, intId); double d2End = distance(intId, endPointInd); - if ((d2Start < d2End) && d2Start != 0 && d2End != 0) { + if ((d2Start < d2End) && d2Start != 0 && d2End != 0 && d2Start < 50) { return false; } // No directional info detected