diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index 246144f..eb53a2d 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -981,13 +981,7 @@ public class RoutingEngine extends Thread { logInfo("second check for way points"); resetCache(false); range = -range; - List tmp = new ArrayList<>(); - // only w/o crosspoint check - for (MatchedWaypoint mwp: unmatchedWaypoints) { - if (mwp.crosspoint == null) tmp.add(mwp); - } - - ok = nodesCache.matchWaypointsToNodes(tmp, range, islandNodePairs); + ok = nodesCache.matchWaypointsToNodes(unmatchedWaypoints, range, islandNodePairs); } if (!ok) { for (MatchedWaypoint mwp :unmatchedWaypoints) { diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/WaypointMatcherImpl.java b/brouter-mapaccess/src/main/java/btools/mapaccess/WaypointMatcherImpl.java index 70aac74..2f09110 100644 --- a/brouter-mapaccess/src/main/java/btools/mapaccess/WaypointMatcherImpl.java +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/WaypointMatcherImpl.java @@ -1,12 +1,12 @@ package btools.mapaccess; -import java.util.List; import java.util.Collections; import java.util.Comparator; +import java.util.List; import btools.codec.WaypointMatcher; -import btools.util.CheapRuler; import btools.util.CheapAngleMeter; +import btools.util.CheapRuler; /** * the WaypointMatcher is feeded by the decoder with geoemtries of ways that are @@ -29,8 +29,9 @@ public final class WaypointMatcherImpl implements WaypointMatcher { private int lonLast; private int latLast; boolean useAsStartWay = true; - public boolean useDynamicRange; private int maxWptIdx; + private double maxDistance; + public boolean useDynamicRange = false; private Comparator comparator; @@ -38,9 +39,11 @@ public final class WaypointMatcherImpl implements WaypointMatcher { this.waypoints = waypoints; this.islandPairs = islandPairs; MatchedWaypoint last = null; - this.useDynamicRange = maxDistance < 0; + this.maxDistance = maxDistance; if (maxDistance < 0.) { + this.maxDistance = -1; maxDistance *= -1; + useDynamicRange = true; } for (MatchedWaypoint mwp : waypoints) { @@ -87,7 +90,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher { //for ( MatchedWaypoint mwp : waypoints ) for (int i = 0; i < waypoints.size(); i++) { - if (!useAsStartWay && i==0) continue; + if (!useAsStartWay && i == 0) continue; MatchedWaypoint mwp = waypoints.get(i); if (mwp.direct && @@ -113,7 +116,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher { double r22 = x2 * x2 + y2 * y2; double radius = Math.abs(r12 < r22 ? y1 * dx - x1 * dy : y2 * dx - x2 * dy) / d; - if (radius <= mwp.radius || this.useDynamicRange) { + if (radius <= mwp.radius || (this.maxDistance == -1d && (i == 0 || i == maxWptIdx))) { double s1 = x1 * dx + y1 * dy; double s2 = x2 * dx + y2 * dy; @@ -123,7 +126,8 @@ public final class WaypointMatcherImpl implements WaypointMatcher { } if (s2 > 0.) { radius = Math.sqrt(s1 < s2 ? r12 : r22); - if (radius > mwp.radius) + + if (radius > mwp.radius && this.maxDistance != -1) continue; } // new match for that waypoint