summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-09-11 15:35:40 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-09-11 15:35:40 +0200
commit53a32113d048c2ab7b98771ae23e470d562bb40a (patch)
tree67e7681afed0131ee0e9b122786eea789c8dd388 /lib
parente51bb2b0dd1727ba5a799ed63ad40eeae66fd1db (diff)
re-add mot support (basics at least)
Diffstat (limited to 'lib')
-rw-r--r--lib/Travel/Status/DE/HAFAS.pm37
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm
index 7cd1c97..b47c2fe 100644
--- a/lib/Travel/Status/DE/HAFAS.pm
+++ b/lib/Travel/Status/DE/HAFAS.pm
@@ -16,18 +16,19 @@ our $VERSION = '1.05';
my %hafas_instance = (
BVG => {
- url => 'http://bvg.hafas.de/bin/stboard.exe',
- name => 'Berliner Verkehrsgesellschaft',
+ url => 'http://bvg.hafas.de/bin/stboard.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',
- productbits => [qw[ice ic_ec d regio s bus ferry u tram ondemand x x x x]],
+ url => 'http://reiseauskunft.bahn.de/bin/bhftafel.exe',
+ name => 'Deutsche Bahn',
+ productbits =>
+ [qw[ice ic_ec d regio s bus ferry u tram ondemand x x x x]],
},
NASA => {
- url => 'http://reiseauskunft.insa.de/bin/stboard.exe',
- name => 'Nahverkehrsservice Sachsen-Anhalt',
+ url => 'http://reiseauskunft.insa.de/bin/stboard.exe',
+ name => 'Nahverkehrsservice Sachsen-Anhalt',
productbits => [qw[ice ice regio regio regio tram bus ondemand]],
},
);
@@ -60,6 +61,7 @@ sub new {
my $ref = {
active_service => $service,
developer_mode => $conf{developer_mode},
+ excluded_mots => $conf{excluded_mots},
post => {
input => $conf{station},
date => $date,
@@ -114,10 +116,25 @@ sub set_productfilter {
my $service = $self->{active_service};
- if ($service and exists $hafas_instance{$service}{productbits}) {
- $self->{post}{productsFilter}
- = '1' x ( scalar @{ $hafas_instance{$service}{productbits} } );
+ if ( not $service or not exists $hafas_instance{$service}{productbits} ) {
+ return;
}
+
+ $self->{post}{productsFilter}
+ = '1' x ( scalar @{ $hafas_instance{$service}{productbits} } );
+
+ if ( $self->{excluded_mots} and @{ $self->{excluded_mots} } ) {
+ my %mot_pos;
+ for my $i ( 0 .. $#{ $hafas_instance{$service}{productbits} } ) {
+ $mot_pos{ $hafas_instance{$service}{productbits}[$i] } = $i;
+ }
+ for my $mot ( @{ $self->{excluded_mots} } ) {
+ if ( exists $mot_pos{$mot} ) {
+ substr( $self->{post}{productsFilter}, $mot_pos{$mot}, 1 ) = 0;
+ }
+ }
+ }
+
}
sub check_input_error {