/usr/bin/geocache2way is in gpsdrive-scripts 2.10~pre4-6.dfsg-5ubuntu4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #!/usr/bin/perl
#
# geocache2way - Kevin Stephens
# 04/30/02
#
# Script to read .loc files from geocaching.com, parse it and add it onto the end of way.txt.
#
use strict;
use XML::Simple;
use Data::Dumper;
use Getopt::Long;
# Open the XML file
my $FILE = 'geocaching.loc';
my $OUTFILE = "$ENV{'HOME'}/.gpsdrive/way.txt";
my ($DEBUG,$verbose);
GetOptions ('debug' => \$DEBUG,'file=s' => \$FILE,'output=s' => \$OUTFILE,'verbose' => \$verbose, 'help' => \&usage);
# Setup the XML object
my $xs = new XML::Simple(keyattr => "id");
my $location = $xs->XMLin($FILE);
if ($DEBUG) {
print Dumper($location);
} else {
# Check if it is single listing or multiple
if ($location->{'waypoint'}{'name'}) {
print_it($location->{'waypoint'});
} else {
foreach my $point (@{$location->{'waypoint'}}) {
print_it($point);
}
}
}
sub print_it {
my ($CACHE_ref) = @_;
my $id = $CACHE_ref->{'name'}{'id'};
my $lat = $CACHE_ref->{'coord'}{'lat'};
my $lon = $CACHE_ref->{'coord'}{'lon'};
my $name = $CACHE_ref->{'name'}{'content'};
# These are here for future expansion.
# Waiting for changes to gpsdrive way.txt.
# my $type = $CACHE_ref->{'type'};
# my $URL = $CACHE_ref->{'link'}{'content'};
# Clean out extra space
$name =~ s/^\s*//;
$name =~ s/\s*$//;
# $URL =~ s/\s//g;
if ($verbose) {
print "$id $lat $lon\n";
} else {
open(OUTFILE,">>$OUTFILE") || die "Can't open $OUTFILE\n";
print OUTFILE "$id $lat $lon\n";
close(OUTFILE);
# Now change the filename for the dsc file
my $DSCFILE = $OUTFILE;
$DSCFILE =~ s/\..*$//;
open(OUTFILE,">>$DSCFILE.dsc") || die "Can't open $DSCFILE\n";
print OUTFILE "\$$id\n$name\n\n";
close(OUTFILE);
}
}
sub usage {
print <<EOP;
Usage: geoparse.pl [-f | --file <filename>] [-o | --output <filename>] [-v | --verbose]
[-d | --debug] [-h | --help]
-f | --file = File to parse, takes a filename
-o | --output = File to write to. Default: \$HOME/.gpsdrive/way.txt
-v | --verbose = Print output to STDOUT instead of a file
-d | --debug = Debug
-h | --help = This usage screen
EOP
}
|