summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-04-25 22:13:17 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-04-25 22:13:17 +0200
commit4a74fe254037d155883e5397c60aad34fe847292 (patch)
treecadc48779a92f8fcf4c7665168f806c210b7f3af
parent8327f304bee2f8c0d5d195cde72a241503cf1c98 (diff)
add is_unscheduled accessor
-rwxr-xr-xbin/db-iris2
-rw-r--r--lib/Travel/Status/DE/IRIS.pm5
-rw-r--r--lib/Travel/Status/DE/IRIS/Result.pm25
3 files changed, 25 insertions, 7 deletions
diff --git a/bin/db-iris b/bin/db-iris
index 684e80a..f2b65b0 100755
--- a/bin/db-iris
+++ b/bin/db-iris
@@ -368,7 +368,7 @@ for my $d ( $status->results() ) {
push(
@output,
[
- $timestr, $d->train,
+ $timestr, $d->train . ($d->is_unscheduled ? ' !' : q{}),
$edata{route} ? join( q{ }, $d->route_interesting ) : q{},
$d->route_end, $platformstr // q{}, $d
]
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 28441e4..95194ff 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -29,7 +29,7 @@ sub new {
datetime => $opt{datetime}
// DateTime->now( time_zone => 'Europe/Berlin' ),
developer_mode => $opt{developer_mode},
- iris_base => $opt{iris_base}
+ iris_base => $opt{iris_base}
// 'http://iris.noncd.db.de/iris-tts/timetable',
lookahead => $opt{lookahead} // ( 4 * 60 ),
serializable => $opt{serializable},
@@ -231,6 +231,9 @@ sub get_realtime {
if ( not $result ) {
$result = $self->add_result( $station, $s );
+ if ($result) {
+ $result->set_unscheduled(1);
+ }
}
if ( not $result ) {
next;
diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm
index 80319b5..82659b3 100644
--- a/lib/Travel/Status/DE/IRIS/Result.pm
+++ b/lib/Travel/Status/DE/IRIS/Result.pm
@@ -95,11 +95,12 @@ my %translation = (
);
Travel::Status::DE::IRIS::Result->mk_ro_accessors(
- qw(arrival classes date datetime delay departure is_cancelled is_transfer is_wing
- line_no train_no_transfer old_train_id old_train_no platform raw_id
- realtime_xml route_start route_end sched_arrival sched_departure
- sched_platform sched_route_start sched_route_end start stop_no time
- train_id train_no transfer type unknown_t unknown_o wing_id)
+ qw(arrival classes date datetime delay departure is_cancelled is_transfer
+ is_unscheduled is_wing line_no train_no_transfer old_train_id
+ old_train_no platform raw_id realtime_xml route_start route_end
+ sched_arrival sched_departure sched_platform sched_route_start
+ sched_route_end start stop_no time train_id train_no transfer type
+ unknown_t unknown_o wing_id)
);
sub new {
@@ -326,6 +327,12 @@ sub set_tl {
return $self;
}
+sub set_unscheduled {
+ my ( $self, $unscheduled ) = @_;
+
+ $self->{is_unscheduled} = $unscheduled;
+}
+
sub add_arrival_wingref {
my ( $self, $ref ) = @_;
@@ -821,6 +828,14 @@ the results and indicates it by setting B<is_transfer> to a true value.
In case of a transfer, B<train_id> and B<train_no> are set to the "new"
value, the old ones are available in B<old_train_id> and B<old_train_no>.
+=item $result->is_unscheduled
+
+True if the train does not appear in the requested plans. This can happen
+because of two reasons: Either the scheduled time and the actual time are so
+far apart that it should've arrived/departed long ago, or it really is an
+unscheduled train. In that case, it can be a replacement or an additional
+train. There is no logic to distinguish these cases yet.
+
=item $result->is_wing
Returns true if this result is a wing, false otherwise.