Closed sensescape closed 11 years ago
/* One-way for cars, effectively one-way for bikes */
.line[oneway='yes'][highway!='motorway'][highway!='motorway_link'][cycleway!='opposite'][cycleway!='opposite_lane'][cycleway!='opposite_track'],
.line[oneway='true'][highway!='motorway'][highway!='motorway_link'][cycleway!='opposite'][cycleway!='opposite_lane'][cycleway!='opposite_track'],
.line[oneway='1'][highway!='motorway'][highway!='motorway_link'][cycleway!='opposite'][cycleway!='opposite_lane'][cycleway!='opposite_track'],
{
[zoom>=16]
{
::overlay
{
line-pattern-file: url("images/oneway_right.png");
}
}
}
.line[oneway='-1'][highway!='motorway'][highway!='motorway_link'][cycleway!='opposite'][cycleway!='opposite_lane'][cycleway!='opposite_track'],
{
[zoom>=16]
{
::overlay
{
line-pattern-file: url("images/oneway_left.png");
}
}
}
/* Explicitly one-way for bikes */
.line['oneway:bicycle'='yes'],
.line['oneway:bicycle'='true'],
.line['oneway:bicycle'='1'],
{
[zoom>=16]
{
::overlay
{
line-pattern-file: url("images/oneway_right.png");
}
}
}
.line['oneway:bicycle'='-1'],
{
[zoom>=16]
{
::overlay
{
line-pattern-file: url("images/oneway_left.png");
}
}
}
-- Explanation of how oneway is determined for bikes.
-- Determining whether a way is oneway for bikes requires considering several tags:
-- highway, junction, oneway, oneway:bicycle, cycleway, cycleway:left, cycleway:right
-- The following way of parsing is what we have arrived at so far, and is verified up by a series of cucumber test
-- located in features/bicycle/. However it's complex, and it's possible that it could be improved :-)
-- The parsing can be summarized as the following list of checks. The first that passed will apply.
-- oneway:bicycle?
-- cycleway=opposite*?
-- cycleway:left and/or cycleway:right?
-- oneway?
-- implied oneway?
-- The detailed explanation below is written as comments to the actual LUA code used by the route engine for parsing OSM data.
-- By default a way is supposed to be bidirectional (not oneway).
-- But several way types implies that the way is in fact oneway:
local impliedOneway = false
if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
impliedOneway = true
end
-- Note that a roundabout is specified using the junction tag.
-- The standard way to specify oneway is with the onway and oneway:bicycle tags, which overrides the default/implied oneway status.
-- oneway:bicycle takes precedence over all other things, including way types, bike tracks, etc.
-- The oneway direction is specified relative to the direction the OSM way is drawn. Several values are valid:
-- forward: yes, 1, true
-- backward: -1
-- not a oneway: no, 0, false
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
-- So far so good.
-- Things are now complicated by the fact that a cycle track or lane in the opposite direction of a oneway street
-- implies that bikes can in fact go in both direction (so the way is not oneway for bikes).
-- The following values specifies a lane or track in the opposite direction, and thus makes the way not oneway:
-- cycleway=opposite_lane
-- cycleway=opposite_track
-- cycleway=opposite
-- Note that the following values normally means a track/lane in both sides:
-- cycleway=track
-- cycleway=lane
-- However, when a way is onway, it's assumed that the track/lane is only in the direction you can move,
-- so the value does not make a oneway traversible in both directions.
elseif cycleway and string.find(cycleway, "opposite") == 1 then
if impliedOneway then
way.direction = Way.opposite
else
way.direction = Way.bidirectional
end
-- Another twist is that cycleway:left and/or cycleway:right could be used instead of cycleway to specify
-- which sides tracks/lane is present, and this in which direction you can move.
-- left/rigth side is relative to the direction the OSM way is drawn.
elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then
way.direction = Way.bidirectional
elseif cycleway_left and cycleway_tags[cycleway_left] then
if impliedOneway then
way.direction = Way.opposite
else
way.direction = Way.bidirectional
end
elseif cycleway_right and cycleway_tags[cycleway_right] then
if impliedOneway then
way.direction = Way.oneway
else
way.direction = Way.bidirectional
end
-- If none of the above applied, look at the good ol' oneway tag
-- The last fallback is the implied value.
-- If that doesn't apply either, the way is assumed to be traversible in both directions.
elseif oneway == "-1" then
way.direction = Way.opposite
elseif oneway == "yes" or oneway == "1" or oneway == "true" then
way.direction = Way.oneway
end
done
Same way it is indicated on maps for cars
Emil will send us email on how to filter these out
Oneway - show only when its oneway for bike