From 73307a610b802930d51c79441b0a7006f57be17b Mon Sep 17 00:00:00 2001 From: golubev Date: Fri, 4 Oct 2019 14:50:05 +0300 Subject: [PATCH] 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 0cfb45a2..9f108d68 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 82a49dc9..58a521f7 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);