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);
77 $dat_file = sprintf("/tmp/vg-t.%u.%u.tmp", time, $$);
78 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
79 my @gpst_array = ("gpst", "-o", "csv", "-rt", "-e", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
80 print(FP
`@gpst_array`);
82 $cmd_file = sprintf("/tmp/vg-t-cmd.%u.%u.tmp", time, $$);
83 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
85 set mouse format "%.6f"
86 load "$Opt{'label-file'}"
88 # set timefmt "%Y-%m-%dT%H:%M:%SZ"
90 splot "$dat_file" using 2:3:1 w $Opt{'with'} palette
91 pause -1 "Trykk Enter..."
94 system("gnuplot -persist $cmd_file");
95 } elsif ($Opt{'2d'}) {
96 $dat_file = sprintf("/tmp/vg-2.%u.%u.tmp", time, $$);
97 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
98 my @gpst_array = ("gpst", "-o", "clean", "-rp", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
99 print(FP
`@gpst_array`);
101 $cmd_file = sprintf("/tmp/vg-2-cmd.%u.%u.tmp", time, $$);
102 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
104 set mouse format "%.6f"
105 load "$Opt{'label-file'}"
106 plot "$dat_file" using 1:2 w $Opt{'with'}
107 pause -1 "Trykk Enter..."
110 system("gnuplot -persist $cmd_file");
112 $dat_file = sprintf("/tmp/vg.%u.%u.tmp", time, $$);
113 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
114 my @gpst_array = ("gpst", "-o", "clean", "-ret", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
115 print(FP
`@gpst_array`);
117 $cmd_file = sprintf("/tmp/vg-cmd.%u.%u.tmp", time, $$);
118 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
120 set mouse format "%.6f"
121 load "$Opt{'label-file'}"
122 splot "$dat_file" w $Opt{'with'} palette
123 pause -1 "Trykk Enter..."
126 system("gnuplot -persist $cmd_file");
128 $Opt{'keep-files'} || unlink($dat_file, $cmd_file);
131 # Print program version {{{
132 print("$progname v$VERSION\n");
137 # Send the help message to stdout {{{
140 if ($Opt{'verbose'}) {
146 Usage: $progname [options] [file [files [...]]]
151 Create 2D plot instead of 3D. Bigger window by default in gnuplot,
152 and it’s faster when plotting lots of data.
156 Don’t remove temporary files after program execution.
159 Default: $Std{'label-file'}
161 Use time as Z axis instead of elevation.
163 Increase level of verbosity. Can be repeated.
169 lp - lines with points
170 Default: $Std{'with'}
172 Print version information.
174 Print debugging messages.
182 # Print a status message to stderr based on verbosity level {{{
183 my ($verbose_level, $Txt) = @_;
185 if ($Opt{'verbose'} >= $verbose_level) {
186 print(STDERR
"$progname: $Txt\n");
192 # Print a debugging message {{{
194 my @call_info = caller;
195 chomp(my $Txt = shift);
196 my $File = $call_info[1];
198 $File =~ s
#^.*/(.*?)$#$1#;
199 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
206 # Plain Old Documentation (POD) {{{
216 [options] [file [files [...]]]
226 =item B<-h>, B<--help>
228 Print a brief help summary.
230 =item B<-v>, B<--verbose>
232 Increase level of verbosity. Can be repeated.
236 Print version information.
240 Print debugging messages.
250 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
254 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
255 This is free software; see the file F<COPYING> for legalese stuff.
259 This program is free software: you can redistribute it and/or modify it
260 under the terms of the GNU General Public License as published by the
261 Free Software Foundation, either version 3 of the License, or (at your
262 option) any later version.
264 This program is distributed in the hope that it will be useful, but
265 WITHOUT ANY WARRANTY; without even the implied warranty of
266 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
267 See the GNU General Public License for more details.
269 You should have received a copy of the GNU General Public License along
271 If not, see L<http://www.gnu.org/licenses/>.
279 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :