Loading bin/dbris-m +11 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,13 @@ sub display_occupancy { return q{?}; } sub format_occupancy { my ($stop) = @_; return display_occupancy( $stop->occupancy_first ) . display_occupancy( $stop->occupancy_second ); } sub format_delay { my ( $delay, $len ) = @_; if ( $delay and $len ) { Loading Loading @@ -257,6 +264,7 @@ elsif ( $opt{journey} ) { my $max_platform = max map { length( $_->platform // q{} ) } $trip->route; my $max_delay = max map { $_->delay ? length( $_->delay ) + 3 : 0 } $trip->route; my $max_occupancy = max map { $_->occupancy ? 2 : 0 } $trip->route; my $mark_stop = 0; my $now = DateTime->now( time_zone => 'Europe/Berlin' ); Loading Loading @@ -298,6 +306,9 @@ elsif ( $opt{journey} ) { } printf( " %${max_delay}s", format_delay( $stop->delay, $max_delay - 3 ) ); if ($max_occupancy) { printf( " %${max_occupancy}s", format_occupancy($stop) ); } printf( " %-${max_name}s %${max_platform}s\n", $stop->name, $stop->platform // q{} ); if ( $stop == $mark_stop ) { Loading lib/Travel/Status/DE/DBRIS/Location.pm +21 −0 Original line number Diff line number Diff line Loading @@ -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 ) ); Loading Loading @@ -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; Loading Loading
bin/dbris-m +11 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,13 @@ sub display_occupancy { return q{?}; } sub format_occupancy { my ($stop) = @_; return display_occupancy( $stop->occupancy_first ) . display_occupancy( $stop->occupancy_second ); } sub format_delay { my ( $delay, $len ) = @_; if ( $delay and $len ) { Loading Loading @@ -257,6 +264,7 @@ elsif ( $opt{journey} ) { my $max_platform = max map { length( $_->platform // q{} ) } $trip->route; my $max_delay = max map { $_->delay ? length( $_->delay ) + 3 : 0 } $trip->route; my $max_occupancy = max map { $_->occupancy ? 2 : 0 } $trip->route; my $mark_stop = 0; my $now = DateTime->now( time_zone => 'Europe/Berlin' ); Loading Loading @@ -298,6 +306,9 @@ elsif ( $opt{journey} ) { } printf( " %${max_delay}s", format_delay( $stop->delay, $max_delay - 3 ) ); if ($max_occupancy) { printf( " %${max_occupancy}s", format_occupancy($stop) ); } printf( " %-${max_name}s %${max_platform}s\n", $stop->name, $stop->platform // q{} ); if ( $stop == $mark_stop ) { Loading
lib/Travel/Status/DE/DBRIS/Location.pm +21 −0 Original line number Diff line number Diff line Loading @@ -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 ) ); Loading Loading @@ -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; Loading