From 8d9a5df48b71da1aabad01c297546ed6a5a2df62 Mon Sep 17 00:00:00 2001 From: golubev Date: Thu, 3 Oct 2019 14:10:36 +0300 Subject: [PATCH 1/7] layers/transportation/: do a tiny code styling (#321) --- layers/transportation/class.sql | 3 +-- layers/transportation/mapping.yaml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/layers/transportation/class.sql b/layers/transportation/class.sql index 3c632f4..28ed41a 100644 --- a/layers/transportation/class.sql +++ b/layers/transportation/class.sql @@ -17,9 +17,8 @@ CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT) RE WHEN highway IN ('secondary', 'secondary_link') THEN 'secondary' WHEN highway IN ('tertiary', 'tertiary_link') THEN 'tertiary' WHEN highway IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor' - WHEN highway IN ('service', 'track') THEN highway WHEN highway IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps', 'bridleway', 'corridor') OR public_transport IN ('platform') THEN 'path' - WHEN highway = 'raceway' THEN 'raceway' + WHEN highway IN ('service', 'track', 'raceway') THEN highway ELSE NULL END; $$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/transportation/mapping.yaml b/layers/transportation/mapping.yaml index facd319..be6ca22 100644 --- a/layers/transportation/mapping.yaml +++ b/layers/transportation/mapping.yaml @@ -187,18 +187,18 @@ tables: - tertiary_link - unclassified - residential - - road - living_street - - raceway - - track - - service - - path - - cycleway - - bridleway - - footway - - corridor + - road - pedestrian + - path + - footway + - cycleway - steps + - bridleway + - corridor + - service + - track + - raceway public_transport: - platform man_made: From 45a50a5bd09d4a09d9d811581e9fafd42d9c74b4 Mon Sep 17 00:00:00 2001 From: golubev Date: Thu, 3 Oct 2019 14:17:44 +0300 Subject: [PATCH 2/7] layers/transportation/: add 'highway=construction' roads (#321) --- layers/transportation/class.sql | 2 +- layers/transportation/mapping.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/layers/transportation/class.sql b/layers/transportation/class.sql index 28ed41a..b15196e 100644 --- a/layers/transportation/class.sql +++ b/layers/transportation/class.sql @@ -18,7 +18,7 @@ CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT) RE WHEN highway IN ('tertiary', 'tertiary_link') THEN 'tertiary' WHEN highway IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor' WHEN highway IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps', 'bridleway', 'corridor') OR public_transport IN ('platform') THEN 'path' - WHEN highway IN ('service', 'track', 'raceway') THEN highway + WHEN highway IN ('service', 'track', 'raceway', 'construction') THEN highway ELSE NULL END; $$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/transportation/mapping.yaml b/layers/transportation/mapping.yaml index be6ca22..7d10ed4 100644 --- a/layers/transportation/mapping.yaml +++ b/layers/transportation/mapping.yaml @@ -199,6 +199,7 @@ tables: - service - track - raceway + - construction public_transport: - platform man_made: From 0636466cfd43ee012d5c41b23bb828402037d53f Mon Sep 17 00:00:00 2001 From: golubev Date: Fri, 4 Oct 2019 13:08:49 +0300 Subject: [PATCH 3/7] layers/transportation/: differentiate roads under construction (#321) --- layers/transportation/class.sql | 15 +++++- layers/transportation/layer.sql | 48 +++++++++---------- layers/transportation/mapping.yaml | 7 ++- .../update_transportation_merge.sql | 38 ++++++++------- 4 files changed, 63 insertions(+), 45 deletions(-) diff --git a/layers/transportation/class.sql b/layers/transportation/class.sql index b15196e..8545430 100644 --- a/layers/transportation/class.sql +++ b/layers/transportation/class.sql @@ -9,7 +9,7 @@ $$ LANGUAGE SQL IMMUTABLE STRICT; -- The classes for highways are derived from the classes used in ClearTables -- https://github.com/ClearTables/ClearTables/blob/master/transportation.lua -CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT) RETURNS TEXT AS $$ +CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT, construction TEXT) RETURNS TEXT AS $$ SELECT CASE WHEN highway IN ('motorway', 'motorway_link') THEN 'motorway' WHEN highway IN ('trunk', 'trunk_link') THEN 'trunk' @@ -18,7 +18,18 @@ CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT) RE WHEN highway IN ('tertiary', 'tertiary_link') THEN 'tertiary' WHEN highway IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor' WHEN highway IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps', 'bridleway', 'corridor') OR public_transport IN ('platform') THEN 'path' - WHEN highway IN ('service', 'track', 'raceway', 'construction') THEN highway + WHEN highway IN ('service', 'track', 'raceway') THEN highway + WHEN highway = 'construction' THEN CASE + WHEN construction IN ('motorway', 'motorway_link') THEN 'motorway_construction' + WHEN construction IN ('trunk', 'trunk_link') THEN 'trunk_construction' + WHEN construction IN ('primary', 'primary_link') THEN 'primary_construction' + WHEN construction IN ('secondary', 'secondary_link') THEN 'secondary_construction' + WHEN construction IN ('tertiary', 'tertiary_link') THEN 'tertiary_construction' + WHEN construction IS NULL OR construction IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor_construction' + WHEN construction IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps', 'bridleway', 'corridor') OR public_transport IN ('platform') THEN 'path_construction' + WHEN construction IN ('service', 'track', 'raceway') THEN CONCAT(highway, '_construction') + ELSE NULL + END ELSE NULL END; $$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 651ea5b..72f3ecf 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -12,7 +12,7 @@ indoor INT, surface TEXT) AS $$ SELECT osm_id, geometry, CASE - WHEN NULLIF(highway, '') IS NOT NULL OR NULLIF(public_transport, '') IS NOT NULL THEN highway_class(highway, public_transport) + WHEN NULLIF(highway, '') IS NOT NULL OR NULLIF(public_transport, '') IS NOT NULL THEN highway_class(highway, public_transport, construction) WHEN NULLIF(railway, '') IS NOT NULL THEN railway_class(railway) WHEN NULLIF(aerialway, '') IS NOT NULL THEN aerialway WHEN NULLIF(shipway, '') IS NOT NULL THEN shipway @@ -21,7 +21,7 @@ indoor INT, surface TEXT) AS $$ CASE WHEN railway IS NOT NULL THEN railway WHEN (highway IS NOT NULL OR public_transport IS NOT NULL) - AND highway_class(highway, public_transport) = 'path' + AND highway_class(highway, public_transport, construction) = 'path' THEN COALESCE(NULLIF(public_transport, ''), highway) ELSE NULL END AS subclass, @@ -39,13 +39,13 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_transportation_merge_linestring_gen7 -> layer_transportation:z4 SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, NULL AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor, - NULL AS surface, + NULL AS surface, z_order FROM osm_transportation_merge_linestring_gen7 WHERE zoom_level = 4 @@ -54,7 +54,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_transportation_merge_linestring_gen6 -> layer_transportation:z5 SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, NULL AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, @@ -68,7 +68,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_transportation_merge_linestring_gen5 -> layer_transportation:z6 SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, NULL AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, @@ -82,7 +82,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_transportation_merge_linestring_gen4 -> layer_transportation:z7 SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, NULL AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, @@ -96,7 +96,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_transportation_merge_linestring_gen3 -> layer_transportation:z8 SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, NULL AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, @@ -111,7 +111,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_highway_linestring_gen2 -> layer_transportation:z10 SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, NULL AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, @@ -126,7 +126,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_highway_linestring_gen1 -> layer_transportation:z11 SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, NULL AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, @@ -143,7 +143,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_highway_linestring -> layer_transportation:z14_ SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, man_made, layer, @@ -158,12 +158,12 @@ indoor INT, surface TEXT) AS $$ FROM osm_highway_linestring WHERE NOT is_area AND ( zoom_level = 12 AND ( - highway_class(highway, public_transport) NOT IN ('track', 'path', 'minor') + highway_class(highway, public_transport, construction) NOT IN ('track', 'path', 'minor') OR highway IN ('unclassified', 'residential') ) AND man_made <> 'pier' OR zoom_level = 13 AND ( - highway_class(highway, public_transport) NOT IN ('track', 'path') AND man_made <> 'pier' + highway_class(highway, public_transport, construction) NOT IN ('track', 'path') AND man_made <> 'pier' OR man_made = 'pier' AND NOT ST_IsClosed(geometry) ) @@ -179,7 +179,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_railway_linestring_gen5 -> layer_transportation:z8 SELECT osm_id, geometry, - NULL AS highway, railway, NULL AS aerialway, NULL AS shipway, + NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, service_value(service) AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, @@ -194,7 +194,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_railway_linestring_gen4 -> layer_transportation:z9 SELECT osm_id, geometry, - NULL AS highway, railway, NULL AS aerialway, NULL AS shipway, + NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, service_value(service) AS service, NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, NULL::boolean AS is_ford, @@ -209,7 +209,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_railway_linestring_gen3 -> layer_transportation:z10 SELECT osm_id, geometry, - NULL AS highway, railway, NULL AS aerialway, NULL AS shipway, + NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, @@ -222,7 +222,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_railway_linestring_gen2 -> layer_transportation:z11 SELECT osm_id, geometry, - NULL AS highway, railway, NULL AS aerialway, NULL AS shipway, + NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, @@ -235,7 +235,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_railway_linestring_gen1 -> layer_transportation:z12 SELECT osm_id, geometry, - NULL AS highway, railway, NULL AS aerialway, NULL AS shipway, + NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, @@ -249,7 +249,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_railway_linestring -> layer_transportation:z14_ SELECT osm_id, geometry, - NULL AS highway, railway, NULL AS aerialway, NULL AS shipway, + NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, @@ -263,7 +263,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_aerialway_linestring_gen1 -> layer_transportation:z12 SELECT osm_id, geometry, - NULL AS highway, NULL as railway, aerialway, NULL AS shipway, + NULL AS highway, NULL AS construction, NULL as railway, aerialway, NULL AS shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, @@ -276,7 +276,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_aerialway_linestring -> layer_transportation:z14_ SELECT osm_id, geometry, - NULL AS highway, NULL as railway, aerialway, NULL AS shipway, + NULL AS highway, NULL AS construction, NULL as railway, aerialway, NULL AS shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, @@ -288,7 +288,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_shipway_linestring_gen2 -> layer_transportation:z11 SELECT osm_id, geometry, - NULL AS highway, NULL AS railway, NULL AS aerialway, shipway, + NULL AS highway, NULL AS construction, NULL AS railway, NULL AS aerialway, shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, @@ -300,7 +300,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_shipway_linestring_gen1 -> layer_transportation:z12 SELECT osm_id, geometry, - NULL AS highway, NULL AS railway, NULL AS aerialway, shipway, + NULL AS highway, NULL AS construction, NULL AS railway, NULL AS aerialway, shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, @@ -313,7 +313,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_shipway_linestring -> layer_transportation:z14_ SELECT osm_id, geometry, - NULL AS highway, NULL AS railway, NULL AS aerialway, shipway, + NULL AS highway, NULL AS construction, NULL AS railway, NULL AS aerialway, shipway, NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, diff --git a/layers/transportation/mapping.yaml b/layers/transportation/mapping.yaml index 7d10ed4..e4e8f7b 100644 --- a/layers/transportation/mapping.yaml +++ b/layers/transportation/mapping.yaml @@ -45,13 +45,13 @@ generalized_tables: # etldoc: imposm3 -> osm_highway_linestring_gen2 highway_linestring_gen2: source: highway_linestring_gen1 - sql_filter: highway IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link') AND NOT is_area + sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link')) AND NOT is_area tolerance: ZRES11 # etldoc: imposm3 -> osm_highway_linestring_gen1 highway_linestring_gen1: source: highway_linestring - sql_filter: highway IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') AND NOT is_area AND ST_IsValid(geometry) + sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link')) AND NOT is_area AND ST_IsValid(geometry) tolerance: ZRES12 name_field: &name @@ -150,6 +150,9 @@ tables: - name: highway key: highway type: string + - name: construction + key: construction + type: string - *ref - *network - *z_order diff --git a/layers/transportation/update_transportation_merge.sql b/layers/transportation/update_transportation_merge.sql index 36d0931..06ef1e8 100644 --- a/layers/transportation/update_transportation_merge.sql +++ b/layers/transportation/update_transportation_merge.sql @@ -22,14 +22,14 @@ CREATE INDEX IF NOT EXISTS osm_highway_linestring_highway_idx -- Improve performance of the sql below CREATE INDEX IF NOT EXISTS osm_highway_linestring_highway_partial_idx ON osm_highway_linestring(highway) - WHERE highway IN ('motorway','trunk', 'primary'); + WHERE highway IN ('motorway','trunk', 'primary', 'construction'); -- etldoc: osm_highway_linestring -> osm_transportation_merge_linestring CREATE MATERIALIZED VIEW osm_transportation_merge_linestring AS ( SELECT (ST_Dump(geometry)).geom AS geometry, NULL::bigint AS osm_id, - highway, + highway, construction, z_order FROM ( SELECT @@ -37,7 +37,8 @@ CREATE MATERIALIZED VIEW osm_transportation_merge_linestring AS ( highway, min(z_order) AS z_order FROM osm_highway_linestring - WHERE highway IN ('motorway','trunk', 'primary') AND ST_IsValid(geometry) + WHERE (highway IN ('motorway','trunk', 'primary') OR highway = 'construction' AND construction IN ('motorway','trunk', 'primary')) + AND ST_IsValid(geometry) group by highway ) AS highway_union ); @@ -45,61 +46,64 @@ CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_geometry_idx ON osm_transportation_merge_linestring USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_highway_partial_idx ON osm_transportation_merge_linestring(highway) - WHERE highway IN ('motorway','trunk', 'primary'); + WHERE highway IN ('motorway','trunk', 'primary', 'construction'); -- etldoc: osm_transportation_merge_linestring -> osm_transportation_merge_linestring_gen3 CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen3 AS ( - SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, highway, z_order + SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, highway, construction, z_order FROM osm_transportation_merge_linestring WHERE highway IN ('motorway','trunk', 'primary') + OR highway = 'construction' AND construction IN ('motorway','trunk', 'primary') ); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen3_geometry_idx ON osm_transportation_merge_linestring_gen3 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen3_highway_partial_idx ON osm_transportation_merge_linestring_gen3(highway) - WHERE highway IN ('motorway','trunk', 'primary'); + WHERE highway IN ('motorway','trunk', 'primary', 'construction'); -- etldoc: osm_transportation_merge_linestring_gen3 -> osm_transportation_merge_linestring_gen4 CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen4 AS ( - SELECT ST_Simplify(geometry, 200) AS geometry, osm_id, highway, z_order + SELECT ST_Simplify(geometry, 200) AS geometry, osm_id, highway, construction, z_order FROM osm_transportation_merge_linestring_gen3 - WHERE highway IN ('motorway','trunk', 'primary') AND ST_Length(geometry) > 50 + WHERE (highway IN ('motorway','trunk', 'primary') OR highway = 'construction' AND construction IN ('motorway','trunk', 'primary')) + AND ST_Length(geometry) > 50 ); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen4_geometry_idx ON osm_transportation_merge_linestring_gen4 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen4_highway_partial_idx ON osm_transportation_merge_linestring_gen4(highway) - WHERE highway IN ('motorway','trunk', 'primary'); + WHERE highway IN ('motorway','trunk', 'primary', 'construction'); -- etldoc: osm_transportation_merge_linestring_gen4 -> osm_transportation_merge_linestring_gen5 CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen5 AS ( - SELECT ST_Simplify(geometry, 500) AS geometry, osm_id, highway, z_order + SELECT ST_Simplify(geometry, 500) AS geometry, osm_id, highway, construction, z_order FROM osm_transportation_merge_linestring_gen4 - WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 100 + WHERE (highway IN ('motorway','trunk') OR highway = 'construction' AND construction IN ('motorway','trunk')) + AND ST_Length(geometry) > 100 ); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen5_geometry_idx ON osm_transportation_merge_linestring_gen5 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen5_highway_partial_idx ON osm_transportation_merge_linestring_gen5(highway) - WHERE highway IN ('motorway', 'trunk'); + WHERE highway IN ('motorway','trunk', 'construction'); -- etldoc: osm_transportation_merge_linestring_gen5 -> osm_transportation_merge_linestring_gen6 CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen6 AS ( - SELECT ST_Simplify(geometry, 1000) AS geometry, osm_id, highway, z_order + SELECT ST_Simplify(geometry, 1000) AS geometry, osm_id, highway, construction, z_order FROM osm_transportation_merge_linestring_gen5 - WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 500 + WHERE (highway IN ('motorway','trunk') OR highway = 'construction' AND construction IN ('motorway','trunk')) AND ST_Length(geometry) > 500 ); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen6_geometry_idx ON osm_transportation_merge_linestring_gen6 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen6_highway_partial_idx ON osm_transportation_merge_linestring_gen6(highway) - WHERE highway IN ('motorway','trunk'); + WHERE highway IN ('motorway','trunk', 'construction'); -- etldoc: osm_transportation_merge_linestring_gen6 -> osm_transportation_merge_linestring_gen7 CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen7 AS ( - SELECT ST_Simplify(geometry, 2000) AS geometry, osm_id, highway, z_order + SELECT ST_Simplify(geometry, 2000) AS geometry, osm_id, highway, construction, z_order FROM osm_transportation_merge_linestring_gen6 - WHERE highway IN ('motorway') AND ST_Length(geometry) > 1000 + WHERE (highway = 'motorway' OR highway = 'construction' AND construction = 'motorway') AND ST_Length(geometry) > 1000 ); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen7_geometry_idx ON osm_transportation_merge_linestring_gen7 USING gist(geometry); From 81c90be19bc6f5c4cb080689611cd0458b3eec2d Mon Sep 17 00:00:00 2001 From: golubev Date: Fri, 4 Oct 2019 14:00:14 +0300 Subject: [PATCH 4/7] layers/transportation/: fix SQL mistakes, modify indices (#321) --- layers/transportation/layer.sql | 2 +- .../transportation/update_transportation_merge.sql | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 72f3ecf..9868768 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -330,7 +330,7 @@ indoor INT, surface TEXT) AS $$ -- etldoc: osm_highway_polygon -> layer_transportation:z14_ SELECT osm_id, geometry, - highway, NULL AS railway, NULL AS aerialway, NULL AS shipway, + highway, NULL AS construction, NULL AS railway, NULL AS aerialway, NULL AS shipway, public_transport, NULL AS service, CASE WHEN man_made IN ('bridge') THEN TRUE ELSE FALSE diff --git a/layers/transportation/update_transportation_merge.sql b/layers/transportation/update_transportation_merge.sql index 06ef1e8..a2c1852 100644 --- a/layers/transportation/update_transportation_merge.sql +++ b/layers/transportation/update_transportation_merge.sql @@ -34,18 +34,18 @@ CREATE MATERIALIZED VIEW osm_transportation_merge_linestring AS ( FROM ( SELECT ST_LineMerge(ST_Collect(geometry)) AS geometry, - highway, + highway, construction, min(z_order) AS z_order FROM osm_highway_linestring WHERE (highway IN ('motorway','trunk', 'primary') OR highway = 'construction' AND construction IN ('motorway','trunk', 'primary')) AND ST_IsValid(geometry) - group by highway + group by highway, construction ) AS highway_union ); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_geometry_idx ON osm_transportation_merge_linestring USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_highway_partial_idx - ON osm_transportation_merge_linestring(highway) + ON osm_transportation_merge_linestring(highway, construction) WHERE highway IN ('motorway','trunk', 'primary', 'construction'); -- etldoc: osm_transportation_merge_linestring -> osm_transportation_merge_linestring_gen3 @@ -58,7 +58,7 @@ CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen3 AS ( CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen3_geometry_idx ON osm_transportation_merge_linestring_gen3 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen3_highway_partial_idx - ON osm_transportation_merge_linestring_gen3(highway) + ON osm_transportation_merge_linestring_gen3(highway, construction) WHERE highway IN ('motorway','trunk', 'primary', 'construction'); -- etldoc: osm_transportation_merge_linestring_gen3 -> osm_transportation_merge_linestring_gen4 @@ -71,7 +71,7 @@ CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen4 AS ( CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen4_geometry_idx ON osm_transportation_merge_linestring_gen4 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen4_highway_partial_idx - ON osm_transportation_merge_linestring_gen4(highway) + ON osm_transportation_merge_linestring_gen4(highway, construction) WHERE highway IN ('motorway','trunk', 'primary', 'construction'); -- etldoc: osm_transportation_merge_linestring_gen4 -> osm_transportation_merge_linestring_gen5 @@ -84,7 +84,7 @@ CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen5 AS ( CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen5_geometry_idx ON osm_transportation_merge_linestring_gen5 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen5_highway_partial_idx - ON osm_transportation_merge_linestring_gen5(highway) + ON osm_transportation_merge_linestring_gen5(highway, construction) WHERE highway IN ('motorway','trunk', 'construction'); -- etldoc: osm_transportation_merge_linestring_gen5 -> osm_transportation_merge_linestring_gen6 @@ -96,7 +96,7 @@ CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen6 AS ( CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen6_geometry_idx ON osm_transportation_merge_linestring_gen6 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen6_highway_partial_idx - ON osm_transportation_merge_linestring_gen6(highway) + ON osm_transportation_merge_linestring_gen6(highway, construction) WHERE highway IN ('motorway','trunk', 'construction'); -- etldoc: osm_transportation_merge_linestring_gen6 -> osm_transportation_merge_linestring_gen7 From 73307a610b802930d51c79441b0a7006f57be17b Mon Sep 17 00:00:00 2001 From: golubev Date: Fri, 4 Oct 2019 14:50:05 +0300 Subject: [PATCH 5/7] layers/transportation_name/: add roads under construction, fix SQL error (#321) --- layers/transportation_name/layer.sql | 11 ++++-- .../update_transportation_name.sql | 37 ++++++++++--------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/layers/transportation_name/layer.sql b/layers/transportation_name/layer.sql index 0cfb45a..9f108d6 100644 --- a/layers/transportation_name/layer.sql +++ b/layers/transportation_name/layer.sql @@ -19,9 +19,9 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, when length(coalesce(ref, ''))>0 then 'road' end as network, - highway_class(highway, '') AS class, + highway_class(highway, '', construction) AS class, CASE - WHEN highway IS NOT NULL AND highway_class(highway, '') = 'path' + WHEN highway IS NOT NULL AND highway_class(highway, '', construction) = 'path' THEN highway ELSE NULL END AS subclass, @@ -70,6 +70,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, "tags", ref, highway, + construction, network, z_order, layer, @@ -78,7 +79,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, FROM osm_transportation_name_linestring WHERE zoom_level = 12 AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) - AND highway_class(highway, '') NOT IN ('minor', 'track', 'path') + AND highway_class(highway, '', construction) NOT IN ('minor', 'track', 'path') AND NOT highway_is_link(highway) UNION ALL @@ -92,6 +93,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, "tags", ref, highway, + construction, network, z_order, layer, @@ -100,7 +102,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, FROM osm_transportation_name_linestring WHERE zoom_level = 13 AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) - AND highway_class(highway, '') NOT IN ('track', 'path') + AND highway_class(highway, '', construction) NOT IN ('track', 'path') UNION ALL -- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z14_ @@ -113,6 +115,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, "tags", ref, highway, + construction, network, z_order, layer, diff --git a/layers/transportation_name/update_transportation_name.sql b/layers/transportation_name/update_transportation_name.sql index 82a49dc..58a521f 100644 --- a/layers/transportation_name/update_transportation_name.sql +++ b/layers/transportation_name/update_transportation_name.sql @@ -24,6 +24,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_network AS ( else hl.ref end as ref, hl.highway, + hl.construction, CASE WHEN highway IN ('footway', 'steps') THEN layer ELSE NULL::int END AS layer, @@ -53,6 +54,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS ( tags || get_basic_names(tags, geometry) AS "tags", ref, highway, + construction, "level", layer, indoor, @@ -68,6 +70,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS ( AS "tags", ref, highway, + construction, "level", layer, indoor, @@ -77,56 +80,56 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS ( WHERE ("rank"=1 OR "rank" is null) AND (name <> '' OR ref <> '') AND NULLIF(highway, '') IS NOT NULL - group by name, name_en, name_de, ref, highway, "level", layer, indoor, network_type + group by name, name_en, name_de, ref, highway, construction, "level", layer, indoor, network_type ) AS highway_union ); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_geometry_idx ON osm_transportation_name_linestring USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_highway_partial_idx - ON osm_transportation_name_linestring(highway) - WHERE highway IN ('motorway','trunk'); + ON osm_transportation_name_linestring(highway, construction) + WHERE highway IN ('motorway','trunk', 'construction'); -- etldoc: osm_transportation_name_linestring -> osm_transportation_name_linestring_gen1 CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen1 AS ( - SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, name, name_en, name_de, tags, ref, highway, network, z_order + SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, name, name_en, name_de, tags, ref, highway, construction, network, z_order FROM osm_transportation_name_linestring - WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000 + WHERE (highway IN ('motorway','trunk') OR highway = 'construction' AND construction IN ('motorway','trunk')) AND ST_Length(geometry) > 8000 ); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_geometry_idx ON osm_transportation_name_linestring_gen1 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_highway_partial_idx - ON osm_transportation_name_linestring_gen1(highway) - WHERE highway IN ('motorway','trunk'); + ON osm_transportation_name_linestring_gen1(highway, construction) + WHERE highway IN ('motorway','trunk', 'construction'); -- etldoc: osm_transportation_name_linestring_gen1 -> osm_transportation_name_linestring_gen2 CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen2 AS ( - SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, name, name_en, name_de, tags, ref, highway, network, z_order + SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, name, name_en, name_de, tags, ref, highway, construction, network, z_order FROM osm_transportation_name_linestring_gen1 - WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000 + WHERE (highway IN ('motorway','trunk') OR highway = 'construction' AND construction IN ('motorway','trunk')) AND ST_Length(geometry) > 14000 ); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_geometry_idx ON osm_transportation_name_linestring_gen2 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_highway_partial_idx - ON osm_transportation_name_linestring_gen2(highway) - WHERE highway = 'motorway'; + ON osm_transportation_name_linestring_gen2(highway, construction) + WHERE highway IN ('motorway','trunk', 'construction'); -- etldoc: osm_transportation_name_linestring_gen2 -> osm_transportation_name_linestring_gen3 CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen3 AS ( - SELECT ST_Simplify(geometry, 200) AS geometry, osm_id, name, name_en, name_de, tags, ref, highway, network, z_order + SELECT ST_Simplify(geometry, 200) AS geometry, osm_id, name, name_en, name_de, tags, ref, highway, construction, network, z_order FROM osm_transportation_name_linestring_gen2 - WHERE highway = 'motorway' AND ST_Length(geometry) > 20000 + WHERE (highway = 'motorway' OR highway = 'construction' AND construction = 'motorway') AND ST_Length(geometry) > 20000 ); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_geometry_idx ON osm_transportation_name_linestring_gen3 USING gist(geometry); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_highway_partial_idx - ON osm_transportation_name_linestring_gen3(highway) - WHERE highway = 'motorway'; + ON osm_transportation_name_linestring_gen3(highway, construction) + WHERE highway IN ('motorway', 'construction'); -- etldoc: osm_transportation_name_linestring_gen3 -> osm_transportation_name_linestring_gen4 CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen4 AS ( - SELECT ST_Simplify(geometry, 500) AS geometry, osm_id, name, name_en, name_de, tags, ref, highway, network, z_order + SELECT ST_Simplify(geometry, 500) AS geometry, osm_id, name, name_en, name_de, tags, ref, highway, construction, network, z_order FROM osm_transportation_name_linestring_gen3 - WHERE highway = 'motorway' AND ST_Length(geometry) > 20000 + WHERE (highway = 'motorway' OR highway = 'construction' AND construction = 'motorway') AND ST_Length(geometry) > 20000 ); CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen4_geometry_idx ON osm_transportation_name_linestring_gen4 USING gist(geometry); From e74bfb67b401e6341aa25ec7b5675eff0b70ac7a Mon Sep 17 00:00:00 2001 From: golubev Date: Fri, 4 Oct 2019 15:19:56 +0300 Subject: [PATCH 6/7] update transportation layers doc (#321) --- layers/transportation/transportation.yaml | 13 ++++++++++++- layers/transportation_name/transportation_name.yaml | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index 83505d3..61f7499 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -14,9 +14,10 @@ layer: fields: class: description: | - Distinguish between more and less important roads or railways. + Distinguish between more and less important roads or railways and roads under construction. Class is derived from the value of the [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway), + [`construction`](http://wiki.openstreetmap.org/wiki/Key:construction), [`railway`](http://wiki.openstreetmap.org/wiki/Key:railway), [`aerialway`](http://wiki.openstreetmap.org/wiki/Key:aerialway), [`route`](http://wiki.openstreetmap.org/wiki/Key:route) tag (for @@ -33,6 +34,16 @@ layer: - track - path - raceway + - motorway_construction + - trunk_construction + - primary_construction + - secondary_construction + - tertiary_construction + - minor_construction + - service_construction + - track_construction + - path_construction + - raceway_construction - rail - transit - cable_car diff --git a/layers/transportation_name/transportation_name.yaml b/layers/transportation_name/transportation_name.yaml index 263032c..746ec50 100644 --- a/layers/transportation_name/transportation_name.yaml +++ b/layers/transportation_name/transportation_name.yaml @@ -29,7 +29,7 @@ layer: - road (default) class: description: | - Distinguish between more and less important roads. + Distinguish between more and less important roads and roads under construction. values: - motorway - trunk @@ -41,6 +41,16 @@ layer: - track - path - raceway + - motorway_construction + - trunk_construction + - primary_construction + - secondary_construction + - tertiary_construction + - minor_construction + - service_construction + - track_construction + - path_construction + - raceway_construction - rail - transit subclass: From 4251701858bbf11de9863e62b1cb9a9efcd48776 Mon Sep 17 00:00:00 2001 From: golubev Date: Mon, 7 Oct 2019 14:15:45 +0300 Subject: [PATCH 7/7] layers/transportation/class.sql: fix up empty value issue (#321) --- layers/transportation/class.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layers/transportation/class.sql b/layers/transportation/class.sql index 8545430..187b5f8 100644 --- a/layers/transportation/class.sql +++ b/layers/transportation/class.sql @@ -25,7 +25,7 @@ CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT, co WHEN construction IN ('primary', 'primary_link') THEN 'primary_construction' WHEN construction IN ('secondary', 'secondary_link') THEN 'secondary_construction' WHEN construction IN ('tertiary', 'tertiary_link') THEN 'tertiary_construction' - WHEN construction IS NULL OR construction IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor_construction' + WHEN construction = '' OR construction IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor_construction' WHEN construction IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps', 'bridleway', 'corridor') OR public_transport IN ('platform') THEN 'path_construction' WHEN construction IN ('service', 'track', 'raceway') THEN CONCAT(highway, '_construction') ELSE NULL