summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-12-07 19:44:18 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-12-07 19:44:18 +0100
commit2ee5332ee5373b87c3a3305c7884f0aaaeb78906 (patch)
tree536bb66d0695485d33f893793f170f31c479e345
parentc509703ce55e4347af3a07e52b989618f06b710b (diff)
warn if a connecting train may not be reached
-rwxr-xr-xlib/Travelynx.pm30
-rw-r--r--templates/_connections.html.ep6
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index edb4637..281a9a0 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -1446,6 +1446,7 @@ sub startup {
my ( $eva, $exclude_via, $exclude_train_id, $exclude_before );
my $now = $self->now->epoch;
+ my ( $stationinfo, $arr_epoch, $arr_platform );
if ( $opt{eva} ) {
if ( $use_history & 0x01 ) {
@@ -1461,8 +1462,11 @@ sub startup {
$eva = $status->{arr_eva};
$exclude_via = $status->{dep_name};
$exclude_train_id = $status->{train_id};
+ $arr_platform = $status->{arr_platform};
+ $stationinfo = $status->{extra_data}{stationinfo_arr};
if ( $status->{real_arrival} ) {
- $exclude_before = $status->{real_arrival}->epoch;
+ $exclude_before = $arr_epoch
+ = $status->{real_arrival}->epoch;
}
}
}
@@ -1578,6 +1582,30 @@ sub startup {
my @message_ids
= List::Util::uniq map { $_->[1] } $train->raw_messages;
$train->{message_id} = { map { $_ => 1 } @message_ids };
+ my $interchange_duration;
+ if ( exists $stationinfo->{i} ) {
+ $interchange_duration
+ = $stationinfo->{i}{$arr_platform}{ $train->platform };
+ $interchange_duration //= $stationinfo->{i}{"*"};
+ }
+ if ( defined $interchange_duration ) {
+ my $interchange_time
+ = ( $train->departure->epoch - $arr_epoch ) / 60;
+ if ( $interchange_time < $interchange_duration ) {
+ $train->{interchange_text} = 'Anschluss knapp';
+ $train->{interchange_icon} = 'warning';
+ }
+ elsif ( $interchange_time == $interchange_duration ) {
+ $train->{interchange_text}
+ = 'Anschluss könnte knapp werden';
+ $train->{interchange_icon} = 'directions_run';
+ }
+
+ #else {
+ # $train->{interchange_text} = 'Anschluss wird voraussichtlich erreicht';
+ # $train->{interchange_icon} = 'check';
+ #}
+ }
}
return ( @results, @cancellations );
diff --git a/templates/_connections.html.ep b/templates/_connections.html.ep
index b44841b..d09f0c0 100644
--- a/templates/_connections.html.ep
+++ b/templates/_connections.html.ep
@@ -50,6 +50,9 @@
% if ($train->departure_delay) {
%= sprintf('(%+d)', $train->departure_delay)
% }
+ % if ($train->{interchange_icon}) {
+ <i class="material-icons tiny" aria-label="<%= $train->{interchange_text} %>"><%= $train->{interchange_icon} %></i>
+ % }
% if ($train->platform) {
<br/>Gleis <%= $train->platform %>
% }
@@ -108,6 +111,9 @@
% if ($train->departure_delay) {
%= sprintf('(%+d)', $train->departure_delay)
% }
+ % if ($train->{interchange_icon}) {
+ <i class="material-icons tiny" aria-label="<%= $train->{interchange_text} %>"><%= $train->{interchange_icon} %></i>
+ % }
% }
</td><td>
% if ($train->platform and not $train->departure_is_cancelled) {