diff --git a/brouter-core/src/test/java/btools/router/RoutingEngineTest.java b/brouter-core/src/test/java/btools/router/RoutingEngineTest.java index 1f95be496..1fb4364f5 100644 --- a/brouter-core/src/test/java/btools/router/RoutingEngineTest.java +++ b/brouter-core/src/test/java/btools/router/RoutingEngineTest.java @@ -39,16 +39,28 @@ public void routeDestinationPointFarOff() { Assert.assertTrue(msg, msg != null && msg.contains("not found")); } + // check that a (short) route and an alternative route can be computed + // while explicitely overriding a routing profile parameter @Test public void overrideParam() { + // 1st route computing (with param) RoutingContext rctx = new RoutingContext(); rctx.keyValues = new HashMap<>(); rctx.keyValues.put("avoid_unsafe", "1.0"); String msg = calcRoute(8.723037, 50.000491, 8.712737, 50.002899, "paramTrack", rctx); - Assert.assertNull("routing failed: " + msg, msg); + Assert.assertNull("routing failed (paramTrack 1st route): " + msg, msg); + // 2nd route computing (same from/to & same param) + rctx = new RoutingContext(); + rctx.keyValues = new HashMap<>(); + rctx.keyValues.put("avoid_unsafe", "1.0"); + msg = calcRoute(8.723037, 50.000491, 8.712737, 50.002899, "paramTrack", rctx); + Assert.assertNull("routing failed (paramTrack 2nd route): " + msg, msg); - File trackFile = new File(workingDir, "paramTrack1.gpx"); + File trackFile = new File(workingDir, "paramTrack0.gpx"); + trackFile.deleteOnExit(); + trackFile = new File(workingDir, "paramTrack1.gpx"); trackFile.deleteOnExit(); + // checks if a gpx file has been created for the alternative route Assert.assertTrue("result content mismatch", trackFile.exists()); } diff --git a/brouter-core/src/test/resources/paramTrack0.gpx b/brouter-core/src/test/resources/paramTrack0.gpx deleted file mode 100644 index 80d1e3e51..000000000 --- a/brouter-core/src/test/resources/paramTrack0.gpx +++ /dev/null @@ -1,67 +0,0 @@ - - - - - brouter_trekking_0 - - 175.25 - 176.75 - 179.25 - 177.5 - 174.5 - 173.25 - 169.5 - 169.5 - 171.0 - 171.25 - 171.25 - 171.0 - 170.25 - 167.75 - 167.5 - 165.25 - 164.75 - 164.5 - 164.25 - 164.25 - 163.75 - 163.75 - 163.25 - 162.25 - 162.0 - 160.0 - 159.25 - 159.0 - 159.0 - 159.0 - 158.0 - 157.5 - 156.25 - 156.0 - 155.25 - 154.25 - 152.5 - 152.5 - 153.0 - 153.25 - 153.75 - 154.0 - 154.25 - 154.5 - 156.25 - 156.5 - 158.5 - 158.5 - 158.5 - 158.5 - 158.5 - 159.5 - 159.75 - 159.5 - - - diff --git a/brouter-server/src/test/java/btools/server/RouteServerTest.java b/brouter-server/src/test/java/btools/server/RouteServerTest.java index ad6776c57..aea30393b 100644 --- a/brouter-server/src/test/java/btools/server/RouteServerTest.java +++ b/brouter-server/src/test/java/btools/server/RouteServerTest.java @@ -93,7 +93,7 @@ public void overrideParameter() throws IOException, URISyntaxException { InputStream inputStream = httpConnection.getInputStream(); JSONObject geoJson = new JSONObject(new String(inputStream.readAllBytes(), StandardCharsets.UTF_8)); - Assert.assertEquals("1570", geoJson.query("/features/0/properties/track-length")); + Assert.assertEquals("1455", geoJson.query("/features/0/properties/track-length")); } @Test diff --git a/misc/profiles2/trekking.brf b/misc/profiles2/trekking.brf index 378a462b1..ea99e31d3 100644 --- a/misc/profiles2/trekking.brf +++ b/misc/profiles2/trekking.brf @@ -76,7 +76,28 @@ assign is_ldcr = if ignore_cycleroutes then false else any_cycleroute -assign isbike = or bicycle_road=yes or bicycle=yes or or bicycle=permissive bicycle=designated lcn=yes +assign badoneway = + if reversedirection=yes then + if oneway:bicycle=yes then true + else if oneway= then junction=roundabout + else oneway=yes|true|1 + else oneway=-1 + +# set isbike considering access, local cycle route or the presence of a usable cycleway on the highway +assign isbike = + or or bicycle_road=yes or bicycle=yes|permissive|designated lcn=yes # also add cyclestreet=yes when lookup has it + or cycleway=lane|track|shared_lane|share_busway + or and badoneway cycleway=opposite|opposite_lane|opposite_track + or + and cycleway:left=lane|track|shared_lane|share_busway + switch badoneway + cycleway:left:oneway=no|-1 + true + and cycleway:right=lane|track|shared_lane|share_busway + switch badoneway + cycleway:right:oneway=no|-1 + true + assign ispaved = or surface=paved|asphalt|concrete|paving_stones|sett smoothness=excellent|good assign isunpaved = not or surface= or ispaved or surface=fine_gravel|cobblestone smoothness=intermediate|bad assign probablyGood = or ispaved and ( or isbike highway=footway ) not isunpaved @@ -155,13 +176,6 @@ assign accesspenalty = # 4 to the costfactor (making it at least 5 - you are allowed # to push your bike) # -assign badoneway = - if reversedirection=yes then - if oneway:bicycle=yes then true - else if oneway= then junction=roundabout - else oneway=yes|true|1 - else oneway=-1 - assign onewaypenalty = if ( badoneway ) then (