diff --git a/features/bicycle/countrybikespeeds.feature b/features/bicycle/countrybikespeeds.feature new file mode 100644 index 000000000..eb37d7d50 --- /dev/null +++ b/features/bicycle/countrybikespeeds.feature @@ -0,0 +1,89 @@ +@routing @bicycle @countrybikespeeds +Feature: Testbot - Country Profile Selection + + # Check that country data is being selected + # CHE (a) does not support trunk on bike + # FIN (c) does not support trunk on bike + # GRC (m) and IRL (o) support bridleway + # LIU (s) is not a country in list so looks like worldwide + # so + # GRC (m) and LIU (s) support trunk + + Scenario: Profile Selection - highway chosen for country + + Given the extract extra arguments "--location-dependent-data test/data/countrytest.geojson" + And the partition extra arguments "--threads 1" + And the customize extra arguments "--threads 1" + + And the profile file "bicycle" initialized with + """ + profile.uselocationtags.countryspeeds = true + """ + + And the node locations + | node | lat | lon | + | a | 9.5 | 5.0 | + | b | 9.5 | 10.0 | + | c | 9.5 | 15.0 | + | d | 9.0 | 5.0 | + | e | 9.0 | 10.0 | + | f | 9.0 | 15.0 | + | g | 8.5 | 5.0 | + | h | 8.5 | 10.0 | + | i | 8.5 | 15.0 | + | j | 8.0 | 5.0 | + | k | 8.0 | 10.0 | + | l | 8.0 | 15.0 | + | m | 7.5 | 5.0 | + | n | 7.5 | 10.0 | + | o | 7.5 | 15.0 | + | p | 7.0 | 5.0 | + | q | 7.0 | 10.0 | + | r | 7.0 | 15.0 | + | s | 6.5 | 5.0 | + | t | 6.5 | 10.0 | + | u | 6.5 | 15.0 | + + And the ways + | nodes | highway | comment + | ab | trunk | CHE - FIN no + | bc | trunk | + | cf | trunk | FIN - BEL no + | fi | trunk | + | fl | trunk | + | or | trunk | IRL - world yes + | ru | trunk | + | mn | bridleway | GRC - IRL yes + | no | bridleway | + | mp | trunk | GRC - liu yes + | ps | trunk | + + And the partition extra arguments "--threads 1" + And the customize extra arguments "--threads 1" + + + When I route I should get + | waypoints | route | status | message | + | a,b,c | | 400 | Impossible route between points | + | c,l | | 400 | Impossible route between points | + | g,i | | 400 | Impossible route between points | + | o,u | or,ru,ru | 200 | | + | m,o | mn,no,no | 200 | | + | m,s | mp,ps,ps | 200 | | + + + + + + + + + + + + + + + + + diff --git a/features/bicycle/countrymotorroad.feature b/features/bicycle/countrymotorroad.feature new file mode 100644 index 000000000..a9b0d4da8 --- /dev/null +++ b/features/bicycle/countrymotorroad.feature @@ -0,0 +1,39 @@ +@routing @bicycle @countrymotorroad +Feature: Testbot - Country motorroad Selection + + # Check that motorroad is avoided + + Scenario: bicycle Profile Selection - motorroad avoided + + 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.countryspeeds = true + """ + + And the node locations + | node | lat | lon | + | a | 9.5 | 5.0 | + | b | 9.5 | 10.0 | + | c | 9.5 | 15.0 | + | d | 9.0 | 5.0 | + | e | 9.0 | 10.0 | + | f | 9.0 | 15.0 | + + And the ways + | nodes | highway | motorroad | + | ab | trunk | yes | + | bc | trunk | | + | ad | trunk | | + | de | trunk | | + | ef | trunk | | + | cf | trunk | | + + When I route I should get + | waypoints | route | status | message | + | a,c | ad,de,ef,cf,cf | 200 | | + | a,b | ad,de,ef,cf,bc,bc | 200 | | + diff --git a/features/bicycle/countryway.feature b/features/bicycle/countryway.feature new file mode 100644 index 000000000..508a35507 --- /dev/null +++ b/features/bicycle/countryway.feature @@ -0,0 +1,42 @@ +@routing @foot @countryway +Feature: bicycle - Accessability of different way types with countryspeeds + + Background: + Given the profile file "bicycle" initialized with + """ + profile.uselocationtags.countryspeeds = true + """ + + Scenario: Countrybicycle - Basic access + 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 | x | + | bridleway | | + + Scenario: Country bicycle - Routability of man_made structures + Then routability should be + | highway | man_made | bothw | + | (nil) | (nil) | | + | (nil) | pier | x | + diff --git a/features/foot/countrymotorroad.feature b/features/foot/countrymotorroad.feature new file mode 100644 index 000000000..7741660f8 --- /dev/null +++ b/features/foot/countrymotorroad.feature @@ -0,0 +1,55 @@ +@routing @foot @countrymotorroad +Feature: Testbot - Country motorroad Selection + + # Check that motorroad is avoided + + Scenario: foot Profile Selection - motorroad avoided + + 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.countryspeeds = true + """ + + And the node locations + | node | lat | lon | + | a | 9.5 | 5.0 | + | b | 9.5 | 10.0 | + | c | 9.5 | 15.0 | + | d | 9.0 | 5.0 | + | e | 9.0 | 10.0 | + | f | 9.0 | 15.0 | + + And the ways + | nodes | highway | motorroad | + | ab | trunk | yes | + | bc | trunk | | + | ad | trunk | | + | de | trunk | | + | ef | trunk | | + | cf | trunk | | + + When I route I should get + | waypoints | route | status | message | + | a,c | ad,de,ef,cf,cf | 200 | | + | a,b | ad,de,ef,cf,bc,bc | 200 | | + + + + + + + + + + + + + + + + + diff --git a/features/foot/countryspeeds.feature b/features/foot/countryspeeds.feature new file mode 100644 index 000000000..dadbaa37e --- /dev/null +++ b/features/foot/countryspeeds.feature @@ -0,0 +1,85 @@ +@routing @foot @countryspeeds +Feature: Testbot - Country Profile Selection + + # Check that country data is being selected + # CHE (a) and FIN (c) support foot on cycleway + # FRA (g) does not support foot on cycleway + # BEL (i) and FIN (c) support foot on cycleway + # BEL (i) and IRL (o) support Bridleway + # GRC (m) and IRL (o) support trunk and bridleway + # LIU (s) is not a country in list so looks like worldwide + # so + # GRC (m) and LIU (s) support trunk + # LIU (s) does not support cycleway or bridleway + # Worldwide (u) is an area without boundaries (so like s) + + Scenario: foot Profile Selection - highway chosen for country + + Given the extract extra arguments "--threads 1 --location-dependent-data test/data/countrytest.geojson" + And the partition extra arguments "--threads 1" + And the customize extra arguments "--threads 1" + + And the profile file "foot" initialized with + """ + profile.uselocationtags.countryspeeds = true + """ + + And the node locations + | node | lat | lon | + | a | 9.5 | 5.0 | + | b | 9.5 | 10.0 | + | c | 9.5 | 15.0 | + | d | 9.0 | 5.0 | + | e | 9.0 | 10.0 | + | f | 9.0 | 15.0 | + | g | 8.5 | 5.0 | + | h | 8.5 | 10.0 | + | i | 8.5 | 15.0 | + | j | 8.0 | 5.0 | + | k | 8.0 | 10.0 | + | l | 8.0 | 15.0 | + | m | 7.5 | 5.0 | + | n | 7.5 | 10.0 | + | o | 7.5 | 15.0 | + | p | 7.0 | 5.0 | + | q | 7.0 | 10.0 | + | r | 7.0 | 15.0 | + | s | 6.5 | 5.0 | + | t | 6.5 | 10.0 | + | u | 6.5 | 15.0 | + + And the ways + | nodes | highway | comment + | ab | cycleway | CHE - FIN yes + | bc | cycleway | + | ad | cycleway | CHE - FRA no + | dg | cycleway | + | gj | cycleway | + | cf | bridleway | FIN - BEL no + | fi | bridleway | + | gh | trunk | FRA - BEL no + | hi | trunk | + | il | bridleway | BEL - IRL yes + | lo | bridleway | + | or | trunk | IRL - world yes + | ru | trunk | + | mn | trunk | GRC - IRL yes + | no | trunk | + | mp | trunk | GRC - liu yes + | ps | trunk | + + And the partition extra arguments "--threads 1" + And the customize extra arguments "--threads 1" + + + When I route I should get + | waypoints | route | status | message | + | a,c | ab,bc,bc | 200 | | + | a,j | | 400 | Impossible route between points | + | c,i | | 400 | Impossible route between points | + | g,i | | 400 | Impossible route between points | + | i,o | il,lo,lo | 200 | | + | o,u | or,ru,ru | 200 | | + | m,o | mn,no,no | 200 | | + | m,s | mp,ps,ps | 200 | | + diff --git a/features/foot/countryway.feature b/features/foot/countryway.feature new file mode 100644 index 000000000..41efaaee2 --- /dev/null +++ b/features/foot/countryway.feature @@ -0,0 +1,41 @@ +@routing @foot @countryway +Feature: foot - Accessability of different way types with countryspeeds + + Background: + Given the profile file "foot" initialized with + """ + profile.uselocationtags.countryspeeds = true + """ + + Scenario: Countryfoot - Basic access + 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 | | + + Scenario: Countryfoot - Basic access + Then routability should be + | highway | leisure | forw | + | (nil) | track | x | + diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 19202768e..717dd680f 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -7,6 +7,7 @@ Sequence = require('lib/sequence') Handlers = require("lib/way_handlers") TrafficSignal = require("lib/traffic_signal") find_access_tag = require("lib/access").find_access_tag +country_speeds = require("lib/country_speeds") limit = require("lib/maxspeed").limit Measure = require("lib/measure") @@ -27,6 +28,7 @@ function setup() mode_change_penalty = 30, }, + profile = 'bicycle', default_mode = mode.cycling, default_speed = default_speed, walking_speed = walking_speed, @@ -217,7 +219,13 @@ function setup() avoid = Set { 'impassable', 'construction', - 'proposed' + 'proposed', + 'motorroad' + }, + + uselocationtags = Set + { + -- 'countryspeeds' } } end @@ -315,11 +323,23 @@ function handle_bicycle_tags(profile,way,result,data) safety_handler(profile,way,result,data) end - - function speed_handler(profile,way,result,data) data.way_type_allows_pushing = false + local extra_speeds + local extraspeed = false + + if profile.uselocationtags and profile.uselocationtags.countryspeeds then + extra_speeds = country_speeds.getAccessProfile(data, profile.profile) + if extra_speeds then + if extra_speeds.highway[data.highway] then + extraspeed = extra_speeds.highway[data.highway] + if extraspeed == -1 then + extraspeed = false + end + end + end + end -- speed local bridge_speed = profile.bridge_speeds[data.bridge] @@ -362,6 +382,12 @@ function speed_handler(profile,way,result,data) result.forward_speed = profile.amenity_speeds[data.amenity] result.backward_speed = profile.amenity_speeds[data.amenity] data.way_type_allows_pushing = true + elseif extraspeed then + if extraspeed ~= -1 then + result.forward_speed = extraspeed + result.backward_speed = extraspeed + data.way_type_allows_pushing = true + end elseif profile.bicycle_speeds[data.highway] then -- regular ways result.forward_speed = profile.bicycle_speeds[data.highway] @@ -606,6 +632,10 @@ function process_way(profile, way, result) implied_oneway = false } + if profile.uselocationtags and profile.uselocationtags.countryspeeds then + data.location = country_speeds.getcountrytag(way) + end + local handlers = Sequence { -- set the default mode for this profile. if can be changed later -- in case it turns we're e.g. on a ferry diff --git a/profiles/foot.lua b/profiles/foot.lua index fa5f8b663..95670d989 100644 --- a/profiles/foot.lua +++ b/profiles/foot.lua @@ -6,6 +6,7 @@ Set = require('lib/set') Sequence = require('lib/sequence') Handlers = require("lib/way_handlers") find_access_tag = require("lib/access").find_access_tag +country_speeds = require("lib/country_speeds") function setup() local walking_speed = 5 @@ -20,6 +21,7 @@ function setup() use_turn_restrictions = false, }, + profile = 'foot', default_mode = mode.walking, default_speed = walking_speed, oneway_handling = 'specific', -- respect 'oneway:foot' but not 'oneway' @@ -70,10 +72,11 @@ function setup() avoid = Set { 'impassable', - 'proposed' + 'proposed', + 'motorroad' }, - speeds = Sequence { + hwyspeeds = Sequence { highway = { primary = walking_speed, primary_link = walking_speed, @@ -94,6 +97,9 @@ function setup() footway = walking_speed, pier = walking_speed, }, + }, + + otherspeeds = Sequence { railway = { platform = walking_speed @@ -132,6 +138,11 @@ function setup() }, smoothness_speeds = { + }, + + uselocationtags = Set + { + -- 'countryspeeds' } } end @@ -198,6 +209,12 @@ function process_way(profile, way, result) if next(data) == nil then -- is the data table empty? return end + local speedhandler = WayHandlers.speed + + if profile.uselocationtags and profile.uselocationtags.countryspeeds then + data.location = country_speeds.getcountrytag(way) + speedhandler =country_speeds.wayspeed + end local handlers = Sequence { -- set the default mode for this profile. if can be changed later @@ -224,7 +241,7 @@ function process_way(profile, way, result) WayHandlers.movables, -- compute speed taking into account way type, maxspeed tags, etc. - WayHandlers.speed, + speedhandler, WayHandlers.surface, -- handle turn lanes and road classification, used for guidance diff --git a/profiles/lib/way_handlers.lua b/profiles/lib/way_handlers.lua index 112c520b2..99d41ecc4 100644 --- a/profiles/lib/way_handlers.lua +++ b/profiles/lib/way_handlers.lua @@ -274,8 +274,27 @@ function WayHandlers.speed(profile,way,result,data) return -- abort if already set, eg. by a route end - local key,value,speed = Tags.get_constant_by_key_value(way,profile.speeds) + local wayspeeds + if profile.speeds then + wayspeeds = profile.speeds + elseif profile.hwyspeeds then + wayspeeds = profile.hwyspeeds + else + return false + end + local key,value,speed = Tags.get_constant_by_key_value(way,wayspeeds) + + if speed then + -- set speed by way type + result.forward_speed = speed + result.backward_speed = speed + else + -- check for other speeds + if profile.otherspeeds then + key,value,speed = Tags.get_constant_by_key_value(way,profile.otherspeeds) + end + end if speed then -- set speed by way type result.forward_speed = speed