diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/db-zugbildung-to-json | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/bin/db-zugbildung-to-json b/bin/db-zugbildung-to-json index 09bd3c5..a98af93 100755 --- a/bin/db-zugbildung-to-json +++ b/bin/db-zugbildung-to-json @@ -13,6 +13,7 @@ use File::Slurp qw(write_file); use IPC::Run3; use JSON; use List::Util qw(uniq); +use Travel::Status::DE::IRIS::Stations; sub show_usage { my ($exit_code) = @_; @@ -32,6 +33,12 @@ my %month = map { ( $months[$_] => $_ ) } ( 0 .. $#months ); my ( $valid, $valid_from, $valid_through ); my $year; +my %ds100_to_name; + +for my $station ( Travel::Status::DE::IRIS::Stations::get_stations() ) { + $ds100_to_name{ $station->[0] } = $station->[1]; +} + sub parse_weekday_range { my ($range) = @_; my $ret = [ ( \0 ) x 7 ]; @@ -577,8 +584,16 @@ for my $train ( values %map ) { $setup{length} = 0 + $1; } if ( %setup and $line =~ m{ ^ \s* ([+]? [A-Z ]{1,7}) }x ) { - $setup{station} = $1; - $setup{station} =~ s{\s+$}{}; + my $station = $1; + $station =~ s{\s+$}{}; + my $special = ( $station =~ s{^[+]}{} ); + if ( $ds100_to_name{$station} ) { + $station = $ds100_to_name{$station}; + } + if ($special) { + $station = "+${station}"; + } + $setup{station} = $station; } push( @setups, {%setup} ); } |