pull/96/head
Lukas Martinelli 2016-12-02 14:37:48 +00:00
rodzic e7665db266
commit 01db9a4e63
5 zmienionych plików z 63 dodań i 1 usunięć

Wyświetl plik

@ -0,0 +1,5 @@
-- etldoc: osm_island_polygon -> osm_island_polygon
UPDATE osm_island_polygon SET geometry=topoint(geometry)
WHERE ST_GeometryType(geometry) <> 'ST_Point';
ANALYZE osm_island_polygon;

Wyświetl plik

@ -0,0 +1,9 @@
CREATE OR REPLACE FUNCTION island_rank(area REAL) RETURNS INT AS $$
SELECT CASE
WHEN area < 10000000 THEN 6
WHEN area BETWEEN 1000000 AND 15000000 THEN 5
WHEN area BETWEEN 15000000 AND 40000000 THEN 4
WHEN area > 40000000 THEN 3
ELSE 7
END;
$$ LANGUAGE SQL IMMUTABLE STRICT;

Wyświetl plik

@ -5,6 +5,8 @@
-- etldoc: osm_continent_point -> layer_place -- etldoc: osm_continent_point -> layer_place
-- etldoc: osm_country_point -> layer_place -- etldoc: osm_country_point -> layer_place
-- etldoc: osm_state_point -> layer_place -- etldoc: osm_state_point -> layer_place
-- etldoc: osm_island_point -> layer_place
-- etldoc: osm_island_polygon -> layer_place
-- etldoc: layer_city -> layer_place -- etldoc: layer_city -> layer_place
CREATE OR REPLACE FUNCTION layer_place(bbox geometry, zoom_level int, pixel_width numeric) CREATE OR REPLACE FUNCTION layer_place(bbox geometry, zoom_level int, pixel_width numeric)
@ -17,7 +19,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t
UNION ALL UNION ALL
SELECT SELECT
osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en,
'country' AS class,"rank", NULL::int AS capital 'country' AS class, "rank", NULL::int AS capital
FROM osm_country_point FROM osm_country_point
WHERE geometry && bbox AND "rank" <= zoom_level AND name <> '' WHERE geometry && bbox AND "rank" <= zoom_level AND name <> ''
UNION ALL UNION ALL
@ -32,6 +34,22 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t
is_in_country IN ('United Kingdom', 'USA', 'Россия', 'Brasil', 'China', 'India') OR is_in_country IN ('United Kingdom', 'USA', 'Россия', 'Brasil', 'China', 'India') OR
is_in_country_code IN ('AU', 'CN', 'IN', 'BR', 'US')) is_in_country_code IN ('AU', 'CN', 'IN', 'BR', 'US'))
UNION ALL UNION ALL
SELECT
osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en,
'island' AS class, 7 AS "rank", NULL::int AS capital
FROM osm_island_point
WHERE zoom_level BETWEEN 12 AND 14
AND geometry && bbox
UNION ALL
SELECT
osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en,
'island' AS class, island_rank(area) AS "rank", NULL::int AS capital
FROM osm_island_polygon
WHERE geometry && bbox AND
((zoom_level = 8 AND island_rank(area) <= 3)
OR (zoom_level = 9 AND island_rank(area) <= 4)
OR (zoom_level >= 10))
UNION ALL
SELECT SELECT
osm_id, geometry, name, name_en, osm_id, geometry, name, name_en,
place::text AS class, "rank", capital place::text AS class, "rank", capital

Wyświetl plik

@ -88,6 +88,34 @@ tables:
place: place:
- country - country
# etldoc: imposm3 -> osm_island_polygon
island_polygon:
type: polygon
fields:
- name: osm_id
type: id
- name: geometry
type: geometry
- name: area
type: pseudoarea
- *name
- *name_en
- *name_de
- *name_fr
- *name_es
- *name_pt
- *name_ru
- *name_zh
- *name_ar
- *name_ja
- *rank
filters:
exclude_tags:
- [ "name", "__nil__" ]
mapping:
place:
- island
# etldoc: imposm3 -> osm_island_point # etldoc: imposm3 -> osm_island_point
island_point: island_point:
type: point type: point

Wyświetl plik

@ -57,6 +57,8 @@ schema:
- ./types.sql - ./types.sql
- ./capital.sql - ./capital.sql
- ./city.sql - ./city.sql
- ./island_polygon_update.sql
- ./island_rank.sql
- ./merge_country_rank.sql - ./merge_country_rank.sql
- ./merge_city_rank.sql - ./merge_city_rank.sql
- ./merge_state_rank.sql - ./merge_state_rank.sql