This commit is contained in:
tombay 2025-02-09 21:06:56 +08:00 committed by GitHub
commit 86411a25fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 512 additions and 5 deletions

View File

@ -81,6 +81,7 @@
- Profiles: - Profiles:
- FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615) - FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615)
- ADDED: Add optional support of cargo bike exclusion and width to bicyle profile [#7044](https://github.com/Project-OSRM/osrm-backend/pull/7044) - ADDED: Add optional support of cargo bike exclusion and width to bicyle profile [#7044](https://github.com/Project-OSRM/osrm-backend/pull/7044)
- FIXED: Support country trunk access in bicycle and foot profiles [#7049](https://github.com/Project-OSRM/osrm-backend/pull/7049)
- Routing: - Routing:
- FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419) - FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419)
- FIXED: Correctly handle compressed traffic signals. [#6724](https://github.com/Project-OSRM/osrm-backend/pull/6724) - FIXED: Correctly handle compressed traffic signals. [#6724](https://github.com/Project-OSRM/osrm-backend/pull/6724)

7
data/notrunk.geojson Normal file

File diff suppressed because one or more lines are too long

View File

@ -114,6 +114,7 @@ classes | Sequence | Determines the allowed
restrictions | Sequence | Determines which turn restrictions will be used for this profile. restrictions | Sequence | Determines which turn restrictions will be used for this profile.
suffix_list | Set | List of name suffixes needed for determining if "Highway 101 NW" the same road as "Highway 101 ES". suffix_list | Set | List of name suffixes needed for determining if "Highway 101 NW" the same road as "Highway 101 ES".
relation_types | Sequence | Determines which relations should be cached for processing in this profile. It contains relations types relation_types | Sequence | Determines which relations should be cached for processing in this profile. It contains relations types
uselocationtags | Set | Defines optional attributes that rely on location tags .e.g. 'trunk' will enable highway="trunk" support for the profile
### process_node(profile, node, result, relations) ### process_node(profile, node, result, relations)
Process an OSM node to determine whether this node is a barrier or can be passed and whether passing it incurs a delay. Process an OSM node to determine whether this node is a barrier or can be passed and whether passing it incurs a delay.
@ -375,3 +376,20 @@ There are a few helper functions defined in the global scope that profiles can u
- `trimLaneString` - `trimLaneString`
- `applyAccessTokens` - `applyAccessTokens`
- `canonicalizeStringList` - `canonicalizeStringList`
### osrm-extract location dependent data
The creation of the dataset for routing use requires preprocessing of the osm data source.
The first preprocessing step is via osrm-extract.
Certain data (like driving-side or vehicle height) may be different between areas.
The "--location-dependent-data" command option can be used to pass geojson polygon data to support this differentiation.
### Highway support for Trunk Roads
The default routing profiles foot.lua and bicycle.lua do not allow access on ways with highway="trunk" or highway="trunk_link".
The wiki page outlining access restrictions ("https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access_restrictions") outlines seven countries that do not allow such access.
If the setup option uselocationtags includes 'trunk' then access is changed to yes for all countries.
To support routing data that honours different trunk access
- confirm uselocationtags = 'trunk' is set
- osrm-extract --location-dependent-data data/notrunk.geojson ...
This geojson sets the notrunk option for the seven countries (Austria, Belgium, Denmark, France, Hungary, Slovakia and Switzerland).

View File

@ -4,7 +4,7 @@ Feature: Bike - Accessability of different way types
Background: Background:
Given the profile "bicycle" Given the profile "bicycle"
Scenario: Bike - Routability of way types Scenario: Bike - Routability of way types trunk not supported
# Bikes are allowed on footways etc because you can pull your bike at a lower speed. # Bikes are allowed on footways etc because you can pull your bike at a lower speed.
# Pier is not allowed, since it's tagged using man_made=pier. # Pier is not allowed, since it's tagged using man_made=pier.
@ -40,3 +40,40 @@ Feature: Bike - Accessability of different way types
| highway | man_made | bothw | | highway | man_made | bothw |
| (nil) | (nil) | | | (nil) | (nil) | |
| (nil) | pier | x | | (nil) | pier | x |
Scenario: Bike - Routability of way types trunk supported
# Bikes are allowed on footways etc because you can pull your bike at a lower speed.
# Pier is not allowed, since it's tagged using man_made=pier.
Given the profile file "bicycle" initialized with
"""
profile.uselocationtags.trunk = true
"""
Then routability should be
| highway | bothw |
| (nil) | |
| motorway | |
| motorway_link | |
| trunk | x |
| trunk_link | x |
| primary | x |
| primary_link | x |
| secondary | x |
| secondary_link | x |
| tertiary | x |
| tertiary_link | x |
| residential | x |
| service | x |
| unclassified | x |
| living_street | x |
| road | x |
| track | x |
| path | x |
| footway | x |
| pedestrian | x |
| steps | x |
| cycleway | x |
| bridleway | |
| pier | |

View File

@ -0,0 +1,183 @@
@testbot @way @notrunk
Feature: Testbot - notrunk allowed
# Check that Nodes need to be in the geojson file to support trunk access.
# Use the default geopoint around 0.0.
# This covers both trunk allowed notrunk allowed and no motorroad
Scenario: bicycle trunk allowed - notrunk failure original behavior
Given the profile "bicycle"
And the extract extra arguments "--threads 1"
And the partition extra arguments "--threads 1"
And the customize extra arguments "--threads 1"
And the node locations
# f through o should all fail
| node | lat | lon |
| a | 48.65729 | 22.26471 |
| b | 48.65648 | 22.26486 |
| c | 48.65503 | 22.26521 |
| d | 48.65489 | 22.26520 |
| e | 48.65426 | 22.26533 |
| f | 48.65277 | 22.26556 |
| g | 48.65026 | 22.26606 |
| h | 48.64937 | 22.26618 |
| i | 48.64858 | 22.26634 |
| j | 48.64763 | 22.26652 |
| k | 48.64730 | 22.26658 |
| l | 48.64616 | 22.26681 |
| m | 48.64599 | 22.26685 |
| n | 48.64568 | 22.26690 |
And the ways
| nodes | highway | motorroad |
| ab | primary | |
| bc | primary | |
| cd | primary | yes |
| de | primary | |
| ef | primary | |
| fg | trunk | |
| gh | trunk | |
| hi | trunk | |
| ij | trunk | |
| jk | trunk | |
| kl | trunk | |
| lm | trunk | yes |
| mn | primary | |
When I route I should get
| from | to | route | status| message | # |
| a | c | ab,bc,bc | 200 | | |
| a | f | | 400 | Impossible route between points | |
| d | f | de,ef,ef | 200 | | |
| d | g | de,ef,ef | 200 | | |
| d | n | | 400 | Impossible route between points | |
Scenario: bicycle trunk allowed - trunk ok with no geojson
Given the extract extra arguments "--threads 1"
And the partition extra arguments "--threads 1"
And the customize extra arguments "--threads 1"
And the profile file "bicycle" initialized with
"""
profile.uselocationtags.trunk = true
"""
And the node locations
# a through g are in Slovakia - in the no trunk allowed set
# h is on the edge (i.e. in Ukraine)
# i through n are in Ukraine
| node | lat | lon |
| a | 48.65729 | 22.26471 |
| b | 48.65648 | 22.26486 |
| c | 48.65503 | 22.26521 |
| d | 48.65489 | 22.26520 |
| e | 48.65426 | 22.26533 |
| f | 48.65277 | 22.26556 |
| g | 48.65026 | 22.26606 |
| h | 48.64937 | 22.26618 |
| i | 48.64858 | 22.26634 |
| j | 48.64763 | 22.26652 |
| k | 48.64730 | 22.26658 |
| l | 48.64616 | 22.26681 |
| m | 48.64599 | 22.26685 |
| n | 48.64568 | 22.26690 |
And the ways
| nodes | highway | motorroad |
| ab | primary | |
| bc | primary | |
| cd | primary | yes |
| de | primary | |
| ef | primary | |
| fg | trunk | |
| gh | trunk | |
| hi | trunk | |
| ij | trunk | |
| jk | trunk | |
| kl | trunk | |
| lm | trunk | yes |
| mn | primary | |
When I route I should get
| from | to | route | status| message | # |
| a | c | ab,bc,bc | 200 | | |
| a | d | | 400 | Impossible route between points | |
| d | f | de,ef,ef | 200 | | |
| d | g | de,ef,fg,fg | 200 | | |
| e | n | | 400 | Impossible route between points | |
| f | h | fg,gh | 200 | | |
| g | l | gh,ij,kl,kl | 200 | | |
| h | l | hi,ij,kl,kl | 200 | | |
| i | l | ij,kl,kl | 200 | | |
| i | m | | 400 | Impossible route between points | |
Scenario: bicycle trunk allowed - notrunk failure with geojson
Given the extract extra arguments "--threads 1 --location-dependent-data data/notrunk.geojson"
And the partition extra arguments "--threads 1"
And the customize extra arguments "--threads 1"
And the profile file "bicycle" initialized with
"""
profile.uselocationtags.trunk = true
"""
And the node locations
# a through g are in Slovakia - in the no trunk allowed set
# h is on the edge (i.e. in Ukraine)
# i through n are in Ukraine
| node | lat | lon |
| a | 48.65729 | 22.26471 |
| b | 48.65648 | 22.26486 |
| c | 48.65503 | 22.26521 |
| d | 48.65489 | 22.26520 |
| e | 48.65426 | 22.26533 |
| f | 48.65277 | 22.26556 |
| g | 48.65026 | 22.26606 |
| h | 48.64937 | 22.26618 |
| i | 48.64858 | 22.26634 |
| j | 48.64763 | 22.26652 |
| k | 48.64730 | 22.26658 |
| l | 48.64616 | 22.26681 |
| m | 48.64599 | 22.26685 |
| n | 48.64568 | 22.26690 |
And the ways
| nodes | highway | motorroad |
| ab | primary | |
| bc | primary | |
| cd | primary | yes |
| de | primary | |
| ef | primary | |
| fg | trunk | |
| gh | trunk | |
| hi | trunk | |
| ij | trunk | |
| jk | trunk | |
| kl | trunk | |
| lm | trunk | yes |
| mn | primary | |
When I route I should get
| from | to | route | status| message | # |
| a | c | ab,bc,bc | 200 | | |
| a | d | | 400 | Impossible route between points | |
| a | f | | 400 | Impossible route between points | |
| d | f | de,ef,ef | 200 | | |
| d | g | | 400 | Impossible route between points | |
| e | n | | 400 | Impossible route between points | |
| f | h | | 400 | Impossible route between points | |
| g | l | hi,ij,kl,kl | 200 | | |
| h | l | hi,ij,kl,kl | 200 | | |
| i | l | ij,kl,kl | 200 | | |
| i | m | | 400 | Impossible route between points | |

View File

@ -42,3 +42,37 @@ Feature: Foot - Accessability of different way types
| footway | | | x | | footway | | | x |
| proposed | | | | | proposed | | | |
| proposed | yes | yes | | | proposed | yes | yes | |
Scenario: Foot - Basic access with profile.uselocationtags.trunk = true
Given the profile file "foot" initialized with
"""
profile.uselocationtags.trunk = true
"""
Then routability should be
| highway | forw |
| motorway | |
| motorway_link | |
| trunk | x |
| trunk_link | x |
| primary | x |
| primary_link | x |
| secondary | x |
| secondary_link | x |
| tertiary | x |
| tertiary_link | x |
| residential | x |
| service | x |
| unclassified | x |
| living_street | x |
| road | x |
| track | x |
| path | x |
| footway | x |
| pedestrian | x |
| steps | x |
| pier | x |
| cycleway | |
| bridleway | |

View File

@ -0,0 +1,186 @@
@testbot @way @notrunk
Feature: Testbot - notrunk allowed
# Check that Nodes need to be in the geojson file to support trunk access.
# Use the default geopoint around 0.0.
# This covers both trunk allowed notrunk allowed and no motorroad
Scenario: foot trunk allowed - notrunk failure original behavior
Given the profile "foot"
And the extract extra arguments "--threads 1"
And the partition extra arguments "--threads 1"
And the customize extra arguments "--threads 1"
And the node locations
# f through o should all fail
| node | lat | lon |
| a | 48.65729 | 22.26471 |
| b | 48.65648 | 22.26486 |
| c | 48.65503 | 22.26521 |
| d | 48.65489 | 22.26520 |
| e | 48.65426 | 22.26533 |
| f | 48.65277 | 22.26556 |
| g | 48.65026 | 22.26606 |
| h | 48.64937 | 22.26618 |
| i | 48.64858 | 22.26634 |
| j | 48.64763 | 22.26652 |
| k | 48.64730 | 22.26658 |
| l | 48.64616 | 22.26681 |
| m | 48.64599 | 22.26685 |
| n | 48.64568 | 22.26690 |
And the ways
| nodes | highway | motorroad |
| ab | primary | |
| bc | primary | |
| cd | primary | yes |
| de | primary | |
| ef | primary | |
| fg | trunk | |
| gh | trunk | |
| hi | trunk | |
| ij | trunk | |
| jk | trunk | |
| kl | trunk | |
| lm | trunk | yes |
| mn | primary | |
When I route I should get
| from | to | route | status| message | # |
| a | c | ab,bc,bc | 200 | | |
| a | f | | 400 | Impossible route between points | |
| a | f | | 400 | Impossible route between points | |
| d | f | de,ef,ef | 200 | | |
| d | g | de,ef,ef | 200 | | |
| d | n | | 400 | Impossible route between points | |
#
Scenario: foot trunk allowed - trunk ok with no geojson
Given the extract extra arguments "--threads 1"
And the partition extra arguments "--threads 1"
And the customize extra arguments "--threads 1"
And the profile file "foot" initialized with
"""
profile.uselocationtags.trunk = true
"""
And the node locations
# a through g are in Slovakia - in the no trunk allowed set
# h is on the edge (i.e. in Ukraine)
# i through n are in Ukraine
| node | lat | lon |
| a | 48.65729 | 22.26471 |
| b | 48.65648 | 22.26486 |
| c | 48.65503 | 22.26521 |
| d | 48.65489 | 22.26520 |
| e | 48.65426 | 22.26533 |
| f | 48.65277 | 22.26556 |
| g | 48.65026 | 22.26606 |
| h | 48.64937 | 22.26618 |
| i | 48.64858 | 22.26634 |
| j | 48.64763 | 22.26652 |
| k | 48.64730 | 22.26658 |
| l | 48.64616 | 22.26681 |
| m | 48.64599 | 22.26685 |
| n | 48.64568 | 22.26690 |
And the ways
| nodes | highway | motorroad |
| ab | primary | |
| bc | primary | |
| cd | primary | yes |
| de | primary | |
| ef | primary | |
| fg | trunk | |
| gh | trunk | |
| hi | trunk | |
| ij | trunk | |
| jk | trunk | |
| kl | trunk | |
| lm | trunk | yes |
| mn | primary | |
When I route I should get
| from | to | route | status| message | # |
| a | c | ab,bc,bc | 200 | | |
| a | f | | 400 | Impossible route between points | |
| d | f | de,ef,ef | 200 | | |
| d | g | de,ef,fg,fg | 200 | | |
| e | n | | 400 | Impossible route between points | |
| f | h | fg,gh | 200 | | |
| g | l | gh,ij,kl,kl | 200 | | |
| h | l | hi,ij,kl,kl | 200 | | |
| i | l | ij,kl,kl | 200 | | |
| i | m | | 400 | Impossible route between points | |
Scenario: foot trunk allowed - notrunk failure with geojson
Given the extract extra arguments "--threads 1 --location-dependent-data data/notrunk.geojson"
And the partition extra arguments "--threads 1"
And the customize extra arguments "--threads 1"
And the profile file "foot" initialized with
"""
profile.uselocationtags.trunk = true
"""
And the node locations
# a through g are in Slovakia - in the no trunk allowed set
# h is on the edge (i.e. in Ukraine)
# i through n are in Ukraine
| node | lat | lon |
| a | 48.65729 | 22.26471 |
| b | 48.65648 | 22.26486 |
| c | 48.65503 | 22.26521 |
| d | 48.65489 | 22.26520 |
| e | 48.65426 | 22.26533 |
| f | 48.65277 | 22.26556 |
| g | 48.65026 | 22.26606 |
| h | 48.64937 | 22.26618 |
| i | 48.64858 | 22.26634 |
| j | 48.64763 | 22.26652 |
| k | 48.64730 | 22.26658 |
| l | 48.64616 | 22.26681 |
| m | 48.64599 | 22.26685 |
| n | 48.64568 | 22.26690 |
And the ways
| nodes | highway | motorroad |
| ab | primary | |
| bc | primary | |
| cd | primary | yes |
| de | primary | |
| ef | primary | |
| fg | trunk | |
| gh | trunk | |
| hi | trunk | |
| ij | trunk | |
| jk | trunk | |
| kl | trunk | |
| lm | trunk | yes |
| mn | primary | |
When I route I should get
| from | to | route | status| message | # |
| a | c | ab,bc,bc | 200 | | |
| a | f | | 400 | Impossible route between points | |
| a | f | | 400 | Impossible route between points | |
| d | f | de,ef,ef | 200 | | |
| d | g | | 400 | Impossible route between points | |
| e | n | | 400 | Impossible route between points | |
| f | h | | 400 | Impossible route between points | |
| g | l | hi,ij,kl,kl | 200 | | |
| h | l | hi,ij,kl,kl | 200 | | |
| i | l | ij,kl,kl | 200 | | |
| i | m | | 400 | Impossible route between points | |

View File

@ -27,6 +27,7 @@ function setup()
mode_change_penalty = 30, mode_change_penalty = 30,
}, },
profile = 'bicycle',
default_mode = mode.cycling, default_mode = mode.cycling,
default_speed = default_speed, default_speed = default_speed,
walking_speed = walking_speed, walking_speed = walking_speed,
@ -134,12 +135,16 @@ function setup()
residential = default_speed, residential = default_speed,
unclassified = default_speed, unclassified = default_speed,
living_street = default_speed, living_street = default_speed,
road = default_speed,
service = default_speed, service = default_speed,
track = 12, track = 12,
path = 13 path = 13
}, },
trunk_speeds = {
trunk = default_speed,
trunk_link = default_speed,
},
pedestrian_speeds = { pedestrian_speeds = {
footway = walking_speed, footway = walking_speed,
pedestrian = walking_speed, pedestrian = walking_speed,
@ -220,8 +225,13 @@ function setup()
avoid = Set { avoid = Set {
'impassable', 'impassable',
'motorroad',
'construction', 'construction',
'proposed' 'proposed'
},
uselocationtags = Set {
-- 'trunk'
} }
} }
end end
@ -394,6 +404,13 @@ function speed_handler(profile,way,result,data)
result.forward_speed = profile.bicycle_speeds[data.highway] result.forward_speed = profile.bicycle_speeds[data.highway]
result.backward_speed = profile.bicycle_speeds[data.highway] result.backward_speed = profile.bicycle_speeds[data.highway]
data.way_type_allows_pushing = true data.way_type_allows_pushing = true
-- check trunk
elseif profile.trunk_speeds[data.highway] and profile.uselocationtags and profile.uselocationtags.trunk then
if not way:get_location_tag(data.highway) or way:get_location_tag(data.highway) ~= "no" then
result.forward_speed = profile.trunk_speeds[data.highway]
result.backward_speed = profile.trunk_speeds[data.highway]
data.way_type_allows_pushing = true
end
elseif data.access and profile.access_tag_whitelist[data.access] then elseif data.access and profile.access_tag_whitelist[data.access] then
-- unknown way, but valid access tag -- unknown way, but valid access tag
result.forward_speed = profile.default_speed result.forward_speed = profile.default_speed

