From b8c760605104322b990674d90940f409c774adff Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 13 Mar 2021 11:39:08 +0100 Subject: show occupancy data if available --- bin/efa | 12 ++++++++++++ lib/Travel/Routing/DE/EFA.pm | 1 + lib/Travel/Routing/DE/EFA/Route/Part.pm | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/bin/efa b/bin/efa index 5840068..5675d1c 100755 --- a/bin/efa +++ b/bin/efa @@ -228,6 +228,18 @@ sub display_connection { } } + if ( $c->occupancy ) { + if ( $c->occupancy == 1 ) { + say "# geringe Auslastung"; + } + elsif ( $c->occupancy == 2 ) { + say "# hohe Auslastung"; + } + elsif ( $c->occupancy == 3 ) { + say "# sehr hohe Auslastung"; + } + } + for my $notice ( $c->current_notes ) { if ( $notice->subtitle ne $notice->subject ) { printf( "# %s - %s\n", $notice->subtitle, $notice->subject ); diff --git a/lib/Travel/Routing/DE/EFA.pm b/lib/Travel/Routing/DE/EFA.pm index a1e07ff..8b936ae 100644 --- a/lib/Travel/Routing/DE/EFA.pm +++ b/lib/Travel/Routing/DE/EFA.pm @@ -682,6 +682,7 @@ sub parse_xml_part { departure_stime => $self->itdtime_str($e_dstime), departure_stop => $e_dep->getAttribute('name'), departure_platform => $e_dep->getAttribute('platformName'), + occupancy => $e_dep->getAttribute('occupancy'), train_line => $e_mot->getAttribute('name'), train_product => $e_mot->getAttribute('productName'), train_destination => $e_mot->getAttribute('destination'), diff --git a/lib/Travel/Routing/DE/EFA/Route/Part.pm b/lib/Travel/Routing/DE/EFA/Route/Part.pm index 3a15fc3..da3d400 100644 --- a/lib/Travel/Routing/DE/EFA/Route/Part.pm +++ b/lib/Travel/Routing/DE/EFA/Route/Part.pm @@ -8,6 +8,12 @@ use parent 'Class::Accessor'; our $VERSION = '2.19'; +my %occupancy = ( + MANY_SEATS => 1, + FEW_SEATS => 2, + STANDING_ONLY => 3 +); + Travel::Routing::DE::EFA::Route::Part->mk_ro_accessors( qw(arrival_platform arrival_stop arrival_date arrival_time arrival_sdate arrival_stime delay @@ -15,6 +21,7 @@ Travel::Routing::DE::EFA::Route::Part->mk_ro_accessors( departure_stop departure_date departure_time departure_sdate departure_stime footpath_duration footpath_type + occupancy train_destination train_line train_product ) ); @@ -24,6 +31,13 @@ sub new { my $ref = \%conf; + if ( $ref->{occupancy} and exists $occupancy{ $ref->{occupancy} } ) { + $ref->{occupancy} = $occupancy{ $ref->{occupancy} }; + } + else { + delete $ref->{occupancy}; + } + return bless( $ref, $obj ); } -- cgit v1.2.3