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, see end of file for legal stuff.
10 #=======================================================================
13 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
32 $progname =~ s
#^.*/(.*?)$#$1#;
35 my $id_date = $rcs_id;
36 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
38 Getopt
::Long
::Configure
("bundling");
40 "debug" => \
$Opt{'debug'},
41 "help|h" => \
$Opt{'help'},
42 "version" => \
$Opt{'version'},
43 ) || die("$progname: Option error. Use -h for help.\n");
45 $Opt{'debug'} && ($Debug = 1);
46 $Opt{'help'} && usage
(0);
47 $Opt{'version'} && print_version
();
50 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
53 creator="gpsman2gpx - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/gpsman2gpx"
54 xmlns="http://www.topografix.com/GPX/1/1"
55 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
56 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
67 (.*?
)\t # some kind of worthless date
70 (.*) # lots of uninteresting stuff but with altitude
74 my ($Name, $Cmt, $wl_date, $Lat, $Lon, $Rest) =
75 ( $1, $2, $3, $4, $5, $6);
78 $Name = txt_to_xml
($Name);
79 $Cmt = txt_to_xml
($Cmt);
80 $Lat = conv_pos
($Lat);
81 $Lon = conv_pos
($Lon);
82 if ($Rest =~ /ele=([\d\.]+)\D/) {
85 print(" <wpt lat=\"$Lat\" lon=\"$Lon\">\n");
86 print(" <ele>$Ele</ele>\n") if length($Ele);
87 print(" <name>$Name</name>\n") if length($Name);
88 print(" <cmt>$Cmt</cmt>\n") if length($Cmt);
99 if ($Retval =~ /^([NSWE])([0-9\.]+)$/) {
100 my ($Pref, $Deg) = ($1, $2);
101 $Retval = ($Pref =~ /[SW]/)
105 warn("\"$Retval\": Invalid coordinate\n");
112 # Print program version {{{
119 # Send the help message to stdout {{{
126 Usage: $progname [options] [file [files [...]]]
133 Print version information.
135 Print debugging messages.
143 # Print a debugging message {{{
145 my @call_info = caller;
146 chomp(my $Txt = shift);
147 my $File = $call_info[1];
149 $File =~ s
#^.*/(.*?)$#$1#;
150 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
157 # Plain Old Documentation (POD) {{{
171 [options] [file [files [...]]]
181 =item B<-h>, B<--help>
183 Print a brief help summary.
187 Print version information.
191 Print debugging messages.
201 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
205 Copyleft © Øyvind A. Holm <sunny@sunbase.org>
206 This is free software; see the file F<COPYING> for legalese stuff.
210 This program is free software; you can redistribute it and/or modify it
211 under the terms of the GNU General Public License as published by the
212 Free Software Foundation; either version 2 of the License, or (at your
213 option) any later version.
215 This program is distributed in the hope that it will be useful, but
216 WITHOUT ANY WARRANTY; without even the implied warranty of
217 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
218 See the GNU General Public License for more details.
220 You should have received a copy of the GNU General Public License along
221 with this program; if not, write to the Free Software Foundation, Inc.,
222 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
230 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :