From 925c9a2ef9ee074f0ed3dff2b0c69c542051cd35 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 20 Oct 2015 18:12:23 +0200 Subject: add candidates for hafas backends too --- index.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.pl b/index.pl index 1b4cd23..5591d30 100644 --- a/index.pl +++ b/index.pl @@ -105,6 +105,9 @@ sub get_results { } else { my $efa_url = 'http://efa.vrr.de/vrr/XSLT_DM_REQUEST'; + if ( not $city ) { + return { errstr => 'City must be specified for this backend' }; + } if ($sub_backend) { my $service = first { lc( $_->{shortname} ) eq lc($sub_backend) } @@ -132,6 +135,13 @@ sub get_results { $data->{name_candidates} = [ $status->name_candidates ]; $data->{place_candidates} = [ $status->place_candidates ]; } + elsif ( $status->errstr + and $status->can('errcode') + and $status->errcode eq 'H730' ) + { + $data->{name_candidates} + = [ map { $_->{name} } $status->similar_stops ]; + } $cache->freeze( $sstr, $data ); } @@ -148,7 +158,7 @@ sub handle_request { my $backend = $self->param('backend') // $default{backend}; my $data; - if ( ( $city and $stop ) or ( $backend eq 'aseag' and $stop ) ) { + if ($stop) { $data = get_results( $self->param('backend') // $default{backend}, $city, $stop ); } -- cgit v1.2.3