diff options
-rwxr-xr-x | bin/dbris | 11 | ||||
-rw-r--r-- | lib/Travel/Routing/DE/DBRIS/Connection.pm | 18 | ||||
-rw-r--r-- | lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm | 2 |
3 files changed, 30 insertions, 1 deletions
@@ -310,6 +310,17 @@ for my $connection ( $ris->connections ) { } for my $segment ( $connection->segments ) { + if ( defined $segment->transfer_duration ) { + if ( $segment->transfer_duration->in_units('minutes') >= 0 ) { + $header .= sprintf( ' (%01d:%02d)', + $segment->transfer_duration->in_units( 'hours', 'minutes' ) + ); + } + else { + $header .= sprintf( " ${output_critical}(%02d)${output_reset}", + $segment->transfer_duration->in_units('minutes') ); + } + } if ( $segment->train_short ) { $header .= sprintf( ' %s', $segment->train_short ); } diff --git a/lib/Travel/Routing/DE/DBRIS/Connection.pm b/lib/Travel/Routing/DE/DBRIS/Connection.pm index 6ff4507..40bce91 100644 --- a/lib/Travel/Routing/DE/DBRIS/Connection.pm +++ b/lib/Travel/Routing/DE/DBRIS/Connection.pm @@ -90,6 +90,24 @@ sub new { ); } + for my $i ( 0 .. $#{ $ref->{segments} // [] } - 1 ) { + if ( $ref->{segments}[$i]{train_short} ) { + my $arr = $ref->{segments}[$i]->arr; + for my $j ( $i + 1 .. $#{ $ref->{segments} // [] } ) { + if ( $ref->{segments}[$j]{train_short} ) { + my $dep = $ref->{segments}[$j]->dep; + if ( $arr and $dep ) { + $ref->{segments}[$j]{transfer_duration} = $dep - $arr; + if ( $dep < $arr ) { + $ref->{segments}[$i]{is_unlikely} = 1; + } + } + last; + } + } + } + } + for my $key (qw(sched_dep rt_dep dep)) { $ref->{$key} = $ref->{segments}[0]{$key}; } diff --git a/lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm b/lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm index 1b01d77..1f6e598 100644 --- a/lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm +++ b/lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm @@ -18,7 +18,7 @@ Travel::Routing::DE::DBRIS::Connection::Segment->mk_ro_accessors( sched_dep rt_dep dep dep_platform sched_arr rt_arr arr arr_platform sched_duration rt_duration duration duration_percent - arr_delay dep_delay delay feasibility is_unlikely + arr_delay dep_delay delay feasibility is_unlikely transfer_duration journey_id occupancy occupancy_first occupancy_second is_transfer is_walk walk_name distance_m |