View File

@ -20,6 +20,7 @@ function setup()
use_turn_restrictions = false, use_turn_restrictions = false,
}, },
profile = 'foot',
default_mode = mode.walking, default_mode = mode.walking,
default_speed = walking_speed, default_speed = walking_speed,
oneway_handling = 'specific', -- respect 'oneway:foot' but not 'oneway' oneway_handling = 'specific', -- respect 'oneway:foot' but not 'oneway'
@ -70,9 +71,15 @@ function setup()
avoid = Set { avoid = Set {
'impassable', 'impassable',
'proposed' 'proposed',
'motorroad'
}, },
trunk_speeds = {
trunk = walking_speed,
trunk_link = walking_speed
},
speeds = Sequence { speeds = Sequence {
highway = { highway = {
primary = walking_speed, primary = walking_speed,
@ -83,7 +90,6 @@ function setup()
tertiary_link = walking_speed, tertiary_link = walking_speed,
unclassified = walking_speed, unclassified = walking_speed,
residential = walking_speed, residential = walking_speed,
road = walking_speed,
living_street = walking_speed, living_street = walking_speed,
service = walking_speed, service = walking_speed,
track = walking_speed, track = walking_speed,
@ -132,6 +138,10 @@ function setup()
}, },
smoothness_speeds = { smoothness_speeds = {
},
uselocationtags = Set {
-- 'trunk'
} }
} }
end end
@ -190,7 +200,6 @@ function process_way(profile, way, result)
amenity = way:get_value_by_key('amenity'), amenity = way:get_value_by_key('amenity'),
public_transport = way:get_value_by_key('public_transport') public_transport = way:get_value_by_key('public_transport')
} }
-- perform an quick initial check and abort if the way is -- perform an quick initial check and abort if the way is
-- obviously not routable. here we require at least one -- obviously not routable. here we require at least one
-- of the prefetched tags to be present, ie. the data table -- of the prefetched tags to be present, ie. the data table

