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",
34 'label-file' => "$Std{'label-file'}",
38 'with' => $Std{'with'},
43 $progname =~ s/^.*\/(.*?)$/$1/;
44 our $VERSION = "0.00";
48 Getopt
::Long
::Configure
("bundling");
51 "2d|2" => \
$Opt{'2d'},
52 "debug" => \
$Opt{'debug'},
53 "help|h" => \
$Opt{'help'},
54 "keep-files|k" => \
$Opt{'keep-files'},
55 "label-file|l=s" => \
$Opt{'label-file'},
56 "time|t" => \
$Opt{'time'},
57 "verbose|v+" => \
$Opt{'verbose'},
58 "version" => \
$Opt{'version'},
59 "with|w=s" => \
$Opt{'with'},
61 ) || die("$progname: Option error. Use -h for help.\n");
63 $Opt{'debug'} && ($Debug = 1);
64 $Opt{'help'} && usage
(0);
65 if ($Opt{'version'}) {
70 ($Opt{'2d'} && $Opt{'time'}) && die("$progname: Cannot mix --2d and --time options\n");
71 ($Opt{'with'} =~ /^(d|l|lp|p)$/) || die("$progname: $Opt{'with'}: Invalid value of --with option, see $progname -h for help\n");
73 my $cmdl_str = join(" ", @cmdl);
74 my ($dat_file, $cmd_file);
78 $dat_file = sprintf("/tmp/vg-t.%u.%u.tmp", time, $$);
79 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
80 my @gpst_array = ("gpst", "-o", "csv", "-rt", "-e", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
81 print($fp `@gpst_array`);
83 $cmd_file = sprintf("/tmp/vg-t-cmd.%u.%u.tmp", time, $$);
84 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
86 set mouse format "%.6f"
87 load "$Opt{'label-file'}"
89 # set timefmt "%Y-%m-%dT%H:%M:%SZ"
91 splot "$dat_file" using 2:3:1 w $Opt{'with'} palette
92 pause -1 "Trykk Enter..."
95 system("gnuplot -persist $cmd_file");
96 } elsif ($Opt{'2d'}) {
97 $dat_file = sprintf("/tmp/vg-2.%u.%u.tmp", time, $$);
98 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
99 my @gpst_array = ("gpst", "-o", "clean", "-rp", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
100 print($fp `@gpst_array`);
102 $cmd_file = sprintf("/tmp/vg-2-cmd.%u.%u.tmp", time, $$);
103 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
105 set mouse format "%.6f"
106 load "$Opt{'label-file'}"
107 plot "$dat_file" using 1:2 w $Opt{'with'}
108 pause -1 "Trykk Enter..."
111 system("gnuplot -persist $cmd_file");
113 $dat_file = sprintf("/tmp/vg.%u.%u.tmp", time, $$);
114 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
115 my @gpst_array = ("gpst", "-o", "clean", "-ret", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
116 print($fp `@gpst_array`);
118 $cmd_file = sprintf("/tmp/vg-cmd.%u.%u.tmp", time, $$);
119 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
121 set mouse format "%.6f"
122 load "$Opt{'label-file'}"
123 splot "$dat_file" w $Opt{'with'} palette
124 pause -1 "Trykk Enter..."
127 system("gnuplot -persist $cmd_file");
129 $Opt{'keep-files'} || unlink($dat_file, $cmd_file);
132 # Print program version {{{
133 print("$progname v$VERSION\n");
138 # Send the help message to stdout {{{
141 if ($Opt{'verbose'}) {
147 Usage: $progname [options] [file [files [...]]]
152 Create 2D plot instead of 3D. Bigger window by default in gnuplot,
153 and it’s faster when plotting lots of data.
157 Don’t remove temporary files after program execution.
160 Default: $Std{'label-file'}
162 Use time as Z axis instead of elevation.
164 Increase level of verbosity. Can be repeated.
170 lp - lines with points
171 Default: $Std{'with'}
173 Print version information.
175 Print debugging messages.
183 # Print a status message to stderr based on verbosity level {{{
184 my ($verbose_level, $Txt) = @_;
186 if ($Opt{'verbose'} >= $verbose_level) {
187 print(STDERR
"$progname: $Txt\n");
193 # Print a debugging message {{{
195 my @call_info = caller;
196 chomp(my $Txt = shift);
197 my $File = $call_info[1];
199 $File =~ s
#^.*/(.*?)$#$1#;
200 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
207 # Plain Old Documentation (POD) {{{
217 [options] [file [files [...]]]
227 =item B<-h>, B<--help>
229 Print a brief help summary.
231 =item B<-v>, B<--verbose>
233 Increase level of verbosity. Can be repeated.
237 Print version information.
241 Print debugging messages.
251 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
255 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
256 This is free software; see the file F<COPYING> for legalese stuff.
260 This program is free software: you can redistribute it and/or modify it
261 under the terms of the GNU General Public License as published by the
262 Free Software Foundation, either version 3 of the License, or (at your
263 option) any later version.
265 This program is distributed in the hope that it will be useful, but
266 WITHOUT ANY WARRANTY; without even the implied warranty of
267 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
268 See the GNU General Public License for more details.
270 You should have received a copy of the GNU General Public License along
272 If not, see L<http://www.gnu.org/licenses/>.
280 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :