Switch place class back to place value

pull/96/head
Lukas Martinelli 2016-12-02 12:30:41 +00:00
rodzic 7e49a7ebfc
commit 227b36c0d6
4 zmienionych plików z 19 dodań i 40 usunięć

Wyświetl plik

@ -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;

Wyświetl plik

@ -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;

Wyświetl plik

@ -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;

Wyświetl plik

@ -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