From 67fffbb4d97e8b353f2696273f62da6087ae2fba Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 12 Dec 2020 11:00:54 +0100 Subject: add conditions and details to json (raw data so far) --- bin/db-wagenreihung-to-json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bin/db-wagenreihung-to-json') diff --git a/bin/db-wagenreihung-to-json b/bin/db-wagenreihung-to-json index 893132e..9827523 100755 --- a/bin/db-wagenreihung-to-json +++ b/bin/db-wagenreihung-to-json @@ -172,6 +172,9 @@ for my $line (@lines) { $map{$number}{route} .= $+{route}; } elsif ( $state eq "route" and $line eq "" ) { + $state = "conditions"; + } + elsif ( $state eq "conditions" and $line =~ m{ Hg | Tfz | BrH }x ) { $state = "details"; } @@ -180,11 +183,23 @@ for my $line (@lines) { =~ m{ ^ \d* \s{1,10} (? D? (WL)? (A|AB|B|W) R? D? [aceimpvw] \S* ) \s* (? \d+ )? (?: $ | \s{6} ) }x ) { + $state = "wagonorder"; push( @{ $wagon_map{$number} }, [ $+{type}, $+{number} ] ); #$map{$number}{has_wagon}{$1} = \1; $map{$number}{wagons}{$1} = \1; } + + if ( $state eq "conditions" and length($line) and $line =~ m{ \S }x ) { + push( @{ $map{$number}{conditions} }, $line ); + } + + if ( $state eq "details" + and length($line) + and $line =~ m{ Hg | Tfz | BrH }x ) + { + push( @{ $map{$number}{details} }, $line ); + } } for my $train_number ( keys %map ) { -- cgit v1.2.3