summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-08-10 17:34:48 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-08-10 17:34:48 +0200
commit84664d24e63baa6efa420f805e387d06d586dbb9 (patch)
tree279eb032e0cc53a79127c0d3f5015ce926dc3574 /lib/Travel/Status/DE
parent563feae6991aaaa0bf3247d8e16ad5a078d7db7c (diff)
Journey, Stop: handle BVG utilization data
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/HAFAS/Journey.pm11
-rw-r--r--lib/Travel/Status/DE/HAFAS/Stop.pm11
2 files changed, 20 insertions, 2 deletions
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;