Move place to imposm3 mapping
This commit is contained in:
parent
a48123657c
commit
8bc57e13e7
33
layers/place/mapping.yaml
Normal file
33
layers/place/mapping.yaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
tables:
|
||||||
|
place_point:
|
||||||
|
type: geometry
|
||||||
|
fields:
|
||||||
|
- name: osm_id
|
||||||
|
type: id
|
||||||
|
- name: geometry
|
||||||
|
type: geometry
|
||||||
|
- key: name
|
||||||
|
name: name
|
||||||
|
type: string
|
||||||
|
- name: name_en
|
||||||
|
key: name:en
|
||||||
|
type: string
|
||||||
|
- name: place
|
||||||
|
key: place
|
||||||
|
type: string
|
||||||
|
- key: population
|
||||||
|
name: population
|
||||||
|
type: integer
|
||||||
|
filters:
|
||||||
|
exclude_tags:
|
||||||
|
- [ "name", "__nil__" ]
|
||||||
|
type_mappings:
|
||||||
|
points:
|
||||||
|
place:
|
||||||
|
- city
|
||||||
|
- town
|
||||||
|
- village
|
||||||
|
- hamlet
|
||||||
|
- suburb
|
||||||
|
- neighbourhood
|
||||||
|
- isolated_dwelling
|
||||||
@ -1,70 +1,63 @@
|
|||||||
CREATE OR REPLACE VIEW place_z2 AS (
|
CREATE OR REPLACE VIEW place_z2 AS (
|
||||||
SELECT geom, name, 'settlement' AS class, 'city'::place AS rank, scalerank, pop_min AS population
|
SELECT geom, name, 'city' AS place, scalerank, pop_min AS population
|
||||||
FROM ne_10m_populated_places
|
FROM ne_10m_populated_places
|
||||||
WHERE scalerank <= 0
|
WHERE scalerank <= 0
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z3 AS (
|
CREATE OR REPLACE VIEW place_z3 AS (
|
||||||
SELECT geom, name, 'settlement' AS class, 'city'::place AS rank, scalerank, pop_min AS population
|
SELECT geom, name, 'city' AS place, scalerank, pop_min AS population
|
||||||
FROM ne_10m_populated_places
|
FROM ne_10m_populated_places
|
||||||
WHERE scalerank <= 2
|
WHERE scalerank <= 2
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z4 AS (
|
CREATE OR REPLACE VIEW place_z4 AS (
|
||||||
SELECT geom, name, 'settlement' AS class, 'city'::place AS rank, scalerank, pop_min AS population
|
SELECT geom, name, 'city' AS place, scalerank, pop_min AS population
|
||||||
FROM ne_10m_populated_places
|
FROM ne_10m_populated_places
|
||||||
WHERE scalerank <= 5
|
WHERE scalerank <= 5
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z5 AS (
|
CREATE OR REPLACE VIEW place_z5 AS (
|
||||||
SELECT geom, name, 'settlement' AS class, 'city'::place AS rank, scalerank, pop_min AS population
|
SELECT geom, name, 'city' AS place, scalerank, pop_min AS population
|
||||||
FROM ne_10m_populated_places
|
FROM ne_10m_populated_places
|
||||||
WHERE scalerank <= 6
|
WHERE scalerank <= 6
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z6 AS (
|
CREATE OR REPLACE VIEW place_z6 AS (
|
||||||
SELECT geom, name, 'settlement' AS class, 'city'::place AS rank, scalerank, pop_min AS population
|
SELECT geom, name, 'city' AS place, scalerank, pop_min AS population
|
||||||
FROM ne_10m_populated_places
|
FROM ne_10m_populated_places
|
||||||
WHERE scalerank <= 7
|
WHERE scalerank <= 7
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z7 AS (
|
CREATE OR REPLACE VIEW place_z7 AS (
|
||||||
SELECT geom, name, 'settlement' AS class, 'city'::place AS rank, scalerank, pop_min AS population
|
SELECT geom, name, 'city' AS place, scalerank, pop_min AS population
|
||||||
FROM ne_10m_populated_places
|
FROM ne_10m_populated_places
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z8 AS (
|
CREATE OR REPLACE VIEW place_z8 AS (
|
||||||
SELECT way AS geom, name, class::text, rank, NULL::integer AS scalerank, population FROM place_point
|
SELECT geometry AS geom, name, place, NULL::integer AS scalerank, population FROM osm_place_point
|
||||||
WHERE rank IN ('city', 'town')
|
WHERE place IN ('city', 'town')
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z10 AS (
|
CREATE OR REPLACE VIEW place_z10 AS (
|
||||||
SELECT way AS geom, name, class::text, rank, NULL::integer AS scalerank, population FROM place_point
|
SELECT geometry AS geom, name, place, NULL::integer AS scalerank, population FROM osm_place_point
|
||||||
WHERE rank IN ('city', 'town', 'village') OR class='subregion'
|
WHERE place IN ('city', 'town', 'village') OR place='subregion'
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z11 AS (
|
CREATE OR REPLACE VIEW place_z11 AS (
|
||||||
SELECT way AS geom, name, class::text, rank, NULL::integer AS scalerank, population FROM place_point
|
SELECT geometry AS geom, name, place, NULL::integer AS scalerank, population FROM osm_place_point
|
||||||
WHERE class IN ('subregion', 'settlement')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z13 AS (
|
CREATE OR REPLACE VIEW place_z13 AS (
|
||||||
SELECT way AS geom, name, class::text, rank, NULL::integer AS scalerank, population FROM place_point
|
SELECT geometry AS geom, name, place, NULL::integer AS scalerank, population FROM osm_place_point
|
||||||
);
|
);
|
||||||
|
|
||||||
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)
|
||||||
RETURNS TABLE(geom geometry, name text, class text, rank text, scalerank int) AS $$
|
RETURNS TABLE(geom geometry, name text, place text, scalerank int) AS $$
|
||||||
SELECT geom, name, class, rank::text, scalerank FROM (
|
SELECT geom, name, place, scalerank FROM (
|
||||||
SELECT geom, name, class, rank, scalerank,
|
SELECT geom, name, place, scalerank,
|
||||||
row_number() OVER (
|
row_number() OVER (
|
||||||
PARTITION BY LabelGrid(geom, 150 * pixel_width)
|
PARTITION BY LabelGrid(geom, 150 * pixel_width)
|
||||||
ORDER BY scalerank ASC NULLS LAST,
|
ORDER BY scalerank ASC NULLS LAST,
|
||||||
CASE class
|
|
||||||
WHEN 'settlement' THEN 10
|
|
||||||
WHEN 'subregion' THEN 5
|
|
||||||
WHEN 'locality' THEN 2 ELSE 1
|
|
||||||
END DESC,
|
|
||||||
rank DESC,
|
|
||||||
population DESC NULLS LAST,
|
population DESC NULLS LAST,
|
||||||
length(name) DESC
|
length(name) DESC
|
||||||
) AS gridrank
|
) AS gridrank
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
layer:
|
layer:
|
||||||
id: "place"
|
id: "place"
|
||||||
description: place
|
description: [OSM Places](http://wiki.openstreetmap.org/wiki/Key:place)
|
||||||
buffer_size: 128
|
buffer_size: 128
|
||||||
datasource:
|
datasource:
|
||||||
query: (SELECT * FROM layer_place(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t
|
query: (SELECT * FROM layer_place(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t
|
||||||
schema:
|
schema:
|
||||||
- ./place.sql
|
- ./place.sql
|
||||||
|
datasources:
|
||||||
|
- type: imposm3
|
||||||
|
mapping_file: ./mapping.yaml
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user