summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-09-18 17:17:31 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-09-18 17:17:31 +0200
commite7edcfd9c675015073c914993fcf47ad4d83a640 (patch)
tree95ecd626b1f3000a4a174386dc58bbdc068854ac /index.pl
parentb2f12dad068aa34e99e800f9318fe97f0ad5597d (diff)
HAFAS stopfinder support
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl20
1 files changed, 20 insertions, 0 deletions
diff --git a/index.pl b/index.pl
index 22dacd8..3c2c305 100644
--- a/index.pl
+++ b/index.pl
@@ -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);