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"
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 :