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";
49 Getopt
::Long
::Configure
("bundling");
52 "2d|2" => \
$Opt{'2d'},
53 "debug" => \
$Opt{'debug'},
54 "help|h" => \
$Opt{'help'},
55 "keep-files|k" => \
$Opt{'keep-files'},
56 "label-file|l=s" => \
$Opt{'label-file'},
57 "time|t" => \
$Opt{'time'},
58 "verbose|v+" => \
$Opt{'verbose'},
59 "version" => \
$Opt{'version'},
60 "with|w=s" => \
$Opt{'with'},
62 ) || die("$progname: Option error. Use -h for help.\n");
64 $Opt{'debug'} && ($Debug = 1);
65 $Opt{'help'} && usage
(0);
66 if ($Opt{'version'}) {
71 ($Opt{'2d'} && $Opt{'time'}) && die("$progname: Cannot mix --2d and --time options\n");
72 ($Opt{'with'} =~ /^(d|l|lp|p)$/) || die("$progname: $Opt{'with'}: Invalid value of --with option, see $progname -h for help\n");
74 my $cmdl_str = join(" ", @cmdl);
75 my ($dat_file, $cmd_file);
79 $dat_file = sprintf("/tmp/vg-t.%u.%u.tmp", time, $$);
80 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
81 my @gpst_array = ("gpst", "-o", "csv", "-rt", "-e", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
82 print($fp `@gpst_array`);
84 $cmd_file = sprintf("/tmp/vg-t-cmd.%u.%u.tmp", time, $$);
85 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
87 set mouse format "%.6f"
88 load "$Opt{'label-file'}"
90 # set timefmt "%Y-%m-%dT%H:%M:%SZ"
92 splot "$dat_file" using 2:3:1 w $Opt{'with'} palette
93 pause -1 "Trykk Enter..."
96 system("gnuplot -persist $cmd_file");
97 } elsif ($Opt{'2d'}) {
98 $dat_file = sprintf("/tmp/vg-2.%u.%u.tmp", time, $$);
99 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
100 my @gpst_array = ("gpst", "-o", "clean", "-rp", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
101 print($fp `@gpst_array`);
103 $cmd_file = sprintf("/tmp/vg-2-cmd.%u.%u.tmp", time, $$);
104 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
106 set mouse format "%.6f"
107 load "$Opt{'label-file'}"
108 plot "$dat_file" using 1:2 w $Opt{'with'}
109 pause -1 "Trykk Enter..."
112 system("gnuplot -persist $cmd_file");
114 $dat_file = sprintf("/tmp/vg.%u.%u.tmp", time, $$);
115 open($fp, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
116 my @gpst_array = ("gpst", "-o", "clean", "-ret", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
117 print($fp `@gpst_array`);
119 $cmd_file = sprintf("/tmp/vg-cmd.%u.%u.tmp", time, $$);
120 open($fp, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
122 set mouse format "%.6f"
123 load "$Opt{'label-file'}"
124 splot "$dat_file" w $Opt{'with'} palette
125 pause -1 "Trykk Enter..."
128 system("gnuplot -persist $cmd_file");
130 $Opt{'keep-files'} || unlink($dat_file, $cmd_file);
133 # Print program version {{{
134 print("$progname v$VERSION\n");
139 # Send the help message to stdout {{{
142 if ($Opt{'verbose'}) {
148 Usage: $progname [options] [file [files [...]]]
153 Create 2D plot instead of 3D. Bigger window by default in gnuplot,
154 and it’s faster when plotting lots of data.
158 Don’t remove temporary files after program execution.
161 Default: $Std{'label-file'}
163 Use time as Z axis instead of elevation.
165 Increase level of verbosity. Can be repeated.
171 lp - lines with points
172 Default: $Std{'with'}
174 Print version information.
176 Print debugging messages.
184 # Print a status message to stderr based on verbosity level {{{
185 my ($verbose_level, $Txt) = @_;
187 if ($Opt{'verbose'} >= $verbose_level) {
188 print(STDERR
"$progname: $Txt\n");
194 # Print a debugging message {{{
196 my @call_info = caller;
197 chomp(my $Txt = shift);
198 my $File = $call_info[1];
200 $File =~ s
#^.*/(.*?)$#$1#;
201 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
208 # Plain Old Documentation (POD) {{{
218 [options] [file [files [...]]]
228 =item B<-h>, B<--help>
230 Print a brief help summary.
232 =item B<-v>, B<--verbose>
234 Increase level of verbosity. Can be repeated.
238 Print version information.
242 Print debugging messages.
252 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
256 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
257 This is free software; see the file F<COPYING> for legalese stuff.
261 This program is free software: you can redistribute it and/or modify it
262 under the terms of the GNU General Public License as published by the
263 Free Software Foundation, either version 3 of the License, or (at your
264 option) any later version.
266 This program is distributed in the hope that it will be useful, but
267 WITHOUT ANY WARRANTY; without even the implied warranty of
268 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
269 See the GNU General Public License for more details.
271 You should have received a copy of the GNU General Public License along
273 If not, see L<http://www.gnu.org/licenses/>.
281 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :