diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-28 18:28:50 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-28 18:28:50 +0100 |
commit | 316f913081689dcdc5ec5915b7520fbee7499377 (patch) | |
tree | d08896ccf7e8fb24519b10715937506824c8b380 /lib/Travel/Status/DE | |
parent | dedd91f52612db4b690dc0fea136a70cdb591a58 (diff) |
add occupancy data
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r-- | lib/Travel/Status/DE/DBRIS/Location.pm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/DBRIS/Location.pm b/lib/Travel/Status/DE/DBRIS/Location.pm index 0355c95..9b7891b 100644 --- a/lib/Travel/Status/DE/DBRIS/Location.pm +++ b/lib/Travel/Status/DE/DBRIS/Location.pm @@ -11,6 +11,7 @@ our $VERSION = '0.01'; Travel::Status::DE::DBRIS::Location->mk_ro_accessors( qw(eva id lat lon name products type is_cancelled is_additional is_separation display_priority dep arr arr_delay dep_delay delay platform sched_platform rt_platform + occupancy_first occupancy_second occupancy ) ); @@ -64,6 +65,26 @@ sub new { $ref->{delay} = $ref->{arr_delay} // $ref->{dep_delay}; + for my $occupancy ( @{ $json->{auslastungsmeldungen} // [] } ) { + if ( $occupancy->{klasse} eq 'KLASSE_1' ) { + $ref->{occupancy_first} = $occupancy->{stufe}; + } + if ( $occupancy->{klasse} eq 'KLASSE_2' ) { + $ref->{occupancy_second} = $occupancy->{stufe}; + } + } + + if ( $ref->{occupancy_first} and $ref->{occupancy_second} ) { + $ref->{occupancy} + = ( $ref->{occupancy_first} + $ref->{occupancy_second} ) / 2; + } + elsif ( $ref->{occupancy_first} ) { + $ref->{occupancy} = $ref->{occupancy_first}; + } + elsif ( $ref->{occupancy_second} ) { + $ref->{occupancy} = $ref->{occupancy_second}; + } + for my $message ( @{ $json->{priorisierteMeldungen} // [] } ) { if ( $message->{type} and $message->{type} eq 'HALT_AUSFALL' ) { $ref->{is_cancelled} = 1; |