diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-09-18 17:17:31 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-09-18 17:17:31 +0200 |
commit | e7edcfd9c675015073c914993fcf47ad4d83a640 (patch) | |
tree | 95ecd626b1f3000a4a174386dc58bbdc068854ac /index.pl | |
parent | b2f12dad068aa34e99e800f9318fe97f0ad5597d (diff) |
HAFAS stopfinder support
Diffstat (limited to 'index.pl')
-rw-r--r-- | index.pl | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -4,6 +4,7 @@ use Cache::File; use File::Slurp qw(read_file write_file); use List::MoreUtils qw(); use Travel::Status::DE::HAFAS; +use Travel::Status::DE::HAFAS::StopFinder; use Travel::Status::DE::IRIS; use Travel::Status::DE::IRIS::Stations; use 5.014; @@ -268,6 +269,25 @@ sub handle_request { } if ( not @results ) { + if ( $backend eq 'ris' ) { + my %db_service = Travel::Status::DE::HAFAS::get_service('DB'); + my $sf = Travel::Status::DE::HAFAS::StopFinder->new( + url => $db_service{stopfinder}, + input => $station, + ); + my @candidates + = map { [ "$_->{name} ($_->{id})", $_->{id} ] } $sf->results; + if ( @candidates > 1 + or ( @candidates == 1 and $candidates[0][1] ne $station ) ) + { + $self->render( + 'landingpage', + stationlist => \@candidates, + hide_opts => 0 + ); + return; + } + } if ( $backend eq 'iris' ) { my @candidates = map { [ "$_->[1] ($_->[0])", $_->[0] ] } Travel::Status::DE::IRIS::Stations::get_station($station); |