Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions brouter-core/src/test/java/btools/router/RoutingEngineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
67 changes: 0 additions & 67 deletions brouter-core/src/test/resources/paramTrack0.gpx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 22 additions & 8 deletions misc/profiles2/trekking.brf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
(
Expand Down