|
|
| version 1.4, 2017/09/10 03:14:30 | version 1.5, 2023/12/26 01:23:11 |
|---|---|
| Line 2 | Line 2 |
| # $Id$ | # $Id$ |
| use XML::Simple; | use XML::Simple; |
| use strict; | use strict; |
| use Data::Dumper; | |
| my $strips = XMLin('OmLand.gpx'); | my $strips = XMLin('OmLand.gpx'); |
| open CUP, "> OmLand.cup" or die "Couldn't open OmLand.cup: $!\n"; | open CUP, "> OmLand.cup" or die "Couldn't open OmLand.cup: $!\n"; |
| open GO, "> OmBook.cup" or die "Couldn't open OmBook.cup: $!\n"; | |
| #name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc,userdata,pics | #name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc,userdata,pics |
| #"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 32 open GO, "> OmBook.cup" or die "Couldn't | Line 32 open GO, "> OmBook.cup" or die "Couldn't |
| my %strips; | my %strips; |
| foreach my $stripnum ( keys %{$strips->{'wpt'}} ){ | foreach my $stripnum ( sort keys %{$strips->{'wpt'}} ){ |
| if ( defined $strips->{'wpt'}->{$stripnum}->{comment} ) { | if ( ! defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'aip'} ) { |
| if ( $strips->{'wpt'}->{$stripnum}->{comment} =~ m/Danger/ ){ | print CUP cupstr($stripnum); |
| next; | |
| } | |
| } | |
| print CUP cupstr($stripnum); | |
| if ( $strips->{'wpt'}->{$stripnum}->{'extensions'}->{gobook} eq "yes" ){ | |
| #addtocup($stripnum); | |
| print GO cupstr($stripnum); | |
| } | } |
| } | } |
| close GO; | |
| close CUP; | close CUP; |
| exit; | exit; |
| sub addtocup { | |
| my $stripnum = shift(@_); | |
| print qq["$strips->{'wpt'}->{$stripnum}->{'desc'}",]; | |
| print qq["L$stripnum",NZ,]; | |
| $strips->{'wpt'}->{$stripnum}->{'lat'} =~ s/://; | |
| print $strips->{'wpt'}->{$stripnum}->{'lat'} . ","; | |
| $strips->{'wpt'}->{$stripnum}->{'lon'} =~ s/://; | |
| print $strips->{'wpt'}->{$stripnum}->{'lon'} . ","; | |
| print $strips->{'wpt'}->{$stripnum}->{'ele'} . "m,3,,,,"; | |
| if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'} ) { | |
| print qq{"$strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'}"}; | |
| } | |
| print ",,\r\n"; | |
| } | |
| sub cupstr { | sub cupstr { |
| my $stripnum = shift(@_); | my $stripnum = shift(@_); |
| my $location = ""; | my $location = ""; |
| my $rwlen = ""; | |
| my $rwdir = ""; | |
| my $freq = ""; | |
| if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'} ) { | if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'} ) { |
| $location = $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'}; | $location = $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'}; |
| } | } |
| return sprintf( qq{"%s","L%s",NZ,%s,%s,%0.1fm,3,,,,"%s",,\r\n}, | if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'rwlen'} ) { |
| $rwlen = $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'rwlen'}; | |
| } | |
| if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'rwdir'} ) { | |
| $rwdir = $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'rwdir'}; | |
| } | |
| if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'freq'} ) { | |
| $freq = qq{"$strips->{'wpt'}->{$stripnum}->{'extensions'}->{'freq'}"}; | |
| } | |
| return sprintf( qq{"%s","L%s",NZ,%s,%s,%0.1fm,3,%s,%s,%s,"%s",,\r\n}, | |
| $strips->{'wpt'}->{$stripnum}->{'desc'}, | $strips->{'wpt'}->{$stripnum}->{'desc'}, |
| $stripnum, | $stripnum, |
| printlat($strips->{'wpt'}->{$stripnum}->{'lat'}), | printlat($strips->{'wpt'}->{$stripnum}->{'lat'}), |
| printlon($strips->{'wpt'}->{$stripnum}->{'lon'}), | printlon($strips->{'wpt'}->{$stripnum}->{'lon'}), |
| $strips->{'wpt'}->{$stripnum}->{'ele'}, | $strips->{'wpt'}->{$stripnum}->{'ele'}, |
| $rwlen, | |
| $rwdir, | |
| $freq, | |
| $location); | $location); |
| } | } |
| sub printlat { | sub printlat { |
| Line 93 sub printlat { | Line 85 sub printlat { |
| } | } |
| $degrees = int($latitude); | $degrees = int($latitude); |
| $minutes = ($latitude - $degrees) * 60; | $minutes = ($latitude - $degrees) * 60; |
| return sprintf("%d:%06.3f%s",$degrees,$minutes,$northing); | return sprintf("%d%06.3f%s",$degrees,$minutes,$northing); |
| } | } |
| sub printlon { | sub printlon { |
| Line 110 sub printlon { | Line 102 sub printlon { |
| } | } |
| $degrees = int($longitude); | $degrees = int($longitude); |
| $minutes = ($longitude - $degrees) * 60; | $minutes = ($longitude - $degrees) * 60; |
| return sprintf("%d:%06.3f%s",$degrees,$minutes,$westing); | return sprintf("%d%06.3f%s",$degrees,$minutes,$westing); |
| } | } |