diff --git a/import/sql/get_station_importance.sql b/import/sql/get_station_importance.sql index 6047dcdb..972c3fe7 100644 --- a/import/sql/get_station_importance.sql +++ b/import/sql/get_station_importance.sql @@ -61,38 +61,45 @@ CREATE OR REPLACE VIEW station_nodes_platforms_rel_count AS -- or about 20 to 30 minutes for the whole planet CREATE MATERIALIZED VIEW IF NOT EXISTS stations_with_route_counts AS SELECT - MIN(id) as id, - MIN(osm_id) as osm_id, - name, - station, - railway_ref, - railway, - MAX(route_count) as route_count, - hstore(string_agg(nullif(name_tags::text, ''), ',')) as name_tags, - ST_RemoveRepeatedPoints(ST_Collect(way)) as way + *, + ST_Centroid(way) as center, + ST_Buffer(ST_ConvexHull(way), 50) as buffered, + ST_NumGeometries(way) as count FROM ( SELECT - *, - ST_ClusterDBSCAN(way, 400, 1) OVER (PARTITION BY name, station, railway_ref, railway) AS cluster_id + MIN(id) as id, + MIN(osm_id) as osm_id, + name, + station, + railway_ref, + railway, + MAX(route_count) as route_count, + hstore(string_agg(nullif(name_tags::text, ''), ',')) as name_tags, + ST_RemoveRepeatedPoints(ST_Collect(way)) as way FROM ( - SELECT MIN(id) as id, MIN(osm_id) as osm_id, name, station, railway_ref, railway, ARRAY_LENGTH(ARRAY_AGG(DISTINCT route_id), 1) AS route_count, name_tags, way + SELECT + *, + ST_ClusterDBSCAN(way, 400, 1) OVER (PARTITION BY name, station, railway_ref, railway) AS cluster_id FROM ( - SELECT id, osm_id, name, station, railway_ref, railway, UNNEST(route_ids) AS route_id, name_tags, way - FROM station_nodes_stop_positions_rel_count + SELECT MIN(id) as id, MIN(osm_id) as osm_id, name, station, railway_ref, railway, ARRAY_LENGTH(ARRAY_AGG(DISTINCT route_id), 1) AS route_count, name_tags, way + FROM ( + SELECT id, osm_id, name, station, railway_ref, railway, UNNEST(route_ids) AS route_id, name_tags, way + FROM station_nodes_stop_positions_rel_count + UNION ALL + SELECT id, osm_id, name, station, railway_ref, railway, UNNEST(route_ids) AS route_id, name_tags, way + FROM station_nodes_platforms_rel_count + ) AS a + GROUP BY name, station, railway_ref, railway, way, name_tags UNION ALL - SELECT id, osm_id, name, station, railway_ref, railway, UNNEST(route_ids) AS route_id, name_tags, way - FROM station_nodes_platforms_rel_count - ) AS a - GROUP BY name, station, railway_ref, railway, way, name_tags - UNION ALL - SELECT id, osm_id, name, station, railway_ref, railway, 0 AS route_count, name_tags, way - FROM stations - WHERE railway IN ('station', 'halt', 'tram_stop', 'service_station', 'yard', 'junction', 'spur_junction', 'crossover', 'site') - ) AS grouped_facilities - ) AS facilities - GROUP BY name, station, railway_ref, railway, cluster_id - -- ORDER BY is required to ensure that the larger route_count is used. - ORDER BY name, station, railway_ref, railway, route_count DESC; + SELECT id, osm_id, name, station, railway_ref, railway, 0 AS route_count, name_tags, way + FROM stations + WHERE railway IN ('station', 'halt', 'tram_stop', 'service_station', 'yard', 'junction', 'spur_junction', 'crossover', 'site') + ) AS grouped_facilities + ) AS facilities + GROUP BY name, station, railway_ref, railway, cluster_id + -- ORDER BY is required to ensure that the larger route_count is used. + ORDER BY name, station, railway_ref, railway, route_count DESC + ) as source_facilities; CREATE INDEX IF NOT EXISTS stations_with_route_counts_geom_index ON stations_with_route_counts diff --git a/import/sql/tile_views.sql b/import/sql/tile_views.sql index ba3847a2..7ef7382f 100644 --- a/import/sql/tile_views.sql +++ b/import/sql/tile_views.sql @@ -139,7 +139,7 @@ CREATE OR REPLACE VIEW standard_railway_text_stations_low AS SELECT id, osm_id, - ST_Centroid(way) as way, + center as way, railway_ref as label FROM stations_with_route_counts WHERE @@ -153,7 +153,7 @@ CREATE OR REPLACE VIEW standard_railway_text_stations_med AS SELECT id, osm_id, - ST_Centroid(way) as way, + center as way, railway_ref as label FROM stations_with_route_counts WHERE @@ -166,7 +166,7 @@ CREATE OR REPLACE VIEW standard_railway_text_stations AS SELECT id, osm_id, - way, + center as way, railway, station, railway_ref as label, @@ -191,13 +191,13 @@ CREATE OR REPLACE VIEW standard_railway_text_stations AS SELECT id, osm_id, - ST_Centroid(way) as way, + center, railway, route_count, station, railway_ref, name, - ST_NumGeometries(way) as count + count FROM stations_with_route_counts WHERE railway IN ('station', 'halt', 'service_station', 'yard', 'junction', 'spur_junction', 'crossover', 'site', 'tram_stop') AND name IS NOT NULL @@ -217,7 +217,7 @@ CREATE OR REPLACE VIEW standard_railway_grouped_stations AS SELECT id, osm_id, - ST_Buffer(ST_ConvexHull(way), 50) as way, + buffered as way, railway, station, railway_ref, diff --git a/proxy/js/styles.mjs b/proxy/js/styles.mjs index 65a5901f..bae2fdd3 100644 --- a/proxy/js/styles.mjs +++ b/proxy/js/styles.mjs @@ -1387,32 +1387,9 @@ const layers = Object.fromEntries(knownThemes.map(theme => [theme, { { id: 'railway_grouped_stations', type: 'fill', - minzoom: 8, + minzoom: 15, source: 'openrailwaymap_standard', 'source-layer': 'standard_railway_grouped_stations', - filter: ['step', ['zoom'], - ['all', - ['==', ['get', 'railway'], 'station'], - ['!=', ['get', 'station'], 'light_rail'], - ['!=', ['get', 'station'], 'subway'], - ['!=', ['get', 'station'], 'funicular'], - ], - 9, - ['all', - ['any', - ['==', ['get', 'railway'], 'station'], - ['==', ['get', 'railway'], 'halt'], - ], - ['!=', ['get', 'station'], 'funicular'], - ], - 10, - ['all', - ['!=', ['get', 'railway'], 'tram_stop'], - ['!=', ['get', 'station'], 'funicular'], - ], - 13, - ['!=', ['get', 'station'], 'funicular'], - ], paint: { 'fill-color': ['case', ['==', ['get', 'railway'], 'tram_stop'], colors[theme].styles.standard.tram,