2016-12-22 17:17:59 -05:00
|
|
|
Feature: Profile API version 0
|
|
|
|
|
2017-05-18 08:27:28 -04:00
|
|
|
Scenario: Profile api version 0
|
2016-12-22 17:17:59 -05:00
|
|
|
Given the profile file
|
2017-05-18 08:27:28 -04:00
|
|
|
"""
|
|
|
|
api_version = 0
|
|
|
|
-- set profile properties
|
|
|
|
properties.u_turn_penalty = 20
|
|
|
|
properties.traffic_signal_penalty = 2
|
|
|
|
properties.max_speed_for_map_matching = 180/3.6
|
|
|
|
properties.use_turn_restrictions = true
|
|
|
|
properties.continue_straight_at_waypoint = true
|
|
|
|
properties.left_hand_driving = false
|
|
|
|
properties.weight_name = 'duration'
|
|
|
|
function node_function (node, result)
|
|
|
|
print ('node_function ' .. node:id())
|
|
|
|
end
|
|
|
|
function way_function(way, result)
|
|
|
|
result.name = way:get_value_by_key('name')
|
|
|
|
result.forward_mode = mode.driving
|
|
|
|
result.backward_mode = mode.driving
|
|
|
|
result.forward_speed = 36
|
|
|
|
result.backward_speed = 36
|
|
|
|
print ('way_function ' .. way:id() .. ' ' .. result.name)
|
|
|
|
end
|
|
|
|
function turn_function (angle)
|
|
|
|
print('turn_function ' .. angle)
|
|
|
|
return angle == 0 and 0 or 42
|
|
|
|
end
|
|
|
|
function segment_function (source, target, distance, weight)
|
|
|
|
print ('segment_function ' .. source.lon .. ' ' .. source.lat)
|
|
|
|
end
|
|
|
|
"""
|
2016-12-22 17:17:59 -05:00
|
|
|
And the node map
|
2017-05-18 08:27:28 -04:00
|
|
|
"""
|
|
|
|
a
|
|
|
|
b c d
|
|
|
|
e
|
|
|
|
"""
|
2016-12-22 17:17:59 -05:00
|
|
|
And the ways
|
|
|
|
| nodes |
|
2017-05-18 08:27:28 -04:00
|
|
|
| ac |
|
|
|
|
| cb |
|
|
|
|
| cd |
|
|
|
|
| ce |
|
2016-12-22 17:17:59 -05:00
|
|
|
And the data has been saved to disk
|
|
|
|
|
2017-05-18 08:27:28 -04:00
|
|
|
When I run "osrm-extract --profile {profile_file} {osm_file}"
|
2016-12-22 17:17:59 -05:00
|
|
|
Then it should exit successfully
|
2017-05-18 08:27:28 -04:00
|
|
|
And stdout should contain "node_function"
|
|
|
|
And stdout should contain "way_function"
|
|
|
|
And stdout should contain "turn_function"
|
|
|
|
And stdout should contain "segment_function"
|
2016-12-22 17:17:59 -05:00
|
|
|
|
2017-05-18 08:27:28 -04:00
|
|
|
When I route I should get
|
|
|
|
| from | to | route | time |
|
|
|
|
| a | b | ac,cb,cb | 24.2s |
|
|
|
|
| a | d | ac,cd,cd | 24.2s |
|
|
|
|
| a | e | ac,ce | 20s |
|
2016-12-22 17:17:59 -05:00
|
|
|
|
2017-05-18 08:27:28 -04:00
|
|
|
Scenario: Profile version undefined, assume version 0
|
2016-12-22 17:17:59 -05:00
|
|
|
Given the profile file
|
2017-05-18 08:27:28 -04:00
|
|
|
"""
|
|
|
|
-- set profile properties
|
|
|
|
properties.u_turn_penalty = 20
|
|
|
|
properties.traffic_signal_penalty = 2
|
|
|
|
properties.max_speed_for_map_matching = 180/3.6
|
|
|
|
properties.use_turn_restrictions = true
|
|
|
|
properties.continue_straight_at_waypoint = true
|
|
|
|
properties.left_hand_driving = false
|
|
|
|
properties.weight_name = 'duration'
|
|
|
|
function node_function (node, result)
|
|
|
|
print ('node_function ' .. node:id())
|
|
|
|
end
|
|
|
|
function way_function(way, result)
|
|
|
|
result.name = way:get_value_by_key('name')
|
|
|
|
result.forward_mode = mode.driving
|
|
|
|
result.backward_mode = mode.driving
|
|
|
|
result.forward_speed = 36
|
|
|
|
result.backward_speed = 36
|
|
|
|
print ('way_function ' .. way:id() .. ' ' .. result.name)
|
|
|
|
end
|
|
|
|
function turn_function (angle)
|
|
|
|
print('turn_function ' .. angle)
|
|
|
|
return angle == 0 and 0 or 42
|
|
|
|
end
|
|
|
|
function segment_function (source, target, distance, weight)
|
|
|
|
print ('segment_function ' .. source.lon .. ' ' .. source.lat)
|
|
|
|
end
|
|
|
|
"""
|
2016-12-22 17:17:59 -05:00
|
|
|
And the node map
|
|
|
|
"""
|
|
|
|
a
|
2017-01-26 11:28:27 -05:00
|
|
|
b c d
|
2016-12-22 17:17:59 -05:00
|
|
|
e
|
|
|
|
"""
|
|
|
|
And the ways
|
|
|
|
| nodes |
|
|
|
|
| ac |
|
|
|
|
| cb |
|
|
|
|
| cd |
|
|
|
|
| ce |
|
|
|
|
And the data has been saved to disk
|
|
|
|
|
|
|
|
When I run "osrm-extract --profile {profile_file} {osm_file}"
|
|
|
|
Then it should exit successfully
|
|
|
|
And stdout should contain "node_function"
|
|
|
|
And stdout should contain "way_function"
|
|
|
|
And stdout should contain "turn_function"
|
|
|
|
And stdout should contain "segment_function"
|
|
|
|
|
|
|
|
When I route I should get
|
|
|
|
| from | to | route | time |
|
2017-01-26 11:28:27 -05:00
|
|
|
| a | b | ac,cb,cb | 24.2s |
|
|
|
|
| a | d | ac,cd,cd | 24.2s |
|
2017-05-18 08:27:28 -04:00
|
|
|
| a | e | ac,ce | 20s |
|