From 35bf7897f6dea60135d829e3b16a38df8ed813cb Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Thu, 1 Aug 2024 20:48:30 +0200 Subject: [PATCH] update station importance views with ID column --- import/sql/get_station_importance.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/import/sql/get_station_importance.sql b/import/sql/get_station_importance.sql index bf59d92d..9128b208 100644 --- a/import/sql/get_station_importance.sql +++ b/import/sql/get_station_importance.sql @@ -42,7 +42,7 @@ CREATE OR REPLACE VIEW platforms_and_their_routes_clustered AS -- Join clustered stop positions with station nodes CREATE OR REPLACE VIEW station_nodes_stop_positions_rel_count AS - SELECT s.osm_id, s.name AS name, s.station as station, s.railway_ref as railway_ref, s.railway AS railway, sprc.route_ids AS route_ids, s.name_tags as name_tags, s.way AS way + SELECT s.id as id, s.osm_id, s.name AS name, s.station as station, s.railway_ref as railway_ref, s.railway AS railway, sprc.route_ids AS route_ids, s.name_tags as name_tags, s.way AS way FROM stations AS s LEFT OUTER JOIN stop_positions_and_their_routes_clustered AS sprc ON (sprc.stop_name = s.name AND ST_DWithin(s.way, sprc.geom, 400)) @@ -50,7 +50,7 @@ CREATE OR REPLACE VIEW station_nodes_stop_positions_rel_count AS -- Join clustered platforms with station nodes CREATE OR REPLACE VIEW station_nodes_platforms_rel_count AS - SELECT s.osm_id AS osm_id, s.name AS name, s.station as station, s.railway_ref as railway_ref, s.railway AS railway, sprc.route_ids AS route_ids, s.name_tags as name_tags, s.way AS way + SELECT s.id as id, s.osm_id AS osm_id, s.name AS name, s.station as station, s.railway_ref as railway_ref, s.railway AS railway, sprc.route_ids AS route_ids, s.name_tags as name_tags, s.way AS way FROM stations AS s JOIN platforms_and_their_routes_clustered AS sprc ON (ST_DWithin(s.way, sprc.geom, 60)) @@ -60,19 +60,19 @@ CREATE OR REPLACE VIEW station_nodes_platforms_rel_count AS -- needs about 3 to 4 minutes for whole Germany -- or about 20 to 30 minutes for the whole planet CREATE MATERIALIZED VIEW IF NOT EXISTS stations_with_route_counts AS - SELECT DISTINCT ON (osm_id, name, station, railway_ref, railway) osm_id, name, station, railway_ref, railway, route_count, name_tags, way + SELECT DISTINCT ON (osm_id, name, station, railway_ref, railway) id, osm_id, name, station, railway_ref, railway, route_count, name_tags, way FROM ( - SELECT osm_id, name, station, railway_ref, railway, ARRAY_LENGTH(ARRAY_AGG(DISTINCT route_id), 1) AS route_count, name_tags, way + SELECT id, osm_id, name, station, railway_ref, railway, ARRAY_LENGTH(ARRAY_AGG(DISTINCT route_id), 1) AS route_count, name_tags, way FROM ( - SELECT osm_id, name, station, railway_ref, railway, UNNEST(route_ids) AS route_id, name_tags, way + 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 osm_id, name, station, railway_ref, railway, UNNEST(route_ids) AS route_id, name_tags, way + 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 osm_id, name, station, railway_ref, railway, way, name_tags + GROUP BY id, osm_id, name, station, railway_ref, railway, way, name_tags UNION ALL - SELECT osm_id, name, station, railway_ref, railway, 0 AS route_count, name_tags, way + 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 facilities