[iRail] Help needed: stationslist & wikipedia
Tim Besard
tim.besard at gmail.com
Mon Aug 15 08:30:58 UTC 2011
Properly translating and converting 939 pages would be a pretty
massive undertaking.
A ready-to-use alternative: OSM. Gives you the station name, location,
and lines passing through it with minimal effort. Misses out on
"fancy" data like history or a picture though.
For example (using a subset of the Belgium OSM data as parsing the
entire country takes about ~15 minutes, which can be improved to
nearly-instant querying by using a Postgres+PostGIS database):
> [tim at galactica Downloads]$ perl /tmp/parse.pl /home/tim/Downloads/oudenaarde.osm
> * Opening
> * Seeking
> * Parsing
> - Station: Zottegem, at 50.8689985 x 3.8145967
> - Station: Eine, at 50.8704357 x 3.6238198
> - Station: Zingem, at 50.9081552 x 3.6463368
> - Station: Gavere-Asper, at 50.9288104 x 3.6401693
> - Station: Oudenaarde, at 50.8512803 x 3.6014922
> - Station: Eke-Nazareth, at 50.9607813 x 3.6279753
> - Station: Burst, at 50.9069103 x 3.9209811
> - Station: Haaltert, at 50.9068941 x 4.0233175
> - Station: Ede, at 50.9109933 x 3.9873011
> - Station: Terhagen, at 50.9013336 x 3.8959655
> - Station: Herzele, at 50.8970064 x 3.8798607
> - Station: Munkzwalm, at 50.8755623 x 3.7330341
> - Station: Sint-Denijs-Boekel, at 50.8742467 x 3.6983949
> - Station: Anzegem, at 50.8263248 x 3.4943328
Code used to generate this:
> use Geo::Parse::OSM::Singlepass;
> my $file = shift || die;
>
> print "* Opening\n";
> my $osm = Geo::Parse::OSM::Singlepass->new($file);
>
> print "* Seeking\n";
> $osm->seek_to_nodes;
>
> print "* Parsing\n";
> $osm->parse( sub {
> if (exists $_[0]->{tag}->{railway} && $_[0]->{tag}->{railway} eq 'station') {
> print " - Station: ", $_[0]->{tag}->{name};
> print ", at ", $_[0]->{lat}, " x ", $_[0]->{lon}, "\n";
> }
> });
Tim
More information about the iRail
mailing list