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 #=======================================================================
23 'label-file' => "$ENV{'HOME'}/gps/poi/labels.gnuplot",
33 'label-file' => "$Std{'label-file'}",
37 'with' => $Std{'with'},
42 $progname =~ s/^.*\/(.*?)$/$1/;
43 our $VERSION = "0.00";
47 Getopt
::Long
::Configure
("bundling");
50 "2d|2" => \
$Opt{'2d'},
51 "debug" => \
$Opt{'debug'},
52 "help|h" => \
$Opt{'help'},
53 "label-file|l=s" => \
$Opt{'label-file'},
54 "time|t" => \
$Opt{'time'},
55 "verbose|v+" => \
$Opt{'verbose'},
56 "version" => \
$Opt{'version'},
57 "with|w=s" => \
$Opt{'with'},
59 ) || die("$progname: Option error. Use -h for help.\n");
61 $Opt{'debug'} && ($Debug = 1);
62 $Opt{'help'} && usage
(0);
63 if ($Opt{'version'}) {
68 ($Opt{'2d'} && $Opt{'time'}) && die("$progname: Cannot mix --2d and --time options\n");
69 ($Opt{'with'} =~ /^(d|l|lp|p)$/) || die("$progname: $Opt{'with'}: Invalid value of --with option, see $progname -h for help\n");
71 my $cmdl_str = join(" ", @cmdl);
72 my ($dat_file, $cmd_file);
75 $dat_file = sprintf("/tmp/vg-t.%u.%u.tmp", time, $$);
76 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
77 my @gpst_array = ("gpst", "-o", "csv", "-rt", "-e", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
78 print(FP
`@gpst_array`);
80 $cmd_file = sprintf("/tmp/vg-t-cmd.%u.%u.tmp", time, $$);
81 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
83 set mouse format "%.6f"
84 load "$Opt{'label-file'}"
86 # set timefmt "%Y-%m-%dT%H:%M:%SZ"
88 splot "$dat_file" using 2:3:1 w $Opt{'with'} palette
89 pause -1 "Trykk Enter..."
92 system("gnuplot -persist $cmd_file");
93 } elsif ($Opt{'2d'}) {
94 $dat_file = sprintf("/tmp/vg-2.%u.%u.tmp", time, $$);
95 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
96 my @gpst_array = ("gpst", "-o", "clean", "-rp", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
97 print(FP
`@gpst_array`);
99 $cmd_file = sprintf("/tmp/vg-2-cmd.%u.%u.tmp", time, $$);
100 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
102 set mouse format "%.6f"
103 load "$Opt{'label-file'}"
104 plot "$dat_file" using 1:2 w $Opt{'with'}
105 pause -1 "Trykk Enter..."
108 system("gnuplot -persist $cmd_file");
110 $dat_file = sprintf("/tmp/vg.%u.%u.tmp", time, $$);
111 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
112 my @gpst_array = ("gpst", "-o", "clean", "-ret", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
113 print(FP
`@gpst_array`);
115 $cmd_file = sprintf("/tmp/vg-cmd.%u.%u.tmp", time, $$);
116 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
118 set mouse format "%.6f"
119 load "$Opt{'label-file'}"
120 splot "$dat_file" w $Opt{'with'} palette
121 pause -1 "Trykk Enter..."
124 system("gnuplot -persist $cmd_file");
126 unlink($dat_file, $cmd_file);
129 # Print program version {{{
130 print("$progname v$VERSION\n");
135 # Send the help message to stdout {{{
138 if ($Opt{'verbose'}) {
144 Usage: $progname [options] [file [files [...]]]
149 Create 2D plot instead of 3D. Bigger window by default in gnuplot,
150 and it’s faster when plotting lots of data.
155 Default: $Std{'label-file'}
157 Use time as Z axis instead of elevation.
159 Increase level of verbosity. Can be repeated.
165 lp - lines with points
166 Default: $Std{'with'}
168 Print version information.
170 Print debugging messages.
178 # Print a status message to stderr based on verbosity level {{{
179 my ($verbose_level, $Txt) = @_;
181 if ($Opt{'verbose'} >= $verbose_level) {
182 print(STDERR
"$progname: $Txt\n");
188 # Print a debugging message {{{
190 my @call_info = caller;
191 chomp(my $Txt = shift);
192 my $File = $call_info[1];
194 $File =~ s
#^.*/(.*?)$#$1#;
195 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
202 # Plain Old Documentation (POD) {{{
212 [options] [file [files [...]]]
222 =item B<-h>, B<--help>
224 Print a brief help summary.
226 =item B<-v>, B<--verbose>
228 Increase level of verbosity. Can be repeated.
232 Print version information.
236 Print debugging messages.
246 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
250 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
251 This is free software; see the file F<COPYING> for legalese stuff.
255 This program is free software: you can redistribute it and/or modify it
256 under the terms of the GNU General Public License as published by the
257 Free Software Foundation, either version 3 of the License, or (at your
258 option) any later version.
260 This program is distributed in the hope that it will be useful, but
261 WITHOUT ANY WARRANTY; without even the implied warranty of
262 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
263 See the GNU General Public License for more details.
265 You should have received a copy of the GNU General Public License along
267 If not, see L<http://www.gnu.org/licenses/>.
275 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :