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

Add z-order for roads under construction #4075

Merged
merged 1 commit into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions openstreetmap-carto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ local roads_info = {
bridleway = {z = 100, roads = false},
cycleway = {z = 100, roads = false},
steps = {z = 90, roads = false},
platform = {z = 90, roads = false},
construction = {z = 10, roads = false}
platform = {z = 90, roads = false}
},
railway = {
rail = {z = 440, roads = true},
Expand Down Expand Up @@ -252,6 +251,15 @@ function z_order(tags)
z = math.max(z, roads_info[k][v].z)
end
end

if tags["highway"] == "construction" then
if tags["construction"] and roads_info["highway"][tags["construction"]] then
z = math.max(z, roads_info["highway"][tags["construction"]].z/10)
else
z = math.max(z, 33)
end
end

return z ~= 0 and z or nil
end

Expand Down
8 changes: 8 additions & 0 deletions scripts/lua/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ assert(z_order({highway="trunk"}) > z_order({highway="primary"}) , "test failed:
assert(z_order({highway="primary"}) > z_order({highway="secondary"}) , "test failed: primary > secondary")
assert(z_order({highway="secondary"}) > z_order({highway="tertiary"}) , "test failed: secondary > tertiary")

assert(z_order({highway="construction"}) == 33 , "test failed: highway=construction")
assert(z_order({highway="construction", construction="motorway"}) == 38 , "test failed: highway=construction construction=motorway")
assert(z_order({highway="construction", construction="motorway", railway="rail"}) == 440, "test failed: construction motorway + rail")
assert(z_order({highway="construction", construction="service"}) == 15 , "test failed: highway=construction construction=service")

assert(z_order({highway="construction", construction="foo"}) == 33 , "test failed: highway=construction construction=foo")
assert(z_order({highway="motorway", construction="service"}) == 380 , "test failed: highway=construction + construction=service")

print("TESTING: roads")
assert(roads({}) == 0, "test failed: no tags")
assert(roads({foo="bar"}) == 0, "test failed: other tags")
Expand Down