From 16c441e4333c205235a3e13fd914b087a1ad6a66 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 23 Jun 2019 17:08:47 +0200 Subject: also show exit direction based on wagon order --- lib/Travelynx.pm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 0755e77..d6a4899 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -13,6 +13,7 @@ use Geo::Distance; use JSON; use List::Util qw(first); use List::MoreUtils qw(after_incl before_incl); +use Travel::Status::DE::DBWagenreihung; use Travel::Status::DE::IRIS; use Travel::Status::DE::IRIS::Stations; use Travelynx::Helper::Sendmail; @@ -2375,6 +2376,38 @@ sub startup { if ( $platform_info->{kopfgleis} ) { $ret->{arr_direction} = $platform_info->{direction}; } + elsif ( $in_transit->{data}{wagonorder_arr} ) { + my $wr; + eval { + $wr + = Travel::Status::DE::DBWagenreihung->new( + from_json => + $in_transit->{data}{wagonorder_arr} ); + }; + if ( $wr + and $wr->sections + and defined $wr->direction ) + { + my $section_0 = ( $wr->sections )[0]; + my $direction = $wr->direction; + if ( $section_0 eq 'A' and $direction == 0 ) { + $ret->{arr_direction} + = $platform_info->{direction}; + } + elsif ( $section_0 ne 'A' + and $direction == 100 ) + { + $ret->{arr_direction} + = $platform_info->{direction}; + } + else { + $ret->{arr_direction} + = $platform_info->{direction} eq 'r' + ? 'l' + : 'r'; + } + } + } } } -- cgit v1.2.3