View File

@ -276,6 +276,16 @@ function WayHandlers.speed(profile,way,result,data)
local key,value,speed = Tags.get_constant_by_key_value(way,profile.speeds) local key,value,speed = Tags.get_constant_by_key_value(way,profile.speeds)
-- if the highway is trunk or trunk_link and locationtag disables it
-- then noroute available
if not speed and data.highway and profile.uselocationtags and profile.uselocationtags.trunk then
if profile.trunk_speeds[data.highway] and
(not way:get_location_tag(data.highway) or way:get_location_tag(data.highway) ~= "no") then
speed = profile.trunk_speeds[data.highway]
end
end
if speed then if speed then
-- set speed by way type -- set speed by way type
result.forward_speed = speed result.forward_speed = speed
@ -634,6 +644,11 @@ function WayHandlers.blocked_ways(profile,way,result,data)
return false return false
end end
-- motorroad
if profile.avoid.motorroad and way:get_value_by_key("motorroad") == "yes" then
return false
end
-- In addition to the highway=construction tag above handle the construction=* tag -- In addition to the highway=construction tag above handle the construction=* tag
-- http://wiki.openstreetmap.org/wiki/Key:construction -- http://wiki.openstreetmap.org/wiki/Key:construction
-- https://taginfo.openstreetmap.org/keys/construction#values -- https://taginfo.openstreetmap.org/keys/construction#values