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 #=======================================================================
15 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
38 $progname =~ s/^.*\/(.*?)$/$1/;
39 our $VERSION = "0.00";
41 Getopt
::Long
::Configure
("bundling");
44 "debug" => \
$Opt{'debug'},
45 "help|h" => \
$Opt{'help'},
46 "quiet|q" => \
$Opt{'quiet'},
47 "verbose|v+" => \
$Opt{'verbose'},
48 "version" => \
$Opt{'version'},
50 ) || die("$progname: Option error. Use -h for help.\n");
52 $Opt{'debug'} && ($Debug = 1);
53 $Opt{'help'} && usage
(0);
54 if ($Opt{'version'}) {
60 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
63 creator="gpsman2gpx - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/gpsman2gpx"
64 xmlns="http://www.topografix.com/GPX/1/1"
65 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
76 (.*?
)\t # some kind of worthless date
79 (.*) # lots of uninteresting stuff but with altitude
83 my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) =
84 ( $1, $2, $3, $4, $5, $6);
87 $Name = txt_to_xml
($Name);
88 $Cmt = txt_to_xml
($Cmt);
89 $Lat = conv_pos
($Lat);
90 $Lon = conv_pos
($Lon);
91 if ($Rest =~ /ele=([\d\.]+)\D/) {
94 print(" <wpt lat=\"$Lat\" lon=\"$Lon\">\n");
95 print(" <ele>$Ele</ele>\n") if length($Ele);
96 print(" <name>$Name</name>\n") if length($Name);
97 print(" <cmt>$Cmt</cmt>\n") if length($Cmt);
108 if ($Retval =~ /^([NSWE])([0-9\.]+)$/) {
109 my ($Pref, $Deg) = ($1, $2);
110 $Retval = ($Pref =~ /[SW]/)
114 warn("\"$Retval\": Invalid coordinate\n") unless $Opt{'quiet'};
121 # Print program version {{{
122 print("$progname v$VERSION\n");
127 # Send the help message to stdout {{{
130 if ($Opt{'verbose'}) {
136 Usage: $progname [options] [file [files [...]]]
143 Increase level of verbosity. Can be repeated.
145 Be quiet, don’t warn about unknown lines and stuff.
147 Print version information.
149 Print debugging messages.
157 # Print a status message to stderr based on verbosity level {{{
158 my ($verbose_level, $Txt) = @_;
160 if ($Opt{'verbose'} >= $verbose_level) {
161 print(STDERR
"$progname: $Txt\n");
167 # Print a debugging message {{{
169 my @call_info = caller;
170 chomp(my $Txt = shift);
171 my $File = $call_info[1];
173 $File =~ s
#^.*/(.*?)$#$1#;
174 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
181 # Plain Old Documentation (POD) {{{
191 [options] [file [files [...]]]
201 =item B<-h>, B<--help>
203 Print a brief help summary.
205 =item B<-v>, B<--verbose>
207 Increase level of verbosity. Can be repeated.
211 Print version information.
215 Print debugging messages.
225 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
229 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
230 This is free software; see the file F<COPYING> for legalese stuff.
234 This program is free software: you can redistribute it and/or modify it
235 under the terms of the GNU General Public License as published by the
236 Free Software Foundation, either version 3 of the License, or (at your
237 option) any later version.
239 This program is distributed in the hope that it will be useful, but
240 WITHOUT ANY WARRANTY; without even the implied warranty of
241 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
242 See the GNU General Public License for more details.
244 You should have received a copy of the GNU General Public License along
246 If not, see L<http://www.gnu.org/licenses/>.
254 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :