From d4a4da7e43d1b9fd165680968277cb6170bd821c Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 25 Feb 2025 10:04:03 +0100 Subject: [PATCH 1/3] enable dynamic range for all --- .../src/main/java/btools/router/RoutingContext.java | 8 +++++--- .../src/main/java/btools/router/RoutingEngine.java | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/RoutingContext.java b/brouter-core/src/main/java/btools/router/RoutingContext.java index 2559f3a..718dd04 100644 --- a/brouter-core/src/main/java/btools/router/RoutingContext.java +++ b/brouter-core/src/main/java/btools/router/RoutingContext.java @@ -77,7 +77,8 @@ public final class RoutingContext { public boolean correctMisplacedViaPoints; public double correctMisplacedViaPointsDistance; public boolean useDynamicDistance; - + public boolean buildBeelineOnRange; + private void setModel(String className) { if (className == null) { pm = new StdModel(); @@ -120,7 +121,7 @@ public final class RoutingContext { considerTurnRestrictions = 0.f != expctxGlobal.getVariableValue("considerTurnRestrictions", footMode ? 0.f : 1.f); correctMisplacedViaPoints = 0.f != expctxGlobal.getVariableValue("correctMisplacedViaPoints", 1.f); - correctMisplacedViaPointsDistance = expctxGlobal.getVariableValue("correctMisplacedViaPointsDistance", 40.f); + correctMisplacedViaPointsDistance = expctxGlobal.getVariableValue("correctMisplacedViaPointsDistance", 0.f); // 0 == don't use distance // process tags not used in the profile (to have them in the data-tab) processUnusedTags = 0.f != expctxGlobal.getVariableValue("processUnusedTags", 0.f); @@ -169,7 +170,8 @@ public final class RoutingContext { // Constant power of the biker (in W) bikerPower = expctxGlobal.getVariableValue("bikerPower", 100.f); - useDynamicDistance = expctxGlobal.getVariableValue("use_dynamic_range", 0f) == 1f; + useDynamicDistance = expctxGlobal.getVariableValue("use_dynamic_range", 1f) == 1f; + buildBeelineOnRange = expctxGlobal.getVariableValue("add_beeline", 0f) == 1f; boolean test = expctxGlobal.getVariableValue("check_start_way", 1f) == 1f; if (!test) freeNoWays(); diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index 14fa36f..06de940 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -1085,6 +1085,7 @@ public class RoutingEngine extends Thread { private void matchWaypointsToNodes(List unmatchedWaypoints) { resetCache(false); boolean useDynamicDistance = routingContext.useDynamicDistance; + boolean bAddBeeline = routingContext.buildBeelineOnRange; double range = routingContext.waypointCatchingRange; boolean ok = nodesCache.matchWaypointsToNodes(unmatchedWaypoints, range, islandNodePairs); if (!ok && useDynamicDistance) { @@ -1093,7 +1094,8 @@ public class RoutingEngine extends Thread { range = -MAX_DYNAMIC_RANGE; List tmp = new ArrayList<>(); for (MatchedWaypoint mwp : unmatchedWaypoints) { - if (mwp.crosspoint == null || mwp.radius >= routingContext.waypointCatchingRange) tmp.add(mwp); + if (mwp.crosspoint == null || mwp.radius >= routingContext.waypointCatchingRange) + tmp.add(mwp); } ok = nodesCache.matchWaypointsToNodes(tmp, range, islandNodePairs); } @@ -1104,7 +1106,7 @@ public class RoutingEngine extends Thread { } } // add beeline points when not already done - if (useDynamicDistance && !useNodePoints) { + if (useDynamicDistance && !useNodePoints && bAddBeeline) { List waypoints = new ArrayList<>(); for (int i = 0; i < unmatchedWaypoints.size(); i++) { MatchedWaypoint wp = unmatchedWaypoints.get(i); From bdd20558a7befaa6bf8ed7890460a484bfcd79a8 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 25 Feb 2025 10:28:45 +0100 Subject: [PATCH 2/3] enable add_beeline for the profiles --- misc/profiles2/car-vario.brf | 7 ++++--- misc/profiles2/gravel.brf | 2 +- misc/profiles2/hiking-mountain.brf | 2 +- misc/profiles2/moped.brf | 2 +- misc/profiles2/mtb.brf | 2 +- misc/profiles2/river.brf | 2 +- misc/profiles2/trekking.brf | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/misc/profiles2/car-vario.brf b/misc/profiles2/car-vario.brf index 0d59d8a..c992b26 100644 --- a/misc/profiles2/car-vario.brf +++ b/misc/profiles2/car-vario.brf @@ -17,7 +17,8 @@ assign avoid_toll = false # %avoid_toll% | Avoid paid roads | boolean assign avoid_unpaved = false # %avoid_unpaved% | Avoid unpaved roads, if possible | boolean assign avoid_motorways = false # %avoid_motorways% | Avoid motorways | boolean -assign use_dynamic_range = false # %use_dynamic_range% | Enable distant start/end points | boolean +assign add_beeline = false # %add_beeline% | Enable beeline on distant start/end points | boolean +assign use_offroad = false # %use_offroad% | Enable additional roads | boolean # Kinematic model parameters assign vmax = 90 # %vmax% | Target speed (in km/h) | number @@ -61,8 +62,8 @@ assign caraccess 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 and highway=track use_offroad 1 + switch and highway=road use_offroad 1 switch route=ferry 1 switch isresidentialorliving 1 switch highway=service 1 diff --git a/misc/profiles2/gravel.brf b/misc/profiles2/gravel.brf index 5485234..2b4a120 100644 --- a/misc/profiles2/gravel.brf +++ b/misc/profiles2/gravel.brf @@ -8,7 +8,7 @@ assign turnInstructionRoundabouts true # %turnInstructionRoundabouts% | Special assign considerTurnRestrictions true assign turnInstructionMode 1 # %turnInstructionMode% | Mode for the generated turn-by-turn directions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=oruxmaps-style] -assign use_dynamic_range = false # %use_dynamic_range% | Enable distant start/end points | boolean +assign add_beeline false # %add_beeline% | Enable beeline on distant start/end points | boolean #assign processUnusedTags true assign pass1coefficient 4 diff --git a/misc/profiles2/hiking-mountain.brf b/misc/profiles2/hiking-mountain.brf index 35ab16e..3f51635 100644 --- a/misc/profiles2/hiking-mountain.brf +++ b/misc/profiles2/hiking-mountain.brf @@ -44,7 +44,7 @@ assign initialcost_value 0 # not used now assign allow_steps true # %allow_steps% | Set to false to disallow steps | boolean assign allow_ferries true # %allow_ferries% | set to false to disallow ferries | boolean -assign use_dynamic_range false # %use_dynamic_range% | Enable distant start/end points | boolean +assign add_beeline false # %add_beeline% | Enable beeline on distant start/end points | boolean assign cost_of_unknown 2 # 2 as default diff --git a/misc/profiles2/moped.brf b/misc/profiles2/moped.brf index e270fbf..3d9739a 100644 --- a/misc/profiles2/moped.brf +++ b/misc/profiles2/moped.brf @@ -16,7 +16,7 @@ assign uphillcutoff 0 assign validForBikes 1 assign validForCars 1 -assign use_dynamic_range = false # %use_dynamic_range% | Enable distant start/end points | boolean +assign add_beeline = false # %add_beeline% | Enable beeline on distant start/end points | boolean assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-old-style] diff --git a/misc/profiles2/mtb.brf b/misc/profiles2/mtb.brf index 3e52cc5..c267696 100644 --- a/misc/profiles2/mtb.brf +++ b/misc/profiles2/mtb.brf @@ -12,7 +12,7 @@ # bstart /global ---context:global - assign use_dynamic_range = false # %use_dynamic_range% | Enable distant start/end points | boolean + assign add_beeline false # %add_beeline% | Enable beeline on distant start/end points | boolean assign iswet 0 # 0 as default, *) flag for weather conditions assign turnInstructionMode = 1 # 0=none, 1=auto-choose, 2=locus-style, 3=osmand-style diff --git a/misc/profiles2/river.brf b/misc/profiles2/river.brf index 45fa29f..2ccf231 100644 --- a/misc/profiles2/river.brf +++ b/misc/profiles2/river.brf @@ -2,7 +2,7 @@ # the elevation parameters -assign use_dynamic_range = false # %use_dynamic_range% | Enable distant start/end points | boolean +assign add_beeline = false # %add_beeline% | Enable beeline on distant start/end points | boolean assign downhillcost 0 assign downhillcutoff 1.5 diff --git a/misc/profiles2/trekking.brf b/misc/profiles2/trekking.brf index 0ad1f6c..4de3ba3 100644 --- a/misc/profiles2/trekking.brf +++ b/misc/profiles2/trekking.brf @@ -15,7 +15,7 @@ assign ignore_cycleroutes = false # %ignore_cycleroutes% | Set true for assign stick_to_cycleroutes = false # %stick_to_cycleroutes% | Set true to just follow cycleroutes | boolean assign avoid_unsafe = false # %avoid_unsafe% | Set true to avoid standard highways | boolean -assign use_dynamic_range = false # %use_dynamic_range% | Enable distant start/end points | boolean +assign add_beeline = false # %add_beeline% | Enable beeline on distant start/end points | boolean assign consider_noise = false # %consider_noise% | Activate to prefer a low-noise route | boolean assign consider_river = false # %consider_river% | Activate to prefer a route along rivers, lakes, etc. | boolean From 0f1c6f2d36c323957930ec45734360c4c167feb2 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 25 Feb 2025 10:29:53 +0100 Subject: [PATCH 3/3] new description dynamic range --- docs/developers/profile_developers_guide.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/developers/profile_developers_guide.md b/docs/developers/profile_developers_guide.md index 4ef89b6..d85ad05 100644 --- a/docs/developers/profile_developers_guide.md +++ b/docs/developers/profile_developers_guide.md @@ -116,14 +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 + - `use_dynamic_range` default=true - To find the start / end points for a route, BRouter normally uses the - variable `waypointCatchingRange` with a default value of 250 m. In some + To find the start / end points for a route, BRouter normally uses for all + waypoint matches the dynamic range logic instead of 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. + + - `add_beeline` default=false + + This enables on dynamic range search the output for the more distant road connection + as a beeline. This is helpful in areas with less road coverage like in the Arabic world or similar areas.