Add validation of GPX output to run-tests.pl
[gpstools.git] / tests / run-tests.pl
blob5a0856e109b6b7f71d9abde2d81158c9e52c3793
1 #!/usr/bin/perl -w
3 #=======================================================================
4 # tests/run-tests.pl
5 # File ID: b9e66fa2-f924-11dd-b57f-0001805bf4b1
6 # Test suite for gpst(1).
8 # Character set: UTF-8
9 # ©opyleft 2006– Ø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 #=======================================================================
14 BEGIN {
15 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
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/;
45 our $VERSION = "0.00";
47 Getopt::Long::Configure("bundling");
48 GetOptions(
50 "all|a" => \$Opt{'all'},
51 "debug" => \$Opt{'debug'},
52 "help|h" => \$Opt{'help'},
53 "todo|t" => \$Opt{'todo'},
54 "verbose|v+" => \$Opt{'verbose'},
55 "version" => \$Opt{'version'},
57 ) || die("$progname: Option error. Use -h for help.\n");
59 our %Cmd = (
60 'gpsbabel' => 'gpsbabel',
63 $Opt{'debug'} && ($Debug = 1);
64 $Opt{'help'} && usage(0);
65 if ($Opt{'version'}) {
66 print_version();
67 exit(0);
70 diag(sprintf("========== Executing %s v%s ==========",
71 $progname,
72 $VERSION));
74 chomp(my $gpx_header = <<END);
75 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
76 <gpx
77 version="1.1"
78 creator="gpst - http://sunny256.github.com/gpstools/"
79 xmlns="http://www.topografix.com/GPX/1/1"
80 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
81 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
83 END
84 my $stripped_gpx_header = $gpx_header;
85 $stripped_gpx_header =~ s/^\s*(.*)$/$1/mg;
87 if ($Opt{'todo'} && !$Opt{'all'}) {
88 goto todo_section;
91 =pod
93 testcmd("$CMD command", # {{{
94 <<END,
95 [expected stdin]
96 END
97 "",
98 "description",
99 is_gpx,
102 # }}}
104 =cut
106 diag("Testing conversion routines...");
108 # txt_to_xml() and xml_to_txt() {{{
110 is(txt_to_xml("abc"),
111 "abc",
112 "txt_to_xml(\"abc\")");
113 is(txt_to_xml("<&>"),
114 "&lt;&amp;&gt;",
115 "txt_to_xml(\"<&>\")");
116 is(txt_to_xml("first line\nsecond <\rthird\r\n<&>"),
117 "first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;",
118 "txt_to_xml() with multiline string");
120 is(xml_to_txt("abc"),
121 "abc",
122 "xml_to_txt(\"abc\")");
123 is(xml_to_txt("&lt;&amp;&gt;"),
124 "<&>",
125 "xml_to_txt(\"&lt;&amp;&gt;\")");
126 is(xml_to_txt("first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;"),
127 "first line\nsecond <\rthird\r\n<&>",
128 "xml_to_txt() with multiline string");
130 # txt_to_xml() and xml_to_txt() }}}
131 # postgresql_copy_safe() {{{
133 is(postgresql_copy_safe(""),
135 "postgresql_copy_safe() with empty string");
137 is(postgresql_copy_safe("abcæøåÆØÅ"),
138 "abcæøåÆØÅ",
139 "postgresql_copy_safe(\"abcæøåÆØÅ\")");
141 is(postgresql_copy_safe("abc\t'\r\n"),
142 "abc\\t'\\r\\n",
143 "postgresql_copy_safe(\"abc\\t'\\r\\n\")");
145 is(postgresql_copy_safe("¤%/&gurgle\t325\\wer\ndfv'\r!\"#\n%\twe\r\x00sdf\xFFsadc\n\t\x00sdc\n"),
146 "¤%/&gurgle\\t325\\\\wer\\ndfv'\\r!\"#\\n%\\twe\\r\x00sdf\xFFsadc\\n\\t\x00sdc\\n",
147 "postgresql_copy_safe() with multiline, nulls and stuff");
149 # postgresql_copy_safe() }}}
151 diag("Testing date routines...");
153 # sec_to_string() {{{
155 is(sec_to_string(1148220825),
156 "2006-05-21 14:13:45",
157 "sec_to_string() without separator");
158 is(sec_to_string(1148220825, "T"),
159 "2006-05-21T14:13:45",
160 "sec_to_string() with separator");
161 is(sec_to_string(-5000),
162 undef,
163 "sec_to_string(-5000) — negative numbers unsupported atm");
164 is(sec_to_string(""),
165 undef,
166 "sec_to_string(\"\")");
167 is(sec_to_string("pH()rtY tW0"),
168 undef,
169 "sec_to_string() with invalid string");
170 is(sec_to_string("00000000000000000000001148220825"),
171 "2006-05-21 14:13:45",
172 "sec_to_string() with a bunch of leading zeros");
173 is(sec_to_string("1148220825.93"),
174 "2006-05-21 14:13:45.93",
175 "sec_to_string() with decimals");
176 is(sec_to_string("000000000000000000000000000001148220825.7312"),
177 "2006-05-21 14:13:45.7312",
178 "sec_to_string() with decimals and prefixing zeros");
179 is(sec_to_string("1148220825.93000"),
180 "2006-05-21 14:13:45.93",
181 "sec_to_string() with decimals and extra trailing zeros");
182 is(sec_to_string(".863"),
183 "1970-01-01 00:00:00.863",
184 "sec_to_string() with missing zero before decimal point");
186 # sec_to_string() }}}
187 # sec_to_readable() {{{
189 is(sec_to_readable(0),
190 "0:00:00:00",
191 "sec_to_readable(0)");
192 is(sec_to_readable("pH()rtY tW0"),
193 undef,
194 "sec_to_readable() with invalid string");
195 is(sec_to_readable(86400),
196 "1:00:00:00",
197 "sec_to_readable(86400)");
198 is(sec_to_readable(86400*1000),
199 "1000:00:00:00",
200 "sec_to_readable(86400*1000)");
201 is(sec_to_readable(86400+7200+180+4),
202 "1:02:03:04",
203 "sec_to_readable(86400+7200+180+4)");
204 is(sec_to_readable("3.14"),
205 "0:00:00:03.14",
206 "sec_to_readable(\"3.14\")");
207 is(sec_to_readable("-124"),
208 undef,
209 "sec_to_readable() rejects negative numbers");
210 is(sec_to_readable("-2.34"),
211 undef,
212 "sec_to_readable() rejects negative decimal");
213 is(sec_to_readable(".87"),
214 "0:00:00:00.87",
215 "sec_to_readable(), missing zero before decimal point");
216 is(sec_to_readable(""),
217 "0:00:00:00",
218 "sec_to_readable() with empty string");
220 # sec_to_readable() }}}
222 diag("Testing geo routines...");
224 # ddd_to_dms() {{{
226 is(ddd_to_dms("12.34567"),
227 "12\xB020'44.4\"",
228 "ddd_to_dms(\"12.34567\")");
230 is(ddd_to_dms("0"),
231 "0\xB000'00.0\"",
232 "ddd_to_dms(\"0\")");
234 is(ddd_to_dms(""),
235 "0\xB000'00.0\"",
236 "ddd_to_dms(\"\")");
238 is(ddd_to_dms("pH()rtY tW0"),
239 undef,
240 "ddd_to_dms(\"pH()rtY tW0\")");
242 is(ddd_to_dms("-12.34567"),
243 "-12\xB020'44.4\"",
244 "ddd_to_dms(\"-12.34567\")");
246 is(ddd_to_dms("0.34567"),
247 "0\xB020'44.4\"",
248 "ddd_to_dms(\"0.34567\")");
250 is(ddd_to_dms(".34567"),
251 "0\xB020'44.4\"",
252 "ddd_to_dms(\".34567\")");
254 is(ddd_to_dms("-.34567"),
255 "-0\xB020'44.4\"",
256 "ddd_to_dms(\"-.34567\")");
258 is(ddd_to_dms("-0.34567"),
259 "-0\xB020'44.4\"",
260 "ddd_to_dms(\"-0.34567\")");
262 is(ddd_to_dms("180"),
263 "180\xB000'00.0\"",
264 "ddd_to_dms(\"180\")");
266 is(ddd_to_dms("-180"),
267 "-180\xB000'00.0\"",
268 "ddd_to_dms(\"-180\")");
270 is(ddd_to_dms("-1"),
271 "-1\xB000'00.0\"",
272 "ddd_to_dms(\"-1\")");
274 is(ddd_to_dms("2-3"),
275 undef,
276 "ddd_to_dms(\"2-3\")");
278 # ddd_to_dms() }}}
280 diag("Testing trackpoint()..."); # {{{
282 my %Dat = ();
284 is(trackpoint(%Dat),
285 undef,
286 "trackpoint() receives empty hash");
288 my %Bck = (
289 # {{{
290 'format' => 'gpsml',
291 'year' => '2003',
292 'month' => '06',
293 'day' => '13',
294 'hour' => '14',
295 'min' => '36',
296 'sec' => '10',
297 'lat' => '59.5214',
298 'lon' => '7.392133',
299 'ele' => '762',
300 'error' => "",
301 'what' => 'tp',
302 # }}}
305 # trackpoint() (gpsml) {{{
306 %Dat = %Bck;
308 trackpoint(%Dat),
309 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
310 "trackpoint() (gpsml)"
313 # trackpoint() (gpsml) }}}
314 # trackpoint() (gpx) {{{
315 %Dat = %Bck;
316 $Dat{'format'} = "gpx";
318 trackpoint(%Dat),
319 qq{ <trkpt lat="59.5214" lon="7.392133"> <ele>762</ele> <time>2003-06-13T14:36:10Z</time> </trkpt>\n},
320 "trackpoint() (gpx)"
323 # trackpoint() (gpx) }}}
325 # trackpoint(): Various loop tests {{{
327 for my $Elem (qw{format lat lon what}) {
328 my %Dat = %Bck;
330 $Dat{"$Elem"} = '2d';
331 is(trackpoint(%Dat),
332 undef,
333 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") returns undef"
338 for my $Elem (qw{year month day hour min sec}) {
339 # Date tests {{{
340 my %Dat;
342 %Dat = %Bck;
343 $Dat{"$Elem"} = '';
344 is(trackpoint(%Dat),
345 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
346 "trackpoint(): {'$Elem'} with empty value skips time"
349 %Dat = %Bck;
350 $Dat{"$Elem"} = '2d';
351 is(trackpoint(%Dat),
352 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
353 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") skips time"
356 %Dat = %Bck;
357 $Dat{$Elem} = "00000$Dat{$Elem}";
358 is(trackpoint(%Dat),
359 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
360 "trackpoint(): Strip prefixing zeros from {'$Elem'}"
363 %Dat = %Bck;
364 $Dat{"$Elem"} = 0-$Dat{$Elem};
365 is(trackpoint(%Dat),
366 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
367 "trackpoint(): {'$Elem'} is negative, skip time"
370 if ($Elem ne "sec") {
371 %Dat = %Bck;
372 $Dat{"$Elem"} = "$Dat{$Elem}.00";
373 is(trackpoint(%Dat),
374 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
375 "trackpoint(): Decimals in {'$Elem'}, skip time"
379 # Date tests }}}
382 %Dat = %Bck;
383 $Dat{'sec'} = "$Dat{'sec'}.00";
384 is(trackpoint(%Dat),
385 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
386 "trackpoint(): Remove trailing zeros in {'sec'} decimals"
389 for my $Elem (qw{format what error}) {
390 my %Dat = %Bck;
391 $Dat{$Elem} = undef;
392 is(trackpoint(%Dat),
393 undef,
394 "trackpoint(): Missing {'$Elem'}, return undef"
398 # Various loop tests }}}
400 # trackpoint() }}}
402 diag("Testing output from ../gpst");
404 diag("Read empty input (/dev/null)..."); # {{{
405 testcmd("../gpst </dev/null", # {{{
406 <<END,
407 <?xml version="1.0" encoding="UTF-8"?>
408 <gpsml>
409 <track>
410 </track>
411 </gpsml>
414 "Read from /dev/null",
418 # }}}
419 testcmd("../gpst -o gpx </dev/null", # {{{
420 <<END,
421 $gpx_header
422 <trk>
423 <trkseg>
424 </trkseg>
425 </trk>
426 </gpx>
429 "Output gpx from /dev/null",
433 # }}}
434 # empty input }}}
435 diag("Read empty files..."); # {{{
436 testcmd("echo '<tp> </tp>' | ../gpst", # {{{
437 <<END,
438 <?xml version="1.0" encoding="UTF-8"?>
439 <gpsml>
440 <track>
441 </track>
442 </gpsml>
445 "Don’t print empty trackpoints",
449 # }}}
450 # Read empty files }}}
451 diag("Testing --chronology option..."); # {{{
452 testcmd("../gpst --chronology chronology-error.gpsml", # {{{
453 <<END,
454 <?xml version="1.0" encoding="UTF-8"?>
455 <gpsml>
456 <track>
457 <title>Chronology errors</title>
458 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
459 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
460 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
461 <break/>
462 <tp> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </tp>
463 <break/>
464 <pause>0:00:37:54</pause>
465 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
466 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
467 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
468 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
469 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
470 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
471 </track>
472 </gpsml>
474 "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" .
475 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
476 "Check for chronology errors and duplicated times",
480 # }}}
481 # --chronology option }}}
482 diag("Testing --skip-dups option..."); # {{{
483 testcmd("../gpst -d no_signal.mayko", # {{{
484 <<END,
485 <?xml version="1.0" encoding="UTF-8"?>
486 <gpsml>
487 <track>
488 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
489 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
490 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
491 <etp err="dup"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
492 <etp err="dup"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
493 <etp err="dup"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
494 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
495 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
496 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
497 </track>
498 </gpsml>
501 "Remove duplicated positions from gpsml",
505 # }}}
506 testcmd("../gpst -d -o csv no_signal.mayko", # {{{
507 <<END,
508 2002-12-22T21:42:24Z\t23.6746151\t70.6800486\t\t
509 2002-12-22T21:42:32Z\t23.6740038\t70.6799322\t\t
510 2002-12-22T21:42:54Z\t23.6723991\t70.6796266\t\t
511 2002-12-22T21:44:45Z\t23.6757566\t70.6800774\t\t
512 2002-12-22T21:44:52Z\t23.6753442\t70.6801502\t\t
513 2002-12-22T21:45:04Z\t23.6757542\t70.6801905\t\t
516 "Remove duplicated positions from csv output format",
520 # }}}
521 testcmd("../gpst -d -o clean no_signal.mayko", # {{{
522 <<END,
523 23.6746151\t70.6800486\t
524 23.6740038\t70.6799322\t
525 23.6723991\t70.6796266\t
526 23.6757566\t70.6800774\t
527 23.6753442\t70.6801502\t
528 23.6757542\t70.6801905\t
531 "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
539 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\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
541 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\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
543 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N
546 "Remove duplicated positions from pgtab output format",
550 # }}}
551 # --skip-dups option }}}
552 diag("Testing --epoch option..."); # {{{
553 testcmd("../gpst -e pause.gpx", # {{{
554 <<END,
555 <?xml version="1.0" encoding="UTF-8"?>
556 <gpsml>
557 <track>
558 <title>ACTIVE LOG164705</title>
559 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
560 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
561 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
562 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
563 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
564 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
565 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
566 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
567 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
568 </track>
569 </gpsml>
572 "--epoch is ignored in gpsml output",
576 # }}}
577 testcmd("../gpst -e -o gpx pause-noname.gpx", # {{{
578 <<END,
579 $gpx_header
580 <trk>
581 <trkseg>
582 <trkpt lat="60.425494" lon="5.299534"> <ele>25.260</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
583 <trkpt lat="60.425464" lon="5.299610"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
584 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
585 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
586 <trkpt lat="60.425339" lon="5.299958"> <ele>30.980</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
587 <trkpt lat="60.425238" lon="5.299640"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
588 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
589 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
590 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
591 </trkseg>
592 </trk>
593 </gpx>
596 "--epoch is ignored in gpx output",
600 # }}}
601 # --epoch option }}}
602 diag("Testing --fix option..."); # {{{
603 testcmd("../gpst --fix --chronology chronology-error.gpsml", # {{{
604 <<END,
605 <?xml version="1.0" encoding="UTF-8"?>
606 <gpsml>
607 <track>
608 <title>Chronology errors</title>
609 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
610 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
611 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
612 <break/>
613 <etp err="chrono"> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </etp>
614 <break/>
615 <pause>0:00:37:54</pause>
616 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
617 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
618 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
619 <etp err="duptime"> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </etp>
620 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
621 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
622 </track>
623 </gpsml>
625 "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" .
626 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
627 "Remove bad timestamps",
631 # }}}
632 # --fix option }}}
633 diag("Testing --from-date option..."); # {{{
634 # --from-date option }}}
635 diag("Testing -h (--help) option...");
636 likecmd("$CMD -h", # {{{
637 '/ Show this help\./',
638 '/^$/',
639 "Option -h prints help screen",
642 # }}}
643 # --help option }}}
644 diag("Testing --inside option..."); # {{{
645 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx", # {{{
646 <<END,
647 <?xml version="1.0" encoding="UTF-8"?>
648 <gpsml>
649 <track>
650 <title>track1</title>
651 <break/>
652 <title>track2</title>
653 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
654 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
655 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
656 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
657 <break/>
658 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
659 <break/>
660 <title>track3</title>
661 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
662 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
663 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
664 </track>
665 </gpsml>
668 "Check --inside option (gpx to gpst)",
671 # }}}
673 # --inside option }}}
674 diag("Testing --undefined option..."); # {{{
675 # --undefined option }}}
676 diag("Testing --near option..."); # {{{
677 # --near option }}}
678 diag("Testing --output option..."); # {{{
679 # gpsml (Default)
680 testcmd("../gpst log.mcsv", # {{{
681 <<END,
682 <?xml version="1.0" encoding="UTF-8"?>
683 <gpsml>
684 <track>
685 <break/>
686 <title>ACTIVE LOG 125</title>
687 <tp> <time>2006-03-04T11:12:30Z</time> <lat>54.96883</lat> <lon>-1.62439</lon> <ele>77</ele> </tp>
688 <tp> <time>2006-03-04T11:12:47Z</time> <lat>54.96878</lat> <lon>-1.62413</lon> <ele>77</ele> </tp>
689 <tp> <time>2006-03-04T11:12:55Z</time> <lat>54.96913</lat> <lon>-1.62616</lon> <ele>77</ele> </tp>
690 <tp> <time>2006-03-04T11:13:04Z</time> <lat>54.96934</lat> <lon>-1.62624</lon> <ele>77.5</ele> </tp>
691 <tp> <time>2006-03-04T11:13:33Z</time> <lat>54.96934</lat> <lon>-1.62596</lon> <ele>78</ele> </tp>
692 <tp> <time>2006-03-04T11:13:48Z</time> <lat>54.96931</lat> <lon>-1.62645</lon> <ele>78</ele> </tp>
693 <tp> <time>2006-03-04T11:14:05Z</time> <lat>54.96918</lat> <lon>-1.62603</lon> <ele>79</ele> </tp>
694 <tp> <time>2006-03-04T11:14:33Z</time> <lat>54.96901</lat> <lon>-1.62364</lon> <ele>76.1</ele> </tp>
695 <tp> <time>2006-03-04T11:15:02Z</time> <lat>54.96922</lat> <lon>-1.6254</lon> <ele>76.1</ele> </tp>
696 <tp> <time>2006-03-04T11:15:27Z</time> <lat>54.96914</lat> <lon>-1.62526</lon> <ele>75.1</ele> </tp>
697 <tp> <time>2006-03-04T11:15:50Z</time> <lat>54.96911</lat> <lon>-1.62494</lon> <ele>75.1</ele> </tp>
698 <tp> <time>2006-03-04T11:16:03Z</time> <lat>54.9693</lat> <lon>-1.62489</lon> <ele>75.1</ele> </tp>
699 <tp> <time>2006-03-04T11:16:19Z</time> <lat>54.96901</lat> <lon>-1.62496</lon> <ele>75.1</ele> </tp>
700 <tp> <time>2006-03-04T11:16:52Z</time> <lat>54.96871</lat> <lon>-1.62466</lon> <ele>74.6</ele> </tp>
701 <tp> <time>2006-03-04T11:17:25Z</time> <lat>54.96908</lat> <lon>-1.62488</lon> <ele>72.7</ele> </tp>
702 <break/>
703 <title>ACTIVE LOG 126</title>
704 <tp> <time>2006-03-04T11:18:32Z</time> <lat>54.96904</lat> <lon>-1.62482</lon> <ele>72.7</ele> </tp>
705 <tp> <time>2006-03-04T11:18:35Z</time> <lat>54.96913</lat> <lon>-1.62499</lon> <ele>71.3</ele> </tp>
706 <tp> <time>2006-03-04T11:18:38Z</time> <lat>54.96904</lat> <lon>-1.62497</lon> <ele>70.8</ele> </tp>
707 <tp> <time>2006-03-04T11:18:48Z</time> <lat>54.96913</lat> <lon>-1.62496</lon> <ele>71.8</ele> </tp>
708 <tp> <time>2006-03-04T11:18:55Z</time> <lat>54.96924</lat> <lon>-1.62501</lon> <ele>72.2</ele> </tp>
709 <tp> <time>2006-03-04T11:19:11Z</time> <lat>54.9694</lat> <lon>-1.62521</lon> <ele>71.8</ele> </tp>
710 <tp> <time>2006-03-04T11:19:30Z</time> <lat>54.96916</lat> <lon>-1.62515</lon> <ele>71.3</ele> </tp>
711 <tp> <time>2006-03-04T11:19:53Z</time> <lat>54.96921</lat> <lon>-1.625</lon> <ele>71.3</ele> </tp>
712 <tp> <time>2006-03-04T11:20:21Z</time> <lat>54.96801</lat> <lon>-1.62417</lon> <ele>71.8</ele> </tp>
713 <break/>
714 <title>ACTIVE LOG 127</title>
715 <tp> <time>2006-03-04T11:21:16Z</time> <lat>54.96887</lat> <lon>-1.62504</lon> <ele>70.8</ele> </tp>
716 <tp> <time>2006-03-04T11:21:18Z</time> <lat>54.96898</lat> <lon>-1.62476</lon> <ele>69.8</ele> </tp>
717 <tp> <time>2006-03-04T11:21:29Z</time> <lat>54.9691</lat> <lon>-1.62475</lon> <ele>69.4</ele> </tp>
718 <tp> <time>2006-03-04T11:21:46Z</time> <lat>54.96918</lat> <lon>-1.62468</lon> <ele>70.3</ele> </tp>
719 <tp> <time>2006-03-04T11:22:39Z</time> <lat>54.9692</lat> <lon>-1.62465</lon> <ele>69.4</ele> </tp>
720 <tp> <time>2006-03-04T11:22:43Z</time> <lat>54.96924</lat> <lon>-1.62462</lon> <ele>71.8</ele> </tp>
721 <tp> <time>2006-03-04T11:22:45Z</time> <lat>54.96928</lat> <lon>-1.62463</lon> <ele>71.8</ele> </tp>
722 <tp> <time>2006-03-04T11:23:00Z</time> <lat>54.96945</lat> <lon>-1.62466</lon> <ele>69.4</ele> </tp>
723 </track>
724 </gpsml>
727 "Read Mapsource TAB-separated format",
731 # }}}
732 testcmd("../gpst two-digit_year.mcsv", # {{{
733 <<END,
734 <?xml version="1.0" encoding="UTF-8"?>
735 <gpsml>
736 <track>
737 <break/>
738 <title>ACTIVE LOG 032</title>
739 <tp> <time>2006-03-20T20:35:33Z</time> <lat>60.41324</lat> <lon>5.33352</lon> <ele>14</ele> </tp>
740 <tp> <time>2006-03-20T20:35:38Z</time> <lat>60.38802</lat> <lon>5.33845</lon> <ele>18</ele> </tp>
741 <tp> <time>2006-03-20T20:35:44Z</time> <lat>60.38709</lat> <lon>5.3379</lon> <ele>19</ele> </tp>
742 <tp> <time>2006-03-20T20:35:49Z</time> <lat>60.38641</lat> <lon>5.33732</lon> <ele>18</ele> </tp>
743 <tp> <time>2006-03-20T20:35:54Z</time> <lat>60.38581</lat> <lon>5.33647</lon> <ele>18</ele> </tp>
744 <tp> <time>2006-03-20T20:36:00Z</time> <lat>60.38516</lat> <lon>5.33528</lon> <ele>15</ele> </tp>
745 <tp> <time>2006-03-20T20:36:02Z</time> <lat>60.38495</lat> <lon>5.3349</lon> <ele>13</ele> </tp>
746 </track>
747 </gpsml>
750 "Read Mapsource TAB-separated format with two-digit year",
754 # }}}
755 testcmd("../gpst log.gpstxt", # {{{
756 <<END,
757 <?xml version="1.0" encoding="UTF-8"?>
758 <gpsml>
759 <track>
760 <tp> <time>2003-06-13T14:36:09Z</time> <lat>59.521517</lat> <lon>7.391867</lon> <ele>762</ele> </tp>
761 <tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>
762 <tp> <time>2003-06-13T14:36:11Z</time> <lat>59.5213</lat> <lon>7.392417</lon> <ele>761</ele> </tp>
763 <tp> <time>2003-06-13T14:36:12Z</time> <lat>59.521183</lat> <lon>7.3927</lon> <ele>761</ele> </tp>
764 <etp err="nosignal"> <time>2003-06-13T14:36:13Z</time> </etp>
765 <tp> <time>2003-06-13T14:36:15Z</time> <lat>59.52085</lat> <lon>7.393517</lon> <ele>760</ele> </tp>
766 <tp> <time>2003-06-13T14:36:16Z</time> <lat>59.520733</lat> <lon>7.393783</lon> <ele>760</ele> </tp>
767 <tp> <time>2003-06-13T14:36:17Z</time> <lat>59.52065</lat> <lon>7.39405</lon> <ele>760</ele> </tp>
768 <tp> <time>2003-06-13T14:36:18Z</time> <lat>59.520583</lat> <lon>7.394333</lon> <ele>760</ele> </tp>
769 <tp> <time>2003-06-13T14:36:19Z</time> <lat>59.520533</lat> <lon>7.394633</lon> <ele>759</ele> </tp>
770 <tp> <time>2003-06-13T14:36:20Z</time> <lat>59.520483</lat> <lon>7.394917</lon> <ele>759</ele> </tp>
771 <tp> <time>2003-06-13T14:36:21Z</time> <lat>59.520433</lat> <lon>7.395233</lon> <ele>759</ele> </tp>
772 <etp err="nosignal"> <time>2003-06-13T14:36:22Z</time> </etp>
773 <tp> <time>2003-06-13T14:36:24Z</time> <lat>59.520283</lat> <lon>7.396233</lon> <ele>758</ele> </tp>
774 <tp> <time>2003-06-13T14:36:25Z</time> <lat>59.520233</lat> <lon>7.39655</lon> <ele>758</ele> </tp>
775 <tp> <time>2003-06-13T14:36:26Z</time> <lat>59.520183</lat> <lon>7.396883</lon> <ele>757</ele> </tp>
776 <tp> <time>2003-06-13T14:36:27Z</time> <lat>59.520133</lat> <lon>7.397217</lon> <ele>757</ele> </tp>
777 <tp> <time>2003-06-13T14:36:28Z</time> <lat>59.5201</lat> <lon>7.397567</lon> <ele>757</ele> </tp>
778 </track>
779 </gpsml>
782 "Read Garmin serial text format",
786 # }}}
787 testcmd("../gpst log.dos.mayko", # {{{
788 <<END,
789 <?xml version="1.0" encoding="UTF-8"?>
790 <gpsml>
791 <track>
792 <tp> <time>2003-06-15T10:27:45Z</time> <lat>58.1818158</lat> <lon>8.1225077</lon> </tp>
793 <tp> <time>2003-06-15T10:27:53Z</time> <lat>58.1818712</lat> <lon>8.12532</lon> </tp>
794 <tp> <time>2003-06-15T10:27:57Z</time> <lat>58.1816347</lat> <lon>8.1266031</lon> </tp>
795 <tp> <time>2003-06-15T10:28:03Z</time> <lat>58.1812099</lat> <lon>8.1284612</lon> </tp>
796 <tp> <time>2003-06-15T10:28:06Z</time> <lat>58.1810315</lat> <lon>8.129395</lon> </tp>
797 <tp> <time>2003-06-15T10:28:10Z</time> <lat>58.1809621</lat> <lon>8.13074</lon> </tp>
798 </track>
799 </gpsml>
802 "Read DOS-formatted Mayko format",
806 # }}}
807 testcmd("../gpst log.dos.gpstxt", # {{{
808 <<END,
809 <?xml version="1.0" encoding="UTF-8"?>
810 <gpsml>
811 <track>
812 <tp> <time>2003-01-05T16:47:11Z</time> <lat>66.908167</lat> <lon>15.022983</lon> <ele>11472</ele> </tp>
813 <tp> <time>2003-01-05T16:47:12Z</time> <lat>66.90625</lat> <lon>15.020667</lon> <ele>11472</ele> </tp>
814 <tp> <time>2003-01-05T16:47:13Z</time> <lat>66.904317</lat> <lon>15.01835</lon> <ele>11472</ele> </tp>
815 <tp> <time>2003-01-05T16:47:14Z</time> <lat>66.9024</lat> <lon>15.016017</lon> <ele>11473</ele> </tp>
816 <tp> <time>2003-01-05T16:47:15Z</time> <lat>66.900483</lat> <lon>15.0137</lon> <ele>11474</ele> </tp>
817 <tp> <time>2003-01-05T16:47:16Z</time> <lat>66.898567</lat> <lon>15.011383</lon> <ele>11474</ele> </tp>
818 <tp> <time>2003-01-05T16:47:17Z</time> <lat>66.896633</lat> <lon>15.009067</lon> <ele>11475</ele> </tp>
819 <tp> <time>2003-01-05T16:47:18Z</time> <lat>66.894717</lat> <lon>15.006733</lon> <ele>11475</ele> </tp>
820 <tp> <time>2003-01-05T16:47:19Z</time> <lat>66.8928</lat> <lon>15.004417</lon> <ele>11475</ele> </tp>
821 <tp> <time>2003-01-05T16:47:20Z</time> <lat>66.890867</lat> <lon>15.0021</lon> <ele>11475</ele> </tp>
822 <tp> <time>2003-01-05T16:47:21Z</time> <lat>66.88895</lat> <lon>14.999783</lon> <ele>11475</ele> </tp>
823 </track>
824 </gpsml>
827 "Read DOS-formatted Garmin serial text format",
831 # }}}
832 testcmd("../gpst log.unix.mcsv", # {{{
833 <<END,
834 <?xml version="1.0" encoding="UTF-8"?>
835 <gpsml>
836 <track>
837 <break/>
838 <title>ACTIVE LOG 058</title>
839 <tp> <time>2006-02-21T15:14:25Z</time> <lat>60.36662</lat> <lon>5.24885</lon> <ele>31.9</ele> </tp>
840 <tp> <time>2006-02-21T15:14:30Z</time> <lat>60.37057</lat> <lon>5.22956</lon> <ele>35.2</ele> </tp>
841 <tp> <time>2006-02-21T15:14:35Z</time> <lat>60.37019</lat> <lon>5.22817</lon> <ele>39.6</ele> </tp>
842 <tp> <time>2006-02-21T15:14:36Z</time> <lat>60.37012</lat> <lon>5.2279</lon> <ele>41</ele> </tp>
843 <tp> <time>2006-02-21T15:14:40Z</time> <lat>60.37009</lat> <lon>5.22682</lon> <ele>47.2</ele> </tp>
844 <tp> <time>2006-02-21T15:14:42Z</time> <lat>60.37011</lat> <lon>5.22641</lon> <ele>49.2</ele> </tp>
845 <tp> <time>2006-02-21T15:14:44Z</time> <lat>60.37011</lat> <lon>5.22607</lon> <ele>50.1</ele> </tp>
846 <tp> <time>2006-02-21T15:14:48Z</time> <lat>60.37002</lat> <lon>5.22568</lon> <ele>51.1</ele> </tp>
847 <tp> <time>2006-02-21T15:14:51Z</time> <lat>60.3701</lat> <lon>5.22548</lon> <ele>52.5</ele> </tp>
848 </track>
849 </gpsml>
852 "Read UNIX-formatted Garmin Mapsource TAB-separated format",
856 # }}}
857 testcmd("../gpst multitrack.gpx", # {{{
858 <<END,
859 <?xml version="1.0" encoding="UTF-8"?>
860 <gpsml>
861 <track>
862 <title>Track 1</title>
863 <tp> <time>2003-02-11T23:35:39Z</time> <lat>51.4968266</lat> <lon>-0.1448824</lon> </tp>
864 <tp> <time>2003-02-11T23:35:49Z</time> <lat>51.4968227</lat> <lon>-0.1449938</lon> </tp>
865 <tp> <time>2003-02-11T23:36:14Z</time> <lat>51.496904</lat> <lon>-0.1453202</lon> </tp>
866 <break/>
867 <title>Track 2</title>
868 <tp> <time>2003-02-11T23:36:16Z</time> <lat>51.4969214</lat> <lon>-0.1453398</lon> </tp>
869 <tp> <time>2003-02-11T23:36:31Z</time> <lat>51.4969816</lat> <lon>-0.1455514</lon> </tp>
870 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
871 <tp> <time>2003-02-11T23:36:50Z</time> <lat>51.4970452</lat> <lon>-0.1457804</lon> </tp>
872 <break/>
873 <title>Track 3</title>
874 <tp> <time>2003-02-11T23:37:05Z</time> <lat>51.497068</lat> <lon>-0.1458608</lon> </tp>
875 <tp> <time>2003-02-11T23:37:22Z</time> <lat>51.4971658</lat> <lon>-0.1460047</lon> </tp>
876 <tp> <time>2003-02-11T23:37:36Z</time> <lat>51.4972469</lat> <lon>-0.1461614</lon> </tp>
877 <break/>
878 <title>Track 4</title>
879 <tp> <time>2003-02-11T23:37:43Z</time> <lat>51.4972731</lat> <lon>-0.1462394</lon> </tp>
880 <tp> <time>2003-02-11T23:38:04Z</time> <lat>51.4973437</lat> <lon>-0.1463232</lon> </tp>
881 <tp> <time>2003-02-11T23:38:28Z</time> <lat>51.4973337</lat> <lon>-0.1462949</lon> </tp>
882 <tp> <time>2003-02-11T23:38:34Z</time> <lat>51.4973218</lat> <lon>-0.1462825</lon> </tp>
883 <tp> <time>2003-02-11T23:38:35Z</time> <lat>51.4973145</lat> <lon>-0.1462732</lon> </tp>
884 </track>
885 </gpsml>
888 "Read GPX file with multiple tracks",
892 # }}}
893 testcmd("../gpst compact.gpx", # {{{
894 <<END,
895 <?xml version="1.0" encoding="UTF-8"?>
896 <gpsml>
897 <track>
898 <title>All whitespace stripped</title>
899 <tp> <time>2002-12-30T15:22:04Z</time> <lat>70.660932</lat> <lon>23.7028354</lon> </tp>
900 <tp> <time>2002-12-30T15:22:06Z</time> <lat>70.6609392</lat> <lon>23.7028468</lon> </tp>
901 <tp> <time>2002-12-30T15:22:08Z</time> <lat>70.6609429</lat> <lon>23.7028499</lon> </tp>
902 <tp> <time>2002-12-30T15:22:11Z</time> <lat>70.6609381</lat> <lon>23.702862</lon> </tp>
903 <tp> <time>2002-12-30T15:22:12Z</time> <lat>70.6609368</lat> <lon>23.7028648</lon> </tp>
904 <tp> <time>2002-12-30T15:22:13Z</time> <lat>70.6609344</lat> <lon>23.7028652</lon> </tp>
905 <tp> <time>2002-12-30T15:22:15Z</time> <lat>70.6609349</lat> <lon>23.7028707</lon> </tp>
906 <tp> <time>2002-12-30T15:22:17Z</time> <lat>70.6609348</lat> <lon>23.7028654</lon> </tp>
907 <tp> <time>2002-12-30T15:22:19Z</time> <lat>70.6609347</lat> <lon>23.7028599</lon> </tp>
908 <tp> <time>2002-12-30T15:22:20Z</time> <lat>70.6609348</lat> <lon>23.7028609</lon> </tp>
909 <tp> <time>2002-12-30T15:22:23Z</time> <lat>70.6609388</lat> <lon>23.7028653</lon> </tp>
910 <tp> <time>2002-12-30T15:22:25Z</time> <lat>70.6609426</lat> <lon>23.7028732</lon> </tp>
911 </track>
912 </gpsml>
915 "Read GPX one-liner",
919 # }}}
920 testcmd("../gpst missing.gpsml", # {{{
921 <<END,
922 <?xml version="1.0" encoding="UTF-8"?>
923 <gpsml>
924 <track>
925 <title>Missing various elements</title>
926 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
927 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
928 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
929 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
930 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
931 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
932 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
933 <tp> <ele>486</ele> </tp>
934 <tp> <desc>Missing everything</desc> </tp>
935 <tp> <lat>60.42339</lat> </tp>
936 <tp> <lon>5.34262</lon> </tp>
937 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
938 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
939 </track>
940 </gpsml>
943 "Read gpsml with various data missing",
947 # }}}
948 testcmd("../gpst different_dateformats.gpsml", # {{{
949 <<END,
950 <?xml version="1.0" encoding="UTF-8"?>
951 <gpsml>
952 <track>
953 <title>Date format variations</title>
954 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1</lat> <lon>1</lon> </tp>
955 <tp> <time>2006-01-01T00:00:02Z</time> <lat>2</lat> <lon>2</lon> </tp>
956 <tp> <time>2006-01-01T00:00:03Z</time> <lat>3</lat> <lon>3</lon> </tp>
957 <tp> <time>2006-01-01T00:00:04Z</time> <lat>4</lat> <lon>4</lon> </tp>
958 </track>
959 </gpsml>
962 "Read different date formats from gpsml file",
966 # }}}
967 testcmd("../gpst multitrack-pause.gpx", # {{{
968 file_data("multitrack-pause.gpsml"),
970 "Should be equal to multitrack-pause.gpsml",
974 # }}}
975 # gpx
976 testcmd("../gpst -o gpx no_signal.mayko", # {{{
977 <<END,
978 $gpx_header
979 <trk>
980 <trkseg>
981 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
982 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
983 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
984 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> </trkpt>
985 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> </trkpt>
986 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> </trkpt>
987 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
988 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
989 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
990 </trkseg>
991 </trk>
992 </gpx>
995 "Output GPX from Mayko file with duplicates",
999 # }}}
1000 testcmd("../gpst -o gpx comments.mayko", # {{{
1001 <<END,
1002 $gpx_header
1003 <trk>
1004 <trkseg>
1005 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
1006 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
1007 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
1008 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1009 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1010 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1011 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
1012 </trkseg>
1013 <trkseg>
1014 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
1015 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
1016 </trkseg>
1017 </trk>
1018 </gpx>
1021 "Output GPX from Mayko file with commented-out lines",
1025 # }}}
1026 testcmd("../gpst -o gpx missing-noname.gpsml", # {{{
1027 <<END,
1028 $gpx_header
1029 <trk>
1030 <trkseg>
1031 <trkpt lat="60.42353" lon="5.34185"> <time>2006-04-30T17:17:09Z</time> </trkpt>
1032 <trkpt> <ele>483</ele> <time>2006-04-30T17:17:11Z</time> </trkpt>
1033 <trkpt> <ele>485</ele> <time>2006-04-30T17:17:22Z</time> </trkpt>
1034 <trkpt lat="60.42347" lon="5.34212"> <ele>486</ele> </trkpt>
1035 <trkpt> <ele>484</ele> </trkpt>
1036 <trkpt> <ele>486</ele> </trkpt>
1037 <trkpt> <ele>490</ele> <time>2006-04-30T17:18:03Z</time> </trkpt>
1038 <trkpt lat="60.42338" lon="5.34269"> <ele>487</ele> <time>2006-04-30T17:18:05Z</time> </trkpt>
1039 </trkseg>
1040 </trk>
1041 </gpx>
1044 "Output GPX from gpsml with missing data",
1048 # }}}
1049 # xgraph
1050 testcmd("../gpst -o xgraph multitrack.gpx", # {{{
1051 <<END,
1052 -0.1448824 51.4968266
1053 -0.1449938 51.4968227
1054 -0.1453202 51.4969040
1055 move -0.1453398 51.4969214
1056 -0.1455514 51.4969816
1057 -0.1457489 51.4970224
1058 -0.1457804 51.4970452
1059 move -0.1458608 51.4970680
1060 -0.1460047 51.4971658
1061 -0.1461614 51.4972469
1062 move -0.1462394 51.4972731
1063 -0.1463232 51.4973437
1064 -0.1462949 51.4973337
1065 -0.1462825 51.4973218
1066 -0.1462732 51.4973145
1069 "Output xgraph format from GPX",
1073 # }}}
1074 # pgtab
1075 testcmd("../gpst -o pgtab compact.gpx", # {{{
1076 <<END,
1077 2002-12-30T15:22:04Z\t(70.6609320,23.7028354)\t\\N\t\\N\t\\N\t\\N
1078 2002-12-30T15:22:06Z\t(70.6609392,23.7028468)\t\\N\t\\N\t\\N\t\\N
1079 2002-12-30T15:22:08Z\t(70.6609429,23.7028499)\t\\N\t\\N\t\\N\t\\N
1080 2002-12-30T15:22:11Z\t(70.6609381,23.7028620)\t\\N\t\\N\t\\N\t\\N
1081 2002-12-30T15:22:12Z\t(70.6609368,23.7028648)\t\\N\t\\N\t\\N\t\\N
1082 2002-12-30T15:22:13Z\t(70.6609344,23.7028652)\t\\N\t\\N\t\\N\t\\N
1083 2002-12-30T15:22:15Z\t(70.6609349,23.7028707)\t\\N\t\\N\t\\N\t\\N
1084 2002-12-30T15:22:17Z\t(70.6609348,23.7028654)\t\\N\t\\N\t\\N\t\\N
1085 2002-12-30T15:22:19Z\t(70.6609347,23.7028599)\t\\N\t\\N\t\\N\t\\N
1086 2002-12-30T15:22:20Z\t(70.6609348,23.7028609)\t\\N\t\\N\t\\N\t\\N
1087 2002-12-30T15:22:23Z\t(70.6609388,23.7028653)\t\\N\t\\N\t\\N\t\\N
1088 2002-12-30T15:22:25Z\t(70.6609426,23.7028732)\t\\N\t\\N\t\\N\t\\N
1091 "Output pgtab from gpx format",
1095 # }}}
1096 testcmd("../gpst -o pgtab no_signal.mayko", # {{{
1097 <<END,
1098 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N
1099 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N
1100 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1101 2002-12-22T21:43:51Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1102 2002-12-22T21:43:52Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1103 2002-12-22T21:43:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1104 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N
1105 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N
1106 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N
1109 "Output pgtab from mayko format",
1113 # }}}
1114 testcmd("../gpst -o pgtab missing.gpsml", # {{{
1115 <<END,
1116 2006-04-30T17:17:09Z\t(60.42353,5.34185)\t\\N\t\\N\t\\N\t\\N
1117 \\N\t(60.42347,5.34212)\t486\t\\N\t\\N\t\\N
1118 2006-04-30T17:18:05Z\t(60.42338,5.34269)\t487\t\\N\t\\N\t\\N
1121 "Output pgtab from missing.gpsml",
1125 # }}}
1126 # csv
1127 testcmd("../gpst -o csv log.dos.mayko", # {{{
1128 <<END,
1129 2003-06-15T10:27:45Z\t8.1225077\t58.1818158\t\t
1130 2003-06-15T10:27:53Z\t8.1253200\t58.1818712\t\t
1131 2003-06-15T10:27:57Z\t8.1266031\t58.1816347\t\t
1132 2003-06-15T10:28:03Z\t8.1284612\t58.1812099\t\t
1133 2003-06-15T10:28:06Z\t8.1293950\t58.1810315\t\t
1134 2003-06-15T10:28:10Z\t8.1307400\t58.1809621\t\t
1137 "Output csv from DOS-formatted Mayko format",
1141 # }}}
1142 # pgwtab
1143 testcmd("../gpst -o pgwtab multitrack.gpx", # {{{
1144 <<END,
1145 (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
1146 (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
1147 (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
1148 (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
1149 (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
1150 (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
1153 "Test pgwtab format",
1157 # }}}
1158 # pgwupd
1159 testcmd("../gpst -o pgwupd multitrack.gpx", # {{{
1160 <<END,
1161 BEGIN;
1162 UPDATE logg SET name = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1163 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1164 COMMIT;
1165 BEGIN;
1166 UPDATE logg SET name = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1167 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1168 COMMIT;
1169 BEGIN;
1170 UPDATE logg SET name = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1171 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1172 COMMIT;
1173 BEGIN;
1174 UPDATE logg SET name = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1175 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1176 COMMIT;
1177 BEGIN;
1178 UPDATE logg SET name = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1179 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1180 COMMIT;
1181 BEGIN;
1182 UPDATE logg SET name = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1183 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1184 COMMIT;
1187 "Test pgwupd format",
1191 # }}}
1192 # clean
1193 testcmd("../gpst -t -o clean pause.gpx", # {{{
1194 <<END,
1195 5.299534\t60.425494\t25.260
1196 5.299610\t60.425464\t24.931
1198 5.299694\t60.425314\t27.975
1200 5.299741\t60.425384\t31.017
1201 5.299958\t60.425339\t30.980
1202 5.299640\t60.425238\t30.538
1203 5.299686\t60.425246\t30.515
1205 5.299773\t60.425345\t31.936
1206 5.299419\t60.425457\t31.794
1209 "Output clean format with time breaks",
1212 # }}}
1213 # gpstrans
1214 # poscount
1215 # ps (Unfinished)
1216 # svg (Unfinished)
1217 # ygraph
1218 # --output option }}}
1219 diag("Testing --outside option..."); # {{{
1220 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --outside multitrack-pause.gpx", # {{{
1221 <<END,
1222 <?xml version="1.0" encoding="UTF-8"?>
1223 <gpsml>
1224 <track>
1225 <title>track1</title>
1226 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1227 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1228 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1229 <break/>
1230 <title>track2</title>
1231 <break/>
1232 <title>track3</title>
1233 <break/>
1234 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1235 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1236 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1237 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1238 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1239 </track>
1240 </gpsml>
1243 "Check --outside option (gpx to gpst)",
1247 # }}}
1248 # --outside option }}}
1249 diag("Testing --pos1 and --pos2 options..."); # {{{
1250 # --pos1 and --pos2 options }}}
1251 diag("Testing --require option..."); # {{{
1252 testcmd("../gpst -re multitrack.gpx", # {{{
1253 <<END,
1254 <?xml version="1.0" encoding="UTF-8"?>
1255 <gpsml>
1256 <track>
1257 <title>Track 1</title>
1258 <break/>
1259 <title>Track 2</title>
1260 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
1261 <break/>
1262 <title>Track 3</title>
1263 <break/>
1264 <title>Track 4</title>
1265 </track>
1266 </gpsml>
1269 "Require elevation from GPX data",
1273 # }}}
1274 testcmd("../gpst -re one_ele.dos.gpsml", # {{{
1275 <<END,
1276 <?xml version="1.0" encoding="UTF-8"?>
1277 <gpsml>
1278 <track>
1279 <title>Only one point has elevation</title>
1280 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1281 </track>
1282 </gpsml>
1285 "Require elevation from gpsml",
1289 # }}}
1290 testcmd("../gpst -re missing.gpsml", # {{{
1291 <<END,
1292 <?xml version="1.0" encoding="UTF-8"?>
1293 <gpsml>
1294 <track>
1295 <title>Missing various elements</title>
1296 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1297 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1298 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1299 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
1300 <tp> <ele>486</ele> </tp>
1301 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1302 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1303 </track>
1304 </gpsml>
1307 "Require elevation",
1311 # }}}
1312 testcmd("../gpst -rt missing.gpsml", # {{{
1313 <<END,
1314 <?xml version="1.0" encoding="UTF-8"?>
1315 <gpsml>
1316 <track>
1317 <title>Missing various elements</title>
1318 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
1319 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
1320 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1321 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1322 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1323 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1324 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1325 </track>
1326 </gpsml>
1329 "Require time",
1333 # }}}
1334 testcmd("../gpst -rp missing.gpsml", # {{{
1335 <<END,
1336 <?xml version="1.0" encoding="UTF-8"?>
1337 <gpsml>
1338 <track>
1339 <title>Missing various elements</title>
1340 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1341 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1342 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1343 </track>
1344 </gpsml>
1347 "Require position",
1351 # }}}
1352 testcmd("../gpst -ret missing.gpsml", # {{{
1353 <<END,
1354 <?xml version="1.0" encoding="UTF-8"?>
1355 <gpsml>
1356 <track>
1357 <title>Missing various elements</title>
1358 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1359 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1360 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1361 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1362 </track>
1363 </gpsml>
1366 "Require elevation and time",
1370 # }}}
1371 testcmd("../gpst -retp missing.gpsml", # {{{
1372 <<END,
1373 <?xml version="1.0" encoding="UTF-8"?>
1374 <gpsml>
1375 <track>
1376 <title>Missing various elements</title>
1377 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1378 </track>
1379 </gpsml>
1382 "Require elevation, time and position",
1386 # }}}
1387 testcmd("../gpst -rep missing.gpsml", # {{{
1388 <<END,
1389 <?xml version="1.0" encoding="UTF-8"?>
1390 <gpsml>
1391 <track>
1392 <title>Missing various elements</title>
1393 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1394 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1395 </track>
1396 </gpsml>
1399 "Require elevation and position",
1403 # }}}
1404 # --require option }}}
1405 diag("Testing --round option..."); # {{{
1406 testcmd("../gpst -R lat=4,lon=5,ele=1 pause.gpx", # {{{
1407 <<END,
1408 <?xml version="1.0" encoding="UTF-8"?>
1409 <gpsml>
1410 <track>
1411 <title>ACTIVE LOG164705</title>
1412 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.4255</lat> <lon>5.29953</lon> <ele>25.3</ele> </tp>
1413 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.4255</lat> <lon>5.29961</lon> <ele>24.9</ele> </tp>
1414 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.4253</lat> <lon>5.29969</lon> <ele>28</ele> </tp>
1415 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.4254</lat> <lon>5.29974</lon> <ele>31</ele> </tp>
1416 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.4253</lat> <lon>5.29996</lon> <ele>31</ele> </tp>
1417 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.4252</lat> <lon>5.29964</lon> <ele>30.5</ele> </tp>
1418 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.4252</lat> <lon>5.29969</lon> <ele>30.5</ele> </tp>
1419 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.4253</lat> <lon>5.29977</lon> <ele>31.9</ele> </tp>
1420 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.4255</lat> <lon>5.29942</lon> <ele>31.8</ele> </tp>
1421 </track>
1422 </gpsml>
1425 "--round works with lat, lon, ele from gpx",
1429 # }}}
1430 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgtab pause.gpx", # {{{
1431 <<END,
1432 2006-05-21T16:49:11Z\t(60.425,5.3)\t25.3\t\\N\t\\N\t\\N
1433 2006-05-21T16:49:46Z\t(60.425,5.3)\t24.9\t\\N\t\\N\t\\N
1434 2006-05-21T16:52:04Z\t(60.425,5.3)\t28\t\\N\t\\N\t\\N
1435 2006-05-21T16:56:36Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N
1436 2006-05-21T16:56:47Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N
1437 2006-05-21T16:56:56Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N
1438 2006-05-21T16:57:03Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N
1439 2006-05-21T16:59:08Z\t(60.425,5.3)\t31.9\t\\N\t\\N\t\\N
1440 2006-05-21T17:00:54Z\t(60.425,5.299)\t31.8\t\\N\t\\N\t\\N
1443 "pgtab output from gpx works with --round lat, lon, ele",
1447 # }}}
1448 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwtab multitrack.gpx", # {{{
1449 <<END,
1450 (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
1451 (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
1452 (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
1453 (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
1454 (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
1455 (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
1458 "--round works with lat, lon, ele from gpx, pgwtab output",
1462 # }}}
1463 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwupd multitrack.gpx", # {{{
1464 <<END,
1465 BEGIN;
1466 UPDATE logg SET name = clname(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1467 UPDATE logg SET dist = cldist(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1468 COMMIT;
1469 BEGIN;
1470 UPDATE logg SET name = clname(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1471 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1472 COMMIT;
1473 BEGIN;
1474 UPDATE logg SET name = clname(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1475 UPDATE logg SET dist = cldist(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1476 COMMIT;
1477 BEGIN;
1478 UPDATE logg SET name = clname(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1479 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1480 COMMIT;
1481 BEGIN;
1482 UPDATE logg SET name = clname(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1483 UPDATE logg SET dist = cldist(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1484 COMMIT;
1485 BEGIN;
1486 UPDATE logg SET name = clname(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1487 UPDATE logg SET dist = cldist(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1488 COMMIT;
1491 "pgwupd output and --round works with lat, lon, ele from gpx",
1495 # }}}
1496 # --round option }}}
1497 diag("Testing --short-date option..."); # {{{
1498 # --short-date option }}}
1499 diag("Testing --save-to-file option..."); # {{{
1500 # --save-to-file option }}}
1501 diag("Testing --create-breaks option..."); # {{{
1502 testcmd("../gpst -t pause.gpx", # {{{
1503 <<END,
1504 <?xml version="1.0" encoding="UTF-8"?>
1505 <gpsml>
1506 <track>
1507 <title>ACTIVE LOG164705</title>
1508 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
1509 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
1510 <pause>0:00:02:18</pause>
1511 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1512 <pause>0:00:04:32</pause>
1513 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
1514 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
1515 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
1516 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
1517 <pause>0:00:02:05</pause>
1518 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
1519 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
1520 </track>
1521 </gpsml>
1524 "Output gpsml with <pause> elements from GPX files",
1528 # }}}
1529 testcmd("../gpst -t multitrack-pause.gpx", # {{{
1530 <<END,
1531 <?xml version="1.0" encoding="UTF-8"?>
1532 <gpsml>
1533 <track>
1534 <title>track1</title>
1535 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1536 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1537 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1538 <break/>
1539 <title>track2</title>
1540 <pause>0:23:59:58</pause>
1541 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1542 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1543 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1544 <pause>0:01:00:00</pause>
1545 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1546 <break/>
1547 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1548 <break/>
1549 <title>track3</title>
1550 <pause>1:01:00:03</pause>
1551 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1552 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1553 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1554 <break/>
1555 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1556 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1557 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1558 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1559 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1560 </track>
1561 </gpsml>
1564 "Insert <pause> between gpx tracks",
1568 # }}}
1569 testcmd("../gpst -t multitrack-pause.gpsml", # {{{
1570 <<END,
1571 <?xml version="1.0" encoding="UTF-8"?>
1572 <gpsml>
1573 <track>
1574 <title>track1</title>
1575 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1576 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1577 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1578 <break/>
1579 <title>track2</title>
1580 <pause>0:23:59:58</pause>
1581 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1582 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1583 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1584 <pause>0:01:00:00</pause>
1585 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1586 <break/>
1587 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1588 <break/>
1589 <title>track3</title>
1590 <pause>1:01:00:03</pause>
1591 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1592 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1593 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1594 <break/>
1595 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1596 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1597 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1598 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1599 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1600 </track>
1601 </gpsml>
1604 "Insert <pause> between gpsml titles",
1608 # }}}
1609 # --create-breaks option }}}
1610 diag("Testing -T (--time-shift) option...");
1611 testcmd("$CMD -T 3600 multitrack-pause.gpx", # {{{
1612 <<END,
1613 <?xml version="1.0" encoding="UTF-8"?>
1614 <gpsml>
1615 <track>
1616 <title>track1</title>
1617 <tp> <time>2006-01-01T01:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1618 <tp> <time>2006-01-01T01:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1619 <tp> <time>2006-01-01T01:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1620 <break/>
1621 <title>track2</title>
1622 <tp> <time>2006-01-02T01:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1623 <tp> <time>2006-01-02T01:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1624 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1625 <tp> <time>2006-01-02T02:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1626 <break/>
1627 <tp> <time>2006-01-02T02:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1628 <break/>
1629 <title>track3</title>
1630 <tp> <time>2006-01-03T03:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1631 <tp> <time>2006-01-03T03:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1632 <tp> <time>2006-01-03T03:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1633 <break/>
1634 <tp> <time>2006-01-03T03:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1635 <tp> <time>2006-01-03T03:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1636 <tp> <time>2006-01-03T03:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1637 <tp> <time>2006-01-03T03:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1638 <tp> <time>2006-01-03T03:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1639 </track>
1640 </gpsml>
1643 "Add one hour to GPX input, output gpsml",
1647 # }}}
1648 testcmd("$CMD -T -3600 multitrack-pause.gpx", # {{{
1649 <<END,
1650 <?xml version="1.0" encoding="UTF-8"?>
1651 <gpsml>
1652 <track>
1653 <title>track1</title>
1654 <tp> <time>2005-12-31T23:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1655 <tp> <time>2005-12-31T23:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1656 <tp> <time>2005-12-31T23:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1657 <break/>
1658 <title>track2</title>
1659 <tp> <time>2006-01-01T23:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1660 <tp> <time>2006-01-01T23:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1661 <tp> <time>2006-01-01T23:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1662 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1663 <break/>
1664 <tp> <time>2006-01-02T00:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1665 <break/>
1666 <title>track3</title>
1667 <tp> <time>2006-01-03T01:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1668 <tp> <time>2006-01-03T01:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1669 <tp> <time>2006-01-03T01:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1670 <break/>
1671 <tp> <time>2006-01-03T01:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1672 <tp> <time>2006-01-03T01:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1673 <tp> <time>2006-01-03T01:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1674 <tp> <time>2006-01-03T01:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1675 <tp> <time>2006-01-03T01:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1676 </track>
1677 </gpsml>
1680 "Subtract one hour from GPX input, output gpsml",
1684 # }}}
1685 testcmd("$CMD -T 1 -o gpx multitrack-pause.gpx", # {{{
1686 <<END,
1687 $gpx_header
1688 <trk>
1689 <trkseg>
1690 <trkpt lat="1.11" lon="1.12"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1691 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:02Z</time> </trkpt>
1692 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:03Z</time> </trkpt>
1693 </trkseg>
1694 <trkseg>
1695 <trkpt lat="2.11" lon="2.12"> <time>2006-01-02T00:00:01Z</time> </trkpt>
1696 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:05Z</time> </trkpt>
1697 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:17Z</time> </trkpt>
1698 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:17Z</time> </trkpt>
1699 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:18Z</time> </trkpt>
1700 </trkseg>
1701 <trkseg>
1702 </trkseg>
1703 <trkseg>
1704 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1705 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1706 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1707 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1708 </trkseg>
1709 <trkseg>
1710 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1711 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1712 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:27Z</time> </trkpt>
1713 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:28Z</time> </trkpt>
1714 </trkseg>
1715 </trk>
1716 </gpx>
1719 "Add one second to GPX input, output GPX",
1723 # }}}
1724 testcmd("$CMD --time-shift -1 -o gpx multitrack-pause.gpsml", # {{{
1725 <<END,
1726 $gpx_header
1727 <trk>
1728 <trkseg>
1729 <trkpt lat="1.11" lon="1.12"> <time>2005-12-31T23:59:59Z</time> </trkpt>
1730 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:00Z</time> </trkpt>
1731 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1732 </trkseg>
1733 <trkseg>
1734 <trkpt lat="2.11" lon="2.12"> <time>2006-01-01T23:59:59Z</time> </trkpt>
1735 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:03Z</time> </trkpt>
1736 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:15Z</time> </trkpt>
1737 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:15Z</time> </trkpt>
1738 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:16Z</time> </trkpt>
1739 </trkseg>
1740 <trkseg>
1741 </trkseg>
1742 <trkseg>
1743 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:19Z</time> </trkpt>
1744 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:20Z</time> </trkpt>
1745 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1746 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1747 </trkseg>
1748 <trkseg>
1749 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1750 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1751 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1752 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1753 </trkseg>
1754 </trk>
1755 </gpx>
1758 "Subtract one second from gpsml input, output GPX, use long option",
1762 # }}}
1763 testcmd("$CMD -T 0 -o pgtab multitrack-pause.gpx", # {{{
1764 <<END,
1765 2006-01-01T00:00:00Z\t(1.11,1.12)\t\\N\t\\N\t\\N\t\\N
1766 2006-01-01T00:00:01Z\t(1.21,1.22)\t\\N\t\\N\t\\N\t\\N
1767 2006-01-01T00:00:02Z\t(1.31,1.32)\t\\N\t\\N\t\\N\t\\N
1768 2006-01-02T00:00:00Z\t(2.11,2.12)\t\\N\t\\N\t\\N\t\\N
1769 2006-01-02T00:00:04Z\t(2.21,2.22)\t\\N\t\\N\t\\N\t\\N
1770 2006-01-02T00:00:16Z\t(2.31,2.32)\t\\N\t\\N\t\\N\t\\N
1771 2006-01-02T01:00:16Z\t(2.41,2.42)\t\\N\t\\N\t\\N\t\\N
1772 2006-01-02T01:00:17Z\t(2.451,2.452)\t\\N\t\\N\t\\N\t\\N
1773 2006-01-03T02:00:20Z\t(3.11,3.12)\t\\N\t\\N\t\\N\t\\N
1774 2006-01-03T02:00:21Z\t(3.21,3.22)\t\\N\t\\N\t\\N\t\\N
1775 2006-01-03T02:00:22Z\t(3.31,3.32)\t\\N\t\\N\t\\N\t\\N
1776 2006-01-03T02:00:23Z\t(3.41,3.42)\t\\N\t\\N\t\\N\t\\N
1777 2006-01-03T02:00:24Z\t(3.51,3.52)\t\\N\t\\N\t\\N\t\\N
1778 2006-01-03T02:00:25Z\t(3.61,3.62)\t\\N\t\\N\t\\N\t\\N
1779 2006-01-03T02:00:26Z\t(3.71,3.72)\t\\N\t\\N\t\\N\t\\N
1780 2006-01-03T02:00:27Z\t(3.81,3.82)\t\\N\t\\N\t\\N\t\\N
1783 "Read GPX, time-shift 0 seconds, output pgtab",
1787 # }}}
1788 diag("Testing -v (--verbose) option...");
1789 likecmd("$CMD -hv", # {{{
1790 '/^\n\S+ v\d\.\d\d\n/s',
1791 '/^$/',
1792 "Option --version with -h returns version number and help screen",
1795 # }}}
1796 diag("Testing --version option...");
1797 likecmd("$CMD --version", # {{{
1798 '/^\S+ v\d\.\d\d\n/',
1799 '/^$/',
1800 "Option --version returns version number",
1803 # }}}
1804 # --version option }}}
1805 diag("Testing --strip-whitespace option..."); # {{{
1806 testcmd("../gpst -w -o gpx pause-noname.gpx", # {{{
1807 <<END,
1808 $stripped_gpx_header
1809 <trk>
1810 <trkseg>
1811 <trkpt lat="60.425494" lon="5.299534"><ele>25.260</ele><time>2006-05-21T16:49:11Z</time></trkpt>
1812 <trkpt lat="60.425464" lon="5.299610"><ele>24.931</ele><time>2006-05-21T16:49:46Z</time></trkpt>
1813 <trkpt lat="60.425314" lon="5.299694"><ele>27.975</ele><time>2006-05-21T16:52:04Z</time></trkpt>
1814 <trkpt lat="60.425384" lon="5.299741"><ele>31.017</ele><time>2006-05-21T16:56:36Z</time></trkpt>
1815 <trkpt lat="60.425339" lon="5.299958"><ele>30.980</ele><time>2006-05-21T16:56:47Z</time></trkpt>
1816 <trkpt lat="60.425238" lon="5.299640"><ele>30.538</ele><time>2006-05-21T16:56:56Z</time></trkpt>
1817 <trkpt lat="60.425246" lon="5.299686"><ele>30.515</ele><time>2006-05-21T16:57:03Z</time></trkpt>
1818 <trkpt lat="60.425345" lon="5.299773"><ele>31.936</ele><time>2006-05-21T16:59:08Z</time></trkpt>
1819 <trkpt lat="60.425457" lon="5.299419"><ele>31.794</ele><time>2006-05-21T17:00:54Z</time></trkpt>
1820 </trkseg>
1821 </trk>
1822 </gpx>
1825 "Strip whitespace from GPX output",
1829 # }}}
1830 testcmd("../gpst -o gpx -w comments.mayko", # {{{
1831 <<END,
1832 $stripped_gpx_header
1833 <trk>
1834 <trkseg>
1835 <trkpt lat="70.6800486" lon="23.6746151"><time>2002-12-22T21:42:24Z</time></trkpt>
1836 <trkpt lat="70.6799322" lon="23.6740038"><time>2002-12-22T21:42:32Z</time></trkpt>
1837 <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:42:54Z</time></trkpt>
1838 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:51Z</time><extensions><error>desc</error></extensions></trkpt> -->
1839 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:52Z</time><extensions><error>desc</error></extensions></trkpt> -->
1840 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:54Z</time><extensions><error>desc</error></extensions></trkpt> -->
1841 <trkpt lat="70.6800774" lon="23.6757566"><time>2002-12-22T21:44:45Z</time></trkpt>
1842 </trkseg>
1843 <trkseg>
1844 <trkpt lat="70.6801502" lon="23.6753442"><time>2002-12-22T21:44:52Z</time></trkpt>
1845 <trkpt lat="70.6801905" lon="23.6757542"><time>2002-12-22T21:45:04Z</time></trkpt>
1846 </trkseg>
1847 </trk>
1848 </gpx>
1851 "Output whitespace-stripped GPX from Mayko file with commented-out lines",
1855 # }}}
1856 testcmd("../gpst -w -o pgwupd multitrack.gpx", # {{{
1857 <<END,
1858 BEGIN;
1859 UPDATE logg SET name = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1860 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1861 COMMIT;
1862 BEGIN;
1863 UPDATE logg SET name = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1864 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1865 COMMIT;
1866 BEGIN;
1867 UPDATE logg SET name = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1868 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1869 COMMIT;
1870 BEGIN;
1871 UPDATE logg SET name = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1872 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1873 COMMIT;
1874 BEGIN;
1875 UPDATE logg SET name = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1876 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1877 COMMIT;
1878 BEGIN;
1879 UPDATE logg SET name = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1880 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1881 COMMIT;
1884 "Strip whitespace from pgwupd output",
1888 # }}}
1889 # --strip-whitespace option }}}
1890 diag("Testing --double-y-scale option..."); # {{{
1891 testcmd("../gpst -y -o clean pause.gpx", # {{{
1892 <<END,
1893 5.299534\t120.850988\t25.260
1894 5.299610\t120.850928\t24.931
1895 5.299694\t120.850628\t27.975
1896 5.299741\t120.850768\t31.017
1897 5.299958\t120.850678\t30.980
1898 5.299640\t120.850476\t30.538
1899 5.299686\t120.850492\t30.515
1900 5.299773\t120.85069\t31.936
1901 5.299419\t120.850914\t31.794
1904 "Double y scale, clean output from gpx format",
1908 # }}}
1909 testcmd("../gpst -y -o clean log.dos.mayko", # {{{
1910 <<END,
1911 8.1225077\t116.3636316\t
1912 8.1253200\t116.3637424\t
1913 8.1266031\t116.3632694\t
1914 8.1284612\t116.3624198\t
1915 8.1293950\t116.362063\t
1916 8.1307400\t116.3619242\t
1919 "Double y scale, clean output from mayko format",
1923 # }}}
1924 # --double-y-scale option }}}
1925 diag("Testing --debug option..."); # {{{
1926 # --debug option }}}
1927 diag("Strip error from Mayko format..."); # {{{
1929 testcmd("../gpst -o csv date_error.mayko", # {{{
1930 <<END,
1931 2003-06-13T09:12:36Z\t5.5794667\t60.4280897\t\t
1932 2003-06-13T09:12:38Z\t5.5802255\t60.4281867\t\t
1933 2003-06-13T09:12:41Z\t5.5813636\t60.4283320\t\t
1934 2003-06-13T09:12:42Z\t5.5817430\t60.4283806\t\t
1937 "Strip error from mayko format in csv output",
1941 # }}}
1942 testcmd("../gpst -o clean date_error.mayko", # {{{
1943 <<END,
1944 5.5794667\t60.4280897\t
1945 5.5802255\t60.4281867\t
1946 5.5813636\t60.4283320\t
1947 5.5817430\t60.4283806\t
1950 "Strip error from mayko format in clean output",
1954 # }}}
1955 testcmd("../gpst -o gpsml date_error.mayko", # {{{
1956 <<END,
1957 <?xml version="1.0" encoding="UTF-8"?>
1958 <gpsml>
1959 <track>
1960 <tp> <time>2003-06-13T09:12:36Z</time> <lat>60.4280897</lat> <lon>5.5794667</lon> </tp>
1961 <tp> <time>2003-06-13T09:12:38Z</time> <lat>60.4281867</lat> <lon>5.5802255</lon> </tp>
1962 <etp err="error"> <time>2037-06-25T17:19:22Z</time> <lat>103.4034054</lat> <lon>129.7271053</lon> </etp>
1963 <tp> <time>2003-06-13T09:12:41Z</time> <lat>60.428332</lat> <lon>5.5813636</lon> </tp>
1964 <tp> <time>2003-06-13T09:12:42Z</time> <lat>60.4283806</lat> <lon>5.581743</lon> </tp>
1965 </track>
1966 </gpsml>
1969 "Strip error from mayko format in gpsml output",
1973 # }}}
1974 testcmd("../gpst -o gpx date_error.mayko", # {{{
1975 <<END,
1976 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1977 <gpx
1978 version="1.1"
1979 creator="gpst - http://sunny256.github.com/gpstools/"
1980 xmlns="http://www.topografix.com/GPX/1/1"
1981 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1982 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
1984 <trk>
1985 <trkseg>
1986 <trkpt lat="60.4280897" lon="5.5794667"> <time>2003-06-13T09:12:36Z</time> </trkpt>
1987 <trkpt lat="60.4281867" lon="5.5802255"> <time>2003-06-13T09:12:38Z</time> </trkpt>
1988 <!-- <trkpt lat="103.4034054" lon="129.7271053"> <time>2037-06-25T17:19:22Z</time> <extensions> <error>error</error> </extensions> </trkpt> -->
1989 <trkpt lat="60.4283320" lon="5.5813636"> <time>2003-06-13T09:12:41Z</time> </trkpt>
1990 <trkpt lat="60.4283806" lon="5.5817430"> <time>2003-06-13T09:12:42Z</time> </trkpt>
1991 </trkseg>
1992 </trk>
1993 </gpx>
1996 "Strip error from mayko format in gpx output",
2000 # }}}
2001 testcmd("../gpst -o gpstrans date_error.mayko", # {{{
2002 <<END,
2003 Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84
2004 T\t06/13/2003 09:12:36\t60\xB025'41.1"\t5\xB034'46.1"
2005 T\t06/13/2003 09:12:38\t60\xB025'41.5"\t5\xB034'48.8"
2006 T\t06/13/2003 09:12:41\t60\xB025'42.0"\t5\xB034'52.9"
2007 T\t06/13/2003 09:12:42\t60\xB025'42.2"\t5\xB034'54.3"
2010 "Strip error from mayko format in gpstrans output",
2014 # }}}
2015 testcmd("../gpst -o pgtab date_error.mayko", # {{{
2016 <<END,
2017 2003-06-13T09:12:36Z\t(60.4280897,5.5794667)\t\\N\t\\N\t\\N\t\\N
2018 2003-06-13T09:12:38Z\t(60.4281867,5.5802255)\t\\N\t\\N\t\\N\t\\N
2019 2003-06-13T09:12:41Z\t(60.4283320,5.5813636)\t\\N\t\\N\t\\N\t\\N
2020 2003-06-13T09:12:42Z\t(60.4283806,5.5817430)\t\\N\t\\N\t\\N\t\\N
2023 "Strip error from mayko format in pgtab output",
2027 # }}}
2028 testcmd("../gpst -o poscount date_error.mayko", # {{{
2029 <<END,
2030 5.5802255\t60.4281867\t1
2031 5.5817430\t60.4283806\t1
2032 5.5813636\t60.4283320\t1
2033 5.5794667\t60.4280897\t1
2036 "Strip error from mayko format in poscount output",
2040 # }}}
2041 testcmd("../gpst -o xgraph date_error.mayko", # {{{
2042 <<END,
2043 5.5794667 60.4280897
2044 5.5802255 60.4281867
2045 5.5813636 60.4283320
2046 5.5817430 60.4283806
2049 "Strip error from mayko format in xgraph output",
2053 # }}}
2054 testcmd("../gpst -o ygraph date_error.mayko", # {{{
2055 <<END,
2056 "Time = 0.0
2057 5.5794667 60.4280897
2059 "Time = 2.0
2060 5.5802255 60.4281867
2062 "Time = 5.0
2063 5.5813636 60.4283320
2065 "Time = 6.0
2066 5.5817430 60.4283806
2070 "Strip error from mayko format in ygraph output",
2074 # }}}
2076 # Strip error from Mayko format }}}
2078 todo_section:
2081 if ($Opt{'all'} || $Opt{'todo'}) {
2082 diag("Running TODO tests..."); # {{{
2084 TODO: {
2085 local $TODO = "Fix read/write of GPX name element";
2086 testcmd("../gpst -o gpx pause.gpx", # {{{
2087 <<END,
2088 $gpx_header
2089 <trk>
2090 <name>ACTIVE LOG164705</name>
2091 <trkseg>
2092 <trkpt lat="60.425494" lon="5.299534"> <ele>25.260</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
2093 <trkpt lat="60.425464" lon="5.299610"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
2094 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
2095 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
2096 <trkpt lat="60.425339" lon="5.299958"> <ele>30.980</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
2097 <trkpt lat="60.425238" lon="5.299640"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
2098 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
2099 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
2100 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
2101 </trkseg>
2102 </trk>
2103 </gpx>
2106 "Read and write name element from/to GPX",
2110 # }}}
2111 local $TODO = "Remove extra \\n in the beginning";
2112 testcmd("../gpst -o csv multitrack.gpx", # {{{
2113 <<END,
2114 2003-02-11T23:35:39Z\t-0.1448824\t51.4968266\t\t
2115 2003-02-11T23:35:49Z\t-0.1449938\t51.4968227\t\t
2116 2003-02-11T23:36:14Z\t-0.1453202\t51.4969040\t\t
2117 \t\t\t\t
2118 2003-02-11T23:36:16Z\t-0.1453398\t51.4969214\t\t
2119 2003-02-11T23:36:31Z\t-0.1455514\t51.4969816\t\t
2120 2003-02-11T23:36:43Z\t-0.1457489\t51.4970224\t1000\t
2121 2003-02-11T23:36:50Z\t-0.1457804\t51.4970452\t\t
2122 \t\t\t\t
2123 2003-02-11T23:37:05Z\t-0.1458608\t51.4970680\t\t
2124 2003-02-11T23:37:22Z\t-0.1460047\t51.4971658\t\t
2125 2003-02-11T23:37:36Z\t-0.1461614\t51.4972469\t\t
2126 \t\t\t\t
2127 2003-02-11T23:37:43Z\t-0.1462394\t51.4972731\t\t
2128 2003-02-11T23:38:04Z\t-0.1463232\t51.4973437\t\t
2129 2003-02-11T23:38:28Z\t-0.1462949\t51.4973337\t\t
2130 2003-02-11T23:38:34Z\t-0.1462825\t51.4973218\t\t
2131 2003-02-11T23:38:35Z\t-0.1462732\t51.4973145\t\t
2134 "Output csv format from multitrack.gpx",
2138 # }}}
2139 testcmd("../gpst -o csv pause.gpx", # {{{
2140 <<END,
2141 2006-05-21T16:49:11Z\t5.299534\t60.425494\t25.260\t
2142 2006-05-21T16:49:46Z\t5.299610\t60.425464\t24.931\t
2143 2006-05-21T16:52:04Z\t5.299694\t60.425314\t27.975\t
2144 2006-05-21T16:56:36Z\t5.299741\t60.425384\t31.017\t
2145 2006-05-21T16:56:47Z\t5.299958\t60.425339\t30.980\t
2146 2006-05-21T16:56:56Z\t5.299640\t60.425238\t30.538\t
2147 2006-05-21T16:57:03Z\t5.299686\t60.425246\t30.515\t
2148 2006-05-21T16:59:08Z\t5.299773\t60.425345\t31.936\t
2149 2006-05-21T17:00:54Z\t5.299419\t60.425457\t31.794\t
2152 "Output csv format from pause.gpx",
2156 # }}}
2157 testcmd("../gpst -e -o csv pause.gpx", # {{{
2158 <<END,
2159 1148230151\t5.299534\t60.425494\t25.260\t
2160 1148230186\t5.299610\t60.425464\t24.931\t
2161 1148230324\t5.299694\t60.425314\t27.975\t
2162 1148230596\t5.299741\t60.425384\t31.017\t
2163 1148230607\t5.299958\t60.425339\t30.980\t
2164 1148230616\t5.299640\t60.425238\t30.538\t
2165 1148230623\t5.299686\t60.425246\t30.515\t
2166 1148230748\t5.299773\t60.425345\t31.936\t
2167 1148230854\t5.299419\t60.425457\t31.794\t
2170 "csv format with epoch seconds from gpx",
2174 # }}}
2175 $TODO = "Tweak output";
2176 testcmd("../gpst -o gpx multitrack-pause.gpsml", # {{{
2177 file_data("multitrack-pause.gpx"),
2179 "Should be equal to multitrack-pause.gpx",
2183 # }}}
2184 $TODO = 'Fix it.';
2185 # list_nearest_waypoints() {{{
2187 like(list_nearest_waypoints(60.42541, 5.29959, 3),
2188 qr/^\(.*,.*,.*\)$/,
2189 "list_nearest_waypoints()"
2192 # }}}
2194 # TODO tests }}}
2197 diag("Testing finished.");
2199 sub testcmd {
2200 # {{{
2201 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc, $is_gpx) = @_;
2202 my $stderr_cmd = "";
2203 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2204 my $Txt = join("",
2205 "\"$Cmd\"",
2206 defined($Desc)
2207 ? " - $Desc"
2208 : ""
2210 my $TMP_STDERR = "gpst-stderr.tmp";
2211 my $TMP_STDOUT = "gpst-stdout.tmp";
2213 if (defined($Exp_stderr) && !length($deb_str)) {
2214 $stderr_cmd = " 2>$TMP_STDERR";
2216 system("$Cmd$deb_str$stderr_cmd >$TMP_STDOUT");
2217 is(file_data($TMP_STDOUT), $Exp_stdout, $Txt);
2218 if ($is_gpx) {
2219 validate_gpx($TMP_STDOUT, $Desc);
2221 if (defined($Exp_stderr)) {
2222 if (!length($deb_str)) {
2223 is(file_data($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
2224 unlink($TMP_STDERR);
2226 } else {
2227 diag("Warning: stderr not defined for '$Txt'");
2229 unlink($TMP_STDOUT);
2230 # }}}
2231 } # testcmd()
2233 sub likecmd {
2234 # {{{
2235 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
2236 my $stderr_cmd = "";
2237 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2238 my $Txt = join("",
2239 "\"$Cmd\"",
2240 defined($Desc)
2241 ? " - $Desc"
2242 : ""
2244 my $TMP_STDERR = "gpst-stderr.tmp";
2246 if (defined($Exp_stderr) && !length($deb_str)) {
2247 $stderr_cmd = " 2>$TMP_STDERR";
2249 like(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
2250 if (defined($Exp_stderr)) {
2251 if (!length($deb_str)) {
2252 like(file_data($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
2253 unlink($TMP_STDERR);
2255 } else {
2256 diag("Warning: stderr not defined for '$Txt'");
2258 # }}}
2259 } # likecmd()
2261 sub file_data {
2262 # Return file content as a string {{{
2263 my $File = shift;
2264 my $Txt;
2265 if (open(FP, "<", $File)) {
2266 $Txt = join("", <FP>);
2267 close(FP);
2268 return($Txt);
2269 } else {
2270 return undef;
2272 # }}}
2273 } # file_data()
2275 sub validate_gpx {
2276 # Check that a file is valid GPX {{{
2277 my ($File, $Txt) = @_;
2278 my $TMP_VALID = "validate_result.tmp";
2279 my $Result = system("xmllint --noout --schema ../Tools/xsd/gpx/gpx-1.1.xsd $File 2>$TMP_VALID");
2280 is($Result, 0, "GPX for \"$Txt\" validates");
2281 if ($Result) {
2282 diag(file_data($TMP_VALID));
2284 unlink($TMP_VALID);
2285 # }}}
2286 } # validate_gpx()
2288 sub print_version {
2289 # Print program version {{{
2290 print("$progname v$VERSION\n");
2291 # }}}
2292 } # print_version()
2294 sub usage {
2295 # Send the help message to stdout {{{
2296 my $Retval = shift;
2298 if ($Opt{'verbose'}) {
2299 print("\n");
2300 print_version();
2302 print(<<END);
2304 Usage: $progname [options] [file [files [...]]]
2306 Contains tests for the gpst(1) program.
2308 Options:
2310 -a, --all
2311 Run all tests, also TODOs.
2312 -h, --help
2313 Show this help.
2314 -t, --todo
2315 Run only the TODO tests.
2316 -v, --verbose
2317 Increase level of verbosity. Can be repeated.
2318 --version
2319 Print version information.
2320 --debug
2321 Print debugging messages.
2324 exit($Retval);
2325 # }}}
2326 } # usage()
2328 sub msg {
2329 # Print a status message to stderr based on verbosity level {{{
2330 my ($verbose_level, $Txt) = @_;
2332 if ($Opt{'verbose'} >= $verbose_level) {
2333 print(STDERR "$progname: $Txt\n");
2335 # }}}
2336 } # msg()
2338 __END__
2340 # Plain Old Documentation (POD) {{{
2342 =pod
2344 =head1 NAME
2346 run-tests.pl
2348 =head1 SYNOPSIS
2350 run-tests.pl [options] [file [files [...]]]
2352 =head1 DESCRIPTION
2354 Contains tests for the gpst(1) program.
2356 =head1 OPTIONS
2358 =over 4
2360 =item B<-a>, B<--all>
2362 Run all tests, also TODOs.
2364 =item B<-h>, B<--help>
2366 Print a brief help summary.
2368 =item B<-t>, B<--todo>
2370 Run only the TODO tests.
2372 =item B<-v>, B<--verbose>
2374 Increase level of verbosity. Can be repeated.
2376 =item B<--version>
2378 Print version information.
2380 =item B<--debug>
2382 Print debugging messages.
2384 =back
2386 =head1 AUTHOR
2388 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
2390 =head1 COPYRIGHT
2392 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
2393 This is free software; see the file F<COPYING> for legalese stuff.
2395 =head1 LICENCE
2397 This program is free software: you can redistribute it and/or modify it
2398 under the terms of the GNU General Public License as published by the
2399 Free Software Foundation, either version 3 of the License, or (at your
2400 option) any later version.
2402 This program is distributed in the hope that it will be useful, but
2403 WITHOUT ANY WARRANTY; without even the implied warranty of
2404 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2405 See the GNU General Public License for more details.
2407 You should have received a copy of the GNU General Public License along
2408 with this program.
2409 If not, see L<http://www.gnu.org/licenses/>.
2411 =head1 SEE ALSO
2413 gpst(1)
2415 =cut
2417 # }}}
2419 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :