summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-10-26 10:50:59 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-10-26 10:50:59 +0100
commitdb2e06e1decb3b25df765b75326a8e35248d1def (patch)
tree79ef77c97753d199604adb00cf014f15dc8da56e
parent34793a5b499f42991fdd5acd7f81074d3e03fb68 (diff)
add support for canceled / additional stops. untested at the moment
-rw-r--r--Build.PL1
-rwxr-xr-xbin/db-iris27
-rw-r--r--lib/Travel/Status/DE/IRIS/Result.pm21
3 files changed, 40 insertions, 9 deletions
diff --git a/Build.PL b/Build.PL
index 90de1eb..c7c02e1 100644
--- a/Build.PL
+++ b/Build.PL
@@ -25,6 +25,7 @@ Module::Build->new(
'DateTime::Format::Strptime' => 0,
'Encode' => 0,
'Getopt::Long' => 0,
+ 'List::Compare' => '0.29',
'List::MoreUtils' => 0,
'List::Util' => 0,
'LWP::UserAgent' => 0,
diff --git a/bin/db-iris b/bin/db-iris
index 6e4accb..a362ccc 100755
--- a/bin/db-iris
+++ b/bin/db-iris
@@ -82,14 +82,16 @@ if ($time) {
for my $efield (@edata_pre) {
given ($efield) {
- when ('d') { $edata{delay} = 1 }
- when ('D') { $edata{delays} = 1 }
- when ('f') { $edata{fullroute} = 1 }
- when ('m') { $edata{messages} = 1 }
- when ('q') { $edata{qos} = 1 }
- when ('r') { $edata{route} = 1 }
- when ('t') { $edata{times} = 1 }
- default { $edata{$efield} = 1 }
+ when ('a') { $edata{additional} = 1 }
+ when ('c') { $edata{canceled} = 1 }
+ when ('d') { $edata{delay} = 1 }
+ when ('D') { $edata{delays} = 1 }
+ when ('f') { $edata{fullroute} = 1 }
+ when ('m') { $edata{messages} = 1 }
+ when ('q') { $edata{qos} = 1 }
+ when ('r') { $edata{route} = 1 }
+ when ('t') { $edata{times} = 1 }
+ default { $edata{$efield} = 1 }
}
}
@@ -247,6 +249,15 @@ sub display_result {
print "\n";
}
+ if ( $edata{additional} and $d->additional_stops ) {
+ printf( "Zusätzlicher Halt in: %s\n",
+ join( q{, }, $d->additional_stops ) );
+ }
+
+ if ( $edata{canceled} and $d->canceled_stops ) {
+ printf( "Ohne Halt in: %s\n", join( q{, }, $d->canceled_stops ) );
+ }
+
if ( $edata{fullroute} ) {
print "\n" . join( "\n", $d->route ) . "\n\n";
}
diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm
index 85abee7..69ed01a 100644
--- a/lib/Travel/Status/DE/IRIS/Result.pm
+++ b/lib/Travel/Status/DE/IRIS/Result.pm
@@ -11,6 +11,7 @@ use parent 'Class::Accessor';
use Carp qw(cluck);
use DateTime;
use DateTime::Format::Strptime;
+use List::Compare;
use List::MoreUtils qw(none uniq firstval);
our $VERSION = '0.05';
@@ -189,6 +190,24 @@ sub add_tl {
return $self;
}
+sub additional_stops {
+ my ($self) = @_;
+
+ $self->{comparator}
+ //= List::Compare->new( $self->{sched_route_post}, $self->{route_post} );
+
+ return $self->{comparator}->get_complement;
+}
+
+sub canceled_stops {
+ my ($self) = @_;
+
+ $self->{comparator}
+ //= List::Compare->new( $self->{sched_route_post}, $self->{route_post} );
+
+ return $self->{comparator}->get_unique;
+}
+
sub merge_with_departure {
my ( $self, $result ) = @_;
@@ -475,7 +494,7 @@ sub translate_msg {
64 => 'Weichenstörung',
55 => 'Technische Störung an einem anderen Zug', # ?
57 => 'Zusätzlicher Halt', # ?
- 58 => 'Umleitung(?)', # ?
+ 58 => 'Umleitung(?)', # ?
63 => 'Technische Untersuchung am Zug',
80 => 'Abweichende Wagenreihung',
82 => 'Mehrere Wagen fehlen',