Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing data after updating with Osm2Psql #221

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions import/docker-startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import)
osm2pgsql \
--create \
--database gis \
--verbose \
--slim \
--output flex \
--style openrailwaymap.lua \
Expand All @@ -64,6 +65,7 @@ update)
--once \
--database gis \
-- \
--verbose \
--slim \
--output flex \
--style openrailwaymap.lua \
Expand All @@ -87,12 +89,60 @@ refresh)

esac

# Clear all tags from the Osm2Psql tables
$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;"
# Re-filter all non-railway objects from the Osm2Psql database.
# Do not delete nodes, because deleted notes will create update failures (missing data
# when ways / relations are updated.
# The filtering for ways/relations must match the filtering of the raw OSM data

$PSQL -c "
update planet_osm_nodes
set tags = null
where
tags is not null and not (
tags->>'public_transport' IN ('platform', 'stop_position')
OR tags ? 'railway'
OR tags ? 'disused:railway'
OR tags ? 'abandoned:railway'
OR tags ? 'razed:railway'
OR tags ? 'construction:railway'
OR tags ? 'proposed:railway'
)
;"
$PSQL -c "
delete from planet_osm_ways
where
tags is null or not (
tags->>'public_transport' = 'platform'
OR tags ? 'railway'
OR tags ? 'disused:railway'
OR tags ? 'abandoned:railway'
OR tags ? 'razed:railway'
OR tags ? 'construction:railway'
OR tags ? 'proposed:railway'
)
"
$PSQL -c "
delete from planet_osm_rels
where
tags is null or not (
tags->>'route' IN ('train', 'tram', 'light_rail', 'subway')
OR tags->>'public_transport' IN ('platform', 'stop_area')
OR tags ? 'railway'
OR tags ? 'disused:railway'
OR tags ? 'abandoned:railway'
OR tags ? 'razed:railway'
OR tags ? 'construction:railway'
OR tags ? 'proposed:railway'
)
"

# 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));"
$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
Expand Down
Loading