From a2b5e2864a0740effe56af3a8894c1691fe65e51 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Sat, 14 Dec 2024 10:45:46 +0100 Subject: [PATCH 1/5] disabled multible wpt additions --- brouter-core/src/main/java/btools/router/RoutingEngine.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index dda43c9..cc84802 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -1039,7 +1039,8 @@ public class RoutingEngine extends Thread { throw new IllegalArgumentException(mwp.name + "-position not mapped in existing datafile"); } } - if (useDynamicDistance) { + // add beeline points when not already done + if (useDynamicDistance && !useNodePoints) { List waypoints = new ArrayList<>(); for (int i = 0; i < unmatchedWaypoints.size(); i++) { MatchedWaypoint wp = unmatchedWaypoints.get(i); From 003cc3df26cb6039d0e4a97db13955cccc36d01c Mon Sep 17 00:00:00 2001 From: afischerdev Date: Sat, 14 Dec 2024 10:51:19 +0100 Subject: [PATCH 2/5] enabled track and road for use on dynamic range --- misc/profiles2/car-vario.brf | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/misc/profiles2/car-vario.brf b/misc/profiles2/car-vario.brf index 87aeac5..0d59d8a 100644 --- a/misc/profiles2/car-vario.brf +++ b/misc/profiles2/car-vario.brf @@ -55,15 +55,17 @@ assign caraccess switch motor_vehicle= switch vehicle= switch access= - switch highway=motorway|motorway_link 1 - switch highway=trunk|trunk_link 1 - switch highway=primary|primary_link 1 - switch highway=secondary|secondary_link 1 - switch highway=tertiary|tertiary_link 1 - switch highway=unclassified 1 - switch route=ferry 1 - switch isresidentialorliving 1 - switch highway=service 1 + switch highway=motorway|motorway_link 1 + switch highway=trunk|trunk_link 1 + switch highway=primary|primary_link 1 + switch highway=secondary|secondary_link 1 + switch highway=tertiary|tertiary_link 1 + switch highway=unclassified 1 + switch and highway=track use_dynamic_range 1 + switch and highway=road use_dynamic_range 1 + switch route=ferry 1 + switch isresidentialorliving 1 + switch highway=service 1 0 access=yes|permissive|designated|destination vehicle=yes|designated|destination From 05420acc040ced7f358208bd27310f56089d0318 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Sun, 15 Dec 2024 11:42:20 +0100 Subject: [PATCH 3/5] more protection for multiple wpt additions --- brouter-core/src/main/java/btools/router/RoutingEngine.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index cc84802..6e9c8b9 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -550,7 +550,7 @@ public class RoutingEngine extends Thread { try { return tryFindTrack(refTracks, lastTracks); } catch (RoutingIslandException rie) { - if (routingContext.useDynamicDistance) { + if (routingContext.useDynamicDistance && !useNodePoints) { useNodePoints = true; boolean useNodeOne = true; if (extraWaypoints != null) useNodeOne = false; @@ -590,6 +590,7 @@ public class RoutingEngine extends Thread { nUnmatched++; } } + extraWaypoints = null; } if (lastTracks.length < waypoints.size()-1) { refTracks = new OsmTrack[waypoints.size()-1]; // used ways for alternatives From aa1473861fbc7b8dc8662ebc4943b3654e5c46b3 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Sun, 22 Dec 2024 17:00:53 +0100 Subject: [PATCH 4/5] recalc when wpt starts/ends in island situation --- .../java/btools/router/RoutingEngine.java | 47 +++++++++++++------ .../java/btools/mapaccess/NodesCache.java | 5 +- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index 6e9c8b9..1c9adad 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -550,17 +550,12 @@ public class RoutingEngine extends Thread { try { return tryFindTrack(refTracks, lastTracks); } catch (RoutingIslandException rie) { - if (routingContext.useDynamicDistance && !useNodePoints) { - useNodePoints = true; - boolean useNodeOne = true; - if (extraWaypoints != null) useNodeOne = false; - extraWaypoints = new ArrayList<>(); + if (routingContext.useDynamicDistance) { for (MatchedWaypoint mwp : matchedWaypoints) { if (mwp.name.contains("_add")) { - OsmNodeNamed wp = new OsmNodeNamed(useNodeOne ? mwp.node1 : mwp.node1); - wp.name = mwp.name; - wp.direct = mwp.direct; - extraWaypoints.add(wp); + long n1 = mwp.node1.getIdFromPos(); + long n2 = mwp.node2.getIdFromPos(); + islandNodePairs.addTempPair(n1, n2); } } } @@ -634,6 +629,10 @@ public class RoutingEngine extends Thread { hasDirectRouting = true; } + for (MatchedWaypoint mwp : matchedWaypoints) { + if (hasInfo()) logInfo("new wp=" + mwp.waypoint + " " + mwp.crosspoint + (mwp.direct ? " direct" : "")); + } + routingContext.checkMatchedWaypointAgainstNogos(matchedWaypoints); // detect target islands: restricted search in inverse direction @@ -1030,7 +1029,7 @@ public class RoutingEngine extends Thread { range = -MAX_DYNAMIC_RANGE; List tmp = new ArrayList<>(); for (MatchedWaypoint mwp : unmatchedWaypoints) { - if (mwp.crosspoint == null) tmp.add(mwp); + if (mwp.crosspoint == null || mwp.radius >= routingContext.waypointCatchingRange) tmp.add(mwp); } ok = nodesCache.matchWaypointsToNodes(tmp, range, islandNodePairs); } @@ -1057,6 +1056,9 @@ public class RoutingEngine extends Thread { onn = new OsmNodeNamed(wp.crosspoint); onn.name = wp.name + "_add"; wp.waypoint = onn; + waypoints.add(nmw); + wp.name = wp.name + "_add"; + waypoints.add(wp); } else { OsmNodeNamed onn = new OsmNodeNamed(wp.crosspoint); onn.name = wp.name + "_add"; @@ -1065,13 +1067,30 @@ public class RoutingEngine extends Thread { nmw.node1 = new OsmNode(wp.node1.ilon, wp.node1.ilat); nmw.node2 = new OsmNode(wp.node2.ilon, wp.node2.ilat); nmw.direct = true; + + if (wp.name != null) nmw.name = wp.name; + waypoints.add(nmw); + wp.name = wp.name + "_add"; + waypoints.add(wp); + if (wp.name.startsWith("via")) { + wp.direct = true; + MatchedWaypoint emw = new MatchedWaypoint(); + OsmNodeNamed onn2 = new OsmNodeNamed(wp.crosspoint); + onn2.name = wp.name + "_2"; + emw.name = onn2.name; + emw.waypoint = onn2; + emw.crosspoint = new OsmNode(nmw.crosspoint.ilon, nmw.crosspoint.ilat); + emw.node1 = new OsmNode(nmw.node1.ilon, nmw.node1.ilat); + emw.node2 = new OsmNode(nmw.node2.ilon, nmw.node2.ilat); + emw.direct = false; + waypoints.add(emw); + } wp.crosspoint = new OsmNode(wp.waypoint.ilon, wp.waypoint.ilat); } - if (wp.name != null) nmw.name = wp.name; - waypoints.add(nmw); - wp.name = wp.name + "_add"; + + } else { + waypoints.add(wp); } - waypoints.add(wp); } unmatchedWaypoints.clear(); unmatchedWaypoints.addAll(waypoints); diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/NodesCache.java b/brouter-mapaccess/src/main/java/btools/mapaccess/NodesCache.java index 4230e8b..f4691d6 100644 --- a/brouter-mapaccess/src/main/java/btools/mapaccess/NodesCache.java +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/NodesCache.java @@ -18,8 +18,11 @@ import btools.expressions.BExpressionContextWay; public final class NodesCache { + final static int RETRY_RANGE = 250; + private int MAX_DYNAMIC_CATCHES = 20; // used with RoutingEngiine MAX_DYNAMIC_RANGE = 60000m + private File segmentDir; private File secondarySegmentsDir = null; @@ -292,7 +295,7 @@ public final class NodesCache { int cellsize = 12500; preloadPosition(mwp.waypoint, cellsize, 1, false); // get a second chance - if (mwp.crosspoint == null || mwp.radius > Math.abs(maxDistance)) { + if (mwp.crosspoint == null || mwp.radius > RETRY_RANGE) { cellsize = 1000000 / 32; preloadPosition(mwp.waypoint, cellsize, maxDistance < 0 ? MAX_DYNAMIC_CATCHES : 2, maxDistance < 0); } From e5003f8092abcae93997c8b3c8cf1d9e9907923c Mon Sep 17 00:00:00 2001 From: afischerdev Date: Sun, 12 Jan 2025 18:02:50 +0100 Subject: [PATCH 5/5] added some description for new var --- docs/developers/profile_developers_guide.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/developers/profile_developers_guide.md b/docs/developers/profile_developers_guide.md index cbc6fc3..5ecbde4 100644 --- a/docs/developers/profile_developers_guide.md +++ b/docs/developers/profile_developers_guide.md @@ -116,6 +116,18 @@ Some variable names are pre-defined and accessed by the routing engine: table exported as CSV. Setting it to true/1, Brouter-web Data page will list all tags present in the RD5 file. + - `use_dynamic_range` default=false + + To find the start / end points for a route, BRouter normally uses the + variable `waypointCatchingRange` with a default value of 250 m. In some + situations, adding a few meters here is not enough to find a point. + With this new variable, it goes deeper and could reach a radius of about 50 km. + From this point, the more distant road connection is established as the beeline + and included in the calculation. + This is helpful in areas with less road coverage like in the Arabic world or + similar areas. + + - for the way section these are - `turncost`