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 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
27 'label-file' => "$ENV{'HOME'}/gps/poi/labels.gnuplot",
36 'label-file' => "$Std{'label-file'}",
44 $progname =~ s/^.*\/(.*?)$/$1/;
47 my $id_date = $rcs_id;
48 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
50 push(@main::version_array
, $rcs_id);
53 Getopt
::Long
::Configure
("bundling");
56 "2d|2" => \
$Opt{'2d'},
57 "debug" => \
$Opt{'debug'},
58 "help|h" => \
$Opt{'help'},
59 "label-file|l=s" => \
$Opt{'label-file'},
60 "time|t" => \
$Opt{'time'},
61 "verbose|v+" => \
$Opt{'verbose'},
62 "version" => \
$Opt{'version'},
64 ) || die("$progname: Option error. Use -h for help.\n");
66 $Opt{'debug'} && ($Debug = 1);
67 $Opt{'help'} && usage
(0);
68 if ($Opt{'version'}) {
73 ($Opt{'2d'} && $Opt{'time'}) && die("$progname: Cannot mix --2d and --time options\n");
75 my $cmdl_str = join(" ", @cmdl);
78 my $dat_file = "/tmp/vg-t.tmp";
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 my $cmd_file = "/tmp/vg-t-cmd.tmp";
84 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
87 load "$Opt{'label-file'}"
89 # set timefmt "%Y-%m-%dT%H:%M:%SZ"
91 splot "$dat_file" using 2:3:1 w l palette
92 pause -1 "Trykk Enter..."
95 system("gnuplot -persist $cmd_file");
96 } elsif ($Opt{'2d'}) {
97 my $dat_file = "/tmp/vg-2.tmp";
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 my $cmd_file = "/tmp/vg-2-cmd.tmp";
103 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
106 load "$Opt{'label-file'}"
107 plot "$dat_file" using 1:2 w l
108 pause -1 "Trykk Enter..."
111 system("gnuplot -persist $cmd_file");
113 my $dat_file = "/tmp/vg.tmp";
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 my $cmd_file = "/tmp/vg-cmd.tmp";
119 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
122 load "$Opt{'label-file'}"
123 splot "$dat_file" w l palette
124 pause -1 "Trykk Enter..."
127 system("gnuplot -persist $cmd_file");
131 # Print program version {{{
132 for (@main::version_array
) {
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.
159 Default: $Std{'label-file'}
161 Use time as Z axis instead of elevation.
163 Increase level of verbosity. Can be repeated.
165 Print version information.
167 Print debugging messages.
175 # Print a status message to stderr based on verbosity level {{{
176 my ($verbose_level, $Txt) = @_;
178 if ($Opt{'verbose'} >= $verbose_level) {
179 print(STDERR
"$progname: $Txt\n");
185 # Print a debugging message {{{
187 my @call_info = caller;
188 chomp(my $Txt = shift);
189 my $File = $call_info[1];
191 $File =~ s
#^.*/(.*?)$#$1#;
192 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
199 # Plain Old Documentation (POD) {{{
213 [options] [file [files [...]]]
223 =item B<-h>, B<--help>
225 Print a brief help summary.
227 =item B<-v>, B<--verbose>
229 Increase level of verbosity. Can be repeated.
233 Print version information.
237 Print debugging messages.
247 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
251 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
252 This is free software; see the file F<COPYING> for legalese stuff.
256 This program is free software; you can redistribute it and/or modify it
257 under the terms of the GNU General Public License as published by the
258 Free Software Foundation; either version 2 of the License, or (at your
259 option) any later version.
261 This program is distributed in the hope that it will be useful, but
262 WITHOUT ANY WARRANTY; without even the implied warranty of
263 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
264 See the GNU General Public License for more details.
266 You should have received a copy of the GNU General Public License along
267 with this program; if not, write to the Free Software Foundation, Inc.,
268 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
276 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :