From 319180820b7a425e59a367ac670f17948454ab13 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:13:09 +0100 Subject: [PATCH 01/14] Do not calculate surface for railways. --- project.mml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/project.mml b/project.mml index a61e51458..cdd1f2684 100644 --- a/project.mml +++ b/project.mml @@ -718,12 +718,7 @@ Layer: WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END) AS feature, tracktype, - CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', - 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved' - WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', - 'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved' - ELSE NULL - END AS int_surface, + NULL AS int_surface, NULL, construction, CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') OR leisure IN ('slipway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, From eaef26b6ffde8ea6d6e55a66ba3758ace49005fd Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:13:47 +0100 Subject: [PATCH 02/14] Name the value for access in railway branch. --- project.mml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.mml b/project.mml index cdd1f2684..8f1a287a0 100644 --- a/project.mml +++ b/project.mml @@ -719,7 +719,7 @@ Layer: ELSE railway END) AS feature, tracktype, NULL AS int_surface, - NULL, + NULL AS access, construction, CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') OR leisure IN ('slipway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, 'no' AS link, From 226cfdea6a507efc282e756d98ac1c54652f2226 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:14:13 +0100 Subject: [PATCH 03/14] Do not calculate service for railways. --- project.mml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.mml b/project.mml index 8f1a287a0..a19e675a6 100644 --- a/project.mml +++ b/project.mml @@ -721,7 +721,7 @@ Layer: NULL AS int_surface, NULL AS access, construction, - CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') OR leisure IN ('slipway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, + NULL AS service, 'no' AS link, (CASE WHEN tags->'railway:preserved' = 'yes' THEN 'yes' From 118dfa6b48438702ba12efddb0a6f9bee8aa6a51 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:27:05 +0100 Subject: [PATCH 04/14] link is always null for railways. --- project.mml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.mml b/project.mml index a19e675a6..a94cb8334 100644 --- a/project.mml +++ b/project.mml @@ -722,7 +722,7 @@ Layer: NULL AS access, construction, NULL AS service, - 'no' AS link, + NULL AS link, (CASE WHEN tags->'railway:preserved' = 'yes' THEN 'yes' ELSE 'no' From 9788f9b918bdf1b54a34aff8f5eebfec50fab818 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:28:41 +0100 Subject: [PATCH 05/14] preserved is always null for roads. --- project.mml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.mml b/project.mml index a94cb8334..0222384e3 100644 --- a/project.mml +++ b/project.mml @@ -701,7 +701,7 @@ Layer: WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes' ELSE 'no' END AS link, - 'no' AS preserved, + NULL AS preserved, COALESCE(layer,0) AS layernotnull, osm_id, z_order From c7e5e6b29d2c50a009591801892faed5273756c9 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:33:08 +0100 Subject: [PATCH 06/14] All other CASE statements are not parenthesized. --- project.mml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project.mml b/project.mml index 0222384e3..dc6a74b3d 100644 --- a/project.mml +++ b/project.mml @@ -723,10 +723,10 @@ Layer: construction, NULL AS service, NULL AS link, - (CASE + CASE WHEN tags->'railway:preserved' = 'yes' THEN 'yes' ELSE 'no' - END) AS preserved, + END AS preserved, COALESCE(layer,0) AS layernotnull, osm_id, z_order From 9ed3f0b40f0841c9350e0f3309fd735bc958f7c3 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:34:12 +0100 Subject: [PATCH 07/14] Alignment. --- project.mml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.mml b/project.mml index dc6a74b3d..d30bed6d8 100644 --- a/project.mml +++ b/project.mml @@ -688,7 +688,7 @@ Layer: tracktype, CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved' - WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', + WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', 'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved' END AS int_surface, carto_highway_int_access(highway, access, foot, bicycle, horse, tags->'motorcar', tags->'motor_vehicle', tags->'vehicle') AS int_access, From 1bc921977d93eeddadaa2e3a16ee62af1397ccb8 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:38:24 +0100 Subject: [PATCH 08/14] Documentation. --- project.mml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/project.mml b/project.mml index d30bed6d8..5fab99020 100644 --- a/project.mml +++ b/project.mml @@ -665,6 +665,10 @@ Layer: <<: *extents Datasource: <<: *osm2pgsql + # NOTE: There are 3 similar queries: here and in the tunnels and bridges layers. Any change introduced + # in this query must be considered for inclusion in the other two. Changes in the WHERE clause should be + # particularly thought through. + # This is one of the most complex layers, so it bears explaining in some detail # It is necessary to # - Have roads and railways in the same layer to get ordering right From 86019fbf093850ba2d0615fb706adf210905f0ef Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Fri, 1 Nov 2024 08:38:33 +0100 Subject: [PATCH 09/14] Documentation. --- project.mml | 1 + 1 file changed, 1 insertion(+) diff --git a/project.mml b/project.mml index 5fab99020..747581102 100644 --- a/project.mml +++ b/project.mml @@ -791,6 +791,7 @@ Layer: <<: *extents Datasource: <<: *osm2pgsql + # see layer roads-casing table: *roads_sql properties: cache-features: true From f679df96584c8874d69e0f891fff2abf231ae0b3 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Sat, 2 Nov 2024 11:12:04 +0100 Subject: [PATCH 10/14] Copy roads_sql subqueries to tunnels. --- project.mml | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/project.mml b/project.mml index 747581102..a458a5a0d 100644 --- a/project.mml +++ b/project.mml @@ -438,8 +438,14 @@ Layer: <<: *extents Datasource: <<: *osm2pgsql - # This query is quite large, having to deal with both roads, railways. To - # allow for ways that are both railways and roads, a UNION ALL is present. + # NOTE: There are 3 similar queries: here and in the roads-casing and bridges layers. Any change introduced + # in this query must be considered for inclusion in the other two. Changes in the WHERE clause should be + # particularly thought through. + + # This is one of the most complex layers, so it bears explaining in some detail + # It is necessary to + # - Have roads and railways in the same layer to get ordering right + # - Return two linestrings for ways which are both a road and railway table: |- (SELECT way, @@ -453,27 +459,29 @@ Layer: preserved, layernotnull FROM ( -- subselect that contains both roads and rail + SELECT SELECT way, 'highway_' || (CASE WHEN highway = 'path' THEN carto_path_type(bicycle, horse) ELSE highway END) AS feature, tracktype, CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved' - WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', + WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', 'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved' END AS int_surface, carto_highway_int_access(highway, access, foot, bicycle, horse, tags->'motorcar', tags->'motor_vehicle', tags->'vehicle') AS int_access, construction, CASE - WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text + WHEN service IN ('parking_aisle', 'drive-through', 'driveway') OR leisure IN ('slipway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, CASE WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes' ELSE 'no' END AS link, - 'no' as preserved, - COALESCE(layer,0) AS layernotnull, + NULL AS preserved, + COALESCE(layer, 0) AS layernotnull, + osm_id, z_order FROM planet_osm_line WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') @@ -486,16 +494,17 @@ Layer: WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END) AS feature, tracktype, - 'null', - NULL, + NULL AS int_surface, + NULL AS access, construction, - CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, - 'no' AS link, - (CASE + NULL AS service, + NULL AS link, + CASE WHEN tags->'railway:preserved' = 'yes' THEN 'yes' ELSE 'no' - END) AS preserved, - COALESCE(layer,0) AS layernotnull, + END AS preserved, + COALESCE(layer, 0) AS layernotnull, + osm_id, z_order FROM planet_osm_line WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') From f26736c4aa5927154fc2eaf0f66c49f861ee1969 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Sat, 2 Nov 2024 11:13:34 +0100 Subject: [PATCH 11/14] Copy roads_sql subqueries to bridges. --- project.mml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/project.mml b/project.mml index a458a5a0d..c734cb6ef 100644 --- a/project.mml +++ b/project.mml @@ -902,6 +902,14 @@ Layer: <<: *extents Datasource: <<: *osm2pgsql + # NOTE: There are 3 similar queries: here and in the roads-casing and bridges layers. Any change introduced + # in this query must be considered for inclusion in the other two. Changes in the WHERE clause should be + # particularly thought through. + + # This is one of the most complex layers, so it bears explaining in some detail + # It is necessary to + # - Have roads and railways in the same layer to get ordering right + # - Return two linestrings for ways which are both a road and railway table: |- (SELECT way, @@ -921,21 +929,22 @@ Layer: tracktype, CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved' - WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', + WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', 'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved' END AS int_surface, carto_highway_int_access(highway, access, foot, bicycle, horse, tags->'motorcar', tags->'motor_vehicle', tags->'vehicle') AS int_access, construction, CASE - WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text + WHEN service IN ('parking_aisle', 'drive-through', 'driveway') OR leisure IN ('slipway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, CASE WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes' ELSE 'no' END AS link, - 'no' AS preserved, + NULL AS preserved, COALESCE(layer,0) AS layernotnull, + osm_id, z_order FROM planet_osm_line WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct') @@ -948,16 +957,17 @@ Layer: WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END) AS feature, tracktype, - 'null', - NULL, + NULL AS int_surface, + NULL AS access, construction, - CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, - 'no' AS link, - (CASE + NULL AS service, + NULL AS link, + CASE WHEN tags->'railway:preserved' = 'yes' THEN 'yes' ELSE 'no' - END) AS preserved, + END AS preserved, COALESCE(layer,0) AS layernotnull, + osm_id, z_order FROM planet_osm_line WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct') From c87d7d53993f053c42e1d4d806b73958e4861f81 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Sat, 2 Nov 2024 11:14:11 +0100 Subject: [PATCH 12/14] Spurious spaces. --- project.mml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project.mml b/project.mml index c734cb6ef..058bbdc2e 100644 --- a/project.mml +++ b/project.mml @@ -480,7 +480,7 @@ Layer: ELSE 'no' END AS link, NULL AS preserved, - COALESCE(layer, 0) AS layernotnull, + COALESCE(layer,0) AS layernotnull, osm_id, z_order FROM planet_osm_line @@ -503,7 +503,7 @@ Layer: WHEN tags->'railway:preserved' = 'yes' THEN 'yes' ELSE 'no' END AS preserved, - COALESCE(layer, 0) AS layernotnull, + COALESCE(layer,0) AS layernotnull, osm_id, z_order FROM planet_osm_line From fd77973483a09c244c8a6d7157d3e0a6150a79d4 Mon Sep 17 00:00:00 2001 From: Marcos Dione Date: Sat, 2 Nov 2024 11:22:07 +0100 Subject: [PATCH 13/14] Duped SELECT. --- project.mml | 1 - 1 file changed, 1 deletion(-) diff --git a/project.mml b/project.mml index 058bbdc2e..da041486c 100644 --- a/project.mml +++ b/project.mml @@ -459,7 +459,6 @@ Layer: preserved, layernotnull FROM ( -- subselect that contains both roads and rail - SELECT SELECT way, 'highway_' || (CASE WHEN highway = 'path' THEN carto_path_type(bicycle, horse) ELSE highway END) AS feature, From 82d5028216bbb14b7d666ef9acdd8c5b5dd4687d Mon Sep 17 00:00:00 2001 From: imagico Date: Wed, 27 Nov 2024 16:44:09 +0200 Subject: [PATCH 14/14] changing column name from access to int_access --- project.mml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project.mml b/project.mml index da041486c..074c28028 100644 --- a/project.mml +++ b/project.mml @@ -494,7 +494,7 @@ Layer: ELSE railway END) AS feature, tracktype, NULL AS int_surface, - NULL AS access, + NULL AS int_access, construction, NULL AS service, NULL AS link, @@ -731,7 +731,7 @@ Layer: ELSE railway END) AS feature, tracktype, NULL AS int_surface, - NULL AS access, + NULL AS int_access, construction, NULL AS service, NULL AS link, @@ -957,7 +957,7 @@ Layer: ELSE railway END) AS feature, tracktype, NULL AS int_surface, - NULL AS access, + NULL AS int_access, construction, NULL AS service, NULL AS link,