Skip to content

Commit

Permalink
HAFAS, hafas-m: Add descriptions for ÖBB MOT bits
Browse files Browse the repository at this point in the history
See #11
  • Loading branch information
derf committed Feb 24, 2024
1 parent f9b37e2 commit cca75a4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
13 changes: 8 additions & 5 deletions bin/hafas-m
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,14 @@ sub parse_mot_options {
$service //= 'DB';
my $desc = Travel::Status::DE::HAFAS::get_service($service);
if ($desc) {
my @mots = @{ $desc->{productbits} };
@mots = grep { $_ ne 'x' } @mots;
@mots = uniq @mots;
@mots = sort @mots;
say join( "\n", @mots );
for my $mot ( @{ $desc->{productbits} } ) {
if ( ref($mot) eq 'ARRAY' ) {
printf( "%-10s %s\n", @{$mot} );
}
else {
say $mot;
}
}
exit 0;
}
else {
Expand Down
40 changes: 30 additions & 10 deletions lib/Travel/Status/DE/HAFAS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ our $VERSION = '5.05';

my %hafas_instance = (
DB => {
stopfinder => 'https://reiseauskunft.bahn.de/bin/ajax-getstop.exe',
mgate => 'https://reiseauskunft.bahn.de/bin/mgate.exe',
name => 'Deutsche Bahn',
productbits => [qw[ice ic_ec d regio s bus ferry u tram ondemand]],
salt => 'bdI8UVj4' . '0K5fvxwf',
languages => [qw[de en fr es]],
request => {
stopfinder => 'https://reiseauskunft.bahn.de/bin/ajax-getstop.exe',
mgate => 'https://reiseauskunft.bahn.de/bin/mgate.exe',
name => 'Deutsche Bahn',
productbits => [qw[ice ic_ec d regio s bus ferry u tram ondemand]],
productgroups =>
[ [qw[ice ic_ec d]], [qw[regio s]], [qw[bus ferry u tram ondemand]] ],
salt => 'bdI8UVj4' . '0K5fvxwf',
languages => [qw[de en fr es]],
request => {
client => {
id => 'DB',
v => '20100000',
Expand Down Expand Up @@ -116,8 +118,21 @@ my %hafas_instance = (
mgate => 'https://fahrplan.oebb.at/bin/mgate.exe',
stopfinder => 'https://fahrplan.oebb.at/bin/ajax-getstop.exe',
name => 'Österreichische Bundesbahnen',
productbits =>
[qw[ice_rj sev ic_ec d_n regio s bus ferry u tram other]],
productbits => [
[ ice_rj => 'long distance trains' ],
[ sev => 'rail replacement service' ],
[ ic_ec => 'long distance trains' ],
[ d_n => 'night trains and rapid trains' ],
[ regio => 'regional trains' ],
[ s => 'suburban trains' ],
[ bus => 'busses' ],
[ ferry => 'maritime transit' ],
[ u => 'underground' ],
[ tram => 'trams' ],
[ other => 'other transit services' ]
],
productgroups =>
[ qw[ice_rj ic_ec d_n], qw[regio s sev], qw[bus ferry u tram other] ],
request => {
client => {
id => 'OEBB',
Expand Down Expand Up @@ -509,7 +524,12 @@ sub mot_mask {

my %mot_pos;
for my $i ( 0 .. $#{ $hafas_instance{$service}{productbits} } ) {
$mot_pos{ $hafas_instance{$service}{productbits}[$i] } = $i;
if ( ref( $hafas_instance{$service}{productbits}[$i] ) eq 'ARRAY' ) {
$mot_pos{ $hafas_instance{$service}{productbits}[$i][0] } = $i;
}
else {
$mot_pos{ $hafas_instance{$service}{productbits}[$i] } = $i;
}
}

if ( my @mots = @{ $self->{exclusive_mots} // [] } ) {
Expand Down

0 comments on commit cca75a4

Please sign in to comment.