summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-12-21 18:37:18 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-12-21 18:37:18 +0100
commitb255c541c539398414df9af152bb85bfaa8cd5fc (patch)
tree294f33d88e5f4d3a56b00a33047a4bf138d97e90 /bin
parent0a89a0a4938b369a75ddbae16fc530cc8cb7c7f9 (diff)
attr: translate DS100 to ordinary station name
Diffstat (limited to 'bin')
-rwxr-xr-xbin/db-zugbildung-to-json19
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} );
}