* /trunk/src/gpstools/doc/gnuplot.txt
[gpstools.git] / branches / gpst.postgis / tests / run-tests.pl
blobedaf16120699bb50a9c102a92fa75ad339e7b2f5
1 #!/usr/bin/perl -w
3 #=======================================================================
4 # $Id$
5 # Test suite for gpst(1).
7 # Character set: UTF-8
8 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
9 # License: GNU General Public License version 2 or later, see end of
10 # file for legal stuff.
11 #=======================================================================
13 BEGIN {
14 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
15 our @version_array;
16 use Test::More qw{no_plan};
17 use_ok(GPST);
18 use_ok(GPSTdate);
19 use_ok(GPSTdebug);
20 use_ok(GPSTgeo);
21 use_ok(GPSTxml);
24 use strict;
25 use Getopt::Long;
27 $| = 1;
29 our $Debug = 0;
30 our $CMD = "../gpst";
32 our %Opt = (
34 'all' => 0,
35 'debug' => 0,
36 'help' => 0,
37 'todo' => 0,
38 'verbose' => 0,
39 'version' => 0,
43 our $progname = $0;
44 $progname =~ s/^.*\/(.*?)$/$1/;
46 my $rcs_id = '$Id$';
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);
52 my @cmdline_array = @ARGV;
54 Getopt::Long::Configure("bundling");
55 GetOptions(
57 "all|a" => \$Opt{'all'},
58 "debug" => \$Opt{'debug'},
59 "help|h" => \$Opt{'help'},
60 "todo|t" => \$Opt{'todo'},
61 "verbose|v+" => \$Opt{'verbose'},
62 "version" => \$Opt{'version'},
64 ) || die("$progname: Option error. Use -h for help.\n");
66 our %Cmd = (
67 'gpsbabel' => 'gpsbabel',
70 $Opt{'debug'} && ($Debug = 1);
71 $Opt{'help'} && usage(0);
72 if ($Opt{'version'}) {
73 print_version();
74 exit(0);
77 diag(sprintf("========== Executing \"%s%s%s\" ==========",
78 $progname,
79 scalar(@cmdline_array) ? " " : "",
80 join(" ", @cmdline_array)));
82 chomp(my $gpx_header = <<END);
83 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
84 <gpx
85 version="1.1"
86 creator="gpst - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/"
87 xmlns="http://www.topografix.com/GPX/1/1"
88 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
89 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
91 END
92 my $stripped_gpx_header = $gpx_header;
93 $stripped_gpx_header =~ s/^\s*(.*)$/$1/mg;
95 if ($Opt{'todo'} && !$Opt{'all'}) {
96 goto todo_section;
99 =pod
101 testcmd("$CMD command", # {{{
102 <<END,
103 [expected stdin]
106 "description",
109 # }}}
111 =cut
113 diag("Testing conversion routines...");
115 # txt_to_xml() and xml_to_txt() {{{
117 is(txt_to_xml("abc"),
118 "abc",
119 "txt_to_xml(\"abc\")");
120 is(txt_to_xml("<&>"),
121 "&lt;&amp;&gt;",
122 "txt_to_xml(\"<&>\")");
123 is(txt_to_xml("first line\nsecond <\rthird\r\n<&>"),
124 "first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;",
125 "txt_to_xml() with multiline string");
127 is(xml_to_txt("abc"),
128 "abc",
129 "xml_to_txt(\"abc\")");
130 is(xml_to_txt("&lt;&amp;&gt;"),
131 "<&>",
132 "xml_to_txt(\"&lt;&amp;&gt;\")");
133 is(xml_to_txt("first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;"),
134 "first line\nsecond <\rthird\r\n<&>",
135 "xml_to_txt() with multiline string");
137 # txt_to_xml() and xml_to_txt() }}}
138 # postgresql_copy_safe() {{{
140 is(postgresql_copy_safe(""),
142 "postgresql_copy_safe() with empty string");
144 is(postgresql_copy_safe("abcæøåÆØÅ"),
145 "abcæøåÆØÅ",
146 "postgresql_copy_safe(\"abcæøåÆØÅ\")");
148 is(postgresql_copy_safe("abc\t'\r\n"),
149 "abc\\t'\\r\\n",
150 "postgresql_copy_safe(\"abc\\t'\\r\\n\")");
152 is(postgresql_copy_safe("¤%/&gurgle\t325\\wer\ndfv'\r!\"#\n%\twe\r\x00sdf\xFFsadc\n\t\x00sdc\n"),
153 "¤%/&gurgle\\t325\\\\wer\\ndfv'\\r!\"#\\n%\\twe\\r\x00sdf\xFFsadc\\n\\t\x00sdc\\n",
154 "postgresql_copy_safe() with multiline, nulls and stuff");
156 # postgresql_copy_safe() }}}
158 diag("Testing date routines...");
160 # sec_to_string() {{{
162 is(sec_to_string(1148220825),
163 "2006-05-21 14:13:45",
164 "sec_to_string() without separator");
165 is(sec_to_string(1148220825, "T"),
166 "2006-05-21T14:13:45",
167 "sec_to_string() with separator");
168 is(sec_to_string(-5000),
169 undef,
170 "sec_to_string(-5000) — negative numbers unsupported atm");
171 is(sec_to_string(""),
172 undef,
173 "sec_to_string(\"\")");
174 is(sec_to_string("pH()rtY tW0"),
175 undef,
176 "sec_to_string() with invalid string");
177 is(sec_to_string("00000000000000000000001148220825"),
178 "2006-05-21 14:13:45",
179 "sec_to_string() with a bunch of leading zeros");
180 is(sec_to_string("1148220825.93"),
181 "2006-05-21 14:13:45.93",
182 "sec_to_string() with decimals");
183 is(sec_to_string("000000000000000000000000000001148220825.7312"),
184 "2006-05-21 14:13:45.7312",
185 "sec_to_string() with decimals and prefixing zeros");
186 is(sec_to_string("1148220825.93000"),
187 "2006-05-21 14:13:45.93",
188 "sec_to_string() with decimals and extra trailing zeros");
189 is(sec_to_string(".863"),
190 "1970-01-01 00:00:00.863",
191 "sec_to_string() with missing zero before decimal point");
193 # sec_to_string() }}}
194 # sec_to_readable() {{{
196 is(sec_to_readable(0),
197 "0:00:00:00",
198 "sec_to_readable(0)");
199 is(sec_to_readable("pH()rtY tW0"),
200 undef,
201 "sec_to_readable() with invalid string");
202 is(sec_to_readable(86400),
203 "1:00:00:00",
204 "sec_to_readable(86400)");
205 is(sec_to_readable(86400*1000),
206 "1000:00:00:00",
207 "sec_to_readable(86400*1000)");
208 is(sec_to_readable(86400+7200+180+4),
209 "1:02:03:04",
210 "sec_to_readable(86400+7200+180+4)");
211 is(sec_to_readable("3.14"),
212 "0:00:00:03.14",
213 "sec_to_readable(\"3.14\")");
214 is(sec_to_readable("-124"),
215 undef,
216 "sec_to_readable() rejects negative numbers");
217 is(sec_to_readable("-2.34"),
218 undef,
219 "sec_to_readable() rejects negative decimal");
220 is(sec_to_readable(".87"),
221 "0:00:00:00.87",
222 "sec_to_readable(), missing zero before decimal point");
223 is(sec_to_readable(""),
224 "0:00:00:00",
225 "sec_to_readable() with empty string");
227 # sec_to_readable() }}}
229 diag("Testing geo routines...");
231 # ddd_to_dms() {{{
233 is(ddd_to_dms("12.34567"),
234 "12\xB020'44.4\"",
235 "ddd_to_dms(\"12.34567\")");
237 is(ddd_to_dms("0"),
238 "0\xB000'00.0\"",
239 "ddd_to_dms(\"0\")");
241 is(ddd_to_dms(""),
242 "0\xB000'00.0\"",
243 "ddd_to_dms(\"\")");
245 is(ddd_to_dms("pH()rtY tW0"),
246 undef,
247 "ddd_to_dms(\"pH()rtY tW0\")");
249 is(ddd_to_dms("-12.34567"),
250 "-12\xB020'44.4\"",
251 "ddd_to_dms(\"-12.34567\")");
253 is(ddd_to_dms("0.34567"),
254 "0\xB020'44.4\"",
255 "ddd_to_dms(\"0.34567\")");
257 is(ddd_to_dms(".34567"),
258 "0\xB020'44.4\"",
259 "ddd_to_dms(\".34567\")");
261 is(ddd_to_dms("-.34567"),
262 "-0\xB020'44.4\"",
263 "ddd_to_dms(\"-.34567\")");
265 is(ddd_to_dms("-0.34567"),
266 "-0\xB020'44.4\"",
267 "ddd_to_dms(\"-0.34567\")");
269 is(ddd_to_dms("180"),
270 "180\xB000'00.0\"",
271 "ddd_to_dms(\"180\")");
273 is(ddd_to_dms("-180"),
274 "-180\xB000'00.0\"",
275 "ddd_to_dms(\"-180\")");
277 is(ddd_to_dms("-1"),
278 "-1\xB000'00.0\"",
279 "ddd_to_dms(\"-1\")");
281 is(ddd_to_dms("2-3"),
282 undef,
283 "ddd_to_dms(\"2-3\")");
285 # ddd_to_dms() }}}
287 diag("Testing trackpoint()..."); # {{{
289 my %Dat = ();
291 is(trackpoint(%Dat),
292 undef,
293 "trackpoint() receives empty hash");
295 my %Bck = (
296 # {{{
297 'format' => 'gpsml',
298 'year' => '2003',
299 'month' => '06',
300 'day' => '13',
301 'hour' => '14',
302 'min' => '36',
303 'sec' => '10',
304 'lat' => '59.5214',
305 'lon' => '7.392133',
306 'ele' => '762',
307 'error' => "",
308 'what' => 'tp',
309 # }}}
312 # trackpoint() (gpsml) {{{
313 %Dat = %Bck;
315 trackpoint(%Dat),
316 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
317 "trackpoint() (gpsml)"
320 # trackpoint() (gpsml) }}}
321 # trackpoint() (gpx) {{{
322 %Dat = %Bck;
323 $Dat{'format'} = "gpx";
325 trackpoint(%Dat),
326 qq{ <trkpt lat="59.5214" lon="7.392133"> <ele>762</ele> <time>2003-06-13T14:36:10Z</time> </trkpt>\n},
327 "trackpoint() (gpx)"
330 # trackpoint() (gpx) }}}
332 # trackpoint(): Various loop tests {{{
334 for my $Elem (qw{format lat lon what}) {
335 my %Dat = %Bck;
337 $Dat{"$Elem"} = '2d';
338 is(trackpoint(%Dat),
339 undef,
340 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") returns undef"
345 for my $Elem (qw{year month day hour min sec}) {
346 # Date tests {{{
347 my %Dat;
349 %Dat = %Bck;
350 $Dat{"$Elem"} = '';
351 is(trackpoint(%Dat),
352 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
353 "trackpoint(): {'$Elem'} with empty value skips time"
356 %Dat = %Bck;
357 $Dat{"$Elem"} = '2d';
358 is(trackpoint(%Dat),
359 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
360 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") skips time"
363 %Dat = %Bck;
364 $Dat{$Elem} = "00000$Dat{$Elem}";
365 is(trackpoint(%Dat),
366 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
367 "trackpoint(): Strip prefixing zeros from {'$Elem'}"
370 %Dat = %Bck;
371 $Dat{"$Elem"} = 0-$Dat{$Elem};
372 is(trackpoint(%Dat),
373 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
374 "trackpoint(): {'$Elem'} is negative, skip time"
377 if ($Elem ne "sec") {
378 %Dat = %Bck;
379 $Dat{"$Elem"} = "$Dat{$Elem}.00";
380 is(trackpoint(%Dat),
381 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
382 "trackpoint(): Decimals in {'$Elem'}, skip time"
386 # Date tests }}}
389 %Dat = %Bck;
390 $Dat{'sec'} = "$Dat{'sec'}.00";
391 is(trackpoint(%Dat),
392 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
393 "trackpoint(): Remove trailing zeros in {'sec'} decimals"
396 for my $Elem (qw{format what error}) {
397 my %Dat = %Bck;
398 $Dat{$Elem} = undef;
399 is(trackpoint(%Dat),
400 undef,
401 "trackpoint(): Missing {'$Elem'}, return undef"
405 # Various loop tests }}}
407 # trackpoint() }}}
409 diag("Testing output from ../gpst");
411 diag("Read empty input (/dev/null)..."); # {{{
412 testcmd("../gpst </dev/null", # {{{
413 <<END,
414 <?xml version="1.0" encoding="UTF-8"?>
415 <gpsml>
416 <track>
417 </track>
418 </gpsml>
421 "Read from /dev/null",
424 # }}}
425 testcmd("../gpst -o gpx </dev/null", # {{{
426 <<END,
427 $gpx_header
428 <trk>
429 <trkseg>
430 </trkseg>
431 </trk>
432 </gpx>
435 "Output gpx from /dev/null",
438 # }}}
439 # empty input }}}
440 diag("Read empty files..."); # {{{
441 testcmd("echo '<tp> </tp>' | ../gpst", # {{{
442 <<END,
443 <?xml version="1.0" encoding="UTF-8"?>
444 <gpsml>
445 <track>
446 </track>
447 </gpsml>
450 "Don’t print empty trackpoints",
453 # }}}
454 # Read empty files }}}
455 diag("Testing --chronology option..."); # {{{
456 testcmd("../gpst --chronology chronology-error.gpsml", # {{{
457 <<END,
458 <?xml version="1.0" encoding="UTF-8"?>
459 <gpsml>
460 <track>
461 <title>Chronology errors</title>
462 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
463 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
464 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
465 <break/>
466 <tp> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </tp>
467 <break/>
468 <pause>0:00:37:54</pause>
469 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
470 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
471 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
472 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
473 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
474 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
475 </track>
476 </gpsml>
478 "gpst: chronology-error.gpsml: \"2006-05-02T09:46:46Z\": Next date is 0:00:06:39 in the past (2006-05-02T09:40:07Z)\n" .
479 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
480 "Check for chronology errors and duplicated times",
483 # }}}
484 # --chronology option }}}
485 diag("Testing --skip-dups option..."); # {{{
486 testcmd("../gpst -d no_signal.mayko", # {{{
487 <<END,
488 <?xml version="1.0" encoding="UTF-8"?>
489 <gpsml>
490 <track>
491 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
492 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
493 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
494 <etp err="dup"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
495 <etp err="dup"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
496 <etp err="dup"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
497 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
498 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
499 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
500 </track>
501 </gpsml>
504 "Remove duplicated positions from gpsml",
507 # }}}
508 testcmd("../gpst -d -o csv no_signal.mayko", # {{{
509 <<END,
510 2002-12-22T21:42:24Z\t23.6746151\t70.6800486\t\t
511 2002-12-22T21:42:32Z\t23.6740038\t70.6799322\t\t
512 2002-12-22T21:42:54Z\t23.6723991\t70.6796266\t\t
513 2002-12-22T21:44:45Z\t23.6757566\t70.6800774\t\t
514 2002-12-22T21:44:52Z\t23.6753442\t70.6801502\t\t
515 2002-12-22T21:45:04Z\t23.6757542\t70.6801905\t\t
518 "Remove duplicated positions from csv output format",
521 # }}}
522 testcmd("../gpst -d -o clean no_signal.mayko", # {{{
523 <<END,
524 23.6746151\t70.6800486\t
525 23.6740038\t70.6799322\t
526 23.6723991\t70.6796266\t
527 23.6757566\t70.6800774\t
528 23.6753442\t70.6801502\t
529 23.6757542\t70.6801905\t
532 "Remove duplicated positions from clean output format",
535 # }}}
536 testcmd("../gpst -d -o pgtab no_signal.mayko", # {{{
537 <<END,
538 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N\t\\N
539 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N\t\\N
540 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
541 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N\t\\N
542 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N\t\\N
543 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N\t\\N
546 "Remove duplicated positions from pgtab output format",
549 # }}}
550 # --skip-dups option }}}
551 diag("Testing --epoch option..."); # {{{
552 testcmd("../gpst -e pause.gpx", # {{{
553 <<END,
554 <?xml version="1.0" encoding="UTF-8"?>
555 <gpsml>
556 <track>
557 <title>ACTIVE LOG164705</title>
558 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
559 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
560 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
561 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
562 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
563 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
564 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
565 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
566 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
567 </track>
568 </gpsml>
571 "--epoch is ignored in gpsml output",
574 # }}}
575 testcmd("../gpst -e -o gpx pause.gpx", # {{{
576 <<END,
577 $gpx_header
578 <trk>
579 <name>ACTIVE LOG164705</name>
580 <trkseg>
581 <trkpt lat="60.425494" lon="5.299534"> <ele>25.260</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
582 <trkpt lat="60.425464" lon="5.299610"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
583 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
584 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
585 <trkpt lat="60.425339" lon="5.299958"> <ele>30.980</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
586 <trkpt lat="60.425238" lon="5.299640"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
587 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
588 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
589 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
590 </trkseg>
591 </trk>
592 </gpx>
595 "--epoch is ignored in gpx output",
598 # }}}
599 # --epoch option }}}
600 diag("Testing --fix option..."); # {{{
601 testcmd("../gpst --fix --chronology chronology-error.gpsml", # {{{
602 <<END,
603 <?xml version="1.0" encoding="UTF-8"?>
604 <gpsml>
605 <track>
606 <title>Chronology errors</title>
607 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
608 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
609 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
610 <break/>
611 <etp err="chrono"> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </etp>
612 <break/>
613 <pause>0:00:37:54</pause>
614 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
615 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
616 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
617 <etp err="duptime"> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </etp>
618 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
619 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
620 </track>
621 </gpsml>
623 "gpst: chronology-error.gpsml: \"2006-05-02T09:46:46Z\": Next date is 0:00:06:39 in the past (2006-05-02T09:40:07Z)\n" .
624 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
625 "Remove bad timestamps",
628 # }}}
629 # --fix option }}}
630 diag("Testing --from-date option..."); # {{{
631 # --from-date option }}}
632 diag("Testing -h (--help) option...");
633 likecmd("$CMD -h", # {{{
634 '/ Show this help\./',
635 '/^$/',
636 "Option -h prints help screen",
639 # }}}
640 ok(`$CMD -h` !~ /\$Id: /s, "\"$CMD -h\" - No Id with only -h");
641 # --help option }}}
642 diag("Testing --inside option..."); # {{{
643 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx", # {{{
644 <<END,
645 <?xml version="1.0" encoding="UTF-8"?>
646 <gpsml>
647 <track>
648 <title>track1</title>
649 <break/>
650 <title>track2</title>
651 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
652 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
653 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
654 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
655 <break/>
656 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
657 <break/>
658 <title>track3</title>
659 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
660 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
661 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
662 </track>
663 </gpsml>
666 "Check --inside option (gpx to gpst)",
668 # }}}
670 # --inside option }}}
671 diag("Testing --undefined option..."); # {{{
672 # --undefined option }}}
673 diag("Testing --near option..."); # {{{
674 # --near option }}}
675 diag("Testing --output option..."); # {{{
676 # gpsml (Default)
677 testcmd("../gpst log.mcsv", # {{{
678 <<END,
679 <?xml version="1.0" encoding="UTF-8"?>
680 <gpsml>
681 <track>
682 <break/>
683 <title>ACTIVE LOG 125</title>
684 <tp> <time>2006-03-04T11:12:30Z</time> <lat>54.96883</lat> <lon>-1.62439</lon> <ele>77</ele> </tp>
685 <tp> <time>2006-03-04T11:12:47Z</time> <lat>54.96878</lat> <lon>-1.62413</lon> <ele>77</ele> </tp>
686 <tp> <time>2006-03-04T11:12:55Z</time> <lat>54.96913</lat> <lon>-1.62616</lon> <ele>77</ele> </tp>
687 <tp> <time>2006-03-04T11:13:04Z</time> <lat>54.96934</lat> <lon>-1.62624</lon> <ele>77.5</ele> </tp>
688 <tp> <time>2006-03-04T11:13:33Z</time> <lat>54.96934</lat> <lon>-1.62596</lon> <ele>78</ele> </tp>
689 <tp> <time>2006-03-04T11:13:48Z</time> <lat>54.96931</lat> <lon>-1.62645</lon> <ele>78</ele> </tp>
690 <tp> <time>2006-03-04T11:14:05Z</time> <lat>54.96918</lat> <lon>-1.62603</lon> <ele>79</ele> </tp>
691 <tp> <time>2006-03-04T11:14:33Z</time> <lat>54.96901</lat> <lon>-1.62364</lon> <ele>76.1</ele> </tp>
692 <tp> <time>2006-03-04T11:15:02Z</time> <lat>54.96922</lat> <lon>-1.6254</lon> <ele>76.1</ele> </tp>
693 <tp> <time>2006-03-04T11:15:27Z</time> <lat>54.96914</lat> <lon>-1.62526</lon> <ele>75.1</ele> </tp>
694 <tp> <time>2006-03-04T11:15:50Z</time> <lat>54.96911</lat> <lon>-1.62494</lon> <ele>75.1</ele> </tp>
695 <tp> <time>2006-03-04T11:16:03Z</time> <lat>54.9693</lat> <lon>-1.62489</lon> <ele>75.1</ele> </tp>
696 <tp> <time>2006-03-04T11:16:19Z</time> <lat>54.96901</lat> <lon>-1.62496</lon> <ele>75.1</ele> </tp>
697 <tp> <time>2006-03-04T11:16:52Z</time> <lat>54.96871</lat> <lon>-1.62466</lon> <ele>74.6</ele> </tp>
698 <tp> <time>2006-03-04T11:17:25Z</time> <lat>54.96908</lat> <lon>-1.62488</lon> <ele>72.7</ele> </tp>
699 <break/>
700 <title>ACTIVE LOG 126</title>
701 <tp> <time>2006-03-04T11:18:32Z</time> <lat>54.96904</lat> <lon>-1.62482</lon> <ele>72.7</ele> </tp>
702 <tp> <time>2006-03-04T11:18:35Z</time> <lat>54.96913</lat> <lon>-1.62499</lon> <ele>71.3</ele> </tp>
703 <tp> <time>2006-03-04T11:18:38Z</time> <lat>54.96904</lat> <lon>-1.62497</lon> <ele>70.8</ele> </tp>
704 <tp> <time>2006-03-04T11:18:48Z</time> <lat>54.96913</lat> <lon>-1.62496</lon> <ele>71.8</ele> </tp>
705 <tp> <time>2006-03-04T11:18:55Z</time> <lat>54.96924</lat> <lon>-1.62501</lon> <ele>72.2</ele> </tp>
706 <tp> <time>2006-03-04T11:19:11Z</time> <lat>54.9694</lat> <lon>-1.62521</lon> <ele>71.8</ele> </tp>
707 <tp> <time>2006-03-04T11:19:30Z</time> <lat>54.96916</lat> <lon>-1.62515</lon> <ele>71.3</ele> </tp>
708 <tp> <time>2006-03-04T11:19:53Z</time> <lat>54.96921</lat> <lon>-1.625</lon> <ele>71.3</ele> </tp>
709 <tp> <time>2006-03-04T11:20:21Z</time> <lat>54.96801</lat> <lon>-1.62417</lon> <ele>71.8</ele> </tp>
710 <break/>
711 <title>ACTIVE LOG 127</title>
712 <tp> <time>2006-03-04T11:21:16Z</time> <lat>54.96887</lat> <lon>-1.62504</lon> <ele>70.8</ele> </tp>
713 <tp> <time>2006-03-04T11:21:18Z</time> <lat>54.96898</lat> <lon>-1.62476</lon> <ele>69.8</ele> </tp>
714 <tp> <time>2006-03-04T11:21:29Z</time> <lat>54.9691</lat> <lon>-1.62475</lon> <ele>69.4</ele> </tp>
715 <tp> <time>2006-03-04T11:21:46Z</time> <lat>54.96918</lat> <lon>-1.62468</lon> <ele>70.3</ele> </tp>
716 <tp> <time>2006-03-04T11:22:39Z</time> <lat>54.9692</lat> <lon>-1.62465</lon> <ele>69.4</ele> </tp>
717 <tp> <time>2006-03-04T11:22:43Z</time> <lat>54.96924</lat> <lon>-1.62462</lon> <ele>71.8</ele> </tp>
718 <tp> <time>2006-03-04T11:22:45Z</time> <lat>54.96928</lat> <lon>-1.62463</lon> <ele>71.8</ele> </tp>
719 <tp> <time>2006-03-04T11:23:00Z</time> <lat>54.96945</lat> <lon>-1.62466</lon> <ele>69.4</ele> </tp>
720 </track>
721 </gpsml>
724 "Read Mapsource TAB-separated format",
727 # }}}
728 testcmd("../gpst two-digit_year.mcsv", # {{{
729 <<END,
730 <?xml version="1.0" encoding="UTF-8"?>
731 <gpsml>
732 <track>
733 <break/>
734 <title>ACTIVE LOG 032</title>
735 <tp> <time>2006-03-20T20:35:33Z</time> <lat>60.41324</lat> <lon>5.33352</lon> <ele>14</ele> </tp>
736 <tp> <time>2006-03-20T20:35:38Z</time> <lat>60.38802</lat> <lon>5.33845</lon> <ele>18</ele> </tp>
737 <tp> <time>2006-03-20T20:35:44Z</time> <lat>60.38709</lat> <lon>5.3379</lon> <ele>19</ele> </tp>
738 <tp> <time>2006-03-20T20:35:49Z</time> <lat>60.38641</lat> <lon>5.33732</lon> <ele>18</ele> </tp>
739 <tp> <time>2006-03-20T20:35:54Z</time> <lat>60.38581</lat> <lon>5.33647</lon> <ele>18</ele> </tp>
740 <tp> <time>2006-03-20T20:36:00Z</time> <lat>60.38516</lat> <lon>5.33528</lon> <ele>15</ele> </tp>
741 <tp> <time>2006-03-20T20:36:02Z</time> <lat>60.38495</lat> <lon>5.3349</lon> <ele>13</ele> </tp>
742 </track>
743 </gpsml>
746 "Read Mapsource TAB-separated format with two-digit year",
749 # }}}
750 testcmd("../gpst log.gpstxt", # {{{
751 <<END,
752 <?xml version="1.0" encoding="UTF-8"?>
753 <gpsml>
754 <track>
755 <tp> <time>2003-06-13T14:36:09Z</time> <lat>59.521517</lat> <lon>7.391867</lon> <ele>762</ele> </tp>
756 <tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>
757 <tp> <time>2003-06-13T14:36:11Z</time> <lat>59.5213</lat> <lon>7.392417</lon> <ele>761</ele> </tp>
758 <tp> <time>2003-06-13T14:36:12Z</time> <lat>59.521183</lat> <lon>7.3927</lon> <ele>761</ele> </tp>
759 <etp err="nosignal"> <time>2003-06-13T14:36:13Z</time> </etp>
760 <tp> <time>2003-06-13T14:36:15Z</time> <lat>59.52085</lat> <lon>7.393517</lon> <ele>760</ele> </tp>
761 <tp> <time>2003-06-13T14:36:16Z</time> <lat>59.520733</lat> <lon>7.393783</lon> <ele>760</ele> </tp>
762 <tp> <time>2003-06-13T14:36:17Z</time> <lat>59.52065</lat> <lon>7.39405</lon> <ele>760</ele> </tp>
763 <tp> <time>2003-06-13T14:36:18Z</time> <lat>59.520583</lat> <lon>7.394333</lon> <ele>760</ele> </tp>
764 <tp> <time>2003-06-13T14:36:19Z</time> <lat>59.520533</lat> <lon>7.394633</lon> <ele>759</ele> </tp>
765 <tp> <time>2003-06-13T14:36:20Z</time> <lat>59.520483</lat> <lon>7.394917</lon> <ele>759</ele> </tp>
766 <tp> <time>2003-06-13T14:36:21Z</time> <lat>59.520433</lat> <lon>7.395233</lon> <ele>759</ele> </tp>
767 <etp err="nosignal"> <time>2003-06-13T14:36:22Z</time> </etp>
768 <tp> <time>2003-06-13T14:36:24Z</time> <lat>59.520283</lat> <lon>7.396233</lon> <ele>758</ele> </tp>
769 <tp> <time>2003-06-13T14:36:25Z</time> <lat>59.520233</lat> <lon>7.39655</lon> <ele>758</ele> </tp>
770 <tp> <time>2003-06-13T14:36:26Z</time> <lat>59.520183</lat> <lon>7.396883</lon> <ele>757</ele> </tp>
771 <tp> <time>2003-06-13T14:36:27Z</time> <lat>59.520133</lat> <lon>7.397217</lon> <ele>757</ele> </tp>
772 <tp> <time>2003-06-13T14:36:28Z</time> <lat>59.5201</lat> <lon>7.397567</lon> <ele>757</ele> </tp>
773 </track>
774 </gpsml>
777 "Read Garmin serial text format",
780 # }}}
781 testcmd("../gpst log.dos.mayko", # {{{
782 <<END,
783 <?xml version="1.0" encoding="UTF-8"?>
784 <gpsml>
785 <track>
786 <tp> <time>2003-06-15T10:27:45Z</time> <lat>58.1818158</lat> <lon>8.1225077</lon> </tp>
787 <tp> <time>2003-06-15T10:27:53Z</time> <lat>58.1818712</lat> <lon>8.12532</lon> </tp>
788 <tp> <time>2003-06-15T10:27:57Z</time> <lat>58.1816347</lat> <lon>8.1266031</lon> </tp>
789 <tp> <time>2003-06-15T10:28:03Z</time> <lat>58.1812099</lat> <lon>8.1284612</lon> </tp>
790 <tp> <time>2003-06-15T10:28:06Z</time> <lat>58.1810315</lat> <lon>8.129395</lon> </tp>
791 <tp> <time>2003-06-15T10:28:10Z</time> <lat>58.1809621</lat> <lon>8.13074</lon> </tp>
792 </track>
793 </gpsml>
796 "Read DOS-formatted Mayko format",
799 # }}}
800 testcmd("../gpst log.dos.gpstxt", # {{{
801 <<END,
802 <?xml version="1.0" encoding="UTF-8"?>
803 <gpsml>
804 <track>
805 <tp> <time>2003-01-05T16:47:11Z</time> <lat>66.908167</lat> <lon>15.022983</lon> <ele>11472</ele> </tp>
806 <tp> <time>2003-01-05T16:47:12Z</time> <lat>66.90625</lat> <lon>15.020667</lon> <ele>11472</ele> </tp>
807 <tp> <time>2003-01-05T16:47:13Z</time> <lat>66.904317</lat> <lon>15.01835</lon> <ele>11472</ele> </tp>
808 <tp> <time>2003-01-05T16:47:14Z</time> <lat>66.9024</lat> <lon>15.016017</lon> <ele>11473</ele> </tp>
809 <tp> <time>2003-01-05T16:47:15Z</time> <lat>66.900483</lat> <lon>15.0137</lon> <ele>11474</ele> </tp>
810 <tp> <time>2003-01-05T16:47:16Z</time> <lat>66.898567</lat> <lon>15.011383</lon> <ele>11474</ele> </tp>
811 <tp> <time>2003-01-05T16:47:17Z</time> <lat>66.896633</lat> <lon>15.009067</lon> <ele>11475</ele> </tp>
812 <tp> <time>2003-01-05T16:47:18Z</time> <lat>66.894717</lat> <lon>15.006733</lon> <ele>11475</ele> </tp>
813 <tp> <time>2003-01-05T16:47:19Z</time> <lat>66.8928</lat> <lon>15.004417</lon> <ele>11475</ele> </tp>
814 <tp> <time>2003-01-05T16:47:20Z</time> <lat>66.890867</lat> <lon>15.0021</lon> <ele>11475</ele> </tp>
815 <tp> <time>2003-01-05T16:47:21Z</time> <lat>66.88895</lat> <lon>14.999783</lon> <ele>11475</ele> </tp>
816 </track>
817 </gpsml>
820 "Read DOS-formatted Garmin serial text format",
823 # }}}
824 testcmd("../gpst log.unix.mcsv", # {{{
825 <<END,
826 <?xml version="1.0" encoding="UTF-8"?>
827 <gpsml>
828 <track>
829 <break/>
830 <title>ACTIVE LOG 058</title>
831 <tp> <time>2006-02-21T15:14:25Z</time> <lat>60.36662</lat> <lon>5.24885</lon> <ele>31.9</ele> </tp>
832 <tp> <time>2006-02-21T15:14:30Z</time> <lat>60.37057</lat> <lon>5.22956</lon> <ele>35.2</ele> </tp>
833 <tp> <time>2006-02-21T15:14:35Z</time> <lat>60.37019</lat> <lon>5.22817</lon> <ele>39.6</ele> </tp>
834 <tp> <time>2006-02-21T15:14:36Z</time> <lat>60.37012</lat> <lon>5.2279</lon> <ele>41</ele> </tp>
835 <tp> <time>2006-02-21T15:14:40Z</time> <lat>60.37009</lat> <lon>5.22682</lon> <ele>47.2</ele> </tp>
836 <tp> <time>2006-02-21T15:14:42Z</time> <lat>60.37011</lat> <lon>5.22641</lon> <ele>49.2</ele> </tp>
837 <tp> <time>2006-02-21T15:14:44Z</time> <lat>60.37011</lat> <lon>5.22607</lon> <ele>50.1</ele> </tp>
838 <tp> <time>2006-02-21T15:14:48Z</time> <lat>60.37002</lat> <lon>5.22568</lon> <ele>51.1</ele> </tp>
839 <tp> <time>2006-02-21T15:14:51Z</time> <lat>60.3701</lat> <lon>5.22548</lon> <ele>52.5</ele> </tp>
840 </track>
841 </gpsml>
844 "Read UNIX-formatted Garmin Mapsource TAB-separated format",
847 # }}}
848 testcmd("../gpst multitrack.gpx", # {{{
849 <<END,
850 <?xml version="1.0" encoding="UTF-8"?>
851 <gpsml>
852 <track>
853 <title>Track 1</title>
854 <tp> <time>2003-02-11T23:35:39Z</time> <lat>51.4968266</lat> <lon>-0.1448824</lon> </tp>
855 <tp> <time>2003-02-11T23:35:49Z</time> <lat>51.4968227</lat> <lon>-0.1449938</lon> </tp>
856 <tp> <time>2003-02-11T23:36:14Z</time> <lat>51.496904</lat> <lon>-0.1453202</lon> </tp>
857 <break/>
858 <title>Track 2</title>
859 <tp> <time>2003-02-11T23:36:16Z</time> <lat>51.4969214</lat> <lon>-0.1453398</lon> </tp>
860 <tp> <time>2003-02-11T23:36:31Z</time> <lat>51.4969816</lat> <lon>-0.1455514</lon> </tp>
861 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
862 <tp> <time>2003-02-11T23:36:50Z</time> <lat>51.4970452</lat> <lon>-0.1457804</lon> </tp>
863 <break/>
864 <title>Track 3</title>
865 <tp> <time>2003-02-11T23:37:05Z</time> <lat>51.497068</lat> <lon>-0.1458608</lon> </tp>
866 <tp> <time>2003-02-11T23:37:22Z</time> <lat>51.4971658</lat> <lon>-0.1460047</lon> </tp>
867 <tp> <time>2003-02-11T23:37:36Z</time> <lat>51.4972469</lat> <lon>-0.1461614</lon> </tp>
868 <break/>
869 <title>Track 4</title>
870 <tp> <time>2003-02-11T23:37:43Z</time> <lat>51.4972731</lat> <lon>-0.1462394</lon> </tp>
871 <tp> <time>2003-02-11T23:38:04Z</time> <lat>51.4973437</lat> <lon>-0.1463232</lon> </tp>
872 <tp> <time>2003-02-11T23:38:28Z</time> <lat>51.4973337</lat> <lon>-0.1462949</lon> </tp>
873 <tp> <time>2003-02-11T23:38:34Z</time> <lat>51.4973218</lat> <lon>-0.1462825</lon> </tp>
874 <tp> <time>2003-02-11T23:38:35Z</time> <lat>51.4973145</lat> <lon>-0.1462732</lon> </tp>
875 </track>
876 </gpsml>
879 "Read GPX file with multiple tracks",
882 # }}}
883 testcmd("../gpst compact.gpx", # {{{
884 <<END,
885 <?xml version="1.0" encoding="UTF-8"?>
886 <gpsml>
887 <track>
888 <title>All whitespace stripped</title>
889 <tp> <time>2002-12-30T15:22:04Z</time> <lat>70.660932</lat> <lon>23.7028354</lon> </tp>
890 <tp> <time>2002-12-30T15:22:06Z</time> <lat>70.6609392</lat> <lon>23.7028468</lon> </tp>
891 <tp> <time>2002-12-30T15:22:08Z</time> <lat>70.6609429</lat> <lon>23.7028499</lon> </tp>
892 <tp> <time>2002-12-30T15:22:11Z</time> <lat>70.6609381</lat> <lon>23.702862</lon> </tp>
893 <tp> <time>2002-12-30T15:22:12Z</time> <lat>70.6609368</lat> <lon>23.7028648</lon> </tp>
894 <tp> <time>2002-12-30T15:22:13Z</time> <lat>70.6609344</lat> <lon>23.7028652</lon> </tp>
895 <tp> <time>2002-12-30T15:22:15Z</time> <lat>70.6609349</lat> <lon>23.7028707</lon> </tp>
896 <tp> <time>2002-12-30T15:22:17Z</time> <lat>70.6609348</lat> <lon>23.7028654</lon> </tp>
897 <tp> <time>2002-12-30T15:22:19Z</time> <lat>70.6609347</lat> <lon>23.7028599</lon> </tp>
898 <tp> <time>2002-12-30T15:22:20Z</time> <lat>70.6609348</lat> <lon>23.7028609</lon> </tp>
899 <tp> <time>2002-12-30T15:22:23Z</time> <lat>70.6609388</lat> <lon>23.7028653</lon> </tp>
900 <tp> <time>2002-12-30T15:22:25Z</time> <lat>70.6609426</lat> <lon>23.7028732</lon> </tp>
901 </track>
902 </gpsml>
905 "Read GPX one-liner",
908 # }}}
909 testcmd("../gpst missing.gpsml", # {{{
910 <<END,
911 <?xml version="1.0" encoding="UTF-8"?>
912 <gpsml>
913 <track>
914 <title>Missing various elements</title>
915 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
916 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
917 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
918 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
919 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
920 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
921 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
922 <tp> <ele>486</ele> </tp>
923 <tp> <desc>Missing everything</desc> </tp>
924 <tp> <lat>60.42339</lat> </tp>
925 <tp> <lon>5.34262</lon> </tp>
926 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
927 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
928 </track>
929 </gpsml>
932 "Read gpsml with various data missing",
935 # }}}
936 testcmd("../gpst different_dateformats.gpsml", # {{{
937 <<END,
938 <?xml version="1.0" encoding="UTF-8"?>
939 <gpsml>
940 <track>
941 <title>Date format variations</title>
942 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1</lat> <lon>1</lon> </tp>
943 <tp> <time>2006-01-01T00:00:02Z</time> <lat>2</lat> <lon>2</lon> </tp>
944 <tp> <time>2006-01-01T00:00:03Z</time> <lat>3</lat> <lon>3</lon> </tp>
945 <tp> <time>2006-01-01T00:00:04Z</time> <lat>4</lat> <lon>4</lon> </tp>
946 </track>
947 </gpsml>
950 "Read different date formats from gpsml file",
953 # }}}
954 testcmd("../gpst multitrack-pause.gpx", # {{{
955 file_data("multitrack-pause.gpsml"),
957 "Should be equal to multitrack-pause.gpsml",
960 # }}}
961 # gpx
962 testcmd("../gpst -o gpx no_signal.mayko", # {{{
963 <<END,
964 $gpx_header
965 <trk>
966 <trkseg>
967 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
968 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
969 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
970 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> </trkpt>
971 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> </trkpt>
972 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> </trkpt>
973 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
974 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
975 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
976 </trkseg>
977 </trk>
978 </gpx>
981 "Output GPX from Mayko file with duplicates",
984 # }}}
985 testcmd("../gpst -o gpx comments.mayko", # {{{
986 <<END,
987 $gpx_header
988 <trk>
989 <trkseg>
990 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
991 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
992 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
993 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
994 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
995 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
996 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
997 </trkseg>
998 <trkseg>
999 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
1000 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
1001 </trkseg>
1002 </trk>
1003 </gpx>
1006 "Output GPX from Mayko file with commented-out lines",
1009 # }}}
1010 testcmd("../gpst -o gpx missing.gpsml", # {{{
1011 <<END,
1012 $gpx_header
1013 <trk>
1014 <name>Missing various elements</name>
1015 <trkseg>
1016 <trkpt lat="60.42353" lon="5.34185"> <time>2006-04-30T17:17:09Z</time> </trkpt>
1017 <trkpt> <ele>483</ele> <time>2006-04-30T17:17:11Z</time> </trkpt>
1018 <trkpt> <ele>485</ele> <time>2006-04-30T17:17:22Z</time> </trkpt>
1019 <trkpt lat="60.42347" lon="5.34212"> <ele>486</ele> </trkpt>
1020 <trkpt> <ele>484</ele> </trkpt>
1021 <trkpt> <ele>486</ele> </trkpt>
1022 <trkpt> <ele>490</ele> <time>2006-04-30T17:18:03Z</time> </trkpt>
1023 <trkpt lat="60.42338" lon="5.34269"> <ele>487</ele> <time>2006-04-30T17:18:05Z</time> </trkpt>
1024 </trkseg>
1025 </trk>
1026 </gpx>
1029 "Output GPX from gpsml with missing data",
1032 # }}}
1033 # xgraph
1034 testcmd("../gpst -o xgraph multitrack.gpx", # {{{
1035 <<END,
1036 -0.1448824 51.4968266
1037 -0.1449938 51.4968227
1038 -0.1453202 51.4969040
1039 move -0.1453398 51.4969214
1040 -0.1455514 51.4969816
1041 -0.1457489 51.4970224
1042 -0.1457804 51.4970452
1043 move -0.1458608 51.4970680
1044 -0.1460047 51.4971658
1045 -0.1461614 51.4972469
1046 move -0.1462394 51.4972731
1047 -0.1463232 51.4973437
1048 -0.1462949 51.4973337
1049 -0.1462825 51.4973218
1050 -0.1462732 51.4973145
1053 "Output xgraph format from GPX",
1056 # }}}
1057 # pgtab
1058 testcmd("../gpst -o pgtab compact.gpx", # {{{
1059 <<END,
1060 2002-12-30T15:22:04Z\t(70.6609320,23.7028354)\t\\N\t\\N\t\\N\t\\N\t\\N
1061 2002-12-30T15:22:06Z\t(70.6609392,23.7028468)\t\\N\t\\N\t\\N\t\\N\t\\N
1062 2002-12-30T15:22:08Z\t(70.6609429,23.7028499)\t\\N\t\\N\t\\N\t\\N\t\\N
1063 2002-12-30T15:22:11Z\t(70.6609381,23.7028620)\t\\N\t\\N\t\\N\t\\N\t\\N
1064 2002-12-30T15:22:12Z\t(70.6609368,23.7028648)\t\\N\t\\N\t\\N\t\\N\t\\N
1065 2002-12-30T15:22:13Z\t(70.6609344,23.7028652)\t\\N\t\\N\t\\N\t\\N\t\\N
1066 2002-12-30T15:22:15Z\t(70.6609349,23.7028707)\t\\N\t\\N\t\\N\t\\N\t\\N
1067 2002-12-30T15:22:17Z\t(70.6609348,23.7028654)\t\\N\t\\N\t\\N\t\\N\t\\N
1068 2002-12-30T15:22:19Z\t(70.6609347,23.7028599)\t\\N\t\\N\t\\N\t\\N\t\\N
1069 2002-12-30T15:22:20Z\t(70.6609348,23.7028609)\t\\N\t\\N\t\\N\t\\N\t\\N
1070 2002-12-30T15:22:23Z\t(70.6609388,23.7028653)\t\\N\t\\N\t\\N\t\\N\t\\N
1071 2002-12-30T15:22:25Z\t(70.6609426,23.7028732)\t\\N\t\\N\t\\N\t\\N\t\\N
1074 "Output pgtab from gpx format",
1077 # }}}
1078 testcmd("../gpst -o pgtab no_signal.mayko", # {{{
1079 <<END,
1080 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N\t\\N
1081 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N\t\\N
1082 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
1083 2002-12-22T21:43:51Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
1084 2002-12-22T21:43:52Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
1085 2002-12-22T21:43:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
1086 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N\t\\N
1087 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N\t\\N
1088 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N\t\\N
1091 "Output pgtab from mayko format",
1094 # }}}
1095 testcmd("../gpst -o pgtab missing.gpsml", # {{{
1096 <<END,
1097 2006-04-30T17:17:09Z\t(60.42353,5.34185)\t\\N\t\\N\t\\N\t\\N\t\\N
1098 \\N\t(60.42347,5.34212)\t486\t\\N\t\\N\t\\N\t\\N
1099 2006-04-30T17:18:05Z\t(60.42338,5.34269)\t487\t\\N\t\\N\t\\N\t\\N
1102 "Output pgtab from missing.gpsml",
1105 # }}}
1106 # csv
1107 testcmd("../gpst -o csv log.dos.mayko", # {{{
1108 <<END,
1109 2003-06-15T10:27:45Z\t8.1225077\t58.1818158\t\t
1110 2003-06-15T10:27:53Z\t8.1253200\t58.1818712\t\t
1111 2003-06-15T10:27:57Z\t8.1266031\t58.1816347\t\t
1112 2003-06-15T10:28:03Z\t8.1284612\t58.1812099\t\t
1113 2003-06-15T10:28:06Z\t8.1293950\t58.1810315\t\t
1114 2003-06-15T10:28:10Z\t8.1307400\t58.1809621\t\t
1117 "Output csv from DOS-formatted Mayko format",
1120 # }}}
1121 # pgwtab
1122 testcmd("../gpst -o pgwtab multitrack.gpx", # {{{
1123 <<END,
1124 (51.477880000,-0.001470000)\t0-Meridian\t\\N\t\\N\t\\N\t11-FEB-03 15:46\t11-FEB-03 15:46\t\\N\t\\N
1125 (51.532030,-0.177330)\tAbbey Road\t34.492798\t\\N\t\\N\tDet hellige gangfeltet der Beatles valsa over.\t26-FEB-06 17:29:46\t\\N\t\\N
1126 (61.636684,8.312254)\tGaldhøpiggen med ', &, < og >. ☺\t2469.012939\tmountain\t2006-05-08T18:27:59Z\tHer er det &, < og >. ☺\tSchwæra greie\thttp://www.example.org/\tWaypoint
1127 (60.397460000,5.350610000)\tHalfdan Griegs vei\t\\N\t\\N\t\\N\t04-AUG-02 19:42\t04-AUG-02 19:42\t\\N\t\\N
1128 (51.510130000,-0.130410000)\tLeicester Square\t\\N\t\\N\t\\N\t11-FEB-03 18:00\t11-FEB-03 18:00\t\\N\t\\N
1129 (60.968540000,9.285350000)\tLeira camping\t\\N\t\\N\t\\N\t03-OKT-02 21:58\t03-OKT-02 21:58\t\\N\t\\N
1132 "Test pgwtab format",
1135 # }}}
1136 # pgwupd
1137 testcmd("../gpst -o pgwupd multitrack.gpx", # {{{
1138 <<END,
1139 BEGIN;
1140 UPDATE logg SET sted = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1141 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1142 COMMIT;
1143 BEGIN;
1144 UPDATE logg SET sted = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1145 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1146 COMMIT;
1147 BEGIN;
1148 UPDATE logg SET sted = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1149 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1150 COMMIT;
1151 BEGIN;
1152 UPDATE logg SET sted = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1153 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1154 COMMIT;
1155 BEGIN;
1156 UPDATE logg SET sted = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1157 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1158 COMMIT;
1159 BEGIN;
1160 UPDATE logg SET sted = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1161 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1162 COMMIT;
1165 "Test pgwupd format",
1168 # }}}
1169 # clean
1170 testcmd("../gpst -t -o clean pause.gpx", # {{{
1171 <<END,
1172 5.299534\t60.425494\t25.260
1173 5.299610\t60.425464\t24.931
1175 5.299694\t60.425314\t27.975
1177 5.299741\t60.425384\t31.017
1178 5.299958\t60.425339\t30.980
1179 5.299640\t60.425238\t30.538
1180 5.299686\t60.425246\t30.515
1182 5.299773\t60.425345\t31.936
1183 5.299419\t60.425457\t31.794
1186 "Output clean format with time breaks",
1188 # }}}
1189 # gpstrans
1190 # poscount
1191 # ps (Unfinished)
1192 # svg (Unfinished)
1193 # ygraph
1194 # --output option }}}
1195 diag("Testing --outside option..."); # {{{
1196 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --outside multitrack-pause.gpx", # {{{
1197 <<END,
1198 <?xml version="1.0" encoding="UTF-8"?>
1199 <gpsml>
1200 <track>
1201 <title>track1</title>
1202 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1203 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1204 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1205 <break/>
1206 <title>track2</title>
1207 <break/>
1208 <title>track3</title>
1209 <break/>
1210 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1211 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1212 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1213 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1214 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1215 </track>
1216 </gpsml>
1219 "Check --outside option (gpx to gpst)",
1222 # }}}
1223 # --outside option }}}
1224 diag("Testing --pos1 and --pos2 options..."); # {{{
1225 # --pos1 and --pos2 options }}}
1226 diag("Testing --require option..."); # {{{
1227 testcmd("../gpst -re multitrack.gpx", # {{{
1228 <<END,
1229 <?xml version="1.0" encoding="UTF-8"?>
1230 <gpsml>
1231 <track>
1232 <title>Track 1</title>
1233 <break/>
1234 <title>Track 2</title>
1235 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
1236 <break/>
1237 <title>Track 3</title>
1238 <break/>
1239 <title>Track 4</title>
1240 </track>
1241 </gpsml>
1244 "Require elevation from GPX data",
1247 # }}}
1248 testcmd("../gpst -re one_ele.dos.gpsml", # {{{
1249 <<END,
1250 <?xml version="1.0" encoding="UTF-8"?>
1251 <gpsml>
1252 <track>
1253 <title>Only one point has elevation</title>
1254 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1255 </track>
1256 </gpsml>
1259 "Require elevation from gpsml",
1262 # }}}
1263 testcmd("../gpst -re missing.gpsml", # {{{
1264 <<END,
1265 <?xml version="1.0" encoding="UTF-8"?>
1266 <gpsml>
1267 <track>
1268 <title>Missing various elements</title>
1269 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1270 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1271 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1272 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
1273 <tp> <ele>486</ele> </tp>
1274 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1275 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1276 </track>
1277 </gpsml>
1280 "Require elevation",
1283 # }}}
1284 testcmd("../gpst -rt missing.gpsml", # {{{
1285 <<END,
1286 <?xml version="1.0" encoding="UTF-8"?>
1287 <gpsml>
1288 <track>
1289 <title>Missing various elements</title>
1290 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
1291 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
1292 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1293 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1294 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1295 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1296 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1297 </track>
1298 </gpsml>
1301 "Require time",
1304 # }}}
1305 testcmd("../gpst -rp missing.gpsml", # {{{
1306 <<END,
1307 <?xml version="1.0" encoding="UTF-8"?>
1308 <gpsml>
1309 <track>
1310 <title>Missing various elements</title>
1311 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1312 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1313 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1314 </track>
1315 </gpsml>
1318 "Require position",
1321 # }}}
1322 testcmd("../gpst -ret missing.gpsml", # {{{
1323 <<END,
1324 <?xml version="1.0" encoding="UTF-8"?>
1325 <gpsml>
1326 <track>
1327 <title>Missing various elements</title>
1328 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1329 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1330 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1331 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1332 </track>
1333 </gpsml>
1336 "Require elevation and time",
1339 # }}}
1340 testcmd("../gpst -retp missing.gpsml", # {{{
1341 <<END,
1342 <?xml version="1.0" encoding="UTF-8"?>
1343 <gpsml>
1344 <track>
1345 <title>Missing various elements</title>
1346 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1347 </track>
1348 </gpsml>
1351 "Require elevation, time and position",
1354 # }}}
1355 testcmd("../gpst -rep missing.gpsml", # {{{
1356 <<END,
1357 <?xml version="1.0" encoding="UTF-8"?>
1358 <gpsml>
1359 <track>
1360 <title>Missing various elements</title>
1361 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1362 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1363 </track>
1364 </gpsml>
1367 "Require elevation and position",
1370 # }}}
1371 # --require option }}}
1372 diag("Testing --round option..."); # {{{
1373 testcmd("../gpst -R lat=4,lon=5,ele=1 pause.gpx", # {{{
1374 <<END,
1375 <?xml version="1.0" encoding="UTF-8"?>
1376 <gpsml>
1377 <track>
1378 <title>ACTIVE LOG164705</title>
1379 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.4255</lat> <lon>5.29953</lon> <ele>25.3</ele> </tp>
1380 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.4255</lat> <lon>5.29961</lon> <ele>24.9</ele> </tp>
1381 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.4253</lat> <lon>5.29969</lon> <ele>28</ele> </tp>
1382 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.4254</lat> <lon>5.29974</lon> <ele>31</ele> </tp>
1383 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.4253</lat> <lon>5.29996</lon> <ele>31</ele> </tp>
1384 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.4252</lat> <lon>5.29964</lon> <ele>30.5</ele> </tp>
1385 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.4252</lat> <lon>5.29969</lon> <ele>30.5</ele> </tp>
1386 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.4253</lat> <lon>5.29977</lon> <ele>31.9</ele> </tp>
1387 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.4255</lat> <lon>5.29942</lon> <ele>31.8</ele> </tp>
1388 </track>
1389 </gpsml>
1392 "--round works with lat, lon, ele from gpx",
1395 # }}}
1396 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgtab pause.gpx", # {{{
1397 <<END,
1398 2006-05-21T16:49:11Z\t(60.425,5.3)\t25.3\t\\N\t\\N\t\\N\t\\N
1399 2006-05-21T16:49:46Z\t(60.425,5.3)\t24.9\t\\N\t\\N\t\\N\t\\N
1400 2006-05-21T16:52:04Z\t(60.425,5.3)\t28\t\\N\t\\N\t\\N\t\\N
1401 2006-05-21T16:56:36Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N\t\\N
1402 2006-05-21T16:56:47Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N\t\\N
1403 2006-05-21T16:56:56Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N\t\\N
1404 2006-05-21T16:57:03Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N\t\\N
1405 2006-05-21T16:59:08Z\t(60.425,5.3)\t31.9\t\\N\t\\N\t\\N\t\\N
1406 2006-05-21T17:00:54Z\t(60.425,5.299)\t31.8\t\\N\t\\N\t\\N\t\\N
1409 "pgtab output from gpx works with --round lat, lon, ele",
1412 # }}}
1413 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwtab multitrack.gpx", # {{{
1414 <<END,
1415 (51.478,-0.001)\t0-Meridian\t\\N\t\\N\t\\N\t11-FEB-03 15:46\t11-FEB-03 15:46\t\\N\t\\N
1416 (51.532,-0.177)\tAbbey Road\t34.5\t\\N\t\\N\tDet hellige gangfeltet der Beatles valsa over.\t26-FEB-06 17:29:46\t\\N\t\\N
1417 (61.637,8.312)\tGaldhøpiggen med ', &, < og >. ☺\t2469\tmountain\t2006-05-08T18:27:59Z\tHer er det &, < og >. ☺\tSchwæra greie\thttp://www.example.org/\tWaypoint
1418 (60.397,5.351)\tHalfdan Griegs vei\t\\N\t\\N\t\\N\t04-AUG-02 19:42\t04-AUG-02 19:42\t\\N\t\\N
1419 (51.51,-0.13)\tLeicester Square\t\\N\t\\N\t\\N\t11-FEB-03 18:00\t11-FEB-03 18:00\t\\N\t\\N
1420 (60.969,9.285)\tLeira camping\t\\N\t\\N\t\\N\t03-OKT-02 21:58\t03-OKT-02 21:58\t\\N\t\\N
1423 "--round works with lat, lon, ele from gpx, pgwtab output",
1426 # }}}
1427 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwupd multitrack.gpx", # {{{
1428 <<END,
1429 BEGIN;
1430 UPDATE logg SET sted = clname(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1431 UPDATE logg SET dist = cldist(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1432 COMMIT;
1433 BEGIN;
1434 UPDATE logg SET sted = clname(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1435 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1436 COMMIT;
1437 BEGIN;
1438 UPDATE logg SET sted = clname(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1439 UPDATE logg SET dist = cldist(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1440 COMMIT;
1441 BEGIN;
1442 UPDATE logg SET sted = clname(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1443 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1444 COMMIT;
1445 BEGIN;
1446 UPDATE logg SET sted = clname(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1447 UPDATE logg SET dist = cldist(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1448 COMMIT;
1449 BEGIN;
1450 UPDATE logg SET sted = clname(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1451 UPDATE logg SET dist = cldist(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1452 COMMIT;
1455 "pgwupd output and --round works with lat, lon, ele from gpx",
1458 # }}}
1459 # --round option }}}
1460 diag("Testing --short-date option..."); # {{{
1461 # --short-date option }}}
1462 diag("Testing --save-to-file option..."); # {{{
1463 # --save-to-file option }}}
1464 diag("Testing --create-breaks option..."); # {{{
1465 testcmd("../gpst -t pause.gpx", # {{{
1466 <<END,
1467 <?xml version="1.0" encoding="UTF-8"?>
1468 <gpsml>
1469 <track>
1470 <title>ACTIVE LOG164705</title>
1471 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
1472 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
1473 <pause>0:00:02:18</pause>
1474 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1475 <pause>0:00:04:32</pause>
1476 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
1477 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
1478 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
1479 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
1480 <pause>0:00:02:05</pause>
1481 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
1482 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
1483 </track>
1484 </gpsml>
1487 "Output gpsml with <pause> elements from GPX files",
1490 # }}}
1491 testcmd("../gpst -t multitrack-pause.gpx", # {{{
1492 <<END,
1493 <?xml version="1.0" encoding="UTF-8"?>
1494 <gpsml>
1495 <track>
1496 <title>track1</title>
1497 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1498 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1499 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1500 <break/>
1501 <title>track2</title>
1502 <pause>0:23:59:58</pause>
1503 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1504 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1505 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1506 <pause>0:01:00:00</pause>
1507 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1508 <break/>
1509 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1510 <break/>
1511 <title>track3</title>
1512 <pause>1:01:00:03</pause>
1513 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1514 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1515 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1516 <break/>
1517 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1518 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1519 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1520 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1521 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1522 </track>
1523 </gpsml>
1526 "Insert <pause> between gpx tracks",
1529 # }}}
1530 testcmd("../gpst -t multitrack-pause.gpsml", # {{{
1531 <<END,
1532 <?xml version="1.0" encoding="UTF-8"?>
1533 <gpsml>
1534 <track>
1535 <title>track1</title>
1536 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1537 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1538 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1539 <break/>
1540 <title>track2</title>
1541 <pause>0:23:59:58</pause>
1542 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1543 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1544 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1545 <pause>0:01:00:00</pause>
1546 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1547 <break/>
1548 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1549 <break/>
1550 <title>track3</title>
1551 <pause>1:01:00:03</pause>
1552 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1553 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1554 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1555 <break/>
1556 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1557 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1558 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1559 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1560 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1561 </track>
1562 </gpsml>
1565 "Insert <pause> between gpsml titles",
1568 # }}}
1569 # --create-breaks option }}}
1570 diag("Testing -T (--time-shift) option...");
1571 testcmd("$CMD -T 3600 multitrack-pause.gpx", # {{{
1572 <<END,
1573 <?xml version="1.0" encoding="UTF-8"?>
1574 <gpsml>
1575 <track>
1576 <title>track1</title>
1577 <tp> <time>2006-01-01T01:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1578 <tp> <time>2006-01-01T01:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1579 <tp> <time>2006-01-01T01:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1580 <break/>
1581 <title>track2</title>
1582 <tp> <time>2006-01-02T01:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1583 <tp> <time>2006-01-02T01:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1584 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1585 <tp> <time>2006-01-02T02:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1586 <break/>
1587 <tp> <time>2006-01-02T02:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1588 <break/>
1589 <title>track3</title>
1590 <tp> <time>2006-01-03T03:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1591 <tp> <time>2006-01-03T03:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1592 <tp> <time>2006-01-03T03:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1593 <break/>
1594 <tp> <time>2006-01-03T03:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1595 <tp> <time>2006-01-03T03:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1596 <tp> <time>2006-01-03T03:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1597 <tp> <time>2006-01-03T03:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1598 <tp> <time>2006-01-03T03:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1599 </track>
1600 </gpsml>
1603 "Add one hour to GPX input, output gpsml",
1606 # }}}
1607 testcmd("$CMD -T -3600 multitrack-pause.gpx", # {{{
1608 <<END,
1609 <?xml version="1.0" encoding="UTF-8"?>
1610 <gpsml>
1611 <track>
1612 <title>track1</title>
1613 <tp> <time>2005-12-31T23:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1614 <tp> <time>2005-12-31T23:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1615 <tp> <time>2005-12-31T23:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1616 <break/>
1617 <title>track2</title>
1618 <tp> <time>2006-01-01T23:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1619 <tp> <time>2006-01-01T23:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1620 <tp> <time>2006-01-01T23:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1621 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1622 <break/>
1623 <tp> <time>2006-01-02T00:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1624 <break/>
1625 <title>track3</title>
1626 <tp> <time>2006-01-03T01:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1627 <tp> <time>2006-01-03T01:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1628 <tp> <time>2006-01-03T01:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1629 <break/>
1630 <tp> <time>2006-01-03T01:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1631 <tp> <time>2006-01-03T01:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1632 <tp> <time>2006-01-03T01:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1633 <tp> <time>2006-01-03T01:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1634 <tp> <time>2006-01-03T01:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1635 </track>
1636 </gpsml>
1639 "Subtract one hour from GPX input, output gpsml",
1642 # }}}
1643 testcmd("$CMD -T 1 -o gpx multitrack-pause.gpx", # {{{
1644 <<END,
1645 $gpx_header
1646 <trk>
1647 <trkseg>
1648 <trkpt lat="1.11" lon="1.12"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1649 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:02Z</time> </trkpt>
1650 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:03Z</time> </trkpt>
1651 </trkseg>
1652 <trkseg>
1653 <trkpt lat="2.11" lon="2.12"> <time>2006-01-02T00:00:01Z</time> </trkpt>
1654 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:05Z</time> </trkpt>
1655 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:17Z</time> </trkpt>
1656 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:17Z</time> </trkpt>
1657 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:18Z</time> </trkpt>
1658 </trkseg>
1659 <trkseg>
1660 </trkseg>
1661 <trkseg>
1662 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1663 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1664 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1665 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1666 </trkseg>
1667 <trkseg>
1668 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1669 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1670 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:27Z</time> </trkpt>
1671 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:28Z</time> </trkpt>
1672 </trkseg>
1673 </trk>
1674 </gpx>
1677 "Add one second to GPX input, output GPX",
1680 # }}}
1681 testcmd("$CMD --time-shift -1 -o gpx multitrack-pause.gpsml", # {{{
1682 <<END,
1683 $gpx_header
1684 <trk>
1685 <trkseg>
1686 <trkpt lat="1.11" lon="1.12"> <time>2005-12-31T23:59:59Z</time> </trkpt>
1687 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:00Z</time> </trkpt>
1688 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1689 </trkseg>
1690 <trkseg>
1691 <trkpt lat="2.11" lon="2.12"> <time>2006-01-01T23:59:59Z</time> </trkpt>
1692 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:03Z</time> </trkpt>
1693 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:15Z</time> </trkpt>
1694 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:15Z</time> </trkpt>
1695 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:16Z</time> </trkpt>
1696 </trkseg>
1697 <trkseg>
1698 </trkseg>
1699 <trkseg>
1700 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:19Z</time> </trkpt>
1701 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:20Z</time> </trkpt>
1702 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1703 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1704 </trkseg>
1705 <trkseg>
1706 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1707 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1708 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1709 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1710 </trkseg>
1711 </trk>
1712 </gpx>
1715 "Subtract one second from gpsml input, output GPX, use long option",
1718 # }}}
1719 testcmd("$CMD -T 0 -o pgtab multitrack-pause.gpx", # {{{
1720 <<END,
1721 2006-01-01T00:00:00Z\t(1.11,1.12)\t\\N\t\\N\t\\N\t\\N\t\\N
1722 2006-01-01T00:00:01Z\t(1.21,1.22)\t\\N\t\\N\t\\N\t\\N\t\\N
1723 2006-01-01T00:00:02Z\t(1.31,1.32)\t\\N\t\\N\t\\N\t\\N\t\\N
1724 2006-01-02T00:00:00Z\t(2.11,2.12)\t\\N\t\\N\t\\N\t\\N\t\\N
1725 2006-01-02T00:00:04Z\t(2.21,2.22)\t\\N\t\\N\t\\N\t\\N\t\\N
1726 2006-01-02T00:00:16Z\t(2.31,2.32)\t\\N\t\\N\t\\N\t\\N\t\\N
1727 2006-01-02T01:00:16Z\t(2.41,2.42)\t\\N\t\\N\t\\N\t\\N\t\\N
1728 2006-01-02T01:00:17Z\t(2.451,2.452)\t\\N\t\\N\t\\N\t\\N\t\\N
1729 2006-01-03T02:00:20Z\t(3.11,3.12)\t\\N\t\\N\t\\N\t\\N\t\\N
1730 2006-01-03T02:00:21Z\t(3.21,3.22)\t\\N\t\\N\t\\N\t\\N\t\\N
1731 2006-01-03T02:00:22Z\t(3.31,3.32)\t\\N\t\\N\t\\N\t\\N\t\\N
1732 2006-01-03T02:00:23Z\t(3.41,3.42)\t\\N\t\\N\t\\N\t\\N\t\\N
1733 2006-01-03T02:00:24Z\t(3.51,3.52)\t\\N\t\\N\t\\N\t\\N\t\\N
1734 2006-01-03T02:00:25Z\t(3.61,3.62)\t\\N\t\\N\t\\N\t\\N\t\\N
1735 2006-01-03T02:00:26Z\t(3.71,3.72)\t\\N\t\\N\t\\N\t\\N\t\\N
1736 2006-01-03T02:00:27Z\t(3.81,3.82)\t\\N\t\\N\t\\N\t\\N\t\\N
1739 "Read GPX, time-shift 0 seconds, output pgtab",
1742 # }}}
1743 diag("Testing -v (--verbose) option...");
1744 likecmd("$CMD -hv", # {{{
1745 '/\$Id: .*? \$.* Show this help\./s',
1746 '/^$/',
1747 "Option --version with -h returns Id string and help screen",
1750 # }}}
1751 diag("Testing --version option...");
1752 likecmd("$CMD --version", # {{{
1753 '/\$Id: .*? \$/',
1754 '/^$/',
1755 "Option --version returns Id string",
1758 # }}}
1759 # --version option }}}
1760 diag("Testing --strip-whitespace option..."); # {{{
1761 testcmd("../gpst -w -o gpx pause.gpx", # {{{
1762 <<END,
1763 $stripped_gpx_header
1764 <trk>
1765 <name>ACTIVE LOG164705</name>
1766 <trkseg>
1767 <trkpt lat="60.425494" lon="5.299534"><ele>25.260</ele><time>2006-05-21T16:49:11Z</time></trkpt>
1768 <trkpt lat="60.425464" lon="5.299610"><ele>24.931</ele><time>2006-05-21T16:49:46Z</time></trkpt>
1769 <trkpt lat="60.425314" lon="5.299694"><ele>27.975</ele><time>2006-05-21T16:52:04Z</time></trkpt>
1770 <trkpt lat="60.425384" lon="5.299741"><ele>31.017</ele><time>2006-05-21T16:56:36Z</time></trkpt>
1771 <trkpt lat="60.425339" lon="5.299958"><ele>30.980</ele><time>2006-05-21T16:56:47Z</time></trkpt>
1772 <trkpt lat="60.425238" lon="5.299640"><ele>30.538</ele><time>2006-05-21T16:56:56Z</time></trkpt>
1773 <trkpt lat="60.425246" lon="5.299686"><ele>30.515</ele><time>2006-05-21T16:57:03Z</time></trkpt>
1774 <trkpt lat="60.425345" lon="5.299773"><ele>31.936</ele><time>2006-05-21T16:59:08Z</time></trkpt>
1775 <trkpt lat="60.425457" lon="5.299419"><ele>31.794</ele><time>2006-05-21T17:00:54Z</time></trkpt>
1776 </trkseg>
1777 </trk>
1778 </gpx>
1781 "Strip whitespace from GPX output",
1784 # }}}
1785 testcmd("../gpst -o gpx -w comments.mayko", # {{{
1786 <<END,
1787 $stripped_gpx_header
1788 <trk>
1789 <trkseg>
1790 <trkpt lat="70.6800486" lon="23.6746151"><time>2002-12-22T21:42:24Z</time></trkpt>
1791 <trkpt lat="70.6799322" lon="23.6740038"><time>2002-12-22T21:42:32Z</time></trkpt>
1792 <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:42:54Z</time></trkpt>
1793 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:51Z</time><extensions><error>desc</error></extensions></trkpt> -->
1794 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:52Z</time><extensions><error>desc</error></extensions></trkpt> -->
1795 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:54Z</time><extensions><error>desc</error></extensions></trkpt> -->
1796 <trkpt lat="70.6800774" lon="23.6757566"><time>2002-12-22T21:44:45Z</time></trkpt>
1797 </trkseg>
1798 <trkseg>
1799 <trkpt lat="70.6801502" lon="23.6753442"><time>2002-12-22T21:44:52Z</time></trkpt>
1800 <trkpt lat="70.6801905" lon="23.6757542"><time>2002-12-22T21:45:04Z</time></trkpt>
1801 </trkseg>
1802 </trk>
1803 </gpx>
1806 "Output whitespace-stripped GPX from Mayko file with commented-out lines",
1809 # }}}
1810 testcmd("../gpst -w -o pgwupd multitrack.gpx", # {{{
1811 <<END,
1812 BEGIN;
1813 UPDATE logg SET sted = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1814 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1815 COMMIT;
1816 BEGIN;
1817 UPDATE logg SET sted = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1818 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1819 COMMIT;
1820 BEGIN;
1821 UPDATE logg SET sted = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1822 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1823 COMMIT;
1824 BEGIN;
1825 UPDATE logg SET sted = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1826 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1827 COMMIT;
1828 BEGIN;
1829 UPDATE logg SET sted = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1830 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1831 COMMIT;
1832 BEGIN;
1833 UPDATE logg SET sted = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1834 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1835 COMMIT;
1838 "Strip whitespace from pgwupd output",
1841 # }}}
1842 # --strip-whitespace option }}}
1843 diag("Testing --double-y-scale option..."); # {{{
1844 testcmd("../gpst -y -o clean pause.gpx", # {{{
1845 <<END,
1846 5.299534\t120.850988\t25.260
1847 5.299610\t120.850928\t24.931
1848 5.299694\t120.850628\t27.975
1849 5.299741\t120.850768\t31.017
1850 5.299958\t120.850678\t30.980
1851 5.299640\t120.850476\t30.538
1852 5.299686\t120.850492\t30.515
1853 5.299773\t120.85069\t31.936
1854 5.299419\t120.850914\t31.794
1857 "Double y scale, clean output from gpx format",
1860 # }}}
1861 testcmd("../gpst -y -o clean log.dos.mayko", # {{{
1862 <<END,
1863 8.1225077\t116.3636316\t
1864 8.1253200\t116.3637424\t
1865 8.1266031\t116.3632694\t
1866 8.1284612\t116.3624198\t
1867 8.1293950\t116.362063\t
1868 8.1307400\t116.3619242\t
1871 "Double y scale, clean output from mayko format",
1874 # }}}
1875 # --double-y-scale option }}}
1876 diag("Testing --debug option..."); # {{{
1877 # --debug option }}}
1878 diag("Strip error from Mayko format..."); # {{{
1880 testcmd("../gpst -o csv date_error.mayko", # {{{
1881 <<END,
1882 2003-06-13T09:12:36Z\t5.5794667\t60.4280897\t\t
1883 2003-06-13T09:12:38Z\t5.5802255\t60.4281867\t\t
1884 2003-06-13T09:12:41Z\t5.5813636\t60.4283320\t\t
1885 2003-06-13T09:12:42Z\t5.5817430\t60.4283806\t\t
1888 "Strip error from mayko format in csv output",
1891 # }}}
1892 testcmd("../gpst -o clean date_error.mayko", # {{{
1893 <<END,
1894 5.5794667\t60.4280897\t
1895 5.5802255\t60.4281867\t
1896 5.5813636\t60.4283320\t
1897 5.5817430\t60.4283806\t
1900 "Strip error from mayko format in clean output",
1903 # }}}
1904 testcmd("../gpst -o gpsml date_error.mayko", # {{{
1905 <<END,
1906 <?xml version="1.0" encoding="UTF-8"?>
1907 <gpsml>
1908 <track>
1909 <tp> <time>2003-06-13T09:12:36Z</time> <lat>60.4280897</lat> <lon>5.5794667</lon> </tp>
1910 <tp> <time>2003-06-13T09:12:38Z</time> <lat>60.4281867</lat> <lon>5.5802255</lon> </tp>
1911 <etp err="error"> <time>2037-06-25T17:19:22Z</time> <lat>103.4034054</lat> <lon>129.7271053</lon> </etp>
1912 <tp> <time>2003-06-13T09:12:41Z</time> <lat>60.428332</lat> <lon>5.5813636</lon> </tp>
1913 <tp> <time>2003-06-13T09:12:42Z</time> <lat>60.4283806</lat> <lon>5.581743</lon> </tp>
1914 </track>
1915 </gpsml>
1918 "Strip error from mayko format in gpsml output",
1921 # }}}
1922 testcmd("../gpst -o gpx date_error.mayko", # {{{
1923 <<END,
1924 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1925 <gpx
1926 version="1.1"
1927 creator="gpst - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/"
1928 xmlns="http://www.topografix.com/GPX/1/1"
1929 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1930 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
1932 <trk>
1933 <trkseg>
1934 <trkpt lat="60.4280897" lon="5.5794667"> <time>2003-06-13T09:12:36Z</time> </trkpt>
1935 <trkpt lat="60.4281867" lon="5.5802255"> <time>2003-06-13T09:12:38Z</time> </trkpt>
1936 <!-- <trkpt lat="103.4034054" lon="129.7271053"> <time>2037-06-25T17:19:22Z</time> <extensions> <error>error</error> </extensions> </trkpt> -->
1937 <trkpt lat="60.4283320" lon="5.5813636"> <time>2003-06-13T09:12:41Z</time> </trkpt>
1938 <trkpt lat="60.4283806" lon="5.5817430"> <time>2003-06-13T09:12:42Z</time> </trkpt>
1939 </trkseg>
1940 </trk>
1941 </gpx>
1944 "Strip error from mayko format in gpx output",
1947 # }}}
1948 testcmd("../gpst -o gpstrans date_error.mayko", # {{{
1949 <<END,
1950 Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84
1951 T\t06/13/2003 09:12:36\t60\xB025'41.1"\t5\xB034'46.1"
1952 T\t06/13/2003 09:12:38\t60\xB025'41.5"\t5\xB034'48.8"
1953 T\t06/13/2003 09:12:41\t60\xB025'42.0"\t5\xB034'52.9"
1954 T\t06/13/2003 09:12:42\t60\xB025'42.2"\t5\xB034'54.3"
1957 "Strip error from mayko format in gpstrans output",
1960 # }}}
1961 testcmd("../gpst -o pgtab date_error.mayko", # {{{
1962 <<END,
1963 2003-06-13T09:12:36Z\t(60.4280897,5.5794667)\t\\N\t\\N\t\\N\t\\N\t\\N
1964 2003-06-13T09:12:38Z\t(60.4281867,5.5802255)\t\\N\t\\N\t\\N\t\\N\t\\N
1965 2003-06-13T09:12:41Z\t(60.4283320,5.5813636)\t\\N\t\\N\t\\N\t\\N\t\\N
1966 2003-06-13T09:12:42Z\t(60.4283806,5.5817430)\t\\N\t\\N\t\\N\t\\N\t\\N
1969 "Strip error from mayko format in pgtab output",
1972 # }}}
1973 testcmd("../gpst -o poscount date_error.mayko", # {{{
1974 <<END,
1975 5.5802255\t60.4281867\t1
1976 5.5817430\t60.4283806\t1
1977 5.5813636\t60.4283320\t1
1978 5.5794667\t60.4280897\t1
1981 "Strip error from mayko format in poscount output",
1984 # }}}
1985 testcmd("../gpst -o xgraph date_error.mayko", # {{{
1986 <<END,
1987 5.5794667 60.4280897
1988 5.5802255 60.4281867
1989 5.5813636 60.4283320
1990 5.5817430 60.4283806
1993 "Strip error from mayko format in xgraph output",
1996 # }}}
1997 testcmd("../gpst -o ygraph date_error.mayko", # {{{
1998 <<END,
1999 "Time = 0.0
2000 5.5794667 60.4280897
2002 "Time = 2.0
2003 5.5802255 60.4281867
2005 "Time = 5.0
2006 5.5813636 60.4283320
2008 "Time = 6.0
2009 5.5817430 60.4283806
2013 "Strip error from mayko format in ygraph output",
2016 # }}}
2018 # Strip error from Mayko format }}}
2020 todo_section:
2023 if ($Opt{'all'} || $Opt{'todo'}) {
2024 diag("Running TODO tests..."); # {{{
2026 TODO: {
2027 local $TODO = "Remove extra \\n in the beginning";
2028 testcmd("../gpst -o csv multitrack.gpx", # {{{
2029 <<END,
2030 2003-02-11T23:35:39Z\t-0.1448824\t51.4968266\t\t
2031 2003-02-11T23:35:49Z\t-0.1449938\t51.4968227\t\t
2032 2003-02-11T23:36:14Z\t-0.1453202\t51.4969040\t\t
2033 \t\t\t\t
2034 2003-02-11T23:36:16Z\t-0.1453398\t51.4969214\t\t
2035 2003-02-11T23:36:31Z\t-0.1455514\t51.4969816\t\t
2036 2003-02-11T23:36:43Z\t-0.1457489\t51.4970224\t1000\t
2037 2003-02-11T23:36:50Z\t-0.1457804\t51.4970452\t\t
2038 \t\t\t\t
2039 2003-02-11T23:37:05Z\t-0.1458608\t51.4970680\t\t
2040 2003-02-11T23:37:22Z\t-0.1460047\t51.4971658\t\t
2041 2003-02-11T23:37:36Z\t-0.1461614\t51.4972469\t\t
2042 \t\t\t\t
2043 2003-02-11T23:37:43Z\t-0.1462394\t51.4972731\t\t
2044 2003-02-11T23:38:04Z\t-0.1463232\t51.4973437\t\t
2045 2003-02-11T23:38:28Z\t-0.1462949\t51.4973337\t\t
2046 2003-02-11T23:38:34Z\t-0.1462825\t51.4973218\t\t
2047 2003-02-11T23:38:35Z\t-0.1462732\t51.4973145\t\t
2050 "Output csv format from multitrack.gpx",
2053 # }}}
2054 testcmd("../gpst -o csv pause.gpx", # {{{
2055 <<END,
2056 2006-05-21T16:49:11Z\t5.299534\t60.425494\t25.260\t
2057 2006-05-21T16:49:46Z\t5.299610\t60.425464\t24.931\t
2058 2006-05-21T16:52:04Z\t5.299694\t60.425314\t27.975\t
2059 2006-05-21T16:56:36Z\t5.299741\t60.425384\t31.017\t
2060 2006-05-21T16:56:47Z\t5.299958\t60.425339\t30.980\t
2061 2006-05-21T16:56:56Z\t5.299640\t60.425238\t30.538\t
2062 2006-05-21T16:57:03Z\t5.299686\t60.425246\t30.515\t
2063 2006-05-21T16:59:08Z\t5.299773\t60.425345\t31.936\t
2064 2006-05-21T17:00:54Z\t5.299419\t60.425457\t31.794\t
2067 "Output csv format from pause.gpx",
2070 # }}}
2071 testcmd("../gpst -e -o csv pause.gpx", # {{{
2072 <<END,
2073 1148230151\t5.299534\t60.425494\t25.260\t
2074 1148230186\t5.299610\t60.425464\t24.931\t
2075 1148230324\t5.299694\t60.425314\t27.975\t
2076 1148230596\t5.299741\t60.425384\t31.017\t
2077 1148230607\t5.299958\t60.425339\t30.980\t
2078 1148230616\t5.299640\t60.425238\t30.538\t
2079 1148230623\t5.299686\t60.425246\t30.515\t
2080 1148230748\t5.299773\t60.425345\t31.936\t
2081 1148230854\t5.299419\t60.425457\t31.794\t
2084 "csv format with epoch seconds from gpx",
2087 # }}}
2088 $TODO = "Tweak output";
2089 testcmd("../gpst -o gpx multitrack-pause.gpsml", # {{{
2090 file_data("multitrack-pause.gpx"),
2092 "Should be equal to multitrack-pause.gpx",
2095 # }}}
2096 $TODO = 'Fix it.';
2097 # list_nearest_waypoints() {{{
2099 like(list_nearest_waypoints(60.42541, 5.29959, 3),
2100 qr/^\(.*,.*,.*\)$/,
2101 "list_nearest_waypoints()"
2104 # }}}
2106 # TODO tests }}}
2109 diag("Testing finished.");
2111 sub testcmd {
2112 # {{{
2113 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
2114 my $stderr_cmd = "";
2115 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2116 my $Txt = join("",
2117 "\"$Cmd\"",
2118 defined($Desc)
2119 ? " - $Desc"
2120 : ""
2122 my $TMP_STDERR = "gpst-stderr.tmp";
2124 if (defined($Exp_stderr) && !length($deb_str)) {
2125 $stderr_cmd = " 2>$TMP_STDERR";
2127 is(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt);
2128 if (defined($Exp_stderr)) {
2129 if (!length($deb_str)) {
2130 is(file_data($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
2131 unlink($TMP_STDERR);
2133 } else {
2134 diag("Warning: stderr not defined for '$Txt'");
2136 # }}}
2139 sub likecmd {
2140 # {{{
2141 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
2142 my $stderr_cmd = "";
2143 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2144 my $Txt = join("",
2145 "\"$Cmd\"",
2146 defined($Desc)
2147 ? " - $Desc"
2148 : ""
2150 my $TMP_STDERR = "gpst-stderr.tmp";
2152 if (defined($Exp_stderr) && !length($deb_str)) {
2153 $stderr_cmd = " 2>$TMP_STDERR";
2155 like(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
2156 if (defined($Exp_stderr)) {
2157 if (!length($deb_str)) {
2158 like(file_data($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
2159 unlink($TMP_STDERR);
2161 } else {
2162 diag("Warning: stderr not defined for '$Txt'");
2164 # }}}
2167 sub file_data {
2168 # Return file content as a string {{{
2169 my $File = shift;
2170 my $Txt;
2171 if (open(FP, "<", $File)) {
2172 $Txt = join("", <FP>);
2173 close(FP);
2174 return($Txt);
2175 } else {
2176 return undef;
2178 # }}}
2181 sub print_version {
2182 # Print program version {{{
2183 for (@main::version_array) {
2184 print("$_\n");
2186 # }}}
2187 } # print_version()
2189 sub usage {
2190 # Send the help message to stdout {{{
2191 my $Retval = shift;
2193 if ($Opt{'verbose'}) {
2194 print("\n");
2195 print_version();
2197 print(<<END);
2199 Usage: $progname [options] [file [files [...]]]
2201 Contains tests for the gpst(1) program.
2203 Options:
2205 -a, --all
2206 Run all tests, also TODOs.
2207 -h, --help
2208 Show this help.
2209 -t, --todo
2210 Run only the TODO tests.
2211 -v, --verbose
2212 Increase level of verbosity. Can be repeated.
2213 --version
2214 Print version information.
2215 --debug
2216 Print debugging messages.
2219 exit($Retval);
2220 # }}}
2221 } # usage()
2223 sub msg {
2224 # Print a status message to stderr based on verbosity level {{{
2225 my ($verbose_level, $Txt) = @_;
2227 if ($Opt{'verbose'} >= $verbose_level) {
2228 print(STDERR "$progname: $Txt\n");
2230 # }}}
2231 } # msg()
2233 __END__
2235 # Plain Old Documentation (POD) {{{
2237 =pod
2239 =head1 NAME
2241 run-tests.pl
2243 =head1 REVISION
2245 $Id$
2247 =head1 SYNOPSIS
2249 run-tests.pl [options] [file [files [...]]]
2251 =head1 DESCRIPTION
2253 Contains tests for the gpst(1) program.
2255 =head1 OPTIONS
2257 =over 4
2259 =item B<-a>, B<--all>
2261 Run all tests, also TODOs.
2263 =item B<-h>, B<--help>
2265 Print a brief help summary.
2267 =item B<-t>, B<--todo>
2269 Run only the TODO tests.
2271 =item B<-v>, B<--verbose>
2273 Increase level of verbosity. Can be repeated.
2275 =item B<--version>
2277 Print version information.
2279 =item B<--debug>
2281 Print debugging messages.
2283 =back
2285 =head1 AUTHOR
2287 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
2289 =head1 COPYRIGHT
2291 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
2292 This is free software; see the file F<COPYING> for legalese stuff.
2294 =head1 LICENCE
2296 This program is free software; you can redistribute it and/or modify it
2297 under the terms of the GNU General Public License as published by the
2298 Free Software Foundation; either version 2 of the License, or (at your
2299 option) any later version.
2301 This program is distributed in the hope that it will be useful, but
2302 WITHOUT ANY WARRANTY; without even the implied warranty of
2303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2304 See the GNU General Public License for more details.
2306 You should have received a copy of the GNU General Public License along
2307 with this program; if not, write to the Free Software Foundation, Inc.,
2308 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2310 =head1 SEE ALSO
2312 gpst(1)
2314 =cut
2316 # }}}
2318 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
2319 # End of file $Id$