From 84664d24e63baa6efa420f805e387d06d586dbb9 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 10 Aug 2024 17:34:48 +0200 Subject: Journey, Stop: handle BVG utilization data --- lib/Travel/Status/DE/HAFAS/Journey.pm | 11 ++++++++++- lib/Travel/Status/DE/HAFAS/Stop.pm | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'lib/Travel') diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm index e02e45c..07325e5 100644 --- a/lib/Travel/Status/DE/HAFAS/Journey.pm +++ b/lib/Travel/Status/DE/HAFAS/Journey.pm @@ -221,7 +221,16 @@ sub new { my %tco; for my $tco_id ( @{ $journey->{stbStop}{dTrnCmpSX}{tcocX} // [] } ) { my $tco_kv = $tcocL[$tco_id]; - $tco{ $tco_kv->{c} } = $tco_kv->{r}; + + # BVG has rRT (real-time?) and r (prognosed?); others only have r + my $load = $tco_kv->{rRT} // $tco_kv->{r}; + + # BVG uses 11 .. 13 rather than 1 .. 4 + if ( $load > 10 ) { + $load -= 10; + } + + $tco{ $tco_kv->{c} } = $load; } if (%tco) { $ref->{load} = \%tco; diff --git a/lib/Travel/Status/DE/HAFAS/Stop.pm b/lib/Travel/Status/DE/HAFAS/Stop.pm index 98af9ed..75560de 100644 --- a/lib/Travel/Status/DE/HAFAS/Stop.pm +++ b/lib/Travel/Status/DE/HAFAS/Stop.pm @@ -135,7 +135,16 @@ sub new { $ref->{load} = {}; for my $tco_id ( @{ $stop->{dTrnCmpSX}{tcocX} // [] } ) { my $tco_kv = $common->{tcocL}[$tco_id]; - $ref->{load}{ $tco_kv->{c} } = $tco_kv->{r}; + + # BVG has rRT (real-time?) and r (prognosed?); others only have r + my $load = $tco_kv->{rRT} // $tco_kv->{r}; + + # BVG uses 11 .. 13 rather than 1 .. 4 + if ( $load > 10 ) { + $load -= 10; + } + + $ref->{load}{ $tco_kv->{c} } = $load; } return $ref; -- cgit v1.2.3