Merge scalerank into osm for high zoom levels
This commit is contained in:
parent
38dcc030b0
commit
0df15c613e
@ -1,14 +1,14 @@
|
||||
CREATE OR REPLACE FUNCTION layer_city(bbox geometry, zoom_level int, pixel_width numeric)
|
||||
RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, place text, scalerank int) AS $$
|
||||
SELECT osm_id, geometry, name, name_en, place, scalerank
|
||||
FROM osm_important_place_point
|
||||
FROM osm_place_point
|
||||
WHERE geometry && bbox
|
||||
AND ((zoom_level = 2 AND scalerank = 0)
|
||||
OR (zoom_level BETWEEN 3 AND 7 AND scalerank < zoom_level)
|
||||
)
|
||||
UNION ALL
|
||||
SELECT osm_id, geometry, name, name_en, place, NULL AS scalerank FROM (
|
||||
SELECT osm_id, geometry, name, name_en, place,
|
||||
SELECT osm_id, geometry, name, name_en, place, scalerank FROM (
|
||||
SELECT osm_id, geometry, name, name_en, place, scalerank,
|
||||
row_number() OVER (
|
||||
PARTITION BY LabelGrid(geometry, 150 * pixel_width)
|
||||
ORDER BY place::place_subclass ASC NULLS LAST,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS osm_important_place_point AS (
|
||||
WITH important_place_point AS (
|
||||
SELECT osm.geometry, osm.osm_id, osm.name, osm.name_en, osm.place, ne.scalerank, COALESCE(osm.population, ne.pop_min) AS population
|
||||
FROM ne_10m_populated_places AS ne, osm_place_point AS osm
|
||||
WHERE
|
||||
@ -16,7 +16,10 @@ CREATE TABLE IF NOT EXISTS osm_important_place_point AS (
|
||||
)
|
||||
AND (osm.place = 'city' OR osm.place= 'town' OR osm.place = 'village')
|
||||
AND ST_DWithin(ne.geom, osm.geometry, 50000)
|
||||
);
|
||||
)
|
||||
UPDATE osm_place_point
|
||||
SET scalerank = important_place_point.scalerank
|
||||
FROM important_place_point
|
||||
WHERE osm_place_point.osm_id = important_place_point.osm_id;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_important_place_point_geometry_idx ON osm_important_place_point USING gist(geometry);
|
||||
CLUSTER osm_important_place_point USING osm_important_place_point_geometry_idx;
|
||||
CREATE INDEX IF NOT EXISTS osm_place_point_scalerank_idx ON osm_place_point (scalerank);
|
||||
|
||||
@ -18,6 +18,9 @@ tables:
|
||||
- key: population
|
||||
name: population
|
||||
type: integer
|
||||
- key: scalerank
|
||||
name: scalerank
|
||||
type: integer
|
||||
filters:
|
||||
exclude_tags:
|
||||
- [ "name", "__nil__" ]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user