3 #=======================================================================
5 # File ID: 58ece940-08f3-11de-ab14-000475e441b9
6 # View GPX files in gnuplot(1)
9 # ©opyleft 2009– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 3 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
24 'label-file' => "$ENV{'HOME'}/gps/poi/labels.gnuplot",
35 'label-file' => "$Std{'label-file'}",
39 'with' => $Std{'with'},
44 $progname =~ s/^.*\/(.*?)$/$1/;
45 our $VERSION = "0.00";
47 Getopt
::Long
::Configure
("bundling");
50 "2d|2" => \
$Opt{'2d'},
51 "debug" => \
$Opt{'debug'},
52 "help|h" => \
$Opt{'help'},
53 "keep-files|k" => \
$Opt{'keep-files'},
54 "label-file|l=s" => \
$Opt{'label-file'},
55 "time|t" => \
$Opt{'time'},
56 "verbose|v+" => \
$Opt{'verbose'},
57 "version" => \
$Opt{'version'},
58 "with|w=s" => \
$Opt{'with'},
60 ) || die("$progname: Option error. Use -h for help.\n");
62 $Opt{'debug'} && ($Debug = 1);
63 $Opt{'help'} && usage
(0);
64 if ($Opt{'version'}) {
69 ($Opt{'2d'} && $Opt{'time'}) && die("$progname: Cannot mix --2d and --time options\n");
70 ($Opt{'with'} =~ /^(d|l|lp|p)$/) || die("$progname: $Opt{'with'}: Invalid value of --with option, see $progname -h for help\n");
72 my ($dat_file, $cmd_file);
76 $dat_file = sprintf("/tmp/vg-t.%u.%u.tmp", time, $$);
77 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
78 my @gpst_array = ("gpst", "-o", "csv", "-rt", "-e", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
79 print($fp `@gpst_array`);
81 $cmd_file = sprintf("/tmp/vg-t-cmd.%u.%u.tmp", time, $$);
82 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
84 set mouse format "%.6f"
85 load "$Opt{'label-file'}"
87 # set timefmt "%Y-%m-%dT%H:%M:%SZ"
89 splot "$dat_file" using 2:3:1 w $Opt{'with'} palette
90 pause -1 "Trykk Enter..."
93 system("gnuplot -persist $cmd_file");
94 } elsif ($Opt{'2d'}) {
95 $dat_file = sprintf("/tmp/vg-2.%u.%u.tmp", time, $$);
96 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
97 my @gpst_array = ("gpst", "-o", "clean", "-rp", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
98 print($fp `@gpst_array`);
100 $cmd_file = sprintf("/tmp/vg-2-cmd.%u.%u.tmp", time, $$);
101 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
103 set mouse format "%.6f"
104 load "$Opt{'label-file'}"
105 plot "$dat_file" using 1:2 w $Opt{'with'}
106 pause -1 "Trykk Enter..."
109 system("gnuplot -persist $cmd_file");
111 $dat_file = sprintf("/tmp/vg.%u.%u.tmp", time, $$);
112 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
113 my @gpst_array = ("gpst", "-o", "clean", "-ret", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
114 print($fp `@gpst_array`);
116 $cmd_file = sprintf("/tmp/vg-cmd.%u.%u.tmp", time, $$);
117 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
119 set mouse format "%.6f"
120 load "$Opt{'label-file'}"
121 splot "$dat_file" w $Opt{'with'} palette
122 pause -1 "Trykk Enter..."
125 system("gnuplot -persist $cmd_file");
127 $Opt{'keep-files'} || unlink($dat_file, $cmd_file);
130 # Print program version {{{
131 print("$progname v$VERSION\n");
136 # Send the help message to stdout {{{
139 if ($Opt{'verbose'}) {
145 Usage: $progname [options] [file [files [...]]]
150 Create 2D plot instead of 3D. Bigger window by default in gnuplot,
151 and it’s faster when plotting lots of data.
155 Don’t remove temporary files after program execution.
158 Default: $Std{'label-file'}
160 Use time as Z axis instead of elevation.
162 Increase level of verbosity. Can be repeated.
168 lp - lines with points
169 Default: $Std{'with'}
171 Print version information.
173 Print debugging messages.
181 # Print a status message to stderr based on verbosity level {{{
182 my ($verbose_level, $Txt) = @_;
184 if ($Opt{'verbose'} >= $verbose_level) {
185 print(STDERR
"$progname: $Txt\n");
191 # Print a debugging message {{{
193 my @call_info = caller;
194 chomp(my $Txt = shift);
195 my $File = $call_info[1];
197 $File =~ s
#^.*/(.*?)$#$1#;
198 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
205 # Plain Old Documentation (POD) {{{
215 [options] [file [files [...]]]
225 =item B<-h>, B<--help>
227 Print a brief help summary.
229 =item B<-v>, B<--verbose>
231 Increase level of verbosity. Can be repeated.
235 Print version information.
239 Print debugging messages.
249 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
253 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
254 This is free software; see the file F<COPYING> for legalese stuff.
258 This program is free software: you can redistribute it and/or modify it
259 under the terms of the GNU General Public License as published by the
260 Free Software Foundation, either version 3 of the License, or (at your
261 option) any later version.
263 This program is distributed in the hope that it will be useful, but
264 WITHOUT ANY WARRANTY; without even the implied warranty of
265 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
266 See the GNU General Public License for more details.
268 You should have received a copy of the GNU General Public License along
270 If not, see L<http://www.gnu.org/licenses/>.
278 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :