diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-12-21 13:57:06 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-12-21 13:57:06 +0100 |
commit | 2accf39cfec2fb023796a07f3de264b1ffc5a96f (patch) | |
tree | 12d733c4b0ba0b3c2b16b9c24c73284e21cd310b | |
parent | 0fbd6b8778fa66a7c31df304b436a2f24fa69c26 (diff) |
remove wagon list if it contains duplicate wagon numbers
-rwxr-xr-x | bin/db-zugbildung-to-json | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/db-zugbildung-to-json b/bin/db-zugbildung-to-json index d6a3832..f5439d1 100755 --- a/bin/db-zugbildung-to-json +++ b/bin/db-zugbildung-to-json @@ -552,6 +552,7 @@ for my $train ( values %map ) { for my $train_number ( keys %map ) { my $wagon_numbers_ok = 1; my $wagon_types_ok = 1; + my $wagon_list_ok = 1; my %bincount; my %type_by_wagon_number; for my $wagon ( @{ $wagon_map{$train_number} // [] } ) { @@ -580,13 +581,12 @@ for my $train_number ( keys %map ) { } if ( $bincount{$wagon_number} > 1 ) { + $wagon_list_ok = 0; if ( $type_by_wagon_number{$wagon_number}[0] ne $type_by_wagon_number{$wagon_number}[1] ) { $wagon_types_ok = 0; } - - # TODO else -> wagon_list_ok = 0 ? } } } @@ -599,6 +599,12 @@ for my $train_number ( keys %map ) { delete $map{$train_number}{wagons}; delete $map{$train_number}{hasWagon}; } + elsif ( not $wagon_list_ok ) { + + # train type appears to be correct, but the list contains duplicates + # (e.g. due to unhandled schedule variants) + delete $map{$train_number}{wagons}; + } } # Cleanup |