Skip to content

Commit 7a86b79

Browse files
daniel-j-hTheMarex
authored andcommitted
Adds cardinal_directions flag to profiles and disables ref-rewriting by default
1 parent 4155111 commit 7a86b79

File tree

4 files changed

+108
-8
lines changed

4 files changed

+108
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 5.13.0 RC3
22
- Changes from 5.12:
33
- Profile:
4-
- Append cardinal directions from route relations to ref fields to improve instructions
4+
- Append cardinal directions from route relations to ref fields to improve instructions; off by default see `profile.cardinal_directions`
55
- Support of `distance` weight in foot and bicycle profiles
66
- Support of relations processing
77
- Added `way:get_location_tag(key)` method to get location-dependent tags https://github.com/Project-OSRM/osrm-backend/wiki/Using-location-dependent-data-in-profiles

features/car/route_relations.feature

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Feature: Car - route relations
44
Given the profile "car"
55

66
Scenario: Assignment using relation membership roles
7+
Given the profile file "car" initialized with
8+
"""
9+
profile.cardinal_directions = true
10+
"""
11+
712
Given the node map
813
"""
914
a----------------b
@@ -26,7 +31,63 @@ Feature: Car - route relations
2631
| b,a | westbound,westbound | I 80 $west,I 80 $west |
2732
| c,d | eastbound,eastbound | I 80 $east; CO 93 $east,I 80 $east; CO 93 $east |
2833

34+
Scenario: No cardinal directions by default
35+
Given the profile file "car" initialized with
36+
"""
37+
profile.cardinal_directions = false
38+
"""
39+
Given the node map
40+
"""
41+
a----------------b
42+
c----------------d
43+
"""
44+
45+
And the ways
46+
| nodes | name | highway | ref |
47+
| ba | westbound | motorway | I 80 |
48+
| cd | eastbound | motorway | I 80;CO 93 |
49+
50+
And the relations
51+
| type | way:east | way:west | route | ref | network |
52+
| route | cd | ba | road | 80 | US:I |
53+
| route | cd | ba | road | 93 | US:CO |
54+
55+
56+
When I route I should get
57+
| waypoints | route | ref |
58+
| b,a | westbound,westbound | I 80,I 80 |
59+
| c,d | eastbound,eastbound | I 80; CO 93,I 80; CO 93 |
60+
61+
Scenario: No cardinal directions by default
62+
Given the node map
63+
"""
64+
a----------------b
65+
c----------------d
66+
"""
67+
68+
And the ways
69+
| nodes | name | highway | ref |
70+
| ba | westbound | motorway | I 80 |
71+
| cd | eastbound | motorway | I 80;CO 93 |
72+
73+
And the relations
74+
| type | way:east | way:west | route | ref | network |
75+
| route | cd | ba | road | 80 | US:I |
76+
| route | cd | ba | road | 93 | US:CO |
77+
78+
79+
When I route I should get
80+
| waypoints | route | ref |
81+
| b,a | westbound,westbound | I 80,I 80 |
82+
| c,d | eastbound,eastbound | I 80; CO 93,I 80; CO 93 |
83+
84+
2985
Scenario: Assignment using relation direction property (no role on members)
86+
Given the profile file "car" initialized with
87+
"""
88+
profile.cardinal_directions = true
89+
"""
90+
3091
Given the node map
3192
"""
3293
a----------------b
@@ -51,6 +112,11 @@ Feature: Car - route relations
51112

52113

53114
Scenario: Forward assignment on one-way roads using relation direction property
115+
Given the profile file "car" initialized with
116+
"""
117+
profile.cardinal_directions = true
118+
"""
119+
54120
Given the node map
55121
"""
56122
a----------------b
@@ -75,6 +141,11 @@ Feature: Car - route relations
75141

76142

77143
Scenario: Forward/backward assignment on non-divided roads with role direction tag
144+
Given the profile file "car" initialized with
145+
"""
146+
profile.cardinal_directions = true
147+
"""
148+
78149
Given the node map
79150
"""
80151
a----------------b
@@ -99,6 +170,11 @@ Feature: Car - route relations
99170

100171

