Initial attempt at moving forests with names into their own 'landmarks' layer. (this is heavely copied and pasted from POI)
This commit is contained in:
31
layers/landmarks/lm_stop_agg.sql
Normal file
31
layers/landmarks/lm_stop_agg.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_lm_stop_centroid CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_lm_stop_centroid AS
|
||||
(
|
||||
SELECT uic_ref,
|
||||
count(*) AS count,
|
||||
CASE WHEN count(*) > 2 THEN ST_Centroid(ST_UNION(geometry)) END AS centroid
|
||||
FROM osm_lm_point
|
||||
WHERE nullif(uic_ref, '') IS NOT NULL
|
||||
AND subclass IN ('bus_stop', 'bus_station', 'tram_stop', 'subway')
|
||||
GROUP BY uic_ref
|
||||
HAVING count(*) > 1
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
|
||||
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_lm_stop_rank CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_lm_stop_rank AS
|
||||
(
|
||||
SELECT p.osm_id,
|
||||
-- p.uic_ref,
|
||||
-- p.subclass,
|
||||
ROW_NUMBER()
|
||||
OVER (
|
||||
PARTITION BY p.uic_ref
|
||||
ORDER BY
|
||||
p.subclass :: public_transport_stop_type NULLS LAST,
|
||||
ST_Distance(c.centroid, p.geometry)
|
||||
) AS rk
|
||||
FROM osm_lm_point p
|
||||
INNER JOIN osm_lm_stop_centroid c ON (p.uic_ref = c.uic_ref)
|
||||
WHERE subclass IN ('bus_stop', 'bus_station', 'tram_stop', 'subway')
|
||||
ORDER BY p.uic_ref, rk
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
|
||||
Reference in New Issue
Block a user