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",
33 'label-file' => "$Std{'label-file'}",
37 'with' => $Std{'with'},
42 $progname =~ s/^.*\/(.*?)$/$1/;
43 our $VERSION = "0.00";
47 Getopt
::Long
::Configure
("bundling");
50 "2d|2" => \
$Opt{'2d'},
51 "debug" => \
$Opt{'debug'},
52 "help|h" => \
$Opt{'help'},
53 "label-file|l=s" => \
$Opt{'label-file'},
54 "time|t" => \
$Opt{'time'},
55 "verbose|v+" => \
$Opt{'verbose'},
56 "version" => \
$Opt{'version'},
57 "with|w=s" => \
$Opt{'with'},
59 ) || die("$progname: Option error. Use -h for help.\n");
61 $Opt{'debug'} && ($Debug = 1);
62 $Opt{'help'} && usage
(0);
63 if ($Opt{'version'}) {
68 ($Opt{'2d'} && $Opt{'time'}) && die("$progname: Cannot mix --2d and --time options\n");
69 ($Opt{'with'} =~ /^(d|l|lp|p)$/) || die("$progname: $Opt{'with'}: Invalid value of --with option, see $progname -h for help\n");
71 my $cmdl_str = join(" ", @cmdl);
74 my $dat_file = "/tmp/vg-t.tmp";
75 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
76 my @gpst_array = ("gpst", "-o", "csv", "-rt", "-e", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
77 print(FP
`@gpst_array`);
79 my $cmd_file = "/tmp/vg-t-cmd.tmp";
80 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
82 set mouse format "%.6f"
83 load "$Opt{'label-file'}"
85 # set timefmt "%Y-%m-%dT%H:%M:%SZ"
87 splot "$dat_file" using 2:3:1 w $Opt{'with'} palette
88 pause -1 "Trykk Enter..."
91 system("gnuplot -persist $cmd_file");
92 } elsif ($Opt{'2d'}) {
93 my $dat_file = "/tmp/vg-2.tmp";
94 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
95 my @gpst_array = ("gpst", "-o", "clean", "-rp", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
96 print(FP
`@gpst_array`);
98 my $cmd_file = "/tmp/vg-2-cmd.tmp";
99 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
101 set mouse format "%.6f"
102 load "$Opt{'label-file'}"
103 plot "$dat_file" using 1:2 w $Opt{'with'}
104 pause -1 "Trykk Enter..."
107 system("gnuplot -persist $cmd_file");
109 my $dat_file = "/tmp/vg.tmp";
110 open(FP
, ">$dat_file") || die("$progname: $dat_file: Cannot open file for write: $!\n");
111 my @gpst_array = ("gpst", "-o", "clean", "-ret", "-d", "-t", @ARGV, "|", "rmspcall", "|", "uniq");
112 print(FP
`@gpst_array`);
114 my $cmd_file = "/tmp/vg-cmd.tmp";
115 open(FP
, ">$cmd_file") || die("$progname: $cmd_file: Cannot open file for write: $!\n");
117 set mouse format "%.6f"
118 load "$Opt{'label-file'}"
119 splot "$dat_file" w $Opt{'with'} palette
120 pause -1 "Trykk Enter..."
123 system("gnuplot -persist $cmd_file");
127 # Print program version {{{
128 print("$progname v$VERSION\n");
133 # Send the help message to stdout {{{
136 if ($Opt{'verbose'}) {
142 Usage: $progname [options] [file [files [...]]]
147 Create 2D plot instead of 3D. Bigger window by default in gnuplot,
148 and it’s faster when plotting lots of data.
153 Default: $Std{'label-file'}
155 Use time as Z axis instead of elevation.
157 Increase level of verbosity. Can be repeated.
163 lp - lines with points
164 Default: $Std{'with'}
166 Print version information.
168 Print debugging messages.
176 # Print a status message to stderr based on verbosity level {{{
177 my ($verbose_level, $Txt) = @_;
179 if ($Opt{'verbose'} >= $verbose_level) {
180 print(STDERR
"$progname: $Txt\n");
186 # Print a debugging message {{{
188 my @call_info = caller;
189 chomp(my $Txt = shift);
190 my $File = $call_info[1];
192 $File =~ s
#^.*/(.*?)$#$1#;
193 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
200 # Plain Old Documentation (POD) {{{
210 [options] [file [files [...]]]
220 =item B<-h>, B<--help>
222 Print a brief help summary.
224 =item B<-v>, B<--verbose>
226 Increase level of verbosity. Can be repeated.
230 Print version information.
234 Print debugging messages.
244 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
248 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
249 This is free software; see the file F<COPYING> for legalese stuff.
253 This program is free software: you can redistribute it and/or modify it
254 under the terms of the GNU General Public License as published by the
255 Free Software Foundation, either version 3 of the License, or (at your
256 option) any later version.
258 This program is distributed in the hope that it will be useful, but
259 WITHOUT ANY WARRANTY; without even the implied warranty of
260 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
261 See the GNU General Public License for more details.
263 You should have received a copy of the GNU General Public License along
265 If not, see L<http://www.gnu.org/licenses/>.
273 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :