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");
38 $progname =~ s/^.*\/(.*?)$/$1/;
41 my $id_date = $rcs_id;
42 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
44 push(@main::version_array
, $rcs_id);
46 Getopt
::Long
::Configure
("bundling");
48 "debug" => \
$Opt{'debug'},
49 "help|h" => \
$Opt{'help'},
50 "verbose|v+" => \
$Opt{'verbose'},
51 "version" => \
$Opt{'version'},
52 ) || die("$progname: Option error. Use -h for help.\n");
54 $Opt{'debug'} && ($Debug = 1);
55 $Opt{'help'} && usage
(0);
56 $Opt{'version'} && print_version
();
59 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
62 creator="gpsman2gpx - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/gpsman2gpx"
63 xmlns="http://www.topografix.com/GPX/1/1"
64 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
65 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
76 (.*?
)\t # some kind of worthless date
79 (.*) # lots of uninteresting stuff but with altitude
83 my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) =
84 ( $1, $2, $3, $4, $5, $6);
87 $Name = txt_to_xml
($Name);
88 $Cmt = txt_to_xml
($Cmt);
89 $Lat = conv_pos
($Lat);
90 $Lon = conv_pos
($Lon);
91 if ($Rest =~ /ele=([\d\.]+)\D/) {
94 print(" <wpt lat=\"$Lat\" lon=\"$Lon\">\n");
95 print(" <ele>$Ele</ele>\n") if length($Ele);
96 print(" <name>$Name</name>\n") if length($Name);
97 print(" <cmt>$Cmt</cmt>\n") if length($Cmt);
108 if ($Retval =~ /^([NSWE])([0-9\.]+)$/) {
109 my ($Pref, $Deg) = ($1, $2);
110 $Retval = ($Pref =~ /[SW]/)
114 warn("\"$Retval\": Invalid coordinate\n");
121 # Print program version {{{
122 for (@main::version_array
) {
130 # Send the help message to stdout {{{
137 Usage: $progname [options] [file [files [...]]]
144 Increase level of verbosity. Can be repeated.
146 Print version information.
148 Print debugging messages.
156 # Print a status message to stderr based on verbosity level {{{
157 my ($verbose_level, $Txt) = @_;
159 if ($Opt{'verbose'} >= $verbose_level) {
160 print(STDERR
"$progname: $Txt\n");
166 # Print a debugging message {{{
168 my @call_info = caller;
169 chomp(my $Txt = shift);
170 my $File = $call_info[1];
172 $File =~ s
#^.*/(.*?)$#$1#;
173 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
180 # Plain Old Documentation (POD) {{{
194 [options] [file [files [...]]]
204 =item B<-h>, B<--help>
206 Print a brief help summary.
208 =item B<-v>, B<--verbose>
210 Increase level of verbosity. Can be repeated.
214 Print version information.
218 Print debugging messages.
228 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
232 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
233 This is free software; see the file F<COPYING> for legalese stuff.
237 This program is free software; you can redistribute it and/or modify it
238 under the terms of the GNU General Public License as published by the
239 Free Software Foundation; either version 2 of the License, or (at your
240 option) any later version.
242 This program is distributed in the hope that it will be useful, but
243 WITHOUT ANY WARRANTY; without even the implied warranty of
244 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
245 See the GNU General Public License for more details.
247 You should have received a copy of the GNU General Public License along
248 with this program; if not, write to the Free Software Foundation, Inc.,
249 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
257 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :