--- cup-aerodromes.perl 2013/12/21 00:40:30 1.2 +++ cup-aerodromes.perl 2013/12/22 01:18:25 1.3 @@ -1,5 +1,5 @@ #! /usr/bin/perl -w -# $Id: cup-aerodromes.perl,v 1.2 2013/12/21 00:40:30 philip Exp $ +# $Id: cup-aerodromes.perl,v 1.3 2013/12/22 01:18:25 philip Exp $ use XML::Simple; use Data::Dumper; use strict; @@ -9,7 +9,7 @@ my $aerodromes; my $xml = "aerodromes.gpx"; if ( defined $xml ){ my $xs = XML::Simple->new(); - $aerodromes = $xs->XMLin($xml, KeyAttr => { wpt => "name", 'runway' => "designation" }, ForceArray => ['runway','frequency']); + $aerodromes = $xs->XMLin($xml, KeyAttr => { wpt => "name" }, ForceArray => ['runway','frequency']); } #print Dumper($aerodromes); @@ -33,11 +33,15 @@ foreach my $ad ( keys %{$aerodromes->{'w print TXT $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'frequencies'}->{'frequency'}->[$f]->{'desc'}; print TXT "\n"; } - # Some aerodromes have two runways with the same designation, e.g. Alexandra. Must find a fix ... - foreach my $rw ( $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'runways'}->{'runway'} ){ - foreach my $runway ( keys %{$rw} ){ - print TXT qq[$runway $rw->{$runway}->{'length'} x $rw->{$runway}->{'width'} $rw->{$runway}->{'surface'}\n]; - } + foreach my $rw ( 0 .. $#{ $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'runways'}->{'runway'} }){ + print TXT $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'runways'}->{'runway'}->[$rw]->{'designation'}; + print TXT " "; + print TXT $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'runways'}->{'runway'}->[$rw]->{'length'}; + print TXT " x "; + print TXT $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'runways'}->{'runway'}->[$rw]->{'width'}; + print TXT " "; + print TXT $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'runways'}->{'runway'}->[$rw]->{'surface'}; + print TXT "\n"; } } }