Merge pull request #441 from ibikecph/lua_bike_oneways_and_names
update bike profile - oneways and way names
This commit is contained in:
commit
bb09cac7f4
@ -26,7 +26,7 @@ Feature: Street names in instructions
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | c | cycleway,trac |
|
||||
| a | c | cycleway,track |
|
||||
|
||||
Scenario: Don't create instructions for every node of unnamed ways
|
||||
Given the node map
|
||||
|
@ -68,7 +68,6 @@ function node_function (node)
|
||||
end
|
||||
|
||||
function way_function (way, numberOfNodesInWay)
|
||||
|
||||
-- A way must have two nodes or more
|
||||
if(numberOfNodesInWay < 2) then
|
||||
return 0;
|
||||
@ -84,62 +83,21 @@ function way_function (way, numberOfNodesInWay)
|
||||
local man_made = way.tags:Find("man_made")
|
||||
local barrier = way.tags:Find("barrier")
|
||||
local oneway = way.tags:Find("oneway")
|
||||
local onewayClass = way.tags:Find("oneway:bicycle")
|
||||
local cycleway = way.tags:Find("cycleway")
|
||||
local duration = way.tags:Find("duration")
|
||||
local service = way.tags:Find("service")
|
||||
local area = way.tags:Find("area")
|
||||
local access = way.tags:Find("access")
|
||||
|
||||
-- Second parse the way according to these properties
|
||||
|
||||
if ignore_areas and ("yes" == area) then
|
||||
return 0
|
||||
end
|
||||
|
||||
-- Check if we are allowed to access the way
|
||||
if access_tag_blacklist[access] ~=nil and access_tag_blacklist[access] then
|
||||
return 0;
|
||||
end
|
||||
|
||||
-- Check if our vehicle types are forbidden
|
||||
for i,v in ipairs(access_tags) do
|
||||
local mode_value = way.tags:Find(v)
|
||||
if nil ~= mode_value and "no" == mode_value then
|
||||
return 0;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Set the name that will be used for instructions
|
||||
if "" ~= ref then
|
||||
way.name = ref
|
||||
elseif "" ~= name then
|
||||
way.name = name
|
||||
end
|
||||
|
||||
if "roundabout" == junction then
|
||||
way.roundabout = true;
|
||||
end
|
||||
|
||||
-- Handling ferries and piers
|
||||
|
||||
if (speed_profile[route] ~= nil and speed_profile[route] > 0) or
|
||||
(speed_profile[man_made] ~= nil and speed_profile[man_made] > 0)
|
||||
then
|
||||
if durationIsValid(duration) then
|
||||
way.speed = parseDuration / math.max(1, numberOfSegments-1);
|
||||
way.is_duration_set = true;
|
||||
end
|
||||
way.direction = Way.bidirectional;
|
||||
if speed_profile[route] ~= nil then
|
||||
highway = route;
|
||||
elseif speed_profile[man_made] ~= nil then
|
||||
highway = man_made;
|
||||
end
|
||||
if not way.is_duration_set then
|
||||
way.speed = speed_profile[highway]
|
||||
end
|
||||
|
||||
else
|
||||
way.name = highway -- if no name exists, use way type
|
||||
end
|
||||
|
||||
-- Set the avg speed on the way if it is accessible by road class
|
||||
@ -158,19 +116,17 @@ function way_function (way, numberOfNodesInWay)
|
||||
way.speed = math.min(speed_profile["default"], maxspeed)
|
||||
end
|
||||
|
||||
-- Set access restriction flag if access is allowed under certain restrictions only
|
||||
if access ~= "" and access_tag_restricted[access] then
|
||||
way.is_access_restricted = true
|
||||
end
|
||||
|
||||
-- Set access restriction flag if service is allowed under certain restrictions only
|
||||
if service ~= "" and service_tag_restricted[service] then
|
||||
way.is_access_restricted = true
|
||||
end
|
||||
|
||||
-- Set direction according to tags on way
|
||||
if obey_oneway then
|
||||
if oneway == "no" or oneway == "0" or oneway == "false" then
|
||||
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
|
||||
way.direction = Way.oneway
|
||||
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
|
||||
way.direction = Way.bidirectional
|
||||
elseif onewayClass == "-1" then
|
||||
way.direction = Way.opposite
|
||||
elseif oneway == "no" or oneway == "0" or oneway == "false" then
|
||||
way.direction = Way.bidirectional
|
||||
elseif cycleway == "opposite" or cycleway == "opposite_track" or cycleway == "opposite_lane" then
|
||||
way.direction = Way.bidirectional
|
||||
elseif oneway == "-1" then
|
||||
way.direction = Way.opposite
|
||||
@ -183,11 +139,6 @@ function way_function (way, numberOfNodesInWay)
|
||||
way.direction = Way.bidirectional
|
||||
end
|
||||
|
||||
-- Override general direction settings of there is a specific one for our mode of travel
|
||||
|
||||
if ignore_in_grid[highway] ~= nil and ignore_in_grid[highway] then
|
||||
way.ignore_in_grid = true
|
||||
end
|
||||
way.type = 1
|
||||
return 1
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user