diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-12-21 18:37:18 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-12-21 18:37:18 +0100 |
commit | b255c541c539398414df9af152bb85bfaa8cd5fc (patch) | |
tree | 294f33d88e5f4d3a56b00a33047a4bf138d97e90 | |
parent | 0a89a0a4938b369a75ddbae16fc530cc8cb7c7f9 (diff) |
attr: translate DS100 to ordinary station name
-rw-r--r-- | README.md | 5 | ||||
-rwxr-xr-x | bin/db-zugbildung-to-json | 19 | ||||
-rw-r--r-- | schema.yml | 4 |
3 files changed, 22 insertions, 6 deletions
@@ -202,13 +202,14 @@ passenger service. Station names may be surrounded by brackets. "brakingPercentage": 177, "length": 402, "series": "406", - "station": "FF", + "station": "Basel SBB", "vmax": 300 } ``` Taken as-is from the PDF file. commonAttr contains only properties which are -identical in each variant. *station* is a DS100 identifier with unknown meaning. +identical in each variant. *station* is translated from DS100 to a station +name; its meaning is unknown. #### schedules 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} ); } @@ -120,8 +120,8 @@ components: description: series of second powercar (if present) station: type: string - example: "FF" - description: DS100 station code, details unknown + example: "Basel SBB" + description: station name, details unknown vmax: type: integer example: 300 |