|
|
| version 1.1, 2013/11/23 00:32:39 | version 1.2, 2013/12/21 00:40:30 |
|---|---|
| Line 8 my $aerodromes; | Line 8 my $aerodromes; |
| my $xml = "aerodromes.gpx"; | my $xml = "aerodromes.gpx"; |
| if ( defined $xml ){ | if ( defined $xml ){ |
| $aerodromes = XMLin($xml); | my $xs = XML::Simple->new(); |
| $aerodromes = $xs->XMLin($xml, KeyAttr => { wpt => "name", 'runway' => "designation" }, ForceArray => ['runway','frequency']); | |
| } | } |
| #print Dumper($aerodromes); | #print Dumper($aerodromes); |
| open CUP, "> aerodromes.cup" or die "Couldn't open aerodromes.cup: $!\n"; | open CUP, "> aerodromes.cup" or die "Couldn't open aerodromes.cup: $!\n"; |
| open TXT, "> aerodromes.txt" or die "Couldn't open aerodromes.txt: $!\n"; | |
| print CUP "name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc,userdata,pics\n"; | print CUP "name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc,userdata,pics\n"; |
| #"Ahuriri",0002,NZ,4414.000S,16936.000E,756.0m,1,,,,"Mouth of Canyon Creek",, | #"Ahuriri",0002,NZ,4414.000S,16936.000E,756.0m,1,,,,"Mouth of Canyon Creek",, |
| Line 21 foreach my $ad ( keys %{$aerodromes->{'w | Line 23 foreach my $ad ( keys %{$aerodromes->{'w |
| if ( defined $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'elev'} ){ | if ( defined $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'elev'} ){ |
| print CUP qq{"$ad",}; | print CUP qq{"$ad",}; |
| print CUP qq["$aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'aip'}",NZ,]; | print CUP qq["$aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'aip'}",NZ,]; |
| print CUP printlat($aerodromes->{'wpt'}->{$ad}->{lat}) . ","; | print CUP printlat($aerodromes->{'wpt'}->{$ad}->{lat}) . ","; |
| print CUP printlon($aerodromes->{'wpt'}->{$ad}->{lon}) . ","; | print CUP printlon($aerodromes->{'wpt'}->{$ad}->{lon}) . ","; |
| print CUP $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'elev'} . "ft,2,,,,,,\r\n"; | print CUP $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'elev'} . "ft,2,,,,,,\r\n"; |
| print TXT qq{[$ad]\n}; | |
| foreach my $f ( 0 .. $#{ $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'frequencies'}->{'frequency'} }){ | |
| print TXT $aerodromes->{'wpt'}->{$ad}->{'extensions'}->{'aerodrome'}->{'frequencies'}->{'frequency'}->[$f]->{'frequency'}; | |
| print TXT " "; | |
| 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]; | |
| } | |
| } | |
| } | } |
| } | } |
| close TXT; | |
| close CUP; | close CUP; |
| exit; | exit; |