Skip to content

Commit 3c5b228

Browse files
committed
adjust speeds to universally use 4/5th of the free-flow speed as expected avg speed
- this is a workaround until we get more thourough work done on the cost model - this is related to #955 and #989
1 parent 881a57b commit 3c5b228

File tree

3 files changed

+36
-30
lines changed

3 files changed

+36
-30
lines changed

features/car/maxspeed.feature

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@routing @maxspeed @car
22
Feature: Car - Max speed restrictions
3-
When a max speed is set, osrm will use 2/3 of that as the actual speed.
3+
OSRM will use 4/5 of the projected free-flow speed.
44

55
Background: Use specific speeds
66
Given the profile "car"
@@ -17,8 +17,8 @@ When a max speed is set, osrm will use 2/3 of that as the actual speed.
1717

1818
When I route I should get
1919
| from | to | route | speed |
20-
| a | b | ab | 85 km/h |
21-
| b | c | bc | 40 km/h +- 1 |
20+
| a | b | ab | 67 km/h |
21+
| b | c | bc | 48 km/h +- 1 |
2222

2323
Scenario: Car - Do not ignore maxspeed when higher than way speed
2424
Given the node map
@@ -31,21 +31,21 @@ When a max speed is set, osrm will use 2/3 of that as the actual speed.
3131

3232
When I route I should get
3333
| from | to | route | speed |
34-
| a | b | ab | 25 km/h |
35-
| b | c | bc | 60 km/h +- 1 |
34+
| a | b | ab | 20 km/h |
35+
| b | c | bc | 72 km/h +- 1 |
3636

3737
Scenario: Car - Forward/backward maxspeed
3838
Given a grid size of 100 meters
3939

4040
Then routability should be
4141
| highway | maxspeed | maxspeed:forward | maxspeed:backward | forw | backw |
42-
| primary | | | | 65 km/h | 65 km/h |
43-
| primary | 60 | | | 40 km/h | 40 km/h |
44-
| primary | | 60 | | 40 km/h | 65 km/h |
45-
| primary | | | 60 | 65 km/h | 40 km/h |
46-
| primary | 15 | 60 | | 40 km/h | 10 km/h +- 1 |
47-
| primary | 15 | | 60 | 10 km/h +- 1| 40 km/h |
48-
| primary | 15 | 30 | 60 | 20 km/h | 40 km/h |
42+
| primary | | | | 51 km/h | 51 km/h |
43+
| primary | 60 | | | 48 km/h | 48 km/h |
44+
| primary | | 60 | | 48 km/h | 65 km/h |
45+
| primary | | | 60 | 51 km/h | 48 km/h |
46+
| primary | 15 | 60 | | 48 km/h | 15 km/h +- 1 |
47+
| primary | 15 | | 60 | 12 km/h +- 1| 48 km/h |
48+
| primary | 15 | 30 | 60 | 24 km/h | 48 km/h |
4949

5050
Scenario: Car - Maxspeed should not allow routing on unroutable ways
5151
Then routability should be

features/car/speed.feature

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ Feature: Car - speeds
88
Scenario: Car - speed of various way types
99
Then routability should be
1010
| highway | oneway | bothw |
11-
| motorway | no | 90 km/h |
12-
| motorway_link | no | 75 km/h |
13-
| trunk | no | 85 km/h +- 1 |
14-
| trunk_link | no | 70 km/h +- 1 |
15-
| primary | no | 65 km/h +- 1 |
16-
| primary_link | no | 60 km/h |
17-
| secondary | no | 55 km/h +- 1 |
18-
| secondary_link | no | 50 km/h |
19-
| tertiary | no | 40 km/h |
20-
| tertiary_link | no | 30 km/h |
21-
| unclassified | no | 25 km/h |
22-
| residential | no | 25 km/h |
23-
| living_street | no | 10 km/h |
24-
| service | no | 15 km/h |
11+
| motorway | no | 72 km/h |
12+
| motorway_link | no | 60 km/h |
13+
| trunk | no | 67 km/h +- 1 |
14+
| trunk_link | no | 55 km/h +- 1 |
15+
| primary | no | 52 km/h +- 1 |
16+
| primary_link | no | 48 km/h |
17+
| secondary | no | 43 km/h +- 1 |
18+
| secondary_link | no | 40 km/h |
19+
| tertiary | no | 32 km/h |
20+
| tertiary_link | no | 24 km/h |
21+
| unclassified | no | 20 km/h |
22+
| residential | no | 20 km/h |
23+
| living_street | no | 8 km/h |
24+
| service | no | 12 km/h |

profiles/car.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ local abs = math.abs
4646
local min = math.min
4747
local max = math.max
4848

49-
local maxspeed_reduction = 0.66
49+
local speed_reduction = 0.8
5050

5151
local function find_access_tag(source,access_tags_hierachy)
5252
for i,v in ipairs(access_tags_hierachy) do
@@ -172,7 +172,7 @@ function way_function (way)
172172

173173
if way.speed == -1 then
174174
local highway_speed = speed_profile[highway]
175-
local max_speed = parse_maxspeed( way.tags:Find("maxspeed") )*maxspeed_reduction
175+
local max_speed = parse_maxspeed( way.tags:Find("maxspeed") )
176176
-- Set the avg speed on the way if it is accessible by road class
177177
if highway_speed then
178178
if max_speed > highway_speed then
@@ -244,8 +244,8 @@ function way_function (way)
244244
end
245245

246246
-- Override speed settings if explicit forward/backward maxspeeds are given
247-
local maxspeed_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward"))*maxspeed_reduction
248-
local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward"))*maxspeed_reduction
247+
local maxspeed_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward"))
248+
local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward"))
249249
if maxspeed_forward > 0 then
250250
if Way.bidirectional == way.direction then
251251
way.backward_speed = way.speed
@@ -261,6 +261,12 @@ function way_function (way)
261261
way.ignore_in_grid = true
262262
end
263263
way.type = 1
264+
265+
-- scale speeds to get better avg driving times
266+
way.speed = way.speed * speed_reduction
267+
if maxspeed_backward > 0 then
268+
way.backward_speed = way.backward_speed*speed_reduction
269+
end
264270
return
265271
end
266272

0 commit comments

Comments
 (0)