Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix layering order for highway=construction by adding z-order for construction=* values #4055

Closed
wants to merge 12 commits into from
Closed
30 changes: 29 additions & 1 deletion openstreetmap-carto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ local roads_info = {
cycleway = {z = 100, roads = false},
steps = {z = 90, roads = false},
platform = {z = 90, roads = false},
construction = {z = 10, roads = false}
},
railway = {
rail = {z = 440, roads = true},
Expand All @@ -237,6 +236,32 @@ local roads_info = {
runway = {z = 60, roads = false},
taxiway = {z = 50, roads = false},
},
construction = {
motorway = {z = 38, roads = true},
trunk = {z = 37, roads = true},
primary = {z = 36, roads = true},
secondary = {z = 35, roads = true},
tertiary = {z = 34, roads = false},
residential = {z = 33, roads = false},
unclassified = {z = 33, roads = false},
road = {z = 33, roads = false},
living_street = {z = 32, roads = false},
pedestrian = {z = 31, roads = false},
raceway = {z = 30, roads = false},
motorway_link = {z = 24, roads = true},
trunk_link = {z = 23, roads = true},
primary_link = {z = 22, roads = true},
secondary_link = {z = 21, roads = true},
tertiary_link = {z = 20, roads = false},
service = {z = 15, roads = false},
track = {z = 11, roads = false},
path = {z = 10, roads = false},
footway = {z = 10, roads = false},
bridleway = {z = 10, roads = false},
cycleway = {z = 10, roads = false},
steps = {z = 9, roads = false},
platform = {z = 9, roads = false},
},
boundary = {
administrative = {z = 0, roads = true}
},
Expand All @@ -256,6 +281,9 @@ function z_order(tags)
if roads_info[k] and roads_info[k][v] then
z = math.max(z, roads_info[k][v].z)
end
if not tags["construction"] then
z = 33
end
end
return z ~= 0 and z or nil
end
Expand Down
1 change: 1 addition & 0 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,7 @@ Layer:
OR oneway IN ('yes', '-1')
OR junction IN ('roundabout'))
ORDER BY
CASE WHEN highway IN ('construction') THEN 0 ELSE 1 END, -- put highway=construction last
z_order DESC, -- put important roads first
COALESCE(layer, 0), -- put top layered roads first
length(name) DESC, -- Try to fit big labels in first
Expand Down
4 changes: 4 additions & 0 deletions scripts/lua/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ assert(z_order({}) == nil, "test failed: no tags")
assert(z_order({foo="bar"}) == nil, "test failed: other tags")
assert(z_order({highway="motorway"}) == 380 , "test failed: motorway")
assert(z_order({highway="motorway", railway="rail"}) == 440 , "test failed: motorway + rail")
assert(z_order({highway="motorway", construction="motorway"}) == 380 , "test failed: highway=construction + construction=service")
assert(z_order({highway="construction", construction=motorway}) == 38 , "test failed: highway=construction")
assert(z_order({highway="construction", construction="service"}) == 15 , "test failed: highway=construction + construction=service")
assert(z_order({highway="construction", construction=null}) == 33 , "test failed: highway=construction with null construction=*")

assert(z_order({highway="motorway"}) > z_order({highway="motorway_link"}) , "test failed: motorway_link")
assert(z_order({highway="trunk"}) > z_order({highway="trunk_link"}) , "test failed: trunk_link")
Expand Down