Use classes from ClearTables and add continents

This commit is contained in:
Lukas Martinelli
2016-11-28 15:42:13 +00:00
parent aed323bb99
commit 2f35ab3ee1
8 changed files with 88 additions and 31 deletions

18
layers/place/class.sql Normal file
View File

@@ -0,0 +1,18 @@
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;