Skip to content
Snippets Groups Projects
Commit f70de256 authored by Riccardo Boero's avatar Riccardo Boero :innocent:
Browse files

Fixed selection of train stations in Europe and NA.

parent 87fa9662
No related branches found
No related tags found
No related merge requests found
...@@ -11,8 +11,30 @@ osmium tags-filter temp/europe-latest.osm.pbf w/railway=rail -o temp/line_europe ...@@ -11,8 +11,30 @@ osmium tags-filter temp/europe-latest.osm.pbf w/railway=rail -o temp/line_europe
osmium export temp/line_europe.pbf --geometry-types=linestring -o temp/line_europe.geojson --overwrite osmium export temp/line_europe.pbf --geometry-types=linestring -o temp/line_europe.geojson --overwrite
# export stations # export stations
osmium tags-filter temp/europe-latest.osm.pbf n/railway=station -R -o temp/station_europe.pbf --overwrite osmium tags-filter temp/europe-latest.osm.pbf n/railway=station -R -o temp/station_europe.pbf --overwrite
osmium tags-filter temp/station_europe.pbf n/railway:traffic_mode -R -o temp/station_europe.pbf --overwrite osmium tags-filter temp/station_europe.pbf n/subway=yes -R -o temp/subway_europe.pbf --overwrite
osmium export temp/station_europe.pbf -o temp/station_europe.geojson --overwrite osmium cat temp/station_europe.pbf -o temp/station_europe.osm
osmium cat temp/subway_europe.pbf -o temp/subway_europe.osm
grep '<node' temp/subway_europe.osm | awk -F ' id="' '{print $2}' | awk -F '"' '{print $1}' > temp/exclude_europe_subway_ids.txt
awk '
BEGIN {
while (getline < "temp/exclude_europe_subway_ids.txt") exclude[$1] = 1;
inNode = 0;
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; # Ensure the XML header is included
print "<osm version=\"0.6\" generator=\"osmium/1.8.0\">"; # Adjust osmium version as needed
}
/^ *<node / {
split($0, a, / id="|"/);
nodeId = a[2];
inNode = !(nodeId in exclude);
}
inNode { print }
/^ *<\/node>/ { inNode = 0; }
END {
print "</osm>";
}
' temp/station_europe.osm > temp/station_europe-filtered.osm
osmium cat temp/station_europe-filtered.osm -o temp/station_europe-filtered.osm.pbf
osmium export temp/station_europe-filtered.osm.pbf -o temp/station_europe.geojson --overwrite
# load in DB # load in DB
ogr2ogr -f MySQL MySQL:FACT_rail,host=plazablanca.nilu.no,user=root,password=impadminPSWD! ./temp/station_europe.geojson -nln eu_stations -update -overwrite -lco engine=Aria ogr2ogr -f MySQL MySQL:FACT_rail,host=plazablanca.nilu.no,user=root,password=impadminPSWD! ./temp/station_europe.geojson -nln eu_stations -update -overwrite -lco engine=Aria
ogr2ogr -f MySQL MySQL:FACT_rail,host=plazablanca.nilu.no,user=root,password=impadminPSWD! ./temp/line_europe.geojson -nln eu_lines -update -overwrite -lco engine=Aria ogr2ogr -f MySQL MySQL:FACT_rail,host=plazablanca.nilu.no,user=root,password=impadminPSWD! ./temp/line_europe.geojson -nln eu_lines -update -overwrite -lco engine=Aria
...@@ -26,10 +48,32 @@ osmium tags-filter temp/north-america-latest.osm.pbf w/railway=rail -o temp/line ...@@ -26,10 +48,32 @@ osmium tags-filter temp/north-america-latest.osm.pbf w/railway=rail -o temp/line
osmium export temp/line_north-america.pbf --geometry-types=linestring -o temp/line_north-america.geojson --overwrite osmium export temp/line_north-america.pbf --geometry-types=linestring -o temp/line_north-america.geojson --overwrite
# export stations # export stations
osmium tags-filter temp/north-america-latest.osm.pbf n/railway=station -R -o temp/station_north-america.pbf --overwrite osmium tags-filter temp/north-america-latest.osm.pbf n/railway=station -R -o temp/station_north-america.pbf --overwrite
osmium tags-filter temp/station_north-america.pbf n/railway:traffic_mode -R -o temp/station_north-america.pbf --overwrite osmium tags-filter temp/station_north-america.pbf n/subway=yes -R -o temp/subway_na.pbf --overwrite
osmium export temp/station_north-america.pbf -o temp/station_north-america.geojson --overwrite osmium cat temp/station_north-america.pbf -o temp/station_north-america.osm --overwrite
osmium cat temp/subway_na.pbf -o temp/subway_na.osm --overwrite
grep '<node' temp/subway_na.osm | awk -F ' id="' '{print $2}' | awk -F '"' '{print $1}' > temp/exclude_na_subway_ids.txt
awk '
BEGIN {
while (getline < "temp/exclude_na_subway_ids.txt") exclude[$1] = 1;
inNode = 0;
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; # Ensure the XML header is included
print "<osm version=\"0.6\" generator=\"osmium/1.8.0\">"; # Adjust osmium version as needed
}
/^ *<node / {
split($0, a, / id="|"/);
nodeId = a[2];
inNode = !(nodeId in exclude);
}
inNode { print }
/^ *<\/node>/ { inNode = 0; }
END {
print "</osm>";
}
' temp/station_north-america.osm > temp/station_na-filtered.osm
osmium cat temp/station_na-filtered.osm -o temp/station_na-filtered.pbf
osmium export temp/station_na-filtered.pbf -o temp/station_north-america.geojson --overwrite
# load in DB # load in DB
ogr2ogr -f MySQL MySQL:FACT_rail,host=plazablanca.nilu.no,user=root,password=impadminPSWD! ./temp/station_north-america.geojson -nln na_stations -update -overwrite -lco engine=Aria ogr2ogr -f MySQL MySQL:FACT_rail,host=plazablanca.nilu.no,user=root,password=impadminPSWD! ./temp/station_north-america.geojson -nln na_stations -update -overwrite -lco engine=Aria
ogr2ogr -f MySQL MySQL:FACT_rail,host=plazablanca.nilu.no,user=root,password=impadminPSWD! ./temp/line_north-america.geojson -nln na_lines -update -overwrite -lco engine=Aria ogr2ogr -f MySQL MySQL:FACT_rail,host=plazablanca.nilu.no,user=root,password=impadminPSWD! ./temp/line_north-america.geojson -nln na_lines -update -overwrite -lco engine=Aria
#clean up #clean up
#rm -r temp rm -r temp
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment