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)
|
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 $$
|
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
|
SELECT osm_id, geometry, name, name_en, place, scalerank
|
||||||
FROM osm_important_place_point
|
FROM osm_place_point
|
||||||
WHERE geometry && bbox
|
WHERE geometry && bbox
|
||||||
AND ((zoom_level = 2 AND scalerank = 0)
|
AND ((zoom_level = 2 AND scalerank = 0)
|
||||||
OR (zoom_level BETWEEN 3 AND 7 AND scalerank < zoom_level)
|
OR (zoom_level BETWEEN 3 AND 7 AND scalerank < zoom_level)
|
||||||
)
|
)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT osm_id, geometry, name, name_en, place, NULL AS scalerank FROM (
|
SELECT osm_id, geometry, name, name_en, place, scalerank FROM (
|
||||||
SELECT osm_id, geometry, name, name_en, place,
|
SELECT osm_id, geometry, name, name_en, place, scalerank,
|
||||||
row_number() OVER (
|
row_number() OVER (
|
||||||
PARTITION BY LabelGrid(geometry, 150 * pixel_width)
|
PARTITION BY LabelGrid(geometry, 150 * pixel_width)
|
||||||
ORDER BY place::place_subclass ASC NULLS LAST,
|
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
|
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
|
FROM ne_10m_populated_places AS ne, osm_place_point AS osm
|
||||||
WHERE
|
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 (osm.place = 'city' OR osm.place= 'town' OR osm.place = 'village')
|
||||||
AND ST_DWithin(ne.geom, osm.geometry, 50000)
|
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);
|
CREATE INDEX IF NOT EXISTS osm_place_point_scalerank_idx ON osm_place_point (scalerank);
|
||||||
CLUSTER osm_important_place_point USING osm_important_place_point_geometry_idx;
|
|
||||||
|
|||||||
@ -18,6 +18,9 @@ tables:
|
|||||||
- key: population
|
- key: population
|
||||||
name: population
|
name: population
|
||||||
type: integer
|
type: integer
|
||||||
|
- key: scalerank
|
||||||
|
name: scalerank
|
||||||
|
type: integer
|
||||||
filters:
|
filters:
|
||||||
exclude_tags:
|
exclude_tags:
|
||||||
- [ "name", "__nil__" ]
|
- [ "name", "__nil__" ]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user