From 14238e986339058b03765ad171e8c0fb7cd6e384 Mon Sep 17 00:00:00 2001 From: Miel Truyen Date: Mon, 10 Aug 2020 18:24:23 +0200 Subject: [PATCH] Attempt at cleaning up the excessive office/industrial POIs, and cleaning up the subtype code while we're at it. (SQL bugs likely) --- layers/poi/class.sql | 6 ++++-- layers/poi/layer.sql | 40 ++++++++++++++++++---------------------- layers/poi/poi.yaml | 4 +++- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/layers/poi/class.sql b/layers/poi/class.sql index 32ed61f..38c40cb 100644 --- a/layers/poi/class.sql +++ b/layers/poi/class.sql @@ -29,8 +29,9 @@ SELECT CASE class WHEN 'car_parking' THEN 300 WHEN 'charging_station' THEN 350 WHEN 'fuel' THEN 350 - WHEN 'bicycle_parking' THEN 390 - WHEN 'motorcycle_parking' THEN 390 + WHEN 'bicycle_parking' THEN 360 + WHEN 'motorcycle_parking' THEN 360 + WHEN 'bank' THEN 380 WHEN 'fast_food' THEN 400 WHEN 'ice_cream' THEN 400 WHEN 'bar' THEN 450 @@ -49,6 +50,7 @@ SELECT CASE class WHEN 'mobile_phone' THEN 700 WHEN 'shoes' THEN 700 WHEN 'clothing_store' THEN 700 + WHEN 'laundry' THEN 700 WHEN 'florist' THEN 750 WHEN 'dog_park' THEN 800 WHEN 'pitch' THEN 800 diff --git a/layers/poi/layer.sql b/layers/poi/layer.sql index b77cd86..b6e6a1c 100644 --- a/layers/poi/layer.sql +++ b/layers/poi/layer.sql @@ -29,17 +29,7 @@ SELECT osm_id_hash AS osm_id, poi_class( subclass, mapping_key, - CASE - WHEN subclass = 'information' - THEN NULLIF(information, '') - WHEN subclass = 'place_of_worship' - THEN NULLIF(religion, '') - WHEN subclass = 'pitch' - THEN NULLIF(sport, '') - WHEN subclass = 'generator' AND mapping_key = 'power' - THEN NULLIF(source, '') - ELSE subclass - END + subtype ) AS class, CASE WHEN subclass = 'information' @@ -63,20 +53,24 @@ SELECT osm_id_hash AS osm_id, ELSE poi_class_rank(poi_class( subclass, mapping_key, - CASE - WHEN subclass = 'information' - THEN NULLIF(information, '') - WHEN subclass = 'place_of_worship' - THEN NULLIF(religion, '') - WHEN subclass = 'pitch' - THEN NULLIF(sport, '') - WHEN subclass = 'generator' AND mapping_key = 'power' - THEN NULLIF(source, '') - ELSE subclass - END + subtype )) END ASC )::int AS "rank" FROM ( + -- Intermediate mapping for subtype and filtering out nameless industrial/office buildings + SELECT *, + CASE + WHEN subclass = 'information' + THEN NULLIF(information, '') + WHEN subclass = 'place_of_worship' + THEN NULLIF(religion, '') + WHEN subclass = 'pitch' + THEN NULLIF(sport, '') + WHEN subclass = 'generator' AND mapping_key = 'power' + THEN NULLIF(source, '') + ELSE subclass + END as subtype + FROM ( -- etldoc: osm_poi_point -> layer_poi:z12 -- etldoc: osm_poi_point -> layer_poi:z13 SELECT *, @@ -125,6 +119,8 @@ FROM ( WHERE geometry && bbox AND zoom_level >= 14 ) AS poi_union + WHERE NOT (mapping_key = 'building' AND (subclass = 'office' OR subclass = 'industrial') AND coalesce(name, name_en, '') = '') +) ORDER BY "rank" $$ LANGUAGE SQL STABLE PARALLEL SAFE; diff --git a/layers/poi/poi.yaml b/layers/poi/poi.yaml index 602fd3d..131cb03 100644 --- a/layers/poi/poi.yaml +++ b/layers/poi/poi.yaml @@ -50,7 +50,7 @@ layer: florist: subclass: ['florist'] town_hall: - subclass: ['townhall', 'public_building', 'courthouse', 'community_centre'] + subclass: ['townhall', 'public_building', 'courthouse'] community_centre: subclass: ['community_centre', 'social_facility'] golf: @@ -143,6 +143,8 @@ layer: subclass: ['wind_mill'] power_tower: subclass: ['tower'] + industry: + subclass: ['industrial'] subclass: description: | Original value of either the