Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
imporve oneway handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rush42 committed Apr 17, 2024
1 parent 338e215 commit 2b18e4f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions processing/topics/roads_bikelanes/bikelanes/Bikelanes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require("DeriveSurface")
require("DeriveSmoothness")
require("BikelanesTodos")
require("Sanitize")
require("InferOneway")
require("DeriveOneway")
require("DefaultId")

local tags_copied = {
Expand Down Expand Up @@ -69,7 +69,7 @@ function Bikelanes(object)
_side = transformedTags._side,
category = category,
offset = SideSignMap[transformedTags._side] * RoadWidth(tags) / 2,
oneway = Sanitize(transformedTags.oneway, Set({ 'yes', 'no' })) or InferOneway(category),
oneway = DeriveOneway(transformedTags, category),
bridge = Sanitize(tags.bridge, Set({ "yes" })),
tunnel = Sanitize(tags.tunnel, Set({ "yes" })),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package.path = package.path .. ";/processing/topics/helper/?.lua"
require("Set")
require("Sanitize")

local onewayAssumedNo = Set({
'bicycleRoad', -- road shared, both lanes
'bicycleRoad_vehicleDestination', -- road shared, both lanes
Expand Down Expand Up @@ -30,13 +34,23 @@ local onewayImplicitYes = Set({
})

---@param category string
---@return 'assumed_no' | 'implicit_yes' | 'unknown'
--- Infer oneway information based on the given category
function InferOneway(category)
-- TODO:
-- We want to make sure that "Fahrradstraßen" which allow bidirectional bicycle traffic
-- but only unidirectional motor_vehicle traffic can express this fact in our atlas Inspector.
-- Which is why we invent a new value `car_not_bike` for the `oneway` tag.
---@return 'yes' | 'no' | 'car_not_bike' | 'assumed_no' | 'implicit_yes' | 'unknown'
--- Derive oneway information based on tags and given category
function DeriveOneway(tags, category)

-- if `oneway:bicycle` is explicitly tagged check if it differs from `oneway`
if tags['oneway:bicycle'] == 'yes' then
return 'yes'
elseif tags['oneway:bicycle'] == 'no' then
if tags.oneway == 'yes' then
return 'car_not_bike'
else
return 'no'
end
end
if Sanitize(tags.oneway, Set({'yes', 'no'})) then
return tags.oneway
end

if onewayAssumedNo[category] then
return 'assumed_no'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function GetTransformedObjects(tags, transformations)
local center = MergeTable({}, tags)
center._side = "self"
center._prefix = ""
center.oneway = tags['oneway:bicycle'] or tags.oneway -- give `bicycle:oneway` precedence

local results = { center }

Expand Down

0 comments on commit 2b18e4f

Please sign in to comment.