diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-01-31 06:53:29 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-01-31 06:53:29 +0100 |
commit | 22d57710f75707fc1fe3f7e36923b72178f39aed (patch) | |
tree | 32d125d8102511a7b516b22eb8344aa0737a45c8 /lib/Travel/Routing/DE/DBRIS/Connection.pm | |
parent | d896bdcddc4e6e0161a3cab449ef4b11963543ab (diff) |
Indicate Add tranfer_duration accessor; set is_unlikely if negative
Diffstat (limited to 'lib/Travel/Routing/DE/DBRIS/Connection.pm')
-rw-r--r-- | lib/Travel/Routing/DE/DBRIS/Connection.pm | 18 |
1 files changed, 18 insertions, 0 deletions
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}; } |