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",
37 'label-file' => "$Std{'label-file'}",
41 'with' => $Std{'with'},
46 $progname =~ s/^.*\/(.*?)$/$1/;
49 my $id_date = $rcs_id;
50 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
52 push(@main::version_array
, $rcs_id);
55 Getopt
::Long
::Configure
("bundling");
58 "2d|2" => \
$Opt{'2d'},
59 "debug" => \
$Opt{'debug'},
60 "help|h" => \
$Opt{'help'},
61 "label-file|l=s" => \
$Opt{'label-file'},
62 "time|t" => \
$Opt{'time'},
63 "verbose|v+" => \
$Opt{'verbose'},
64 "version" => \
$Opt{'version'},
65 "with|w=s" => \
$Opt{'with'},
67 ) || die("$progname: Option error. Use -h for help.\n");
69 $Opt{'debug'} && ($Debug = 1);
70 $Opt{'help'} && usage
(0);
71 if ($Opt{'version'}) {
76 ($Opt{'2d'} && $Opt{'time'}) && die("$progname: Cannot mix --2d and --time options\n");
77 ($Opt{'with'} =~ /^(d|l|lp|p)$/) || die("$progname: $Opt{'with'}: Invalid value of --with option, see $progname -h for help\n");
79 my $cmdl_str = join(" ", @cmdl);
82 my $dat_file = "/tmp/vg-t.tmp";
83 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
84 my @gpst_array = ("gpst", "-o", "csv", "-rt", "-e", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
85 print(FP
`@gpst_array`);
87 my $cmd_file = "/tmp/vg-t-cmd.tmp";
88 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
91 load "$Opt{'label-file'}"
93 # set timefmt "%Y-%m-%dT%H:%M:%SZ"
95 splot "$dat_file" using 2:3:1 w $Opt{'with'} palette
96 pause -1 "Trykk Enter..."
99 system("gnuplot -persist $cmd_file");
100 } elsif ($Opt{'2d'}) {
101 my $dat_file = "/tmp/vg-2.tmp";
102 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
103 my @gpst_array = ("gpst", "-o", "clean", "-rp", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
104 print(FP
`@gpst_array`);
106 my $cmd_file = "/tmp/vg-2-cmd.tmp";
107 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
110 load "$Opt{'label-file'}"
111 plot "$dat_file" using 1:2 w $Opt{'with'}
112 pause -1 "Trykk Enter..."
115 system("gnuplot -persist $cmd_file");
117 my $dat_file = "/tmp/vg.tmp";
118 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
119 my @gpst_array = ("gpst", "-o", "clean", "-ret", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
120 print(FP
`@gpst_array`);
122 my $cmd_file = "/tmp/vg-cmd.tmp";
123 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
126 load "$Opt{'label-file'}"
127 splot "$dat_file" w $Opt{'with'} palette
128 pause -1 "Trykk Enter..."
131 system("gnuplot -persist $cmd_file");
135 # Print program version {{{
136 for (@main::version_array
) {
143 # Send the help message to stdout {{{
146 if ($Opt{'verbose'}) {
152 Usage: $progname [options] [file [files [...]]]
157 Create 2D plot instead of 3D. Bigger window by default in gnuplot,
158 and it’s faster when plotting lots of data.
163 Default: $Std{'label-file'}
165 Use time as Z axis instead of elevation.
167 Increase level of verbosity. Can be repeated.
173 lp - lines with points
174 Default: $Std{'with'}
176 Print version information.
178 Print debugging messages.
186 # Print a status message to stderr based on verbosity level {{{
187 my ($verbose_level, $Txt) = @_;
189 if ($Opt{'verbose'} >= $verbose_level) {
190 print(STDERR
"$progname: $Txt\n");
196 # Print a debugging message {{{
198 my @call_info = caller;
199 chomp(my $Txt = shift);
200 my $File = $call_info[1];
202 $File =~ s
#^.*/(.*?)$#$1#;
203 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
210 # Plain Old Documentation (POD) {{{
224 [options] [file [files [...]]]
234 =item B<-h>, B<--help>
236 Print a brief help summary.
238 =item B<-v>, B<--verbose>
240 Increase level of verbosity. Can be repeated.
244 Print version information.
248 Print debugging messages.
258 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
262 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
263 This is free software; see the file F<COPYING> for legalese stuff.
267 This program is free software; you can redistribute it and/or modify it
268 under the terms of the GNU General Public License as published by the
269 Free Software Foundation; either version 2 of the License, or (at your
270 option) any later version.
272 This program is distributed in the hope that it will be useful, but
273 WITHOUT ANY WARRANTY; without even the implied warranty of
274 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
275 See the GNU General Public License for more details.
277 You should have received a copy of the GNU General Public License along
278 with this program; if not, write to the Free Software Foundation, Inc.,
279 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
287 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :