3 #=======================================================================
5 # Quick & dirty script for converting gpsman(1) sdata files to GPX.
8 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
9 # License: GNU General Public License version 2 or later, see end of
10 # file for legal stuff.
11 #=======================================================================
14 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
41 $progname =~ s/^.*\/(.*?)$/$1/;
44 my $id_date = $rcs_id;
45 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
47 push(@main::version_array
, $rcs_id);
49 Getopt
::Long
::Configure
("bundling");
52 "debug" => \
$Opt{'debug'},
53 "help|h" => \
$Opt{'help'},
54 "quiet|q" => \
$Opt{'quiet'},
55 "verbose|v+" => \
$Opt{'verbose'},
56 "version" => \
$Opt{'version'},
58 ) || die("$progname: Option error. Use -h for help.\n");
60 $Opt{'debug'} && ($Debug = 1);
61 $Opt{'help'} && usage
(0);
62 if ($Opt{'version'}) {
68 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
71 creator="gpsman2gpx - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/gpsman2gpx"
72 xmlns="http://www.topografix.com/GPX/1/1"
73 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
74 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
85 (.*?
)\t # some kind of worthless date
88 (.*) # lots of uninteresting stuff but with altitude
92 my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) =
93 ( $1, $2, $3, $4, $5, $6);
96 $Name = txt_to_xml
($Name);
97 $Cmt = txt_to_xml
($Cmt);
98 $Lat = conv_pos
($Lat);
99 $Lon = conv_pos
($Lon);
100 if ($Rest =~ /ele=([\d\.]+)\D/) {
103 print(" <wpt lat=\"$Lat\" lon=\"$Lon\">\n");
104 print(" <ele>$Ele</ele>\n") if length($Ele);
105 print(" <name>$Name</name>\n") if length($Name);
106 print(" <cmt>$Cmt</cmt>\n") if length($Cmt);
117 if ($Retval =~ /^([NSWE])([0-9\.]+)$/) {
118 my ($Pref, $Deg) = ($1, $2);
119 $Retval = ($Pref =~ /[SW]/)
123 warn("\"$Retval\": Invalid coordinate\n") unless $Opt{'quiet'};
130 # Print program version {{{
131 for (@main::version_array
) {
138 # Send the help message to stdout {{{
141 if ($Opt{'verbose'}) {
147 Usage: $progname [options] [file [files [...]]]
154 Increase level of verbosity. Can be repeated.
156 Be quiet, don’t warn about unknown lines and stuff.
158 Print version information.
160 Print debugging messages.
168 # Print a status message to stderr based on verbosity level {{{
169 my ($verbose_level, $Txt) = @_;
171 if ($Opt{'verbose'} >= $verbose_level) {
172 print(STDERR
"$progname: $Txt\n");
178 # Print a debugging message {{{
180 my @call_info = caller;
181 chomp(my $Txt = shift);
182 my $File = $call_info[1];
184 $File =~ s
#^.*/(.*?)$#$1#;
185 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
192 # Plain Old Documentation (POD) {{{
206 [options] [file [files [...]]]
216 =item B<-h>, B<--help>
218 Print a brief help summary.
220 =item B<-v>, B<--verbose>
222 Increase level of verbosity. Can be repeated.
226 Print version information.
230 Print debugging messages.
240 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
244 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
245 This is free software; see the file F<COPYING> for legalese stuff.
249 This program is free software; you can redistribute it and/or modify it
250 under the terms of the GNU General Public License as published by the
251 Free Software Foundation; either version 2 of the License, or (at your
252 option) any later version.
254 This program is distributed in the hope that it will be useful, but
255 WITHOUT ANY WARRANTY; without even the implied warranty of
256 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
257 See the GNU General Public License for more details.
259 You should have received a copy of the GNU General Public License along
260 with this program; if not, write to the Free Software Foundation, Inc.,
261 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
269 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :