summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl36
1 files changed, 24 insertions, 12 deletions
diff --git a/index.pl b/index.pl
index 2795d7f..b22197e 100644
--- a/index.pl
+++ b/index.pl
@@ -71,19 +71,31 @@ sub get_results_for {
= Travel::Status::DE::IRIS::Stations::get_station($station);
if ( @station_matches == 1 ) {
$station = $station_matches[0][0];
+ my $status = Travel::Status::DE::IRIS->new(
+ station => $station,
+ main_cache => $cache_iris_main,
+ realtime_cache => $cache_iris_rt,
+ %opt
+ );
+ $data = {
+ results => [ $status->results ],
+ errstr => $status->errstr,
+ station_name =>
+ ( $status->station ? $status->station->{name} : $station ),
+ };
+ }
+ elsif ( @station_matches > 1 ) {
+ $data = {
+ results => [],
+ errstr => 'Ambiguous station name',
+ };
+ }
+ else {
+ $data = {
+ results => [],
+ errstr => 'Unknown station name',
+ };
}
-
- my $status = Travel::Status::DE::IRIS->new(
- station => $station,
- main_cache => $cache_iris_main,
- realtime_cache => $cache_iris_rt,
- %opt
- );
- $data = {
- results => [ $status->results ],
- errstr => $status->errstr,
- station_name => $status->station->{name},
- };
}
elsif ( $backend eq 'ris' ) {
$data = $cache_hafas->thaw($cache_str);