3 #=======================================================================
5 # File ID: f66b9fe8-f923-11dd-a087-0001805bf4b1
6 # Quick & dirty script for converting gpsman(1) sdata files to GPX.
9 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 3 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
17 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
39 $progname =~ s/^.*\/(.*?)$/$1/;
40 our $VERSION = "0.00";
42 Getopt
::Long
::Configure
("bundling");
45 "debug" => \
$Opt{'debug'},
46 "help|h" => \
$Opt{'help'},
47 "quiet|q" => \
$Opt{'quiet'},
48 "verbose|v+" => \
$Opt{'verbose'},
49 "version" => \
$Opt{'version'},
51 ) || die("$progname: Option error. Use -h for help.\n");
53 $Opt{'debug'} && ($Debug = 1);
54 $Opt{'help'} && usage
(0);
55 if ($Opt{'version'}) {
61 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
64 creator="gpsman2gpx - http://sunny256.github.com/gpstools/"
65 xmlns="http://www.topografix.com/GPX/1/1"
66 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
67 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
77 (.*?
)\t # some kind of worthless date
80 (.*) # lots of uninteresting stuff but with altitude
84 my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) =
85 ( $1, $2, $3, $4, $5, $6);
88 $Name = txt_to_xml
($Name);
89 $Cmt = txt_to_xml
($Cmt);
90 $Lat = conv_pos
($Lat);
91 $Lon = conv_pos
($Lon);
92 if ($Rest =~ /ele=([\d\.]+)\D/) {
95 print(" <wpt lat=\"$Lat\" lon=\"$Lon\">\n");
96 print(" <ele>$Ele</ele>\n") if length($Ele);
97 print(" <name>$Name</name>\n") if length($Name);
98 print(" <cmt>$Cmt</cmt>\n") if length($Cmt);
109 if ($Retval =~ /^([NSWE])([0-9\.]+)$/) {
110 my ($Pref, $Deg) = ($1, $2);
111 $Retval = ($Pref =~ /[SW]/)
115 warn("\"$Retval\": Invalid coordinate\n") unless $Opt{'quiet'};
122 # Print program version {{{
123 print("$progname v$VERSION\n");
128 # Send the help message to stdout {{{
131 if ($Opt{'verbose'}) {
137 Usage: $progname [options] [file [files [...]]]
144 Increase level of verbosity. Can be repeated.
146 Be quiet, don’t warn about unknown lines and stuff.
148 Print version information.
150 Print debugging messages.
158 # Print a status message to stderr based on verbosity level {{{
159 my ($verbose_level, $Txt) = @_;
161 if ($Opt{'verbose'} >= $verbose_level) {
162 print(STDERR
"$progname: $Txt\n");
168 # Print a debugging message {{{
170 my @call_info = caller;
171 chomp(my $Txt = shift);
172 my $File = $call_info[1];
174 $File =~ s
#^.*/(.*?)$#$1#;
175 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
182 # Plain Old Documentation (POD) {{{
192 [options] [file [files [...]]]
202 =item B<-h>, B<--help>
204 Print a brief help summary.
206 =item B<-v>, B<--verbose>
208 Increase level of verbosity. Can be repeated.
212 Print version information.
216 Print debugging messages.
226 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
230 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
231 This is free software; see the file F<COPYING> for legalese stuff.
235 This program is free software: you can redistribute it and/or modify it
236 under the terms of the GNU General Public License as published by the
237 Free Software Foundation, either version 3 of the License, or (at your
238 option) any later version.
240 This program is distributed in the hope that it will be useful, but
241 WITHOUT ANY WARRANTY; without even the implied warranty of
242 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
243 See the GNU General Public License for more details.
245 You should have received a copy of the GNU General Public License along
247 If not, see L<http://www.gnu.org/licenses/>.
255 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :