profiles api v2

This commit is contained in:
Emil Tin
2017-05-18 14:27:28 +02:00
committed by Patrick Niklaus
parent 5ece65cade
commit e413b25cd9
41 changed files with 1858 additions and 1208 deletions
+2 -3
View File
@@ -2,10 +2,9 @@
Feature: Bicycle - Route around alleys
Background:
Given the profile file
Given the profile file "bicycle" initialized with
"""
require 'bicycle'
properties.weight_name = 'cyclability'
profile.properties.weight_name = 'cyclability'
"""
Scenario: Bicycle - Avoid taking alleys
+1 -1
View File
@@ -4,7 +4,7 @@ Feature: Bicycle - Handle cycling
Background:
Given the profile "bicycle"
Scenario: Bicycle - Use a ferry route
Scenario: Bicycle - Use a movable bridge
Given the node map
"""
a b c
+2 -3
View File
@@ -2,10 +2,9 @@
Feature: Bicycle - Adds penalties to unsafe roads
Background:
Given the profile file
Given the profile file "bicycle" initialized with
"""
require 'bicycle'
properties.weight_name = 'cyclability'
profile.properties.weight_name = 'cyclability'
"""
Scenario: Bike - Apply penalties to ways without cycleways
+2 -3
View File
@@ -7,10 +7,9 @@ Feature: Turn Penalties
Scenario: Bicycle - Turn penalties on cyclability
Given the profile file
Given the profile file "bicycle" initialized with
"""
require 'bicycle'
properties.weight_name = 'cyclability'
profile.properties.weight_name = 'cyclability'
"""
Given the node map
+13 -15
View File
@@ -1,18 +1,11 @@
@routing @testbot @sidebias
Feature: Testbot - side bias
Background:
Given the profile file
Scenario: Left-hand bias
Given the profile file "car" initialized with
"""
require 'testbot'
properties.left_hand_driving = true
"""
Scenario: Left hand bias
Given the profile file "car" extended with
"""
properties.left_hand_driving = true
profile.turn_bias = properties.left_hand_driving and 1/1.075 or 1.075
profile.left_hand_driving = true
profile.turn_bias = 1/1.075
"""
Given the node map
"""
@@ -31,11 +24,11 @@ Feature: Testbot - side bias
| d | a | bd,ab,ab | 24s +-1 |
| d | c | bd,bc,bc | 27s +-1 |
Scenario: Right hand bias
Given the profile file "car" extended with
Scenario: Right-hand bias
Given the profile file "car" initialized with
"""
properties.left_hand_driving = false
profile.turn_bias = properties.left_hand_driving and 1/1.075 or 1.075
profile.left_hand_driving = true
profile.turn_bias = 1.075
"""
And the node map
"""
@@ -56,6 +49,11 @@ Feature: Testbot - side bias
| d | c | bd,bc,bc | 24s +-1 |
Scenario: Roundabout exit counting for left sided driving
Given the profile file "testbot" initialized with
"""
profile.left_hand_driving = true
profile.turn_bias = 1/1.075
"""
And a grid size of 10 meters
And the node map
"""
+6 -8
View File
@@ -1,11 +1,9 @@
@routing @car @weight
Feature: Car - weights
Background: Use specific speeds
Given the profile "car"
Scenario: Only routes down service road when that's the destination
Given the node map
Given the profile "car"
And the node map
"""
a--b--c
|
@@ -25,7 +23,8 @@ Feature: Car - weights
| a | d | abc,bdf,bdf | 18 km/h | 71.7 |
Scenario: Does not jump off the highway to go down service road
Given the node map
Given the profile "car"
And the node map
"""
a
|
@@ -63,10 +62,9 @@ Feature: Car - weights
| a | e | ab,be,be | 14 km/h | 112 |
Scenario: Distance weights
Given the profile file "car" extended with
Given the profile file "car" initialized with
"""
api_version = 1
properties.weight_name = 'distance'
profile.properties.weight_name = 'distance'
"""
Given the node map
+2 -2
View File
@@ -582,9 +582,9 @@ Feature: Turn Lane Guidance
@anticipate
Scenario: No Lanes for Roundabouts, see #2626
Given the profile file "car" extended with
Given the profile file "car" initialized with
"""
properties.left_hand_driving = true
profile.left_hand_driving = true
"""
And the node map
"""
@@ -3,11 +3,10 @@ Feature: Basic Roundabout
Background:
Given a grid size of 10 meters
Given the profile file
"""
require 'car'
properties.left_hand_driving = true
"""
Given the profile file "car" initialized with
"""
profile.properties.left_hand_driving = true
"""
Scenario: Roundabout exit counting for left sided driving
And a grid size of 10 meters
@@ -33,15 +33,25 @@ Feature: osrm-contract command line option: edge-weight-updates-over-factor
Scenario: Logging using weigts as durations for non-duration profile
Given the profile file "testbot" extended with
Given the profile file
"""
properties.weight_name = 'steps'
function way_function(way, result)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.properties.weight_name = 'steps'
return profile
end
functions.process_way = function(profile, way, result)
result.forward_mode = mode.driving
result.backward_mode = mode.driving
result.weight = 1
result.duration = 1
end
return functions
"""
And the data has been saved to disk
+7 -2
View File
@@ -12,15 +12,20 @@ Feature: osrm-extract lua ways:get_nodes()
And the data has been saved to disk
Scenario: osrm-extract - Passing base file
Given the profile file "testbot" extended with
Given the profile file
"""
function way_function(way, result)
functions = require('testbot')
function way_function(profile, way, result)
for _, node in ipairs(way:get_nodes()) do
print('node id ' .. node:id())
end
result.forward_mode = mode.driving
result.forward_speed = 1
end
functions.process_way = way_function
return functions
"""
When I run "osrm-extract --profile {profile_file} {osm_file}"
Then it should exit successfully
@@ -0,0 +1,40 @@
Feature: Invalid profile API versions
Background:
Given a grid size of 100 meters
Scenario: Profile API version too low
Given the profile file
"""
api_version = -1
"""
And the node map
"""
ab
"""
And the ways
| nodes |
| ab |
And the data has been saved to disk
When I try to run "osrm-extract --profile {profile_file} {osm_file}"
Then it should exit with an error
And stderr should contain "Invalid profile API version"
Scenario: Profile API version too high
Given the profile file
"""
api_version = 3
"""
And the node map
"""
ab
"""
And the ways
| nodes |
| ab |
And the data has been saved to disk
When I try to run "osrm-extract --profile {profile_file} {osm_file}"
Then it should exit with an error
And stderr should contain "Invalid profile API version"
+87 -78
View File
@@ -1,84 +1,36 @@
Feature: Profile API version 0
Background:
Given a grid size of 100 meters
Scenario: Not-defined API version
Scenario: Profile api version 0
Given the profile file
"""
function way_function(way, result)
result.forward_mode = mode.driving
result.forward_speed = 1
end
"""
And the node map
"""
ab
"""
And the ways
| nodes |
| ab |
And the data has been saved to disk
When I try to run "osrm-extract --profile {profile_file} {osm_file}"
Then it should exit successfully
And stderr should not contain "Invalid profile API version"
Scenario: Out-bound API version
Given the profile file
"""
api_version = 2
"""
And the node map
"""
ab
"""
And the ways
| nodes |
| ab |
And the data has been saved to disk
When I try to run "osrm-extract --profile {profile_file} {osm_file}"
Then it should exit with an error
And stderr should contain "Invalid profile API version"
Scenario: Basic profile function calls and property values
Given the profile file
"""
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
"""
"""
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
"""
And the node map
"""
a
@@ -105,3 +57,60 @@ end
| a | b | ac,cb,cb | 24.2s |
| a | d | ac,cd,cd | 24.2s |
| a | e | ac,ce | 20s |
Scenario: Profile version undefined, assume version 0
Given the profile file
"""
-- 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
"""
And the node map
"""
a
b c d
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 | 24.2s |
| a | d | ac,cd,cd | 24.2s |
| a | e | ac,ce | 20s |
+192 -29
View File
@@ -6,41 +6,42 @@ Feature: Profile API version 1
Scenario: Basic profile function calls and property values
Given the profile file
"""
api_version = 1
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'
properties.weight_precision = 2
-- 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'
properties.weight_precision = 2
assert(properties.max_turn_weight == 327.67)
assert(properties.max_turn_weight == 327.67)
function node_function (node, result)
print ('node_function ' .. node:id())
end
function node_function (node, result)
print(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 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 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
"""
function segment_function (segment)
print ('segment_function ' .. segment.source.lon .. ' ' .. segment.source.lat)
end
"""
And the node map
"""
a
@@ -67,3 +68,165 @@ end
| a | b | ac,cb,cb | 19.2s |
| a | d | ac,cd,cd | 19.2s |
| a | e | ac,ce | 20s |
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'
properties.weight_precision = 2
assert(properties.max_turn_weight == 327.67)
function node_function (node, result)
print(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 | 20s |
Scenario: Weighting based on raster sources
Given the profile file
"""
api_version = 1
properties.force_split_edges = true
function source_function()
local path = os.getenv('OSRM_RASTER_SOURCE')
if not path then
path = 'rastersource.asc'
end
raster_source = sources:load(
path,
0, -- lon_min
0.1, -- lon_max
0, -- lat_min
0.1, -- lat_max
5, -- nrows
4 -- ncols
)
end
function way_function (way, result)
result.name = way:get_value_by_key('name')
result.forward_mode = mode.cycling
result.backward_mode = mode.cycling
result.forward_speed = 15
result.backward_speed = 15
end
function segment_function (segment)
local sourceData = sources:query(raster_source, segment.source.lon, segment.source.lat)
local targetData = sources:query(raster_source, segment.target.lon, segment.target.lat)
io.write('evaluating segment: ' .. sourceData.datum .. ' ' .. targetData.datum .. '\n')
local invalid = sourceData.invalid_data()
local scaled_weight = segment.weight
local scaled_duration = segment.duration
if sourceData.datum ~= invalid and targetData.datum ~= invalid then
local slope = (targetData.datum - sourceData.datum) / segment.distance
scaled_weight = scaled_weight / (1.0 - (slope * 5.0))
scaled_duration = scaled_duration / (1.0 - (slope * 5.0))
io.write(' slope: ' .. slope .. '\n')
io.write(' was weight: ' .. segment.weight .. '\n')
io.write(' new weight: ' .. scaled_weight .. '\n')
io.write(' was duration: ' .. segment.duration .. '\n')
io.write(' new duration: ' .. scaled_duration .. '\n')
end
segment.weight = scaled_weight
segment.duration = scaled_duration
end
"""
And the node locations
| node | lat | lon |
| a | 0.1 | 0.1 |
| b | 0.05 | 0.1 |
| c | 0.0 | 0.1 |
| d | 0.05 | 0.03 |
| e | 0.05 | 0.066 |
| f | 0.075 | 0.066 |
And the ways
| nodes | highway |
| ab | primary |
| ad | primary |
| bc | primary |
| dc | primary |
| de | primary |
| eb | primary |
| df | primary |
| fb | primary |
And the raster source
"""
0 0 0 0
0 0 0 250
0 0 250 500
0 0 0 250
0 0 0 0
"""
And the data has been saved to disk
When I route I should get
| from | to | route | speed |
| a | b | ab,ab | 8 km/h |
| b | a | ab,ab | 22 km/h |
| a | c | ab,bc,bc | 12 km/h |
| b | c | bc,bc | 22 km/h |
| a | d | ad,ad | 15 km/h |
| d | c | dc,dc | 15 km/h |
| d | e | de,de | 10 km/h |
| e | b | eb,eb | 10 km/h |
| d | f | df,df | 15 km/h |
| f | b | fb,fb | 7 km/h |
| d | b | de,eb,eb | 10 km/h |
@@ -0,0 +1,87 @@
Feature: Profile API version 2
Background:
Given a grid size of 100 meters
Scenario: Basic profile function calls and property values
Given the profile file
"""
api_version = 2
Set = require('lib/set')
Sequence = require('lib/sequence')
Handlers = require("lib/way_handlers")
find_access_tag = require("lib/access").find_access_tag
limit = require("lib/maxspeed").limit
function setup()
return {
properties = {
max_speed_for_map_matching = 180/3.6,
use_turn_restrictions = true,
continue_straight_at_waypoint = true,
weight_name = 'test_version2',
weight_precision = 2
}
}
end
function process_node(profile, node, result)
print ('process_node ' .. node:id())
end
function process_way(profile, 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 ('process_way ' .. way:id() .. ' ' .. result.name)
end
function process_turn (profile, turn)
print('process_turn', 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 process_segment (profile, segment)
print ('process_segment ' .. segment.source.lon .. ' ' .. segment.source.lat)
end
return {
setup = setup,
process_node = process_node,
process_way = process_way,
process_segment = process_segment,
process_turn = process_turn
}
"""
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 "process_node"
And stdout should contain "process_way"
And stdout should contain "process_turn"
And stdout should contain "process_segment"
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 | 20s |
+9 -6
View File
@@ -248,17 +248,20 @@ module.exports = function () {
fs.writeFile(this.penaltiesCacheFile, data, callback);
});
this.Given(/^the profile file(?: "([^"]*)" extended with)?$/, (profile, data, callback) => {
this.Given(/^the profile file(?: "([^"]*)" initialized with)?$/, (profile, data, callback) => {
const lua_profiles_path = this.PROFILES_PATH.split(path.sep).join('/');
let text = 'package.path = "' + lua_profiles_path + '/?.lua;" .. package.path\n';
if (profile == null) {
text += data + '\n';
} else {
text += 'local f = assert(io.open("' + lua_profiles_path + '/' + profile + '.lua", "r"))\n';
text += 'local s = f:read("*all") .. [[\n' + data + '\n]]\n';
text += 'f:close()\n';
text += 'local m = assert(loadstring and loadstring(s) or load(s))\n';
text += 'm()\n';
text += 'local functions = require("' + profile + '")\n';
text += 'functions.setup_parent = functions.setup\n';
text += 'functions.setup = function()\n';
text += 'local profile = functions.setup_parent()\n';
text += data + '\n';
text += 'return profile\n';
text += 'end\n';
text += 'return functions\n';
}
this.profileFile = this.profileCacheFile;
// TODO: Don't overwrite if it exists
+29 -11
View File
@@ -221,15 +221,24 @@ Feature: Basic Distance Matrix
| 4 | 30 +-1 | 40 +-1 | 70 +-1 | 0 |
Scenario: Testbot - Travel time matrix based on segment durations
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
function segment_function (segment)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.traffic_signal_penalty = 0
profile.u_turn_penalty = 0
return profile
end
functions.process_segment = function(profile, segment)
segment.weight = 2
segment.duration = 11
end
return functions
"""
And the node map
@@ -254,16 +263,25 @@ Feature: Basic Distance Matrix
Scenario: Testbot - Travel time matrix for alternative loop paths
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_precision = 3
function segment_function (segment)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.traffic_signal_penalty = 0
profile.u_turn_penalty = 0
profile.weight_precision = 3
return profile
end
functions.process_segment = function(profile, segment)
segment.weight = 777
segment.duration = 3
end
return functions
"""
And the node map
"""
+17 -19
View File
@@ -1,29 +1,27 @@
@routing @testbot @nil
Feature: Testbot - Check assigning nil values
Scenario: Assign nil values to all way strings
Given the profile file "testbot" extended with
Given the profile file
"""
function way_function (way, result)
result.name = "name"
result.ref = "ref"
result.destinations = "destinations"
result.pronunciation = "pronunciation"
result.turn_lanes_forward = "turn_lanes_forward"
result.turn_lanes_backward = "turn_lanes_backward"
functions = require('testbot')
result.name = nil
result.ref = nil
result.destinations = nil
result.exits = nil
result.pronunciation = nil
result.turn_lanes_forward = nil
result.turn_lanes_backward = nil
function way_function(profile, way, result)
result.name = nil
result.ref = nil
result.destinations = nil
result.exits = nil
result.pronunciation = nil
result.turn_lanes_forward = nil
result.turn_lanes_backward = nil
result.forward_speed = 10
result.backward_speed = 10
result.forward_mode = mode.driving
result.backward_mode = mode.driving
result.forward_speed = 10
result.backward_speed = 10
result.forward_mode = mode.driving
result.backward_mode = mode.driving
end
functions.process_way = way_function
return functions
"""
Given the node map
"""
+7 -3
View File
@@ -39,13 +39,17 @@ Feature: Projection to nearest point on road
Scenario: Projection results negative duration
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
function segment_function (segment)
functions = require('testbot')
function segment_function(profile, segment)
segment.weight = 5.5
segment.duration = 2.8
end
functions.process_segment = segment_function
return functions
"""
Given the node locations
+4 -5
View File
@@ -84,12 +84,11 @@ Feature: Traffic - speeds
Scenario: Weighting based on speed file weights, ETA based on file durations
Given the profile file "testbot" extended with
Given the profile file "testbot" initialized with
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_precision = 2
profile.properties.traffic_signal_penalty = 0
profile.properties.u_turn_penalty = 0
profile.properties.weight_precision = 2
"""
And the contract extra arguments "--segment-speed-file {speeds_file}"
And the customize extra arguments "--segment-speed-file {speeds_file}"
@@ -8,12 +8,11 @@ Feature: Traffic - speeds edge cases
And the ways
| nodes | highway |
| ab | primary |
And the profile file "testbot" extended with
And the profile file "testbot" initialized with
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_precision = 2
profile.properties.traffic_signal_penalty = 0
profile.properties.u_turn_penalty = 0
profile.properties.weight_precision = 2
"""
And the contract extra arguments "--segment-speed-file {speeds_file}"
And the customize extra arguments "--segment-speed-file {speeds_file}"
+1 -4
View File
@@ -1,12 +1,9 @@
@routing @testbot @turn_penalty
Feature: Turn Penalties
Background:
Scenario: Turns should incur a delay that depend on the angle
Given the profile "turnbot"
Given a grid size of 200 meters
Scenario: Turns should incur a delay that depend on the angle
Given the node map
"""
c d e
+101 -44
View File
@@ -60,18 +60,27 @@ Feature: Weight tests
Scenario: Step weights -- way_function: fail if no weight or weight_per_meter property
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_name = 'steps'
function way_function(way, result)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.properties.traffic_signal_penalty = 0
profile.properties.u_turn_penalty = 0
profile.properties.weight_name = 'steps'
return profile
end
functions.process_way = function(profile, way, result)
result.forward_mode = mode.driving
result.backward_mode = mode.driving
result.forward_speed = 42
result.backward_speed = 42
end
return functions
"""
And the node map
"""
@@ -87,18 +96,27 @@ Feature: Weight tests
And it should exit with an error
Scenario: Step weights -- way_function: second way wins
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_name = 'steps'
function way_function(way, result)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.properties.traffic_signal_penalty = 0
profile.properties.u_turn_penalty = 0
profile.properties.weight_name = 'steps'
return profile
end
functions.process_way = function(profile, way, result)
result.forward_mode = mode.driving
result.backward_mode = mode.driving
result.duration = 42
result.weight = 35
end
return functions
"""
Given the node map
@@ -119,19 +137,28 @@ Feature: Weight tests
| h,a | , | 140m +-1 | 35,0 | 42s,0s |
Scenario: Step weights -- way_function: higher weight_per_meter is preferred
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_name = 'steps'
function way_function(way, result)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.properties.traffic_signal_penalty = 0
profile.properties.u_turn_penalty = 0
profile.properties.weight_name = 'steps'
return profile
end
functions.process_way = function(profile, way, result)
result.forward_mode = mode.driving
result.backward_mode = mode.driving
result.duration = 42
result.forward_rate = 1
result.backward_rate = 0.5
end
return functions
"""
Given the node map
@@ -155,22 +182,32 @@ Feature: Weight tests
| h,f | , | 40m | 80,0 | 12s,0s |
Scenario: Step weights -- segment_function
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_name = 'steps'
function way_function(way, result)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.properties.traffic_signal_penalty = 0
profile.properties.u_turn_penalty = 0
profile.properties.weight_name = 'steps'
return profile
end
functions.process_way = function(profile, way, result)
result.forward_mode = mode.driving
result.backward_mode = mode.driving
result.weight = 42
result.duration = 3
end
function segment_function (segment)
functions.process_segment = function(profile, segment)
segment.weight = 1
segment.duration = 11
end
return functions
"""
Given the node map
@@ -195,28 +232,39 @@ Feature: Weight tests
Scenario: Step weights -- segment_function and turn_function with weight precision
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_name = 'steps'
properties.weight_precision = 3
function way_function(way, result)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.properties.traffic_signal_penalty = 0
profile.properties.u_turn_penalty = 0
profile.properties.weight_name = 'steps'
profile.properties.weight_precision = 3
return profile
end
functions.process_way = function(profile, way, result)
result.forward_mode = mode.driving
result.backward_mode = mode.driving
result.weight = 42
result.duration = 3
end
function segment_function (segment)
functions.process_segment = function(profile, segment)
segment.weight = 1.11
segment.duration = 100
end
function turn_function (turn)
functions.process_turn = function(profile, turn)
print (turn.angle)
turn.weight = 2 + turn.angle / 100
turn.duration = turn.angle
end
return functions
"""
Given the node map
@@ -241,22 +289,32 @@ Feature: Weight tests
@traffic @speed
Scenario: Step weights -- segment_function with speed and turn updates
Given the profile file "testbot" extended with
Given the profile file
"""
api_version = 1
properties.traffic_signal_penalty = 0
properties.u_turn_penalty = 0
properties.weight_name = 'steps'
function way_function(way, result)
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.properties.traffic_signal_penalty = 0
profile.properties.u_turn_penalty = 0
profile.properties.weight_name = 'steps'
return profile
end
functions.process_way = function(profile, way, result)
result.forward_mode = mode.driving
result.backward_mode = mode.driving
result.weight = 42
result.duration = 3
end
function segment_function (segment)
functions.process_segment = function(profile, segment)
segment.weight = 10
segment.duration = 11
end
return functions
"""
And the node map
@@ -289,10 +347,9 @@ Feature: Weight tests
@traffic @speed
Scenario: Step weights -- segment_function with speed and turn updates with fallback to durations
Given the profile file "testbot" extended with
Given the profile file "testbot" initialized with
"""
api_version = 1
properties.weight_precision = 3
profile.properties.weight_precision = 3
"""
And the node map