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 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
15 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
42 $progname =~ s/^.*\/(.*?)$/$1/;
45 my $id_date = $rcs_id;
46 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
48 push(@main::version_array
, $rcs_id);
50 Getopt
::Long
::Configure
("bundling");
53 "debug" => \
$Opt{'debug'},
54 "help|h" => \
$Opt{'help'},
55 "quiet|q" => \
$Opt{'quiet'},
56 "verbose|v+" => \
$Opt{'verbose'},
57 "version" => \
$Opt{'version'},
59 ) || die("$progname: Option error. Use -h for help.\n");
61 $Opt{'debug'} && ($Debug = 1);
62 $Opt{'help'} && usage
(0);
63 if ($Opt{'version'}) {
69 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
72 creator="gpsman2gpx - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/gpsman2gpx"
73 xmlns="http://www.topografix.com/GPX/1/1"
74 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
75 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
86 (.*?
)\t # some kind of worthless date
89 (.*) # lots of uninteresting stuff but with altitude
93 my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) =
94 ( $1, $2, $3, $4, $5, $6);
97 $Name = txt_to_xml
($Name);
98 $Cmt = txt_to_xml
($Cmt);
99 $Lat = conv_pos
($Lat);
100 $Lon = conv_pos
($Lon);
101 if ($Rest =~ /ele=([\d\.]+)\D/) {
104 print(" <wpt lat=\"$Lat\" lon=\"$Lon\">\n");
105 print(" <ele>$Ele</ele>\n") if length($Ele);
106 print(" <name>$Name</name>\n") if length($Name);
107 print(" <cmt>$Cmt</cmt>\n") if length($Cmt);
118 if ($Retval =~ /^([NSWE])([0-9\.]+)$/) {
119 my ($Pref, $Deg) = ($1, $2);
120 $Retval = ($Pref =~ /[SW]/)
124 warn("\"$Retval\": Invalid coordinate\n") unless $Opt{'quiet'};
131 # Print program version {{{
132 for (@main::version_array
) {
139 # Send the help message to stdout {{{
142 if ($Opt{'verbose'}) {
148 Usage: $progname [options] [file [files [...]]]
155 Increase level of verbosity. Can be repeated.
157 Be quiet, don’t warn about unknown lines and stuff.
159 Print version information.
161 Print debugging messages.
169 # Print a status message to stderr based on verbosity level {{{
170 my ($verbose_level, $Txt) = @_;
172 if ($Opt{'verbose'} >= $verbose_level) {
173 print(STDERR
"$progname: $Txt\n");
179 # Print a debugging message {{{
181 my @call_info = caller;
182 chomp(my $Txt = shift);
183 my $File = $call_info[1];
185 $File =~ s
#^.*/(.*?)$#$1#;
186 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
193 # Plain Old Documentation (POD) {{{
207 [options] [file [files [...]]]
217 =item B<-h>, B<--help>
219 Print a brief help summary.
221 =item B<-v>, B<--verbose>
223 Increase level of verbosity. Can be repeated.
227 Print version information.
231 Print debugging messages.
241 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
245 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
246 This is free software; see the file F<COPYING> for legalese stuff.
250 This program is free software; you can redistribute it and/or modify it
251 under the terms of the GNU General Public License as published by the
252 Free Software Foundation; either version 2 of the License, or (at your
253 option) any later version.
255 This program is distributed in the hope that it will be useful, but
256 WITHOUT ANY WARRANTY; without even the implied warranty of
257 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
258 See the GNU General Public License for more details.
260 You should have received a copy of the GNU General Public License along
261 with this program; if not, write to the Free Software Foundation, Inc.,
262 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
270 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :