4 # geo://wpname:cmnt@34.15,-118.15/topo=/somedir,aerial=/someotherdir
7 die "Usage: viking-remote uri\n" if ( $#ARGV < 0 );
9 if ( $ARGV[0] eq "debug" ) {
16 ($ARGV[0] =~ m
<(geo
:)?
/*([^/]*)(/(.*))?
>) or die "Bad URI";
20 if ( $loc =~ /^(GC[0-9A-Z]+)$/ ) {
22 $loc=`gcfetchtxt http://www.geocaching.com/seek/cache_details.aspx?wp=$loc|head -2|tail +2`;
25 # have a lot of fun...
26 ($loc =~ /^(([^:@]*)(:([^:@]*))?@)?N?(S?)\s*((([0-9'"`°o\-\.])|(° ))*)[, ]\s*E?(W?)\s*(([0-9'"`o\-\.]|(° ))*)(:([0-9\-\.]*))?$/)
29 $wp = $2 ?
$2 : ( $gc ?
$gc : "waypoint" );
30 $cmt = $4; $lat = $6; $lon = $11; $alt = $15;
32 $latfact = ($5 eq "S") ?
-1 : 1;
33 $lonfact = ($10 eq "W") ?
-1 : 1;
35 if ( $lat =~ /^(-?)(\d*)[°'"`o] *([\d.]*)$/ ) {
36 $lat = ($2 + ($3/60)) * ($1 ?
-1 : 1);
38 if ( $lon =~ /^(-?)(\d*)[°'"`o] *([\d.]*)$/ ) {
39 $lon = ($2 + ($3/60)) * ($1 ?
-1 : 1);
45 if ( $extras =~ /^(auto)?street/ ) {
56 open(PIPE
, "|viking -- -");
60 #VIKING GPS Data file http://gpsmaps.org/viking/
68 @maps = split(',', $extras);
69 foreach $map (@maps) {
74 if ( $map =~ /^auto/ ) {
76 $map = substr($map, 4, 999);
78 if ( $map =~ /^street/i ) {
80 } elsif ( $map =~ /^expedia/i ) {
82 } elsif ( $map =~ /^urban/ || $map =~ /^color/ ) {
84 } elsif ( $map =~ /^topo/ || $map =~ /^terraserver/ ) {
86 } elsif ( $map =~ /^ortho/ || $map =~ /^aerial/ ) {
89 if ( $maptype != -1 ) {
90 @mapanddir = split('=', $map);
91 if ( $#mapanddir > 0 ) {
92 $mapname = $mapanddir[0];
93 $mapdir = $mapanddir[1];
107 print PIPE
<<ENDDATA;
114 type="waypoint" latitude="$lat" longitude="$lon" name="$wp" comment="$cmt" altitude="$alt"