diff options
Diffstat (limited to 'lib/Travelynx/Helper/IRIS.pm')
-rw-r--r-- | lib/Travelynx/Helper/IRIS.pm | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/lib/Travelynx/Helper/IRIS.pm b/lib/Travelynx/Helper/IRIS.pm index a529e28..34739eb 100644 --- a/lib/Travelynx/Helper/IRIS.pm +++ b/lib/Travelynx/Helper/IRIS.pm @@ -28,11 +28,25 @@ sub get_departures { my $lookahead = $opt{lookahead} // 30; my $with_related = $opt{with_related} // 0; + # Berlin Hbf exists twice: + # - BLS / 8011160 + # - BL / 8098160 (formerly "Berlin Hbf (tief)") + # Right now, travelynx assumes that station name -> EVA / DS100 is a unique + # map. This is not the case. Work around it here until travelynx has been + # adjusted properly. + if ( $station eq 'Berlin Hbf' or $station eq '8011160' ) { + $with_related = 1; + } + my @station_matches = Travel::Status::DE::IRIS::Stations::get_station($station); + if ( $station =~ m{ ^ \d+ $ }x ) { + @station_matches = ( [ undef, undef, $station ] ); + } + if ( @station_matches == 1 ) { - $station = $station_matches[0][0]; + $station = $station_matches[0][2]; my $status = Travel::Status::DE::IRIS->new( station => $station, main_cache => $self->{main_cache}, @@ -85,11 +99,25 @@ sub get_departures_p { my $lookahead = $opt{lookahead} // 30; my $with_related = $opt{with_related} // 0; + # Berlin Hbf exists twice: + # - BLS / 8011160 + # - BL / 8098160 (formerly "Berlin Hbf (tief)") + # Right now, travelynx assumes that station name -> EVA / DS100 is a unique + # map. This is not the case. Work around it here until travelynx has been + # adjusted properly. + if ( $station eq 'Berlin Hbf' or $station eq '8011160' ) { + $with_related = 1; + } + my @station_matches = Travel::Status::DE::IRIS::Stations::get_station($station); + if ( $station =~ m{ ^ \d+ $ }x ) { + @station_matches = ( [ undef, undef, $station ] ); + } + if ( @station_matches == 1 ) { - $station = $station_matches[0][0]; + $station = $station_matches[0][2]; my $promise = Mojo::Promise->new; Travel::Status::DE::IRIS->new_p( station => $station, @@ -192,27 +220,23 @@ sub route_diff { # this branch is inefficient, but won't be taken frequently elsif ( not( grep { $_ eq $route[$route_idx] } @sched_route ) ) { push( @json_route, - [ $route[$route_idx], undef, { isAdditional => 1 } ], - ); + [ $route[$route_idx], undef, { isAdditional => 1 } ], ); $route_idx++; } else { push( @json_route, - [ $sched_route[$sched_idx], undef, { isCancelled => 1 } ], - ); + [ $sched_route[$sched_idx], undef, { isCancelled => 1 } ], ); $sched_idx++; } } while ( $route_idx <= $#route ) { push( @json_route, - [ $route[$route_idx], undef, { isAdditional => 1 } ], - ); + [ $route[$route_idx], undef, { isAdditional => 1 } ], ); $route_idx++; } while ( $sched_idx <= $#sched_route ) { push( @json_route, - [ $sched_route[$sched_idx], undef, { isCancelled => 1 } ], - ); + [ $sched_route[$sched_idx], undef, { isCancelled => 1 } ], ); $sched_idx++; } return @json_route; |