Skip to content

Commit 4cc45e7

Browse files
authored
Merge pull request abrensch#852 from Totorrr/detect_usable_cycleways_v2
trekking: add whether there is a usable cycleway in the isbike bike hint (v2)
2 parents 106cd3f + 7fcd9f2 commit 4cc45e7

File tree

4 files changed

+37
-78
lines changed

4 files changed

+37
-78
lines changed

brouter-core/src/test/java/btools/router/RoutingEngineTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,28 @@ public void routeDestinationPointFarOff() {
3939
Assert.assertTrue(msg, msg != null && msg.contains("not found"));
4040
}
4141

42+
// check that a (short) route and an alternative route can be computed
43+
// while explicitely overriding a routing profile parameter
4244
@Test
4345
public void overrideParam() {
46+
// 1st route computing (with param)
4447
RoutingContext rctx = new RoutingContext();
4548
rctx.keyValues = new HashMap<>();
4649
rctx.keyValues.put("avoid_unsafe", "1.0");
4750
String msg = calcRoute(8.723037, 50.000491, 8.712737, 50.002899, "paramTrack", rctx);
48-
Assert.assertNull("routing failed: " + msg, msg);
51+
Assert.assertNull("routing failed (paramTrack 1st route): " + msg, msg);
52+
// 2nd route computing (same from/to & same param)
53+
rctx = new RoutingContext();
54+
rctx.keyValues = new HashMap<>();
55+
rctx.keyValues.put("avoid_unsafe", "1.0");
56+
msg = calcRoute(8.723037, 50.000491, 8.712737, 50.002899, "paramTrack", rctx);
57+
Assert.assertNull("routing failed (paramTrack 2nd route): " + msg, msg);
4958

50-
File trackFile = new File(workingDir, "paramTrack1.gpx");
59+
File trackFile = new File(workingDir, "paramTrack0.gpx");
60+
trackFile.deleteOnExit();
61+
trackFile = new File(workingDir, "paramTrack1.gpx");
5162
trackFile.deleteOnExit();
63+
// checks if a gpx file has been created for the alternative route
5264
Assert.assertTrue("result content mismatch", trackFile.exists());
5365
}
5466

brouter-core/src/test/resources/paramTrack0.gpx

Lines changed: 0 additions & 67 deletions
This file was deleted.

brouter-server/src/test/java/btools/server/RouteServerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void overrideParameter() throws IOException, URISyntaxException {
9393

9494
InputStream inputStream = httpConnection.getInputStream();
9595
JSONObject geoJson = new JSONObject(new String(inputStream.readAllBytes(), StandardCharsets.UTF_8));
96-
Assert.assertEquals("1570", geoJson.query("/features/0/properties/track-length"));
96+
Assert.assertEquals("1455", geoJson.query("/features/0/properties/track-length"));
9797
}
9898

9999
@Test

misc/profiles2/trekking.brf

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,28 @@ assign is_ldcr =
7676
if ignore_cycleroutes then false
7777
else any_cycleroute
7878

79-
assign isbike = or bicycle_road=yes or bicycle=yes or or bicycle=permissive bicycle=designated lcn=yes
79+
assign badoneway =
80+
if reversedirection=yes then
81+
if oneway:bicycle=yes then true
82+
else if oneway= then junction=roundabout
83+
else oneway=yes|true|1
84+
else oneway=-1
85+
86+
# set isbike considering access, local cycle route or the presence of a usable cycleway on the highway
87+
assign isbike =
88+
or or bicycle_road=yes or bicycle=yes|permissive|designated lcn=yes # also add cyclestreet=yes when lookup has it
89+
or cycleway=lane|track|shared_lane|share_busway
90+
or and badoneway cycleway=opposite|opposite_lane|opposite_track
91+
or
92+
and cycleway:left=lane|track|shared_lane|share_busway
93+
switch badoneway
94+
cycleway:left:oneway=no|-1
95+
true
96+
and cycleway:right=lane|track|shared_lane|share_busway
97+
switch badoneway
98+
cycleway:right:oneway=no|-1
99+
true
100+
80101
assign ispaved = or surface=paved|asphalt|concrete|paving_stones|sett smoothness=excellent|good
81102
assign isunpaved = not or surface= or ispaved or surface=fine_gravel|cobblestone smoothness=intermediate|bad
82103
assign probablyGood = or ispaved and ( or isbike highway=footway ) not isunpaved
@@ -155,13 +176,6 @@ assign accesspenalty =
155176
# 4 to the costfactor (making it at least 5 - you are allowed
156177
# to push your bike)
157178
#
158-
assign badoneway =
159-
if reversedirection=yes then
160-
if oneway:bicycle=yes then true
161-
else if oneway= then junction=roundabout
162-
else oneway=yes|true|1
163-
else oneway=-1
164-
165179
assign onewaypenalty =
166180
if ( badoneway ) then
167181
(

0 commit comments

Comments
 (0)