From 584ba447945629db739a7640c8f48a104ac1b380 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sat, 14 Mar 2020 08:29:59 -0700 Subject: [PATCH] Add z-order for roads under construction --- openstreetmap-carto.lua | 12 ++++++++++-- scripts/lua/test.lua | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 441f1dbe5b..8dbca62a64 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -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}, @@ -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 diff --git a/scripts/lua/test.lua b/scripts/lua/test.lua index cfa967bbca..9f7962fc48 100644 --- a/scripts/lua/test.lua +++ b/scripts/lua/test.lua @@ -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")