Allow specifing a weight for routing that is independent of duration

This commit is contained in:
Patrick Niklaus
2016-05-12 18:50:10 +02:00
committed by Patrick Niklaus
parent e463733138
commit 279f8aabfb
85 changed files with 2100 additions and 853 deletions
+5 -4
View File
@@ -27,7 +27,7 @@ end
Scenario: Out-bound API version
Given the profile file
"""
api_version = 1
api_version = 2
"""
And the node map
"""
@@ -55,6 +55,7 @@ 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())
@@ -71,7 +72,7 @@ end
function turn_function (angle)
print('turn_function ' .. angle)
return angle == 0 and 0 or 42
return angle == 0 and 0 or 17
end
function segment_function (source, target, distance, weight)
@@ -101,6 +102,6 @@ end
When I route I should get
| from | to | route | time |
| a | b | ac,cb,cb | 19.2s |
| a | d | ac,cd,cd | 19.2s |
| a | b | ac,cb,cb | 16.7s |
| a | d | ac,cd,cd | 16.7s |
| a | e | ac,ce,ce | 20s |
@@ -0,0 +1,66 @@
Feature: Profile API version 1
Background:
Given a grid size of 100 meters
Scenario: Basic profile function calls and property values
Given the profile file
"""
api_version = 1
-- set profile properties
properties.max_speed_for_map_matching = 180/3.6
properties.use_turn_restrictions = true
properties.continue_straight_at_waypoint = true
properties.weight_name = 'test_version1'
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.weight = 10
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 (turn)
print('turn_function', turn.angle, turn.turn_type, turn.direction_modifier, turn.has_traffic_light)
turn.weight = turn.angle == 0 and 0 or 4.2
turn.duration = turn.weight
end
function segment_function (segment)
print ('segment_function ' .. segment.source.lon .. ' ' .. segment.source.lat)
end
"""
And the node map
"""
a
bcd
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 |
| a | b | ac,cb,cb | 19.2s |
| a | d | ac,cd,cd | 19.2s |
| a | e | ac,ce,ce | 20s |