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");
40 $progname =~ s/^.*\/(.*?)$/$1/;
43 my $id_date = $rcs_id;
44 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
46 push(@main::version_array
, $rcs_id);
48 Getopt
::Long
::Configure
("bundling");
51 "debug" => \
$Opt{'debug'},
52 "help|h" => \
$Opt{'help'},
53 "verbose|v+" => \
$Opt{'verbose'},
54 "version" => \
$Opt{'version'},
56 ) || die("$progname: Option error. Use -h for help.\n");
58 $Opt{'debug'} && ($Debug = 1);
59 $Opt{'help'} && usage
(0);
60 if ($Opt{'version'}) {
66 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
69 creator="gpsman2gpx - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/gpsman2gpx"
70 xmlns="http://www.topografix.com/GPX/1/1"
71 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
72 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
83 (.*?
)\t # some kind of worthless date
86 (.*) # lots of uninteresting stuff but with altitude
90 my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) =
91 ( $1, $2, $3, $4, $5, $6);
94 $Name = txt_to_xml
($Name);
95 $Cmt = txt_to_xml
($Cmt);
96 $Lat = conv_pos
($Lat);
97 $Lon = conv_pos
($Lon);
98 if ($Rest =~ /ele=([\d\.]+)\D/) {
101 print(" <wpt lat=\"$Lat\" lon=\"$Lon\">\n");
102 print(" <ele>$Ele</ele>\n") if length($Ele);
103 print(" <name>$Name</name>\n") if length($Name);
104 print(" <cmt>$Cmt</cmt>\n") if length($Cmt);
115 if ($Retval =~ /^([NSWE])([0-9\.]+)$/) {
116 my ($Pref, $Deg) = ($1, $2);
117 $Retval = ($Pref =~ /[SW]/)
121 warn("\"$Retval\": Invalid coordinate\n");
128 # Print program version {{{
129 for (@main::version_array
) {
136 # Send the help message to stdout {{{
139 if ($Opt{'verbose'}) {
145 Usage: $progname [options] [file [files [...]]]
152 Increase level of verbosity. Can be repeated.
154 Print version information.
156 Print debugging messages.
164 # Print a status message to stderr based on verbosity level {{{
165 my ($verbose_level, $Txt) = @_;
167 if ($Opt{'verbose'} >= $verbose_level) {
168 print(STDERR
"$progname: $Txt\n");
174 # Print a debugging message {{{
176 my @call_info = caller;
177 chomp(my $Txt = shift);
178 my $File = $call_info[1];
180 $File =~ s
#^.*/(.*?)$#$1#;
181 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
188 # Plain Old Documentation (POD) {{{
202 [options] [file [files [...]]]
212 =item B<-h>, B<--help>
214 Print a brief help summary.
216 =item B<-v>, B<--verbose>
218 Increase level of verbosity. Can be repeated.
222 Print version information.
226 Print debugging messages.
236 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
240 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
241 This is free software; see the file F<COPYING> for legalese stuff.
245 This program is free software; you can redistribute it and/or modify it
246 under the terms of the GNU General Public License as published by the
247 Free Software Foundation; either version 2 of the License, or (at your
248 option) any later version.
250 This program is distributed in the hope that it will be useful, but
251 WITHOUT ANY WARRANTY; without even the implied warranty of
252 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
253 See the GNU General Public License for more details.
255 You should have received a copy of the GNU General Public License along
256 with this program; if not, write to the Free Software Foundation, Inc.,
257 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
265 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :