summaryrefslogtreecommitdiff
path: root/lib/Travel/Status
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-09-14 15:55:14 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-09-14 15:55:14 +0200
commit52b55d2a5c982c4a56db7dfde4326eb195798c63 (patch)
tree70f7c033a8a8aa1fb388bc9302aae42ebde32de5 /lib/Travel/Status
parentaaa3810ffba6e7908b5a5480fc55887d1879fcf3 (diff)
HAFAS/hafas-m: Add StopFinder support
Diffstat (limited to 'lib/Travel/Status')
-rw-r--r--lib/Travel/Status/DE/HAFAS.pm34
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm
index 61e3469..2a7bb11 100644
--- a/lib/Travel/Status/DE/HAFAS.pm
+++ b/lib/Travel/Status/DE/HAFAS.pm
@@ -11,6 +11,7 @@ use Carp qw(confess);
use LWP::UserAgent;
use POSIX qw(strftime);
use Travel::Status::DE::HAFAS::Result;
+use Travel::Status::DE::HAFAS::StopFinder;
use XML::LibXML;
our $VERSION = '1.05';
@@ -18,12 +19,14 @@ our $VERSION = '1.05';
my %hafas_instance = (
BVG => {
url => 'http://bvg.hafas.de/bin/stboard.exe',
+ stopfinder => 'http://bvg.hafas.de/bin/ajax-getstop.exe',
name => 'Berliner Verkehrsgesellschaft',
productbits => [qw[s u tram bus ferry ice regio ondemand]],
},
DB => {
- url => 'http://reiseauskunft.bahn.de/bin/bhftafel.exe',
- name => 'Deutsche Bahn',
+ url => 'http://reiseauskunft.bahn.de/bin/bhftafel.exe',
+ stopfinder => 'http://reiseauskunft.bahn.de/bin/ajax-getstop.exe',
+ name => 'Deutsche Bahn',
productbits =>
[qw[ice ic_ec d regio s bus ferry u tram ondemand x x x x]],
},
@@ -102,6 +105,7 @@ sub new {
developer_mode => $conf{developer_mode},
exclusive_mots => $conf{exclusive_mots},
excluded_mots => $conf{excluded_mots},
+ station => $conf{station},
post => {
input => $conf{station},
date => $date,
@@ -210,17 +214,43 @@ sub check_input_error {
= $err->getAttribute('text')
. ' (code '
. $err->getAttribute('code') . ')';
+ $self->{errcode} = $err->getAttribute('code');
}
return;
}
+sub errcode {
+ my ($self) = @_;
+
+ return $self->{errcode};
+}
+
sub errstr {
my ($self) = @_;
return $self->{errstr};
}
+sub similar_stops {
+ my ($self) = @_;
+
+ my $service = $self->{active_service};
+
+ if ( $service and exists $hafas_instance{$service}{stopfinder} ) {
+ my $sf = Travel::Status::DE::HAFAS::StopFinder->new(
+ url => $hafas_instance{$service}{stopfinder},
+ input => $self->{station},
+ );
+ if ( my $err = $sf->errstr ) {
+ $self->{errstr} = $err;
+ return;
+ }
+ return $sf->results;
+ }
+ return;
+}
+
sub results {
my ($self) = @_;
my $mode = $self->{post}->{boardType};