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 #=======================================================================
18 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
40 $progname =~ s/^.*\/(.*?)$/$1/;
41 our $VERSION = "0.00";
43 Getopt
::Long
::Configure
("bundling");
46 "debug" => \
$Opt{'debug'},
47 "help|h" => \
$Opt{'help'},
48 "quiet|q" => \
$Opt{'quiet'},
49 "verbose|v+" => \
$Opt{'verbose'},
50 "version" => \
$Opt{'version'},
52 ) || die("$progname: Option error. Use -h for help.\n");
54 $Opt{'debug'} && ($Debug = 1);
55 $Opt{'help'} && usage
(0);
56 if ($Opt{'version'}) {
62 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
65 creator="gpsman2gpx - http://sunny256.github.com/gpstools/"
66 xmlns="http://www.topografix.com/GPX/1/1"
67 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
68 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
78 (.*?
)\t # some kind of worthless date
81 (.*) # lots of uninteresting stuff but with altitude
85 my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) =
86 ( $1, $2, $3, $4, $5, $6);
89 $Name = txt_to_xml
($Name);
90 $Cmt = txt_to_xml
($Cmt);
91 $Lat = conv_pos
($Lat);
92 $Lon = conv_pos
($Lon);
93 if ($Rest =~ /ele=([\d\.]+)\D/) {
96 print(" <wpt lat=\"$Lat\" lon=\"$Lon\">\n");
97 print(" <ele>$Ele</ele>\n") if length($Ele);
98 print(" <name>$Name</name>\n") if length($Name);
99 print(" <cmt>$Cmt</cmt>\n") if length($Cmt);
110 if ($Retval =~ /^([NSWE])([0-9\.]+)$/) {
111 my ($Pref, $Deg) = ($1, $2);
112 $Retval = ($Pref =~ /[SW]/)
116 warn("\"$Retval\": Invalid coordinate\n") unless $Opt{'quiet'};
123 # Print program version {{{
124 print("$progname v$VERSION\n");
129 # Send the help message to stdout {{{
132 if ($Opt{'verbose'}) {
138 Usage: $progname [options] [file [files [...]]]
145 Increase level of verbosity. Can be repeated.
147 Be quiet, don’t warn about unknown lines and stuff.
149 Print version information.
151 Print debugging messages.
159 # Print a status message to stderr based on verbosity level {{{
160 my ($verbose_level, $Txt) = @_;
162 if ($Opt{'verbose'} >= $verbose_level) {
163 print(STDERR
"$progname: $Txt\n");
169 # Print a debugging message {{{
171 my @call_info = caller;
172 chomp(my $Txt = shift);
173 my $File = $call_info[1];
175 $File =~ s
#^.*/(.*?)$#$1#;
176 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
183 # Plain Old Documentation (POD) {{{
193 [options] [file [files [...]]]
203 =item B<-h>, B<--help>
205 Print a brief help summary.
207 =item B<-v>, B<--verbose>
209 Increase level of verbosity. Can be repeated.
213 Print version information.
217 Print debugging messages.
227 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
231 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
232 This is free software; see the file F<COPYING> for legalese stuff.
236 This program is free software: you can redistribute it and/or modify it
237 under the terms of the GNU General Public License as published by the
238 Free Software Foundation, either version 3 of the License, or (at your
239 option) any later version.
241 This program is distributed in the hope that it will be useful, but
242 WITHOUT ANY WARRANTY; without even the implied warranty of
243 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
244 See the GNU General Public License for more details.
246 You should have received a copy of the GNU General Public License along
248 If not, see L<http://www.gnu.org/licenses/>.
256 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :