summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-10-20 18:12:23 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-10-20 18:12:23 +0200
commit925c9a2ef9ee074f0ed3dff2b0c69c542051cd35 (patch)
tree3cb592bb75ddd585fed06dcdd17f1e202f3a8131
parent2c0a1f463ce56683ca8394f10eee27cbb8ff47f2 (diff)
add candidates for hafas backends too
-rw-r--r--index.pl12
1 files changed, 11 insertions, 1 deletions
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 );
}