Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profiles api v2 #4072

Merged
merged 1 commit into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# 5.10.0
- Changes from 5.9:
- Changes from 5.9:
- Profiles:
- New version 2 profile API which cleans up a number of things and makes it easier to for profiles to include each other. Profiles using the old version 0 and 1 APIs are still supported.
- New required `setup()` function that must return a configuration hash. Storing configuration in globals is deprecated.
- Passes the config hash returned in `setup()` as an argument to `process_node/way/segment/turn`.
- Properties are now set in `.properties` in the config hash returend by setup().
- initialize raster sources in `setup()` instead of in a separate callback.
- Renames the `sources` helper to `raster`.
- Renames `way_functions` to `process_way` (same for node, segment and turn).
- Removes `get_restrictions()`. Instead set `.restrictions` in the config hash in `setup()`.
- Removes `get_name_suffix_list()`. Instead set `.suffix_list` in the config hash in `setup()`.
- Renames `Handlers` to `WayHandlers`.
- Pass functions instead of strings to `WayHandlers.run()`, so it's possible to mix in your own functions.
- Reorders arguments to `WayHandlers` functions to match `process_way()`.
- Profiles must return a hash of profile functions. This makes it easier for profiles to include each other.

# 5.9.0
- Changes from 5.8:
Expand Down
237 changes: 192 additions & 45 deletions docs/profiles.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions features/bicycle/alley.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion features/bicycle/bridge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions features/bicycle/safety.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions features/bicycle/turn_penalty.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 13 additions & 15 deletions features/car/side_bias.feature
Original file line number Diff line number Diff line change
@@ -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
"""
Expand All @@ -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
"""
Expand All @@ -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
"""
Expand Down
14 changes: 6 additions & 8 deletions features/car/weight.feature
Original file line number Diff line number Diff line change
@@ -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
|
Expand All @@ -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
|
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions features/guidance/anticipate-lanes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
9 changes: 4 additions & 5 deletions features/guidance/roundabout-left-sided.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions features/options/contract/edge-weight-updates-over-factor.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions features/options/extract/lua.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions features/options/profiles/invalid_version.feature
Original file line number Diff line number Diff line change
@@ -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"
Loading