From 228476067c3bb9d0e5c029ae745dd615881eaec5 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 5 Jan 2019 22:25:35 +0100 Subject: destinations: Show sections for each destination --- bin/db-wagenreihung | 7 ++++++- lib/Travel/Status/DE/DBWagenreihung.pm | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/db-wagenreihung b/bin/db-wagenreihung index 8884547..3f8e77c 100755 --- a/bin/db-wagenreihung +++ b/bin/db-wagenreihung @@ -74,7 +74,12 @@ printf( "%s: %s → %s (%s)\n%s Gleis %s\n\n", join( ' / ', map { $wr->train_type . ' ' . $_ } $wr->train_numbers ), join( ' / ', $wr->origins ), - join( ' / ', $wr->destinations ), + join( + ' / ', + map { + sprintf( '%s (%s)', $_->{name}, join( q{}, @{ $_->{sections} } ) ) + } $wr->destinations + ), $wr->train_subtype // 'IC?', $wr->station_name, $wr->platform diff --git a/lib/Travel/Status/DE/DBWagenreihung.pm b/lib/Travel/Status/DE/DBWagenreihung.pm index 7bba010..1f3c440 100644 --- a/lib/Travel/Status/DE/DBWagenreihung.pm +++ b/lib/Travel/Status/DE/DBWagenreihung.pm @@ -121,13 +121,21 @@ sub destinations { } my @destinations; + my %section; for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) { - push( @destinations, $group->{zielbetriebsstellename} ); + my $destination = $group->{zielbetriebsstellename}; + my @sections = map { $_->{fahrzeugsektor} } @{ $group->{allFahrzeug} }; + @sections = uniq @sections; + push( @{ $section{$destination} }, @sections ); + push( @destinations, $destination ); } @destinations = uniq @destinations; + @destinations + = map { { name => $_, sections => $section{$_} } } @destinations; + $self->{destinations} = \@destinations; return @destinations; -- cgit v1.2.3