From 80139a3a3166ee8cd8bfbed4f67e1bdca03cfa81 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 27 Apr 2024 10:49:48 +0200 Subject: Make origins return a list of hashrefs, just like destinations --- lib/Travel/Status/DE/DBWagenreihung.pm | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'lib/Travel') diff --git a/lib/Travel/Status/DE/DBWagenreihung.pm b/lib/Travel/Status/DE/DBWagenreihung.pm index 5f7f0ba..dceaf2f 100644 --- a/lib/Travel/Status/DE/DBWagenreihung.pm +++ b/lib/Travel/Status/DE/DBWagenreihung.pm @@ -255,13 +255,20 @@ sub origins { } my @origins; + my %section; for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) { - push( @origins, $group->{startbetriebsstellename} ); + my $origin = $group->{startbetriebsstellename}; + my @sections = map { $_->{fahrzeugsektor} } @{ $group->{allFahrzeug} }; + push( @{ $section{$origin} }, @sections ); + push( @origins, $origin ); } @origins = uniq @origins; + @origins + = map { { name => $_, sections => [ uniq @{ $section{$_} } ] } } @origins; + $self->{origins} = \@origins; return @origins; @@ -805,13 +812,13 @@ Train number. Do not include the train type: Use "8" for "EC 8" or =item $wr->destinations -Returns a list describing all final destinations of this train. In most -cases, it contains one element, however, for trains consisting of multiple -wings, it contains one element for each wing. +Returns a list describing the destinations of this train's wagons. In most +cases, it contains one element. For trains consisting of multiple wings or +trains that switch locomotives along the way, it contains one element for each +wing or other kind of wagon group. -Each destination is a hash ref containing the destination B and the -corresponding platform I (at the moment, this is a list of section -identifiers). +Each destination is a hash ref containing its B and the corresponding +platform I (at the moment, this is a list of section identifiers). This function is subject to change. @@ -828,11 +835,13 @@ Returns undef otherwise. =item $wr->origins -Returns a list of stations this train originates from. In most cases, this is -just one element; however, for trains consisting of multiple wings, it gives -the origin of each wing unless they are identical. +Returns a list describing the origins of this train's wagons. In most +cases, it contains one element. For trains consisting of multiple wings or +trains that switch locomotives along the way, it contains one element for each +wing or other kind of wagon group. -Each origin is a station name. +Each origin is a hash ref containing its B and the corresponding +platform I (at the moment, this is a list of section identifiers). This function is subject to change. -- cgit v1.2.3