diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-11-17 22:23:40 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-11-17 22:23:40 +0100 |
commit | 06715210605df16181cf43c7c60cd39678a95c01 (patch) | |
tree | a0afbc4ae79b667fb550b22ebce0620180ac36dd | |
parent | 692c8d22b3e55fe0b8dbf7defcada9f8d31f0a8e (diff) |
Section: parse load data
-rwxr-xr-x | bin/hafas | 4 | ||||
-rw-r--r-- | lib/Travel/Routing/DE/HAFAS/Connection/Section.pm | 15 |
2 files changed, 16 insertions, 3 deletions
@@ -348,8 +348,8 @@ for my $res ( $hafas->connections ) { for my $sec ( $res->sections ) { if ( $sec->type eq 'JNY' ) { - printf( "${output_bold}%s${output_reset} → %s\n", - $sec->name, $sec->direction ); + printf( "${output_bold}%s${output_reset} → %s %s\n", + $sec->name, $sec->direction, display_occupancies($sec->load) ); printf( "%-5s %-${delay_fmt}s ab %s%s%s\n", $sec->dep_cancelled diff --git a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm index 50e3ff1..375398b 100644 --- a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm +++ b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm @@ -72,7 +72,12 @@ sub new { } } - # TODO load + my $tco = {}; + for my $tco_id ( @{ $sec->{jny}{dTrnCmpSX}{tcocX} // [] } ) { + my $tco_kv = $opt{common}{tcocL}[$tco_id]; + $tco->{ $tco_kv->{c} } = $tco_kv->{r}; + } + # TODO operator my $ref = { @@ -89,6 +94,7 @@ sub new { arr_platform => $sec->{arr}{aplatfR} // $sec->{arr}{aPlatfS}, dep_cancelled => $sec->{dep}{dCncl}, arr_cancelled => $sec->{arr}{aCncl}, + load => $tco, messages => \@messages, }; @@ -286,6 +292,13 @@ The line identifier may be a single number such as "11" (underground train line U 11), a single word such as "AIR" or a combination (e.g. "SB16"). May also provide line numbers of IC/ICE services. +=item $sec->load + +Maximum expected occupancy along this section. +Returns a hashref with keys FIRST and SECOND; each value ranges from 1 +(low occupancy) to 4 (fully booked). +Returns undef if occupancy data is not available. + =item $section->messages List of Travel::Status::DE::HAFAS::Message(3pm) objects associated with this |