From 67352734864b4387c95de60b4259daf0744263a6 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 20 Dec 2020 16:12:26 +0100 Subject: add locomotives to wagon list --- bin/db-wagenreihung-to-json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/db-wagenreihung-to-json b/bin/db-wagenreihung-to-json index 18d509e..45b9074 100755 --- a/bin/db-wagenreihung-to-json +++ b/bin/db-wagenreihung-to-json @@ -512,10 +512,10 @@ for my $train_number ( keys %map ) { my ( $wagon_type, $wagon_number ) = @{$wagon}; if ( $wagon_type =~ m{ 40[1-9] | 146 }x ) { - #push( @{ $type_by_wagon_number{$wagon_number} }, $wagon_type ); + # Locomotives do not have a wagon number. That's OK. next; } - if ( not $wagon_number ) { + elsif ( not $wagon_number ) { $wagon_numbers_ok = 0; } else { @@ -526,11 +526,13 @@ for my $train_number ( keys %map ) { if ($wagon_numbers_ok) { for my $wagon ( @{ $wagon_map{$train_number} // [] } ) { my ( $wagon_type, $wagon_number ) = @{$wagon}; + + push( @{ $map{$train_number}{wagons} }, $wagon ); + if ( $wagon_type =~ m{ 40[1-9] | 146 }x ) { next; } - push( @{ $map{$train_number}{wagons} }, $wagon ); if ( $bincount{$wagon_number} > 1 ) { if ( $type_by_wagon_number{$wagon_number}[0] ne $type_by_wagon_number{$wagon_number}[1] ) -- cgit v1.2.3