From a0fbcc372fce6117e5541adb27f7e8bd4fea888d Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Mon, 7 Aug 2017 18:27:11 -0700 Subject: [PATCH 1/3] Use the new z_order to order roads layers --- project.mml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/project.mml b/project.mml index ad3305274b..cb1ac07798 100644 --- a/project.mml +++ b/project.mml @@ -482,7 +482,8 @@ Layer: WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, - COALESCE(layer,0) AS layernotnull + COALESCE(layer,0) AS layernotnull, + z_order FROM planet_osm_line WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') AND highway IS NOT NULL -- end of road select @@ -508,7 +509,8 @@ Layer: construction, CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, 'no' AS link, - COALESCE(layer,0) AS layernotnull + COALESCE(layer,0) AS layernotnull, + z_order FROM planet_osm_line WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select @@ -561,7 +563,7 @@ Layer: USING (feature) ORDER BY layernotnull, - prio, + z_order, CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END, CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END ) AS tunnels @@ -743,7 +745,8 @@ Layer: WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, - COALESCE(layer,0) AS layernotnull + COALESCE(layer,0) AS layernotnull, + z_order FROM planet_osm_line WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage')) AND (covered IS NULL OR NOT covered = 'yes') @@ -771,7 +774,8 @@ Layer: construction, CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, 'no' AS link, - COALESCE(layer,0) AS layernotnull + COALESCE(layer,0) AS layernotnull, + z_order FROM planet_osm_line WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage')) AND (covered IS NULL OR NOT covered = 'yes') @@ -826,7 +830,7 @@ Layer: USING (feature) ORDER BY layernotnull, - prio, + z_order, CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END, CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END ) AS roads_casing @@ -906,7 +910,8 @@ Layer: WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, - COALESCE(layer,0) AS layernotnull + COALESCE(layer,0) AS layernotnull, + z_order FROM planet_osm_line WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage')) AND (covered IS NULL OR NOT covered = 'yes') @@ -934,7 +939,8 @@ Layer: construction, CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, 'no' AS link, - COALESCE(layer,0) AS layernotnull + COALESCE(layer,0) AS layernotnull, + z_order FROM planet_osm_line WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage')) AND (covered IS NULL OR NOT covered = 'yes') @@ -989,7 +995,7 @@ Layer: USING (feature) ORDER BY layernotnull, - prio, + z_order, CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END, CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END ) AS roads_fill @@ -1135,7 +1141,8 @@ Layer: WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, - COALESCE(layer,0) AS layernotnull + COALESCE(layer,0) AS layernotnull, + z_order FROM planet_osm_line WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct') AND highway IS NOT NULL -- end of road select @@ -1161,7 +1168,8 @@ Layer: construction, CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, 'no' AS link, - COALESCE(layer,0) AS layernotnull + COALESCE(layer,0) AS layernotnull, + z_order FROM planet_osm_line WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct') AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select @@ -1214,7 +1222,7 @@ Layer: USING (feature) ORDER BY layernotnull, - prio, + z_order, CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END, CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END ) AS bridges @@ -1931,7 +1939,7 @@ Layer: OR oneway IN ('yes', '-1') OR junction IN ('roundabout')) ORDER BY - prio DESC, -- put important roads first + 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 name DESC, -- Force a consistent ordering between differently named streets From 7487ff0300bf93eaa7daf19d33c7195cf96cfc5d Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Mon, 7 Aug 2017 19:27:00 -0700 Subject: [PATCH 2/3] Check for _link instead of link in roads --- project.mml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/project.mml b/project.mml index cb1ac07798..23c4d73c1f 100644 --- a/project.mml +++ b/project.mml @@ -444,7 +444,7 @@ Layer: table: |- (SELECT way, - (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature, + (CASE WHEN substr(feature, length(feature)-4, 5) = '_link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature, horse, foot, bicycle, @@ -479,7 +479,7 @@ Layer: ELSE 'INT-normal'::text END AS service, CASE - WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' + WHEN substr(highway, length(highway)-4, 5) = '_link' THEN 'yes' ELSE 'no' END AS link, COALESCE(layer,0) AS layernotnull, @@ -707,7 +707,7 @@ Layer: table: |- (SELECT way, - (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature, + (CASE WHEN substr(feature, length(feature)-4, 5) = '_link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature, horse, foot, bicycle, @@ -742,7 +742,7 @@ Layer: ELSE 'INT-normal'::text END AS service, CASE - WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' + WHEN substr(highway, length(highway)-4, 5) = '_link' THEN 'yes' ELSE 'no' END AS link, COALESCE(layer,0) AS layernotnull, @@ -872,7 +872,7 @@ Layer: table: |- (SELECT way, - (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature, + (CASE WHEN substr(feature, length(feature)-4, 5) = '_link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature, horse, foot, bicycle, @@ -907,7 +907,7 @@ Layer: ELSE 'INT-normal'::text END AS service, CASE - WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' + WHEN substr(highway, length(highway)-4, 5) = '_link' THEN 'yes' ELSE 'no' END AS link, COALESCE(layer,0) AS layernotnull, @@ -1052,12 +1052,12 @@ Layer: (SELECT way, COALESCE( - ('highway_' || (CASE WHEN substr(highway, length(highway)-3, 4) = 'link' THEN substr(highway, 0, length(highway)-4) ELSE highway end)), + ('highway_' || (CASE WHEN substr(highway, length(highway)-4, 5) = '_link' THEN substr(highway, 0, length(highway)-4) ELSE highway end)), ('railway_' || (CASE WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' WHEN railway IN ('rail', 'tram', 'light_rail', 'funicular', 'narrow_gauge') THEN railway ELSE NULL END)) ) AS feature, CASE WHEN tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes' THEN 'yes' ELSE 'no' END AS int_tunnel, - CASE WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, + CASE WHEN substr(highway, length(highway)-4, 5) = '_link' THEN 'yes' ELSE 'no' END AS link, CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', @@ -1103,7 +1103,7 @@ Layer: table: |- (SELECT way, - (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature, + (CASE WHEN substr(feature, length(feature)-4, 5) = '_link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature, horse, foot, bicycle, @@ -1138,7 +1138,7 @@ Layer: ELSE 'INT-normal'::text END AS service, CASE - WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' + WHEN substr(highway, length(highway)-4, 5) = '_link' THEN 'yes' ELSE 'no' END AS link, COALESCE(layer,0) AS layernotnull, @@ -1901,7 +1901,7 @@ Layer: table: |- (SELECT way, - CASE WHEN substr(highway, length(highway)-3, 4) = 'link' THEN substr(highway, 0, length(highway)-4) ELSE highway END, + CASE WHEN substr(highway, length(highway)-4, 5) = '_link' THEN substr(highway, 0, length(highway)-4) ELSE highway END, CASE WHEN (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') THEN 'yes' ELSE 'no' END AS tunnel, construction, name, From 1fabf499a76154e229ccc413386742aa290e879e Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Mon, 7 Aug 2017 19:41:40 -0700 Subject: [PATCH 3/3] Remove priority table from roads queries With z_order being used, these are no longer needed --- project.mml | 184 ---------------------------------------------------- 1 file changed, 184 deletions(-) diff --git a/project.mml b/project.mml index 23c4d73c1f..3bb45d6e22 100644 --- a/project.mml +++ b/project.mml @@ -515,52 +515,6 @@ Layer: WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select ) AS features - JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results. - ('railway_rail', 440), - ('railway_INT-preserved-ssy', 430), - ('railway_INT-spur-siding-yard', 430), - ('railway_subway', 420), - ('railway_narrow_gauge', 420), - ('railway_light_rail', 420), - ('railway_preserved', 420), - ('railway_funicular', 420), - ('railway_monorail', 420), - ('railway_miniature', 420), - ('railway_turntable', 420), - ('railway_tram', 410), - ('railway_tram-service', 405), - ('railway_disused', 400), - ('railway_construction', 400), - ('highway_motorway', 380), - ('highway_trunk', 370), - ('highway_primary', 360), - ('highway_secondary', 350), - ('highway_tertiary', 340), - ('highway_residential', 330), - ('highway_unclassified', 330), - ('highway_road', 330), - ('highway_living_street', 320), - ('highway_pedestrian', 310), - ('highway_raceway', 300), - ('highway_motorway_link', 240), - ('highway_trunk_link', 230), - ('highway_primary_link', 220), - ('highway_secondary_link', 210), - ('highway_tertiary_link', 200), - ('highway_service', 150), - ('highway_track', 110), - ('highway_path', 100), - ('highway_footway', 100), - ('highway_bridleway', 100), - ('highway_cycleway', 100), - ('highway_steps', 100), - ('highway_platform', 90), - ('railway_platform', 90), - ('aeroway_runway', 60), - ('aeroway_taxiway', 50), - ('highway_construction', 10) - ) AS ordertable (feature, prio) - USING (feature) ORDER BY layernotnull, z_order, @@ -782,52 +736,6 @@ Layer: AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct')) AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select ) AS features - JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results. - ('railway_rail', 440), - ('railway_INT-preserved-ssy', 430), - ('railway_INT-spur-siding-yard', 430), - ('railway_subway', 420), - ('railway_narrow_gauge', 420), - ('railway_light_rail', 420), - ('railway_preserved', 420), - ('railway_funicular', 420), - ('railway_monorail', 420), - ('railway_miniature', 420), - ('railway_turntable', 420), - ('railway_tram', 410), - ('railway_tram-service', 405), - ('railway_disused', 400), - ('railway_construction', 400), - ('highway_motorway', 380), - ('highway_trunk', 370), - ('highway_primary', 360), - ('highway_secondary', 350), - ('highway_tertiary', 340), - ('highway_residential', 330), - ('highway_unclassified', 330), - ('highway_road', 330), - ('highway_living_street', 320), - ('highway_pedestrian', 310), - ('highway_raceway', 300), - ('highway_motorway_link', 240), - ('highway_trunk_link', 230), - ('highway_primary_link', 220), - ('highway_secondary_link', 210), - ('highway_tertiary_link', 200), - ('highway_service', 150), - ('highway_track', 110), - ('highway_path', 100), - ('highway_footway', 100), - ('highway_bridleway', 100), - ('highway_cycleway', 100), - ('highway_steps', 100), - ('highway_platform', 90), - ('railway_platform', 90), - ('aeroway_runway', 60), - ('aeroway_taxiway', 50), - ('highway_construction', 10) - ) AS ordertable (feature, prio) - USING (feature) ORDER BY layernotnull, z_order, @@ -947,52 +855,6 @@ Layer: AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct')) AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select ) AS features - JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results. - ('railway_rail', 440), - ('railway_INT-preserved-ssy', 430), - ('railway_INT-spur-siding-yard', 430), - ('railway_subway', 420), - ('railway_narrow_gauge', 420), - ('railway_light_rail', 420), - ('railway_preserved', 420), - ('railway_funicular', 420), - ('railway_monorail', 420), - ('railway_miniature', 420), - ('railway_turntable', 420), - ('railway_tram', 410), - ('railway_tram-service', 405), - ('railway_disused', 400), - ('railway_construction', 400), - ('highway_motorway', 380), - ('highway_trunk', 370), - ('highway_primary', 360), - ('highway_secondary', 350), - ('highway_tertiary', 340), - ('highway_residential', 330), - ('highway_unclassified', 330), - ('highway_road', 330), - ('highway_living_street', 320), - ('highway_pedestrian', 310), - ('highway_raceway', 300), - ('highway_motorway_link', 240), - ('highway_trunk_link', 230), - ('highway_primary_link', 220), - ('highway_secondary_link', 210), - ('highway_tertiary_link', 200), - ('highway_service', 150), - ('highway_track', 110), - ('highway_path', 100), - ('highway_footway', 100), - ('highway_bridleway', 100), - ('highway_cycleway', 100), - ('highway_steps', 100), - ('highway_platform', 90), - ('railway_platform', 90), - ('aeroway_runway', 60), - ('aeroway_taxiway', 50), - ('highway_construction', 10) - ) AS ordertable (feature, prio) - USING (feature) ORDER BY layernotnull, z_order, @@ -1174,52 +1036,6 @@ Layer: WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct') AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select ) AS features - JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results. - ('railway_rail', 440), - ('railway_INT-preserved-ssy', 430), - ('railway_INT-spur-siding-yard', 430), - ('railway_subway', 420), - ('railway_narrow_gauge', 420), - ('railway_light_rail', 420), - ('railway_preserved', 420), - ('railway_funicular', 420), - ('railway_monorail', 420), - ('railway_miniature', 420), - ('railway_turntable', 420), - ('railway_tram', 410), - ('railway_tram-service', 405), - ('railway_disused', 400), - ('railway_construction', 400), - ('highway_motorway', 380), - ('highway_trunk', 370), - ('highway_primary', 360), - ('highway_secondary', 350), - ('highway_tertiary', 340), - ('highway_residential', 330), - ('highway_unclassified', 330), - ('highway_road', 330), - ('highway_living_street', 320), - ('highway_pedestrian', 310), - ('highway_raceway', 300), - ('highway_motorway_link', 240), - ('highway_trunk_link', 230), - ('highway_primary_link', 220), - ('highway_secondary_link', 210), - ('highway_tertiary_link', 200), - ('highway_service', 150), - ('highway_track', 110), - ('highway_path', 100), - ('highway_footway', 100), - ('highway_bridleway', 100), - ('highway_cycleway', 100), - ('highway_steps', 100), - ('highway_platform', 90), - ('railway_platform', 90), - ('aeroway_runway', 60), - ('aeroway_taxiway', 50), - ('highway_construction', 10) - ) AS ordertable (feature, prio) - USING (feature) ORDER BY layernotnull, z_order,