From 227b36c0d670228599d207fa5e3301552aba23fc Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Fri, 2 Dec 2016 12:30:41 +0000 Subject: [PATCH] Switch place class back to place value --- layers/place/capital.sql | 8 ++++++++ layers/place/class.sql | 18 ------------------ layers/place/layer.sql | 10 +++++----- layers/place/place.yaml | 23 ++++++----------------- 4 files changed, 19 insertions(+), 40 deletions(-) create mode 100644 layers/place/capital.sql delete mode 100644 layers/place/class.sql diff --git a/layers/place/capital.sql b/layers/place/capital.sql new file mode 100644 index 00000000..e132530c --- /dev/null +++ b/layers/place/capital.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE FUNCTION normalize_capital_level(capital TEXT) +RETURNS INT AS $$ + SELECT CASE + WHEN capital IN ('yes', '2') THEN 2 + WHEN capital = '4' THEN 4 + ELSE NULL + END; +$$ LANGUAGE SQL IMMUTABLE STRICT; diff --git a/layers/place/class.sql b/layers/place/class.sql deleted file mode 100644 index fa349217..00000000 --- a/layers/place/class.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE OR REPLACE FUNCTION place_class(place TEXT) -RETURNS TEXT AS $$ - SELECT CASE - WHEN place IN ('city', 'town', 'village', 'hamlet', 'isolated_dwelling') THEN 'settlement' - WHEN place IN ('suburb', 'neighbourhood') THEN 'subregion' - WHEN place IN ('locality', 'farm') THEN 'other' - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE STRICT; - -CREATE OR REPLACE FUNCTION normalize_capital_level(capital TEXT) -RETURNS INT AS $$ - SELECT CASE - WHEN capital IN ('yes', '2') THEN 2 - WHEN capital = '4' THEN 4 - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE STRICT; diff --git a/layers/place/layer.sql b/layers/place/layer.sql index 053a2601..8b498d16 100644 --- a/layers/place/layer.sql +++ b/layers/place/layer.sql @@ -8,22 +8,22 @@ -- etldoc: layer_city -> layer_place CREATE OR REPLACE FUNCTION layer_place(bbox geometry, zoom_level int, pixel_width numeric) -RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text, subclass text, "rank" int, capital INT) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text, "rank" int, capital INT) AS $$ SELECT osm_id, geometry, name, name_en, - 'continent' AS class, 'continent' AS subclass, 1 AS "rank", NULL::int AS capital + 'continent' AS class, 1 AS "rank", NULL::int AS capital FROM osm_continent_point WHERE geometry && bbox AND zoom_level < 4 UNION ALL SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, - 'country' AS class, 'country' AS subclass,"rank", NULL::int AS capital + 'country' AS class,"rank", NULL::int AS capital FROM osm_country_point WHERE geometry && bbox AND "rank" <= zoom_level AND name <> '' UNION ALL SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, - 'state' AS class, 'state' AS subclass, "rank", NULL::int AS capital + 'state' AS class, "rank", NULL::int AS capital FROM osm_state_point WHERE geometry && bbox AND name <> '' AND @@ -34,7 +34,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t UNION ALL SELECT osm_id, geometry, name, name_en, - place_class(place::text) AS class, place::text AS subclass, "rank", capital + place::text AS class, "rank", capital FROM layer_city(bbox, zoom_level, pixel_width) ORDER BY "rank" ASC $$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/place/place.yaml b/layers/place/place.yaml index 443c268d..afc2533b 100644 --- a/layers/place/place.yaml +++ b/layers/place/place.yaml @@ -16,23 +16,12 @@ layer: values: [2, 4] class: | description: | - Distinguish between continents, countries, states and - places like settlements or smaller entities. - Use this to separately style the different places and build - a text hierarchy according to their importance. - than cities). - values: - - continent - - country - - state - - settlement - - subregion - - other - subclass: - description: | - Use **subclass** to do more precise styling. Original value of the [`place`](http://wiki.openstreetmap.org/wiki/Key:place) tag. + Distinguish between continents, countries, states and + places like settlements or smaller entities. + Use **class** to separately style the different places and build + a text hierarchy according to their importance. values: - continent - country @@ -63,10 +52,10 @@ layer: buffer_size: 128 datasource: geometry_field: geometry - query: (SELECT geometry, name, name_en, class, subclass, rank, capital FROM layer_place(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t + query: (SELECT geometry, name, name_en, class, rank, capital FROM layer_place(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t schema: - ./types.sql - - ./class.sql + - ./capital.sql - ./city.sql - ./merge_country_rank.sql - ./merge_city_rank.sql