101172
Scenario: Conflict between role and direction
173+
Given the profile file "car" initialized with
174+
"""
175+
profile.cardinal_directions = true
176+
"""
177+
102178
Given the node map
103179
"""
104180
a----------------b
@@ -118,6 +194,11 @@ Feature: Car - route relations
118194

119195

120196
Scenario: Conflict between role and superrelation direction
197+
Given the profile file "car" initialized with
198+
"""
199+
profile.cardinal_directions = true
200+
"""
201+
121202
Given the node map
122203
"""
123204
a----------------b
@@ -140,6 +221,11 @@ Feature: Car - route relations
140221
| a,b | eastbound,eastbound | I 80,I 80 |
141222

142223
Scenario: Conflict between role and superrelation role
224+
Given the profile file "car" initialized with
225+
"""
226+
profile.cardinal_directions = true
227+
"""
228+
143229
Given the node map
144230
"""
145231
a----------------b
@@ -162,6 +248,11 @@ Feature: Car - route relations
162248
| a,b | eastbound,eastbound | I 80,I 80 |
163249

164250
Scenario: Direction only available via superrelation role
251+
Given the profile file "car" initialized with
252+
"""
253+
profile.cardinal_directions = true
254+
"""
255+
165256
Given the node map
166257
"""
167258
a----------------b
@@ -184,6 +275,11 @@ Feature: Car - route relations
184275
| a,b | eastbound,eastbound | I 80 $east,I 80 $east |
185276

186277
Scenario: Direction only available via superrelation direction
278+
Given the profile file "car" initialized with
279+
"""
280+
profile.cardinal_directions = true
281+
"""
282+
187283
Given the node map
188284
"""
189285
a----------------b
@@ -205,6 +301,7 @@ Feature: Car - route relations
205301
| waypoints | route | ref |
206302
| a,b | eastbound,eastbound | I 80 $east,I 80 $east |
207303

304+
208305
# Scenario: Three levels of indirection
209306
# Given the node map
210307
# """
@@ -229,4 +326,4 @@ Feature: Car - route relations
229326
#
230327
# When I route I should get
231328
# | waypoints | route | ref |
232-
# | a,b | eastbound,eastbound | I 80 $east,I 80 $east |
329+
# | a,b | eastbound,eastbound | I 80 $east,I 80 $east |

profiles/car.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function setup()
3535
turn_penalty = 7.5,
3636
speed_reduction = 0.8,
3737
turn_bias = 1.075,
38+
cardinal_directions = false,
3839

3940
-- a list of suffixes to suppress in name change instructions. The suffixes also include common substrings of each other
4041
suffix_list = {
@@ -403,7 +404,9 @@ function process_way(profile, way, result, relations)
403404

404405
WayHandlers.run(profile, way, result, data, handlers, relations)
405406

406-
Relations.process_way_refs(way, relations, result)
407+
if profile.cardinal_directions then
408+
Relations.process_way_refs(way, relations, result)
409+
end
407410
end
408411

409412
function process_turn(profile, turn)

profiles/lib/relations.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function Relations.match_to_ref(relations, ref)
6565
if direction then
6666
local best_score = -1
6767
local best_ref = nil
68-
68+
6969
function find_best(scores)
7070
if scores then
7171
for k ,v in pairs(scores) do
@@ -79,7 +79,7 @@ function Relations.match_to_ref(relations, ref)
7979

8080
find_best(name_scores)
8181
find_best(ref_scores)
82-
82+
8383
if best_ref then
8484
local result_direction = result_match[best_ref]
8585

@@ -230,7 +230,7 @@ function Relations.process_way_refs(way, relations, result)
230230
local matched_refs = nil;
231231
if result.ref then
232232
local match_res = Relations.match_to_ref(parsed_rel_list, result.ref)
233-
233+
234234
function gen_ref(is_forward)
235235
local ref = ''
236236
for _, m in pairs(match_res) do
@@ -252,10 +252,10 @@ function Relations.process_way_refs(way, relations, result)
252252

253253
return ref
254254
end
255-
255+
256256
result.forward_ref = gen_ref(true)
257257
result.backward_ref = gen_ref(false)
258258
end
259259
end
260260

261-
return Relations
261+
return Relations

0 commit comments

Comments
 (0)