From 9d489892cb00727bca8769b1758f839c6d8a527a Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sun, 4 Aug 2024 12:29:47 +0200 Subject: [PATCH] Delete all non-train platforms from database (#87) More than 90% of the platforms in Europe are non-train platforms. These are hundreds of MB of data, and can be removed --- import/docker-startup.sh | 4 +++- import/openrailwaymap.lua | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/import/docker-startup.sh b/import/docker-startup.sh index 20e9d74b..5de8533e 100755 --- a/import/docker-startup.sh +++ b/import/docker-startup.sh @@ -87,11 +87,13 @@ esac $PSQL -c "update planet_osm_nodes set tags = null where tags is not null;" $PSQL -c "update planet_osm_ways set tags = null where tags is not null;" $PSQL -c "update planet_osm_rels set tags = null where tags is not null;" +# Remove platforms which are not near any railway line, and also not part of any railway route +$PSQL -c "delete from platforms p where not exists(select * from routes r where r.platform_ref_ids @> Array[-p.osm_id]) and not exists(select * from railway_line l where st_dwithin(p.way, l.way, 20));" echo "Post processing imported data" $PSQL -f sql/functions.sql -$PSQL -f sql/get_station_importance.sql $PSQL -f sql/signals_with_azimuth.sql +$PSQL -f sql/get_station_importance.sql $PSQL -f sql/tile_views.sql echo "Updating materialized views" diff --git a/import/openrailwaymap.lua b/import/openrailwaymap.lua index fbcc1a79..38b470b8 100644 --- a/import/openrailwaymap.lua +++ b/import/openrailwaymap.lua @@ -443,7 +443,8 @@ function osm2pgsql.process_way(object) if gauge_tag then for gauge in string.gmatch(gauge_tag, '[^;]+') do if gauge then - table.insert(gauges, gauge) + -- Raw SQL array syntax + table.insert(gauges, "\"" .. gauge:gsub("\"", "\\\"") .. "\"") end end end