Remove "No Id with only -h" from all tests.
[gpstools.git] / tests / run-tests.pl
blob3ae8b022f70d1d91b7f35fbc5f31068510e4649c
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://svn.sunbase.org/repos/utils/trunk/src/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",
101 # }}}
103 =cut
105 diag("Testing conversion routines...");
107 # txt_to_xml() and xml_to_txt() {{{
109 is(txt_to_xml("abc"),
110 "abc",
111 "txt_to_xml(\"abc\")");
112 is(txt_to_xml("<&>"),
113 "&lt;&amp;&gt;",
114 "txt_to_xml(\"<&>\")");
115 is(txt_to_xml("first line\nsecond <\rthird\r\n<&>"),
116 "first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;",
117 "txt_to_xml() with multiline string");
119 is(xml_to_txt("abc"),
120 "abc",
121 "xml_to_txt(\"abc\")");
122 is(xml_to_txt("&lt;&amp;&gt;"),
123 "<&>",
124 "xml_to_txt(\"&lt;&amp;&gt;\")");
125 is(xml_to_txt("first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;"),
126 "first line\nsecond <\rthird\r\n<&>",
127 "xml_to_txt() with multiline string");
129 # txt_to_xml() and xml_to_txt() }}}
130 # postgresql_copy_safe() {{{
132 is(postgresql_copy_safe(""),
134 "postgresql_copy_safe() with empty string");
136 is(postgresql_copy_safe("abcæøåÆØÅ"),
137 "abcæøåÆØÅ",
138 "postgresql_copy_safe(\"abcæøåÆØÅ\")");
140 is(postgresql_copy_safe("abc\t'\r\n"),
141 "abc\\t'\\r\\n",
142 "postgresql_copy_safe(\"abc\\t'\\r\\n\")");
144 is(postgresql_copy_safe("¤%/&gurgle\t325\\wer\ndfv'\r!\"#\n%\twe\r\x00sdf\xFFsadc\n\t\x00sdc\n"),
145 "¤%/&gurgle\\t325\\\\wer\\ndfv'\\r!\"#\\n%\\twe\\r\x00sdf\xFFsadc\\n\\t\x00sdc\\n",
146 "postgresql_copy_safe() with multiline, nulls and stuff");
148 # postgresql_copy_safe() }}}
150 diag("Testing date routines...");
152 # sec_to_string() {{{
154 is(sec_to_string(1148220825),
155 "2006-05-21 14:13:45",
156 "sec_to_string() without separator");
157 is(sec_to_string(1148220825, "T"),
158 "2006-05-21T14:13:45",
159 "sec_to_string() with separator");
160 is(sec_to_string(-5000),
161 undef,
162 "sec_to_string(-5000) — negative numbers unsupported atm");
163 is(sec_to_string(""),
164 undef,
165 "sec_to_string(\"\")");
166 is(sec_to_string("pH()rtY tW0"),
167 undef,
168 "sec_to_string() with invalid string");
169 is(sec_to_string("00000000000000000000001148220825"),
170 "2006-05-21 14:13:45",
171 "sec_to_string() with a bunch of leading zeros");
172 is(sec_to_string("1148220825.93"),
173 "2006-05-21 14:13:45.93",
174 "sec_to_string() with decimals");
175 is(sec_to_string("000000000000000000000000000001148220825.7312"),
176 "2006-05-21 14:13:45.7312",
177 "sec_to_string() with decimals and prefixing zeros");
178 is(sec_to_string("1148220825.93000"),
179 "2006-05-21 14:13:45.93",
180 "sec_to_string() with decimals and extra trailing zeros");
181 is(sec_to_string(".863"),
182 "1970-01-01 00:00:00.863",
183 "sec_to_string() with missing zero before decimal point");
185 # sec_to_string() }}}
186 # sec_to_readable() {{{
188 is(sec_to_readable(0),
189 "0:00:00:00",
190 "sec_to_readable(0)");
191 is(sec_to_readable("pH()rtY tW0"),
192 undef,
193 "sec_to_readable() with invalid string");
194 is(sec_to_readable(86400),
195 "1:00:00:00",
196 "sec_to_readable(86400)");
197 is(sec_to_readable(86400*1000),
198 "1000:00:00:00",
199 "sec_to_readable(86400*1000)");
200 is(sec_to_readable(86400+7200+180+4),
201 "1:02:03:04",
202 "sec_to_readable(86400+7200+180+4)");
203 is(sec_to_readable("3.14"),
204 "0:00:00:03.14",
205 "sec_to_readable(\"3.14\")");
206 is(sec_to_readable("-124"),
207 undef,
208 "sec_to_readable() rejects negative numbers");
209 is(sec_to_readable("-2.34"),
210 undef,
211 "sec_to_readable() rejects negative decimal");
212 is(sec_to_readable(".87"),
213 "0:00:00:00.87",
214 "sec_to_readable(), missing zero before decimal point");
215 is(sec_to_readable(""),
216 "0:00:00:00",
217 "sec_to_readable() with empty string");
219 # sec_to_readable() }}}
221 diag("Testing geo routines...");
223 # ddd_to_dms() {{{
225 is(ddd_to_dms("12.34567"),
226 "12\xB020'44.4\"",
227 "ddd_to_dms(\"12.34567\")");
229 is(ddd_to_dms("0"),
230 "0\xB000'00.0\"",
231 "ddd_to_dms(\"0\")");
233 is(ddd_to_dms(""),
234 "0\xB000'00.0\"",
235 "ddd_to_dms(\"\")");
237 is(ddd_to_dms("pH()rtY tW0"),
238 undef,
239 "ddd_to_dms(\"pH()rtY tW0\")");
241 is(ddd_to_dms("-12.34567"),
242 "-12\xB020'44.4\"",
243 "ddd_to_dms(\"-12.34567\")");
245 is(ddd_to_dms("0.34567"),
246 "0\xB020'44.4\"",
247 "ddd_to_dms(\"0.34567\")");
249 is(ddd_to_dms(".34567"),
250 "0\xB020'44.4\"",
251 "ddd_to_dms(\".34567\")");
253 is(ddd_to_dms("-.34567"),
254 "-0\xB020'44.4\"",
255 "ddd_to_dms(\"-.34567\")");
257 is(ddd_to_dms("-0.34567"),
258 "-0\xB020'44.4\"",
259 "ddd_to_dms(\"-0.34567\")");
261 is(ddd_to_dms("180"),
262 "180\xB000'00.0\"",
263 "ddd_to_dms(\"180\")");
265 is(ddd_to_dms("-180"),
266 "-180\xB000'00.0\"",
267 "ddd_to_dms(\"-180\")");
269 is(ddd_to_dms("-1"),
270 "-1\xB000'00.0\"",
271 "ddd_to_dms(\"-1\")");
273 is(ddd_to_dms("2-3"),
274 undef,
275 "ddd_to_dms(\"2-3\")");
277 # ddd_to_dms() }}}
279 diag("Testing trackpoint()..."); # {{{
281 my %Dat = ();
283 is(trackpoint(%Dat),
284 undef,
285 "trackpoint() receives empty hash");
287 my %Bck = (
288 # {{{
289 'format' => 'gpsml',
290 'year' => '2003',
291 'month' => '06',
292 'day' => '13',
293 'hour' => '14',
294 'min' => '36',
295 'sec' => '10',
296 'lat' => '59.5214',
297 'lon' => '7.392133',
298 'ele' => '762',
299 'error' => "",
300 'what' => 'tp',
301 # }}}
304 # trackpoint() (gpsml) {{{
305 %Dat = %Bck;
307 trackpoint(%Dat),
308 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
309 "trackpoint() (gpsml)"
312 # trackpoint() (gpsml) }}}
313 # trackpoint() (gpx) {{{
314 %Dat = %Bck;
315 $Dat{'format'} = "gpx";
317 trackpoint(%Dat),
318 qq{ <trkpt lat="59.5214" lon="7.392133"> <ele>762</ele> <time>2003-06-13T14:36:10Z</time> </trkpt>\n},
319 "trackpoint() (gpx)"
322 # trackpoint() (gpx) }}}
324 # trackpoint(): Various loop tests {{{
326 for my $Elem (qw{format lat lon what}) {
327 my %Dat = %Bck;
329 $Dat{"$Elem"} = '2d';
330 is(trackpoint(%Dat),
331 undef,
332 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") returns undef"
337 for my $Elem (qw{year month day hour min sec}) {
338 # Date tests {{{
339 my %Dat;
341 %Dat = %Bck;
342 $Dat{"$Elem"} = '';
343 is(trackpoint(%Dat),
344 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
345 "trackpoint(): {'$Elem'} with empty value skips time"
348 %Dat = %Bck;
349 $Dat{"$Elem"} = '2d';
350 is(trackpoint(%Dat),
351 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
352 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") skips time"
355 %Dat = %Bck;
356 $Dat{$Elem} = "00000$Dat{$Elem}";
357 is(trackpoint(%Dat),
358 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
359 "trackpoint(): Strip prefixing zeros from {'$Elem'}"
362 %Dat = %Bck;
363 $Dat{"$Elem"} = 0-$Dat{$Elem};
364 is(trackpoint(%Dat),
365 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
366 "trackpoint(): {'$Elem'} is negative, skip time"
369 if ($Elem ne "sec") {
370 %Dat = %Bck;
371 $Dat{"$Elem"} = "$Dat{$Elem}.00";
372 is(trackpoint(%Dat),
373 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
374 "trackpoint(): Decimals in {'$Elem'}, skip time"
378 # Date tests }}}
381 %Dat = %Bck;
382 $Dat{'sec'} = "$Dat{'sec'}.00";
383 is(trackpoint(%Dat),
384 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
385 "trackpoint(): Remove trailing zeros in {'sec'} decimals"
388 for my $Elem (qw{format what error}) {
389 my %Dat = %Bck;
390 $Dat{$Elem} = undef;
391 is(trackpoint(%Dat),
392 undef,
393 "trackpoint(): Missing {'$Elem'}, return undef"
397 # Various loop tests }}}
399 # trackpoint() }}}
401 diag("Testing output from ../gpst");
403 diag("Read empty input (/dev/null)..."); # {{{
404 testcmd("../gpst </dev/null", # {{{
405 <<END,
406 <?xml version="1.0" encoding="UTF-8"?>
407 <gpsml>
408 <track>
409 </track>
410 </gpsml>
413 "Read from /dev/null",
416 # }}}
417 testcmd("../gpst -o gpx </dev/null", # {{{
418 <<END,
419 $gpx_header
420 <trk>
421 <trkseg>
422 </trkseg>
423 </trk>
424 </gpx>
427 "Output gpx from /dev/null",
430 # }}}
431 # empty input }}}
432 diag("Read empty files..."); # {{{
433 testcmd("echo '<tp> </tp>' | ../gpst", # {{{
434 <<END,
435 <?xml version="1.0" encoding="UTF-8"?>
436 <gpsml>
437 <track>
438 </track>
439 </gpsml>
442 "Don’t print empty trackpoints",
445 # }}}
446 # Read empty files }}}
447 diag("Testing --chronology option..."); # {{{
448 testcmd("../gpst --chronology chronology-error.gpsml", # {{{
449 <<END,
450 <?xml version="1.0" encoding="UTF-8"?>
451 <gpsml>
452 <track>
453 <title>Chronology errors</title>
454 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
455 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
456 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
457 <break/>
458 <tp> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </tp>
459 <break/>
460 <pause>0:00:37:54</pause>
461 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
462 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
463 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
464 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
465 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
466 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
467 </track>
468 </gpsml>
470 "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" .
471 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
472 "Check for chronology errors and duplicated times",
475 # }}}
476 # --chronology option }}}
477 diag("Testing --skip-dups option..."); # {{{
478 testcmd("../gpst -d no_signal.mayko", # {{{
479 <<END,
480 <?xml version="1.0" encoding="UTF-8"?>
481 <gpsml>
482 <track>
483 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
484 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
485 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
486 <etp err="dup"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
487 <etp err="dup"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
488 <etp err="dup"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
489 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
490 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
491 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
492 </track>
493 </gpsml>
496 "Remove duplicated positions from gpsml",
499 # }}}
500 testcmd("../gpst -d -o csv no_signal.mayko", # {{{
501 <<END,
502 2002-12-22T21:42:24Z\t23.6746151\t70.6800486\t\t
503 2002-12-22T21:42:32Z\t23.6740038\t70.6799322\t\t
504 2002-12-22T21:42:54Z\t23.6723991\t70.6796266\t\t
505 2002-12-22T21:44:45Z\t23.6757566\t70.6800774\t\t
506 2002-12-22T21:44:52Z\t23.6753442\t70.6801502\t\t
507 2002-12-22T21:45:04Z\t23.6757542\t70.6801905\t\t
510 "Remove duplicated positions from csv output format",
513 # }}}
514 testcmd("../gpst -d -o clean no_signal.mayko", # {{{
515 <<END,
516 23.6746151\t70.6800486\t
517 23.6740038\t70.6799322\t
518 23.6723991\t70.6796266\t
519 23.6757566\t70.6800774\t
520 23.6753442\t70.6801502\t
521 23.6757542\t70.6801905\t
524 "Remove duplicated positions from clean output format",
527 # }}}
528 testcmd("../gpst -d -o pgtab no_signal.mayko", # {{{
529 <<END,
530 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N
531 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N
532 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
533 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N
534 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N
535 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N
538 "Remove duplicated positions from pgtab output format",
541 # }}}
542 # --skip-dups option }}}
543 diag("Testing --epoch option..."); # {{{
544 testcmd("../gpst -e pause.gpx", # {{{
545 <<END,
546 <?xml version="1.0" encoding="UTF-8"?>
547 <gpsml>
548 <track>
549 <title>ACTIVE LOG164705</title>
550 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
551 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
552 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
553 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
554 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
555 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
556 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
557 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
558 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
559 </track>
560 </gpsml>
563 "--epoch is ignored in gpsml output",
566 # }}}
567 testcmd("../gpst -e -o gpx pause-noname.gpx", # {{{
568 <<END,
569 $gpx_header
570 <trk>
571 <trkseg>
572 <trkpt lat="60.425494" lon="5.299534"> <ele>25.260</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
573 <trkpt lat="60.425464" lon="5.299610"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
574 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
575 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
576 <trkpt lat="60.425339" lon="5.299958"> <ele>30.980</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
577 <trkpt lat="60.425238" lon="5.299640"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
578 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
579 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
580 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
581 </trkseg>
582 </trk>
583 </gpx>
586 "--epoch is ignored in gpx output",
589 # }}}
590 # --epoch option }}}
591 diag("Testing --fix option..."); # {{{
592 testcmd("../gpst --fix --chronology chronology-error.gpsml", # {{{
593 <<END,
594 <?xml version="1.0" encoding="UTF-8"?>
595 <gpsml>
596 <track>
597 <title>Chronology errors</title>
598 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
599 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
600 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
601 <break/>
602 <etp err="chrono"> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </etp>
603 <break/>
604 <pause>0:00:37:54</pause>
605 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
606 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
607 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
608 <etp err="duptime"> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </etp>
609 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
610 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
611 </track>
612 </gpsml>
614 "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" .
615 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
616 "Remove bad timestamps",
619 # }}}
620 # --fix option }}}
621 diag("Testing --from-date option..."); # {{{
622 # --from-date option }}}
623 diag("Testing -h (--help) option...");
624 likecmd("$CMD -h", # {{{
625 '/ Show this help\./',
626 '/^$/',
627 "Option -h prints help screen",
630 # }}}
631 # --help option }}}
632 diag("Testing --inside option..."); # {{{
633 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx", # {{{
634 <<END,
635 <?xml version="1.0" encoding="UTF-8"?>
636 <gpsml>
637 <track>
638 <title>track1</title>
639 <break/>
640 <title>track2</title>
641 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
642 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
643 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
644 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
645 <break/>
646 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
647 <break/>
648 <title>track3</title>
649 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
650 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
651 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
652 </track>
653 </gpsml>
656 "Check --inside option (gpx to gpst)",
658 # }}}
660 # --inside option }}}
661 diag("Testing --undefined option..."); # {{{
662 # --undefined option }}}
663 diag("Testing --near option..."); # {{{
664 # --near option }}}
665 diag("Testing --output option..."); # {{{
666 # gpsml (Default)
667 testcmd("../gpst log.mcsv", # {{{
668 <<END,
669 <?xml version="1.0" encoding="UTF-8"?>
670 <gpsml>
671 <track>
672 <break/>
673 <title>ACTIVE LOG 125</title>
674 <tp> <time>2006-03-04T11:12:30Z</time> <lat>54.96883</lat> <lon>-1.62439</lon> <ele>77</ele> </tp>
675 <tp> <time>2006-03-04T11:12:47Z</time> <lat>54.96878</lat> <lon>-1.62413</lon> <ele>77</ele> </tp>
676 <tp> <time>2006-03-04T11:12:55Z</time> <lat>54.96913</lat> <lon>-1.62616</lon> <ele>77</ele> </tp>
677 <tp> <time>2006-03-04T11:13:04Z</time> <lat>54.96934</lat> <lon>-1.62624</lon> <ele>77.5</ele> </tp>
678 <tp> <time>2006-03-04T11:13:33Z</time> <lat>54.96934</lat> <lon>-1.62596</lon> <ele>78</ele> </tp>
679 <tp> <time>2006-03-04T11:13:48Z</time> <lat>54.96931</lat> <lon>-1.62645</lon> <ele>78</ele> </tp>
680 <tp> <time>2006-03-04T11:14:05Z</time> <lat>54.96918</lat> <lon>-1.62603</lon> <ele>79</ele> </tp>
681 <tp> <time>2006-03-04T11:14:33Z</time> <lat>54.96901</lat> <lon>-1.62364</lon> <ele>76.1</ele> </tp>
682 <tp> <time>2006-03-04T11:15:02Z</time> <lat>54.96922</lat> <lon>-1.6254</lon> <ele>76.1</ele> </tp>
683 <tp> <time>2006-03-04T11:15:27Z</time> <lat>54.96914</lat> <lon>-1.62526</lon> <ele>75.1</ele> </tp>
684 <tp> <time>2006-03-04T11:15:50Z</time> <lat>54.96911</lat> <lon>-1.62494</lon> <ele>75.1</ele> </tp>
685 <tp> <time>2006-03-04T11:16:03Z</time> <lat>54.9693</lat> <lon>-1.62489</lon> <ele>75.1</ele> </tp>
686 <tp> <time>2006-03-04T11:16:19Z</time> <lat>54.96901</lat> <lon>-1.62496</lon> <ele>75.1</ele> </tp>
687 <tp> <time>2006-03-04T11:16:52Z</time> <lat>54.96871</lat> <lon>-1.62466</lon> <ele>74.6</ele> </tp>
688 <tp> <time>2006-03-04T11:17:25Z</time> <lat>54.96908</lat> <lon>-1.62488</lon> <ele>72.7</ele> </tp>
689 <break/>
690 <title>ACTIVE LOG 126</title>
691 <tp> <time>2006-03-04T11:18:32Z</time> <lat>54.96904</lat> <lon>-1.62482</lon> <ele>72.7</ele> </tp>
692 <tp> <time>2006-03-04T11:18:35Z</time> <lat>54.96913</lat> <lon>-1.62499</lon> <ele>71.3</ele> </tp>
693 <tp> <time>2006-03-04T11:18:38Z</time> <lat>54.96904</lat> <lon>-1.62497</lon> <ele>70.8</ele> </tp>
694 <tp> <time>2006-03-04T11:18:48Z</time> <lat>54.96913</lat> <lon>-1.62496</lon> <ele>71.8</ele> </tp>
695 <tp> <time>2006-03-04T11:18:55Z</time> <lat>54.96924</lat> <lon>-1.62501</lon> <ele>72.2</ele> </tp>
696 <tp> <time>2006-03-04T11:19:11Z</time> <lat>54.9694</lat> <lon>-1.62521</lon> <ele>71.8</ele> </tp>
697 <tp> <time>2006-03-04T11:19:30Z</time> <lat>54.96916</lat> <lon>-1.62515</lon> <ele>71.3</ele> </tp>
698 <tp> <time>2006-03-04T11:19:53Z</time> <lat>54.96921</lat> <lon>-1.625</lon> <ele>71.3</ele> </tp>
699 <tp> <time>2006-03-04T11:20:21Z</time> <lat>54.96801</lat> <lon>-1.62417</lon> <ele>71.8</ele> </tp>
700 <break/>
701 <title>ACTIVE LOG 127</title>
702 <tp> <time>2006-03-04T11:21:16Z</time> <lat>54.96887</lat> <lon>-1.62504</lon> <ele>70.8</ele> </tp>
703 <tp> <time>2006-03-04T11:21:18Z</time> <lat>54.96898</lat> <lon>-1.62476</lon> <ele>69.8</ele> </tp>
704 <tp> <time>2006-03-04T11:21:29Z</time> <lat>54.9691</lat> <lon>-1.62475</lon> <ele>69.4</ele> </tp>
705 <tp> <time>2006-03-04T11:21:46Z</time> <lat>54.96918</lat> <lon>-1.62468</lon> <ele>70.3</ele> </tp>
706 <tp> <time>2006-03-04T11:22:39Z</time> <lat>54.9692</lat> <lon>-1.62465</lon> <ele>69.4</ele> </tp>
707 <tp> <time>2006-03-04T11:22:43Z</time> <lat>54.96924</lat> <lon>-1.62462</lon> <ele>71.8</ele> </tp>
708 <tp> <time>2006-03-04T11:22:45Z</time> <lat>54.96928</lat> <lon>-1.62463</lon> <ele>71.8</ele> </tp>
709 <tp> <time>2006-03-04T11:23:00Z</time> <lat>54.96945</lat> <lon>-1.62466</lon> <ele>69.4</ele> </tp>
710 </track>
711 </gpsml>
714 "Read Mapsource TAB-separated format",
717 # }}}
718 testcmd("../gpst two-digit_year.mcsv", # {{{
719 <<END,
720 <?xml version="1.0" encoding="UTF-8"?>
721 <gpsml>
722 <track>
723 <break/>
724 <title>ACTIVE LOG 032</title>
725 <tp> <time>2006-03-20T20:35:33Z</time> <lat>60.41324</lat> <lon>5.33352</lon> <ele>14</ele> </tp>
726 <tp> <time>2006-03-20T20:35:38Z</time> <lat>60.38802</lat> <lon>5.33845</lon> <ele>18</ele> </tp>
727 <tp> <time>2006-03-20T20:35:44Z</time> <lat>60.38709</lat> <lon>5.3379</lon> <ele>19</ele> </tp>
728 <tp> <time>2006-03-20T20:35:49Z</time> <lat>60.38641</lat> <lon>5.33732</lon> <ele>18</ele> </tp>
729 <tp> <time>2006-03-20T20:35:54Z</time> <lat>60.38581</lat> <lon>5.33647</lon> <ele>18</ele> </tp>
730 <tp> <time>2006-03-20T20:36:00Z</time> <lat>60.38516</lat> <lon>5.33528</lon> <ele>15</ele> </tp>
731 <tp> <time>2006-03-20T20:36:02Z</time> <lat>60.38495</lat> <lon>5.3349</lon> <ele>13</ele> </tp>
732 </track>
733 </gpsml>
736 "Read Mapsource TAB-separated format with two-digit year",
739 # }}}
740 testcmd("../gpst log.gpstxt", # {{{
741 <<END,
742 <?xml version="1.0" encoding="UTF-8"?>
743 <gpsml>
744 <track>
745 <tp> <time>2003-06-13T14:36:09Z</time> <lat>59.521517</lat> <lon>7.391867</lon> <ele>762</ele> </tp>
746 <tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>
747 <tp> <time>2003-06-13T14:36:11Z</time> <lat>59.5213</lat> <lon>7.392417</lon> <ele>761</ele> </tp>
748 <tp> <time>2003-06-13T14:36:12Z</time> <lat>59.521183</lat> <lon>7.3927</lon> <ele>761</ele> </tp>
749 <etp err="nosignal"> <time>2003-06-13T14:36:13Z</time> </etp>
750 <tp> <time>2003-06-13T14:36:15Z</time> <lat>59.52085</lat> <lon>7.393517</lon> <ele>760</ele> </tp>
751 <tp> <time>2003-06-13T14:36:16Z</time> <lat>59.520733</lat> <lon>7.393783</lon> <ele>760</ele> </tp>
752 <tp> <time>2003-06-13T14:36:17Z</time> <lat>59.52065</lat> <lon>7.39405</lon> <ele>760</ele> </tp>
753 <tp> <time>2003-06-13T14:36:18Z</time> <lat>59.520583</lat> <lon>7.394333</lon> <ele>760</ele> </tp>
754 <tp> <time>2003-06-13T14:36:19Z</time> <lat>59.520533</lat> <lon>7.394633</lon> <ele>759</ele> </tp>
755 <tp> <time>2003-06-13T14:36:20Z</time> <lat>59.520483</lat> <lon>7.394917</lon> <ele>759</ele> </tp>
756 <tp> <time>2003-06-13T14:36:21Z</time> <lat>59.520433</lat> <lon>7.395233</lon> <ele>759</ele> </tp>
757 <etp err="nosignal"> <time>2003-06-13T14:36:22Z</time> </etp>
758 <tp> <time>2003-06-13T14:36:24Z</time> <lat>59.520283</lat> <lon>7.396233</lon> <ele>758</ele> </tp>
759 <tp> <time>2003-06-13T14:36:25Z</time> <lat>59.520233</lat> <lon>7.39655</lon> <ele>758</ele> </tp>
760 <tp> <time>2003-06-13T14:36:26Z</time> <lat>59.520183</lat> <lon>7.396883</lon> <ele>757</ele> </tp>
761 <tp> <time>2003-06-13T14:36:27Z</time> <lat>59.520133</lat> <lon>7.397217</lon> <ele>757</ele> </tp>
762 <tp> <time>2003-06-13T14:36:28Z</time> <lat>59.5201</lat> <lon>7.397567</lon> <ele>757</ele> </tp>
763 </track>
764 </gpsml>
767 "Read Garmin serial text format",
770 # }}}
771 testcmd("../gpst log.dos.mayko", # {{{
772 <<END,
773 <?xml version="1.0" encoding="UTF-8"?>
774 <gpsml>
775 <track>
776 <tp> <time>2003-06-15T10:27:45Z</time> <lat>58.1818158</lat> <lon>8.1225077</lon> </tp>
777 <tp> <time>2003-06-15T10:27:53Z</time> <lat>58.1818712</lat> <lon>8.12532</lon> </tp>
778 <tp> <time>2003-06-15T10:27:57Z</time> <lat>58.1816347</lat> <lon>8.1266031</lon> </tp>
779 <tp> <time>2003-06-15T10:28:03Z</time> <lat>58.1812099</lat> <lon>8.1284612</lon> </tp>
780 <tp> <time>2003-06-15T10:28:06Z</time> <lat>58.1810315</lat> <lon>8.129395</lon> </tp>
781 <tp> <time>2003-06-15T10:28:10Z</time> <lat>58.1809621</lat> <lon>8.13074</lon> </tp>
782 </track>
783 </gpsml>
786 "Read DOS-formatted Mayko format",
789 # }}}
790 testcmd("../gpst log.dos.gpstxt", # {{{
791 <<END,
792 <?xml version="1.0" encoding="UTF-8"?>
793 <gpsml>
794 <track>
795 <tp> <time>2003-01-05T16:47:11Z</time> <lat>66.908167</lat> <lon>15.022983</lon> <ele>11472</ele> </tp>
796 <tp> <time>2003-01-05T16:47:12Z</time> <lat>66.90625</lat> <lon>15.020667</lon> <ele>11472</ele> </tp>
797 <tp> <time>2003-01-05T16:47:13Z</time> <lat>66.904317</lat> <lon>15.01835</lon> <ele>11472</ele> </tp>
798 <tp> <time>2003-01-05T16:47:14Z</time> <lat>66.9024</lat> <lon>15.016017</lon> <ele>11473</ele> </tp>
799 <tp> <time>2003-01-05T16:47:15Z</time> <lat>66.900483</lat> <lon>15.0137</lon> <ele>11474</ele> </tp>
800 <tp> <time>2003-01-05T16:47:16Z</time> <lat>66.898567</lat> <lon>15.011383</lon> <ele>11474</ele> </tp>
801 <tp> <time>2003-01-05T16:47:17Z</time> <lat>66.896633</lat> <lon>15.009067</lon> <ele>11475</ele> </tp>
802 <tp> <time>2003-01-05T16:47:18Z</time> <lat>66.894717</lat> <lon>15.006733</lon> <ele>11475</ele> </tp>
803 <tp> <time>2003-01-05T16:47:19Z</time> <lat>66.8928</lat> <lon>15.004417</lon> <ele>11475</ele> </tp>
804 <tp> <time>2003-01-05T16:47:20Z</time> <lat>66.890867</lat> <lon>15.0021</lon> <ele>11475</ele> </tp>
805 <tp> <time>2003-01-05T16:47:21Z</time> <lat>66.88895</lat> <lon>14.999783</lon> <ele>11475</ele> </tp>
806 </track>
807 </gpsml>
810 "Read DOS-formatted Garmin serial text format",
813 # }}}
814 testcmd("../gpst log.unix.mcsv", # {{{
815 <<END,
816 <?xml version="1.0" encoding="UTF-8"?>
817 <gpsml>
818 <track>
819 <break/>
820 <title>ACTIVE LOG 058</title>
821 <tp> <time>2006-02-21T15:14:25Z</time> <lat>60.36662</lat> <lon>5.24885</lon> <ele>31.9</ele> </tp>
822 <tp> <time>2006-02-21T15:14:30Z</time> <lat>60.37057</lat> <lon>5.22956</lon> <ele>35.2</ele> </tp>
823 <tp> <time>2006-02-21T15:14:35Z</time> <lat>60.37019</lat> <lon>5.22817</lon> <ele>39.6</ele> </tp>
824 <tp> <time>2006-02-21T15:14:36Z</time> <lat>60.37012</lat> <lon>5.2279</lon> <ele>41</ele> </tp>
825 <tp> <time>2006-02-21T15:14:40Z</time> <lat>60.37009</lat> <lon>5.22682</lon> <ele>47.2</ele> </tp>
826 <tp> <time>2006-02-21T15:14:42Z</time> <lat>60.37011</lat> <lon>5.22641</lon> <ele>49.2</ele> </tp>
827 <tp> <time>2006-02-21T15:14:44Z</time> <lat>60.37011</lat> <lon>5.22607</lon> <ele>50.1</ele> </tp>
828 <tp> <time>2006-02-21T15:14:48Z</time> <lat>60.37002</lat> <lon>5.22568</lon> <ele>51.1</ele> </tp>
829 <tp> <time>2006-02-21T15:14:51Z</time> <lat>60.3701</lat> <lon>5.22548</lon> <ele>52.5</ele> </tp>
830 </track>
831 </gpsml>
834 "Read UNIX-formatted Garmin Mapsource TAB-separated format",
837 # }}}
838 testcmd("../gpst multitrack.gpx", # {{{
839 <<END,
840 <?xml version="1.0" encoding="UTF-8"?>
841 <gpsml>
842 <track>
843 <title>Track 1</title>
844 <tp> <time>2003-02-11T23:35:39Z</time> <lat>51.4968266</lat> <lon>-0.1448824</lon> </tp>
845 <tp> <time>2003-02-11T23:35:49Z</time> <lat>51.4968227</lat> <lon>-0.1449938</lon> </tp>
846 <tp> <time>2003-02-11T23:36:14Z</time> <lat>51.496904</lat> <lon>-0.1453202</lon> </tp>
847 <break/>
848 <title>Track 2</title>
849 <tp> <time>2003-02-11T23:36:16Z</time> <lat>51.4969214</lat> <lon>-0.1453398</lon> </tp>
850 <tp> <time>2003-02-11T23:36:31Z</time> <lat>51.4969816</lat> <lon>-0.1455514</lon> </tp>
851 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
852 <tp> <time>2003-02-11T23:36:50Z</time> <lat>51.4970452</lat> <lon>-0.1457804</lon> </tp>
853 <break/>
854 <title>Track 3</title>
855 <tp> <time>2003-02-11T23:37:05Z</time> <lat>51.497068</lat> <lon>-0.1458608</lon> </tp>
856 <tp> <time>2003-02-11T23:37:22Z</time> <lat>51.4971658</lat> <lon>-0.1460047</lon> </tp>
857 <tp> <time>2003-02-11T23:37:36Z</time> <lat>51.4972469</lat> <lon>-0.1461614</lon> </tp>
858 <break/>
859 <title>Track 4</title>
860 <tp> <time>2003-02-11T23:37:43Z</time> <lat>51.4972731</lat> <lon>-0.1462394</lon> </tp>
861 <tp> <time>2003-02-11T23:38:04Z</time> <lat>51.4973437</lat> <lon>-0.1463232</lon> </tp>
862 <tp> <time>2003-02-11T23:38:28Z</time> <lat>51.4973337</lat> <lon>-0.1462949</lon> </tp>
863 <tp> <time>2003-02-11T23:38:34Z</time> <lat>51.4973218</lat> <lon>-0.1462825</lon> </tp>
864 <tp> <time>2003-02-11T23:38:35Z</time> <lat>51.4973145</lat> <lon>-0.1462732</lon> </tp>
865 </track>
866 </gpsml>
869 "Read GPX file with multiple tracks",
872 # }}}
873 testcmd("../gpst compact.gpx", # {{{
874 <<END,
875 <?xml version="1.0" encoding="UTF-8"?>
876 <gpsml>
877 <track>
878 <title>All whitespace stripped</title>
879 <tp> <time>2002-12-30T15:22:04Z</time> <lat>70.660932</lat> <lon>23.7028354</lon> </tp>
880 <tp> <time>2002-12-30T15:22:06Z</time> <lat>70.6609392</lat> <lon>23.7028468</lon> </tp>
881 <tp> <time>2002-12-30T15:22:08Z</time> <lat>70.6609429</lat> <lon>23.7028499</lon> </tp>
882 <tp> <time>2002-12-30T15:22:11Z</time> <lat>70.6609381</lat> <lon>23.702862</lon> </tp>
883 <tp> <time>2002-12-30T15:22:12Z</time> <lat>70.6609368</lat> <lon>23.7028648</lon> </tp>
884 <tp> <time>2002-12-30T15:22:13Z</time> <lat>70.6609344</lat> <lon>23.7028652</lon> </tp>
885 <tp> <time>2002-12-30T15:22:15Z</time> <lat>70.6609349</lat> <lon>23.7028707</lon> </tp>
886 <tp> <time>2002-12-30T15:22:17Z</time> <lat>70.6609348</lat> <lon>23.7028654</lon> </tp>
887 <tp> <time>2002-12-30T15:22:19Z</time> <lat>70.6609347</lat> <lon>23.7028599</lon> </tp>
888 <tp> <time>2002-12-30T15:22:20Z</time> <lat>70.6609348</lat> <lon>23.7028609</lon> </tp>
889 <tp> <time>2002-12-30T15:22:23Z</time> <lat>70.6609388</lat> <lon>23.7028653</lon> </tp>
890 <tp> <time>2002-12-30T15:22:25Z</time> <lat>70.6609426</lat> <lon>23.7028732</lon> </tp>
891 </track>
892 </gpsml>
895 "Read GPX one-liner",
898 # }}}
899 testcmd("../gpst missing.gpsml", # {{{
900 <<END,
901 <?xml version="1.0" encoding="UTF-8"?>
902 <gpsml>
903 <track>
904 <title>Missing various elements</title>
905 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
906 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
907 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
908 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
909 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
910 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
911 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
912 <tp> <ele>486</ele> </tp>
913 <tp> <desc>Missing everything</desc> </tp>
914 <tp> <lat>60.42339</lat> </tp>
915 <tp> <lon>5.34262</lon> </tp>
916 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
917 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
918 </track>
919 </gpsml>
922 "Read gpsml with various data missing",
925 # }}}
926 testcmd("../gpst different_dateformats.gpsml", # {{{
927 <<END,
928 <?xml version="1.0" encoding="UTF-8"?>
929 <gpsml>
930 <track>
931 <title>Date format variations</title>
932 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1</lat> <lon>1</lon> </tp>
933 <tp> <time>2006-01-01T00:00:02Z</time> <lat>2</lat> <lon>2</lon> </tp>
934 <tp> <time>2006-01-01T00:00:03Z</time> <lat>3</lat> <lon>3</lon> </tp>
935 <tp> <time>2006-01-01T00:00:04Z</time> <lat>4</lat> <lon>4</lon> </tp>
936 </track>
937 </gpsml>
940 "Read different date formats from gpsml file",
943 # }}}
944 testcmd("../gpst multitrack-pause.gpx", # {{{
945 file_data("multitrack-pause.gpsml"),
947 "Should be equal to multitrack-pause.gpsml",
950 # }}}
951 # gpx
952 testcmd("../gpst -o gpx no_signal.mayko", # {{{
953 <<END,
954 $gpx_header
955 <trk>
956 <trkseg>
957 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
958 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
959 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
960 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> </trkpt>
961 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> </trkpt>
962 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> </trkpt>
963 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
964 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
965 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
966 </trkseg>
967 </trk>
968 </gpx>
971 "Output GPX from Mayko file with duplicates",
974 # }}}
975 testcmd("../gpst -o gpx comments.mayko", # {{{
976 <<END,
977 $gpx_header
978 <trk>
979 <trkseg>
980 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
981 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
982 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
983 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
984 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
985 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
986 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
987 </trkseg>
988 <trkseg>
989 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
990 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
991 </trkseg>
992 </trk>
993 </gpx>
996 "Output GPX from Mayko file with commented-out lines",
999 # }}}
1000 testcmd("../gpst -o gpx missing-noname.gpsml", # {{{
1001 <<END,
1002 $gpx_header
1003 <trk>
1004 <trkseg>
1005 <trkpt lat="60.42353" lon="5.34185"> <time>2006-04-30T17:17:09Z</time> </trkpt>
1006 <trkpt> <ele>483</ele> <time>2006-04-30T17:17:11Z</time> </trkpt>
1007 <trkpt> <ele>485</ele> <time>2006-04-30T17:17:22Z</time> </trkpt>
1008 <trkpt lat="60.42347" lon="5.34212"> <ele>486</ele> </trkpt>
1009 <trkpt> <ele>484</ele> </trkpt>
1010 <trkpt> <ele>486</ele> </trkpt>
1011 <trkpt> <ele>490</ele> <time>2006-04-30T17:18:03Z</time> </trkpt>
1012 <trkpt lat="60.42338" lon="5.34269"> <ele>487</ele> <time>2006-04-30T17:18:05Z</time> </trkpt>
1013 </trkseg>
1014 </trk>
1015 </gpx>
1018 "Output GPX from gpsml with missing data",
1021 # }}}
1022 # xgraph
1023 testcmd("../gpst -o xgraph multitrack.gpx", # {{{
1024 <<END,
1025 -0.1448824 51.4968266
1026 -0.1449938 51.4968227
1027 -0.1453202 51.4969040
1028 move -0.1453398 51.4969214
1029 -0.1455514 51.4969816
1030 -0.1457489 51.4970224
1031 -0.1457804 51.4970452
1032 move -0.1458608 51.4970680
1033 -0.1460047 51.4971658
1034 -0.1461614 51.4972469
1035 move -0.1462394 51.4972731
1036 -0.1463232 51.4973437
1037 -0.1462949 51.4973337
1038 -0.1462825 51.4973218
1039 -0.1462732 51.4973145
1042 "Output xgraph format from GPX",
1045 # }}}
1046 # pgtab
1047 testcmd("../gpst -o pgtab compact.gpx", # {{{
1048 <<END,
1049 2002-12-30T15:22:04Z\t(70.6609320,23.7028354)\t\\N\t\\N\t\\N\t\\N
1050 2002-12-30T15:22:06Z\t(70.6609392,23.7028468)\t\\N\t\\N\t\\N\t\\N
1051 2002-12-30T15:22:08Z\t(70.6609429,23.7028499)\t\\N\t\\N\t\\N\t\\N
1052 2002-12-30T15:22:11Z\t(70.6609381,23.7028620)\t\\N\t\\N\t\\N\t\\N
1053 2002-12-30T15:22:12Z\t(70.6609368,23.7028648)\t\\N\t\\N\t\\N\t\\N
1054 2002-12-30T15:22:13Z\t(70.6609344,23.7028652)\t\\N\t\\N\t\\N\t\\N
1055 2002-12-30T15:22:15Z\t(70.6609349,23.7028707)\t\\N\t\\N\t\\N\t\\N
1056 2002-12-30T15:22:17Z\t(70.6609348,23.7028654)\t\\N\t\\N\t\\N\t\\N
1057 2002-12-30T15:22:19Z\t(70.6609347,23.7028599)\t\\N\t\\N\t\\N\t\\N
1058 2002-12-30T15:22:20Z\t(70.6609348,23.7028609)\t\\N\t\\N\t\\N\t\\N
1059 2002-12-30T15:22:23Z\t(70.6609388,23.7028653)\t\\N\t\\N\t\\N\t\\N
1060 2002-12-30T15:22:25Z\t(70.6609426,23.7028732)\t\\N\t\\N\t\\N\t\\N
1063 "Output pgtab from gpx format",
1066 # }}}
1067 testcmd("../gpst -o pgtab no_signal.mayko", # {{{
1068 <<END,
1069 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N
1070 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N
1071 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1072 2002-12-22T21:43:51Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1073 2002-12-22T21:43:52Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1074 2002-12-22T21:43:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1075 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N
1076 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N
1077 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N
1080 "Output pgtab from mayko format",
1083 # }}}
1084 testcmd("../gpst -o pgtab missing.gpsml", # {{{
1085 <<END,
1086 2006-04-30T17:17:09Z\t(60.42353,5.34185)\t\\N\t\\N\t\\N\t\\N
1087 \\N\t(60.42347,5.34212)\t486\t\\N\t\\N\t\\N
1088 2006-04-30T17:18:05Z\t(60.42338,5.34269)\t487\t\\N\t\\N\t\\N
1091 "Output pgtab from missing.gpsml",
1094 # }}}
1095 # csv
1096 testcmd("../gpst -o csv log.dos.mayko", # {{{
1097 <<END,
1098 2003-06-15T10:27:45Z\t8.1225077\t58.1818158\t\t
1099 2003-06-15T10:27:53Z\t8.1253200\t58.1818712\t\t
1100 2003-06-15T10:27:57Z\t8.1266031\t58.1816347\t\t
1101 2003-06-15T10:28:03Z\t8.1284612\t58.1812099\t\t
1102 2003-06-15T10:28:06Z\t8.1293950\t58.1810315\t\t
1103 2003-06-15T10:28:10Z\t8.1307400\t58.1809621\t\t
1106 "Output csv from DOS-formatted Mayko format",
1109 # }}}
1110 # pgwtab
1111 testcmd("../gpst -o pgwtab multitrack.gpx", # {{{
1112 <<END,
1113 (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
1114 (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
1115 (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
1116 (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
1117 (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
1118 (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
1121 "Test pgwtab format",
1124 # }}}
1125 # pgwupd
1126 testcmd("../gpst -o pgwupd multitrack.gpx", # {{{
1127 <<END,
1128 BEGIN;
1129 UPDATE logg SET name = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1130 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1131 COMMIT;
1132 BEGIN;
1133 UPDATE logg SET name = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1134 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1135 COMMIT;
1136 BEGIN;
1137 UPDATE logg SET name = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1138 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1139 COMMIT;
1140 BEGIN;
1141 UPDATE logg SET name = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1142 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1143 COMMIT;
1144 BEGIN;
1145 UPDATE logg SET name = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1146 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1147 COMMIT;
1148 BEGIN;
1149 UPDATE logg SET name = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1150 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1151 COMMIT;
1154 "Test pgwupd format",
1157 # }}}
1158 # clean
1159 testcmd("../gpst -t -o clean pause.gpx", # {{{
1160 <<END,
1161 5.299534\t60.425494\t25.260
1162 5.299610\t60.425464\t24.931
1164 5.299694\t60.425314\t27.975
1166 5.299741\t60.425384\t31.017
1167 5.299958\t60.425339\t30.980
1168 5.299640\t60.425238\t30.538
1169 5.299686\t60.425246\t30.515
1171 5.299773\t60.425345\t31.936
1172 5.299419\t60.425457\t31.794
1175 "Output clean format with time breaks",
1177 # }}}
1178 # gpstrans
1179 # poscount
1180 # ps (Unfinished)
1181 # svg (Unfinished)
1182 # ygraph
1183 # --output option }}}
1184 diag("Testing --outside option..."); # {{{
1185 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --outside multitrack-pause.gpx", # {{{
1186 <<END,
1187 <?xml version="1.0" encoding="UTF-8"?>
1188 <gpsml>
1189 <track>
1190 <title>track1</title>
1191 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1192 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1193 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1194 <break/>
1195 <title>track2</title>
1196 <break/>
1197 <title>track3</title>
1198 <break/>
1199 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1200 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1201 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1202 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1203 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1204 </track>
1205 </gpsml>
1208 "Check --outside option (gpx to gpst)",
1211 # }}}
1212 # --outside option }}}
1213 diag("Testing --pos1 and --pos2 options..."); # {{{
1214 # --pos1 and --pos2 options }}}
1215 diag("Testing --require option..."); # {{{
1216 testcmd("../gpst -re multitrack.gpx", # {{{
1217 <<END,
1218 <?xml version="1.0" encoding="UTF-8"?>
1219 <gpsml>
1220 <track>
1221 <title>Track 1</title>
1222 <break/>
1223 <title>Track 2</title>
1224 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
1225 <break/>
1226 <title>Track 3</title>
1227 <break/>
1228 <title>Track 4</title>
1229 </track>
1230 </gpsml>
1233 "Require elevation from GPX data",
1236 # }}}
1237 testcmd("../gpst -re one_ele.dos.gpsml", # {{{
1238 <<END,
1239 <?xml version="1.0" encoding="UTF-8"?>
1240 <gpsml>
1241 <track>
1242 <title>Only one point has elevation</title>
1243 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1244 </track>
1245 </gpsml>
1248 "Require elevation from gpsml",
1251 # }}}
1252 testcmd("../gpst -re missing.gpsml", # {{{
1253 <<END,
1254 <?xml version="1.0" encoding="UTF-8"?>
1255 <gpsml>
1256 <track>
1257 <title>Missing various elements</title>
1258 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1259 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1260 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1261 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
1262 <tp> <ele>486</ele> </tp>
1263 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1264 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1265 </track>
1266 </gpsml>
1269 "Require elevation",
1272 # }}}
1273 testcmd("../gpst -rt missing.gpsml", # {{{
1274 <<END,
1275 <?xml version="1.0" encoding="UTF-8"?>
1276 <gpsml>
1277 <track>
1278 <title>Missing various elements</title>
1279 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
1280 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
1281 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1282 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1283 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1284 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1285 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1286 </track>
1287 </gpsml>
1290 "Require time",
1293 # }}}
1294 testcmd("../gpst -rp missing.gpsml", # {{{
1295 <<END,
1296 <?xml version="1.0" encoding="UTF-8"?>
1297 <gpsml>
1298 <track>
1299 <title>Missing various elements</title>
1300 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1301 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</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 position",
1310 # }}}
1311 testcmd("../gpst -ret missing.gpsml", # {{{
1312 <<END,
1313 <?xml version="1.0" encoding="UTF-8"?>
1314 <gpsml>
1315 <track>
1316 <title>Missing various elements</title>
1317 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1318 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1319 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1320 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1321 </track>
1322 </gpsml>
1325 "Require elevation and time",
1328 # }}}
1329 testcmd("../gpst -retp missing.gpsml", # {{{
1330 <<END,
1331 <?xml version="1.0" encoding="UTF-8"?>
1332 <gpsml>
1333 <track>
1334 <title>Missing various elements</title>
1335 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1336 </track>
1337 </gpsml>
1340 "Require elevation, time and position",
1343 # }}}
1344 testcmd("../gpst -rep missing.gpsml", # {{{
1345 <<END,
1346 <?xml version="1.0" encoding="UTF-8"?>
1347 <gpsml>
1348 <track>
1349 <title>Missing various elements</title>
1350 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1351 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1352 </track>
1353 </gpsml>
1356 "Require elevation and position",
1359 # }}}
1360 # --require option }}}
1361 diag("Testing --round option..."); # {{{
1362 testcmd("../gpst -R lat=4,lon=5,ele=1 pause.gpx", # {{{
1363 <<END,
1364 <?xml version="1.0" encoding="UTF-8"?>
1365 <gpsml>
1366 <track>
1367 <title>ACTIVE LOG164705</title>
1368 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.4255</lat> <lon>5.29953</lon> <ele>25.3</ele> </tp>
1369 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.4255</lat> <lon>5.29961</lon> <ele>24.9</ele> </tp>
1370 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.4253</lat> <lon>5.29969</lon> <ele>28</ele> </tp>
1371 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.4254</lat> <lon>5.29974</lon> <ele>31</ele> </tp>
1372 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.4253</lat> <lon>5.29996</lon> <ele>31</ele> </tp>
1373 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.4252</lat> <lon>5.29964</lon> <ele>30.5</ele> </tp>
1374 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.4252</lat> <lon>5.29969</lon> <ele>30.5</ele> </tp>
1375 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.4253</lat> <lon>5.29977</lon> <ele>31.9</ele> </tp>
1376 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.4255</lat> <lon>5.29942</lon> <ele>31.8</ele> </tp>
1377 </track>
1378 </gpsml>
1381 "--round works with lat, lon, ele from gpx",
1384 # }}}
1385 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgtab pause.gpx", # {{{
1386 <<END,
1387 2006-05-21T16:49:11Z\t(60.425,5.3)\t25.3\t\\N\t\\N\t\\N
1388 2006-05-21T16:49:46Z\t(60.425,5.3)\t24.9\t\\N\t\\N\t\\N
1389 2006-05-21T16:52:04Z\t(60.425,5.3)\t28\t\\N\t\\N\t\\N
1390 2006-05-21T16:56:36Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N
1391 2006-05-21T16:56:47Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N
1392 2006-05-21T16:56:56Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N
1393 2006-05-21T16:57:03Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N
1394 2006-05-21T16:59:08Z\t(60.425,5.3)\t31.9\t\\N\t\\N\t\\N
1395 2006-05-21T17:00:54Z\t(60.425,5.299)\t31.8\t\\N\t\\N\t\\N
1398 "pgtab output from gpx works with --round lat, lon, ele",
1401 # }}}
1402 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwtab multitrack.gpx", # {{{
1403 <<END,
1404 (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
1405 (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
1406 (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
1407 (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
1408 (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
1409 (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
1412 "--round works with lat, lon, ele from gpx, pgwtab output",
1415 # }}}
1416 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwupd multitrack.gpx", # {{{
1417 <<END,
1418 BEGIN;
1419 UPDATE logg SET name = clname(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1420 UPDATE logg SET dist = cldist(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1421 COMMIT;
1422 BEGIN;
1423 UPDATE logg SET name = clname(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1424 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1425 COMMIT;
1426 BEGIN;
1427 UPDATE logg SET name = clname(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1428 UPDATE logg SET dist = cldist(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1429 COMMIT;
1430 BEGIN;
1431 UPDATE logg SET name = clname(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1432 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1433 COMMIT;
1434 BEGIN;
1435 UPDATE logg SET name = clname(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1436 UPDATE logg SET dist = cldist(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1437 COMMIT;
1438 BEGIN;
1439 UPDATE logg SET name = clname(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1440 UPDATE logg SET dist = cldist(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1441 COMMIT;
1444 "pgwupd output and --round works with lat, lon, ele from gpx",
1447 # }}}
1448 # --round option }}}
1449 diag("Testing --short-date option..."); # {{{
1450 # --short-date option }}}
1451 diag("Testing --save-to-file option..."); # {{{
1452 # --save-to-file option }}}
1453 diag("Testing --create-breaks option..."); # {{{
1454 testcmd("../gpst -t pause.gpx", # {{{
1455 <<END,
1456 <?xml version="1.0" encoding="UTF-8"?>
1457 <gpsml>
1458 <track>
1459 <title>ACTIVE LOG164705</title>
1460 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
1461 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
1462 <pause>0:00:02:18</pause>
1463 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1464 <pause>0:00:04:32</pause>
1465 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
1466 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
1467 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
1468 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
1469 <pause>0:00:02:05</pause>
1470 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
1471 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
1472 </track>
1473 </gpsml>
1476 "Output gpsml with <pause> elements from GPX files",
1479 # }}}
1480 testcmd("../gpst -t multitrack-pause.gpx", # {{{
1481 <<END,
1482 <?xml version="1.0" encoding="UTF-8"?>
1483 <gpsml>
1484 <track>
1485 <title>track1</title>
1486 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1487 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1488 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1489 <break/>
1490 <title>track2</title>
1491 <pause>0:23:59:58</pause>
1492 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1493 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1494 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1495 <pause>0:01:00:00</pause>
1496 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1497 <break/>
1498 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1499 <break/>
1500 <title>track3</title>
1501 <pause>1:01:00:03</pause>
1502 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1503 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1504 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1505 <break/>
1506 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1507 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1508 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1509 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1510 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1511 </track>
1512 </gpsml>
1515 "Insert <pause> between gpx tracks",
1518 # }}}
1519 testcmd("../gpst -t multitrack-pause.gpsml", # {{{
1520 <<END,
1521 <?xml version="1.0" encoding="UTF-8"?>
1522 <gpsml>
1523 <track>
1524 <title>track1</title>
1525 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1526 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1527 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1528 <break/>
1529 <title>track2</title>
1530 <pause>0:23:59:58</pause>
1531 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1532 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1533 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1534 <pause>0:01:00:00</pause>
1535 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1536 <break/>
1537 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1538 <break/>
1539 <title>track3</title>
1540 <pause>1:01:00:03</pause>
1541 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1542 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1543 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1544 <break/>
1545 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1546 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1547 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1548 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1549 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1550 </track>
1551 </gpsml>
1554 "Insert <pause> between gpsml titles",
1557 # }}}
1558 # --create-breaks option }}}
1559 diag("Testing -T (--time-shift) option...");
1560 testcmd("$CMD -T 3600 multitrack-pause.gpx", # {{{
1561 <<END,
1562 <?xml version="1.0" encoding="UTF-8"?>
1563 <gpsml>
1564 <track>
1565 <title>track1</title>
1566 <tp> <time>2006-01-01T01:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1567 <tp> <time>2006-01-01T01:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1568 <tp> <time>2006-01-01T01:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1569 <break/>
1570 <title>track2</title>
1571 <tp> <time>2006-01-02T01:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1572 <tp> <time>2006-01-02T01:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1573 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1574 <tp> <time>2006-01-02T02:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1575 <break/>
1576 <tp> <time>2006-01-02T02:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1577 <break/>
1578 <title>track3</title>
1579 <tp> <time>2006-01-03T03:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1580 <tp> <time>2006-01-03T03:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1581 <tp> <time>2006-01-03T03:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1582 <break/>
1583 <tp> <time>2006-01-03T03:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1584 <tp> <time>2006-01-03T03:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1585 <tp> <time>2006-01-03T03:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1586 <tp> <time>2006-01-03T03:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1587 <tp> <time>2006-01-03T03:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1588 </track>
1589 </gpsml>
1592 "Add one hour to GPX input, output gpsml",
1595 # }}}
1596 testcmd("$CMD -T -3600 multitrack-pause.gpx", # {{{
1597 <<END,
1598 <?xml version="1.0" encoding="UTF-8"?>
1599 <gpsml>
1600 <track>
1601 <title>track1</title>
1602 <tp> <time>2005-12-31T23:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1603 <tp> <time>2005-12-31T23:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1604 <tp> <time>2005-12-31T23:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1605 <break/>
1606 <title>track2</title>
1607 <tp> <time>2006-01-01T23:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1608 <tp> <time>2006-01-01T23:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1609 <tp> <time>2006-01-01T23:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1610 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1611 <break/>
1612 <tp> <time>2006-01-02T00:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1613 <break/>
1614 <title>track3</title>
1615 <tp> <time>2006-01-03T01:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1616 <tp> <time>2006-01-03T01:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1617 <tp> <time>2006-01-03T01:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1618 <break/>
1619 <tp> <time>2006-01-03T01:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1620 <tp> <time>2006-01-03T01:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1621 <tp> <time>2006-01-03T01:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1622 <tp> <time>2006-01-03T01:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1623 <tp> <time>2006-01-03T01:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1624 </track>
1625 </gpsml>
1628 "Subtract one hour from GPX input, output gpsml",
1631 # }}}
1632 testcmd("$CMD -T 1 -o gpx multitrack-pause.gpx", # {{{
1633 <<END,
1634 $gpx_header
1635 <trk>
1636 <trkseg>
1637 <trkpt lat="1.11" lon="1.12"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1638 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:02Z</time> </trkpt>
1639 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:03Z</time> </trkpt>
1640 </trkseg>
1641 <trkseg>
1642 <trkpt lat="2.11" lon="2.12"> <time>2006-01-02T00:00:01Z</time> </trkpt>
1643 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:05Z</time> </trkpt>
1644 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:17Z</time> </trkpt>
1645 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:17Z</time> </trkpt>
1646 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:18Z</time> </trkpt>
1647 </trkseg>
1648 <trkseg>
1649 </trkseg>
1650 <trkseg>
1651 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1652 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1653 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1654 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1655 </trkseg>
1656 <trkseg>
1657 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1658 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1659 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:27Z</time> </trkpt>
1660 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:28Z</time> </trkpt>
1661 </trkseg>
1662 </trk>
1663 </gpx>
1666 "Add one second to GPX input, output GPX",
1669 # }}}
1670 testcmd("$CMD --time-shift -1 -o gpx multitrack-pause.gpsml", # {{{
1671 <<END,
1672 $gpx_header
1673 <trk>
1674 <trkseg>
1675 <trkpt lat="1.11" lon="1.12"> <time>2005-12-31T23:59:59Z</time> </trkpt>
1676 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:00Z</time> </trkpt>
1677 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1678 </trkseg>
1679 <trkseg>
1680 <trkpt lat="2.11" lon="2.12"> <time>2006-01-01T23:59:59Z</time> </trkpt>
1681 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:03Z</time> </trkpt>
1682 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:15Z</time> </trkpt>
1683 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:15Z</time> </trkpt>
1684 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:16Z</time> </trkpt>
1685 </trkseg>
1686 <trkseg>
1687 </trkseg>
1688 <trkseg>
1689 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:19Z</time> </trkpt>
1690 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:20Z</time> </trkpt>
1691 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1692 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1693 </trkseg>
1694 <trkseg>
1695 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1696 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1697 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1698 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1699 </trkseg>
1700 </trk>
1701 </gpx>
1704 "Subtract one second from gpsml input, output GPX, use long option",
1707 # }}}
1708 testcmd("$CMD -T 0 -o pgtab multitrack-pause.gpx", # {{{
1709 <<END,
1710 2006-01-01T00:00:00Z\t(1.11,1.12)\t\\N\t\\N\t\\N\t\\N
1711 2006-01-01T00:00:01Z\t(1.21,1.22)\t\\N\t\\N\t\\N\t\\N
1712 2006-01-01T00:00:02Z\t(1.31,1.32)\t\\N\t\\N\t\\N\t\\N
1713 2006-01-02T00:00:00Z\t(2.11,2.12)\t\\N\t\\N\t\\N\t\\N
1714 2006-01-02T00:00:04Z\t(2.21,2.22)\t\\N\t\\N\t\\N\t\\N
1715 2006-01-02T00:00:16Z\t(2.31,2.32)\t\\N\t\\N\t\\N\t\\N
1716 2006-01-02T01:00:16Z\t(2.41,2.42)\t\\N\t\\N\t\\N\t\\N
1717 2006-01-02T01:00:17Z\t(2.451,2.452)\t\\N\t\\N\t\\N\t\\N
1718 2006-01-03T02:00:20Z\t(3.11,3.12)\t\\N\t\\N\t\\N\t\\N
1719 2006-01-03T02:00:21Z\t(3.21,3.22)\t\\N\t\\N\t\\N\t\\N
1720 2006-01-03T02:00:22Z\t(3.31,3.32)\t\\N\t\\N\t\\N\t\\N
1721 2006-01-03T02:00:23Z\t(3.41,3.42)\t\\N\t\\N\t\\N\t\\N
1722 2006-01-03T02:00:24Z\t(3.51,3.52)\t\\N\t\\N\t\\N\t\\N
1723 2006-01-03T02:00:25Z\t(3.61,3.62)\t\\N\t\\N\t\\N\t\\N
1724 2006-01-03T02:00:26Z\t(3.71,3.72)\t\\N\t\\N\t\\N\t\\N
1725 2006-01-03T02:00:27Z\t(3.81,3.82)\t\\N\t\\N\t\\N\t\\N
1728 "Read GPX, time-shift 0 seconds, output pgtab",
1731 # }}}
1732 diag("Testing -v (--verbose) option...");
1733 likecmd("$CMD -hv", # {{{
1734 '/^\n\S+ v\d\.\d\d\n/s',
1735 '/^$/',
1736 "Option --version with -h returns version number and help screen",
1739 # }}}
1740 diag("Testing --version option...");
1741 likecmd("$CMD --version", # {{{
1742 '/^\S+ v\d\.\d\d\n/',
1743 '/^$/',
1744 "Option --version returns version number",
1747 # }}}
1748 # --version option }}}
1749 diag("Testing --strip-whitespace option..."); # {{{
1750 testcmd("../gpst -w -o gpx pause-noname.gpx", # {{{
1751 <<END,
1752 $stripped_gpx_header
1753 <trk>
1754 <trkseg>
1755 <trkpt lat="60.425494" lon="5.299534"><ele>25.260</ele><time>2006-05-21T16:49:11Z</time></trkpt>
1756 <trkpt lat="60.425464" lon="5.299610"><ele>24.931</ele><time>2006-05-21T16:49:46Z</time></trkpt>
1757 <trkpt lat="60.425314" lon="5.299694"><ele>27.975</ele><time>2006-05-21T16:52:04Z</time></trkpt>
1758 <trkpt lat="60.425384" lon="5.299741"><ele>31.017</ele><time>2006-05-21T16:56:36Z</time></trkpt>
1759 <trkpt lat="60.425339" lon="5.299958"><ele>30.980</ele><time>2006-05-21T16:56:47Z</time></trkpt>
1760 <trkpt lat="60.425238" lon="5.299640"><ele>30.538</ele><time>2006-05-21T16:56:56Z</time></trkpt>
1761 <trkpt lat="60.425246" lon="5.299686"><ele>30.515</ele><time>2006-05-21T16:57:03Z</time></trkpt>
1762 <trkpt lat="60.425345" lon="5.299773"><ele>31.936</ele><time>2006-05-21T16:59:08Z</time></trkpt>
1763 <trkpt lat="60.425457" lon="5.299419"><ele>31.794</ele><time>2006-05-21T17:00:54Z</time></trkpt>
1764 </trkseg>
1765 </trk>
1766 </gpx>
1769 "Strip whitespace from GPX output",
1772 # }}}
1773 testcmd("../gpst -o gpx -w comments.mayko", # {{{
1774 <<END,
1775 $stripped_gpx_header
1776 <trk>
1777 <trkseg>
1778 <trkpt lat="70.6800486" lon="23.6746151"><time>2002-12-22T21:42:24Z</time></trkpt>
1779 <trkpt lat="70.6799322" lon="23.6740038"><time>2002-12-22T21:42:32Z</time></trkpt>
1780 <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:42:54Z</time></trkpt>
1781 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:51Z</time><extensions><error>desc</error></extensions></trkpt> -->
1782 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:52Z</time><extensions><error>desc</error></extensions></trkpt> -->
1783 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:54Z</time><extensions><error>desc</error></extensions></trkpt> -->
1784 <trkpt lat="70.6800774" lon="23.6757566"><time>2002-12-22T21:44:45Z</time></trkpt>
1785 </trkseg>
1786 <trkseg>
1787 <trkpt lat="70.6801502" lon="23.6753442"><time>2002-12-22T21:44:52Z</time></trkpt>
1788 <trkpt lat="70.6801905" lon="23.6757542"><time>2002-12-22T21:45:04Z</time></trkpt>
1789 </trkseg>
1790 </trk>
1791 </gpx>
1794 "Output whitespace-stripped GPX from Mayko file with commented-out lines",
1797 # }}}
1798 testcmd("../gpst -w -o pgwupd multitrack.gpx", # {{{
1799 <<END,
1800 BEGIN;
1801 UPDATE logg SET name = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1802 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1803 COMMIT;
1804 BEGIN;
1805 UPDATE logg SET name = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1806 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1807 COMMIT;
1808 BEGIN;
1809 UPDATE logg SET name = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1810 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1811 COMMIT;
1812 BEGIN;
1813 UPDATE logg SET name = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1814 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1815 COMMIT;
1816 BEGIN;
1817 UPDATE logg SET name = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1818 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1819 COMMIT;
1820 BEGIN;
1821 UPDATE logg SET name = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1822 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1823 COMMIT;
1826 "Strip whitespace from pgwupd output",
1829 # }}}
1830 # --strip-whitespace option }}}
1831 diag("Testing --double-y-scale option..."); # {{{
1832 testcmd("../gpst -y -o clean pause.gpx", # {{{
1833 <<END,
1834 5.299534\t120.850988\t25.260
1835 5.299610\t120.850928\t24.931
1836 5.299694\t120.850628\t27.975
1837 5.299741\t120.850768\t31.017
1838 5.299958\t120.850678\t30.980
1839 5.299640\t120.850476\t30.538
1840 5.299686\t120.850492\t30.515
1841 5.299773\t120.85069\t31.936
1842 5.299419\t120.850914\t31.794
1845 "Double y scale, clean output from gpx format",
1848 # }}}
1849 testcmd("../gpst -y -o clean log.dos.mayko", # {{{
1850 <<END,
1851 8.1225077\t116.3636316\t
1852 8.1253200\t116.3637424\t
1853 8.1266031\t116.3632694\t
1854 8.1284612\t116.3624198\t
1855 8.1293950\t116.362063\t
1856 8.1307400\t116.3619242\t
1859 "Double y scale, clean output from mayko format",
1862 # }}}
1863 # --double-y-scale option }}}
1864 diag("Testing --debug option..."); # {{{
1865 # --debug option }}}
1866 diag("Strip error from Mayko format..."); # {{{
1868 testcmd("../gpst -o csv date_error.mayko", # {{{
1869 <<END,
1870 2003-06-13T09:12:36Z\t5.5794667\t60.4280897\t\t
1871 2003-06-13T09:12:38Z\t5.5802255\t60.4281867\t\t
1872 2003-06-13T09:12:41Z\t5.5813636\t60.4283320\t\t
1873 2003-06-13T09:12:42Z\t5.5817430\t60.4283806\t\t
1876 "Strip error from mayko format in csv output",
1879 # }}}
1880 testcmd("../gpst -o clean date_error.mayko", # {{{
1881 <<END,
1882 5.5794667\t60.4280897\t
1883 5.5802255\t60.4281867\t
1884 5.5813636\t60.4283320\t
1885 5.5817430\t60.4283806\t
1888 "Strip error from mayko format in clean output",
1891 # }}}
1892 testcmd("../gpst -o gpsml date_error.mayko", # {{{
1893 <<END,
1894 <?xml version="1.0" encoding="UTF-8"?>
1895 <gpsml>
1896 <track>
1897 <tp> <time>2003-06-13T09:12:36Z</time> <lat>60.4280897</lat> <lon>5.5794667</lon> </tp>
1898 <tp> <time>2003-06-13T09:12:38Z</time> <lat>60.4281867</lat> <lon>5.5802255</lon> </tp>
1899 <etp err="error"> <time>2037-06-25T17:19:22Z</time> <lat>103.4034054</lat> <lon>129.7271053</lon> </etp>
1900 <tp> <time>2003-06-13T09:12:41Z</time> <lat>60.428332</lat> <lon>5.5813636</lon> </tp>
1901 <tp> <time>2003-06-13T09:12:42Z</time> <lat>60.4283806</lat> <lon>5.581743</lon> </tp>
1902 </track>
1903 </gpsml>
1906 "Strip error from mayko format in gpsml output",
1909 # }}}
1910 testcmd("../gpst -o gpx date_error.mayko", # {{{
1911 <<END,
1912 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1913 <gpx
1914 version="1.1"
1915 creator="gpst - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/"
1916 xmlns="http://www.topografix.com/GPX/1/1"
1917 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1918 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
1920 <trk>
1921 <trkseg>
1922 <trkpt lat="60.4280897" lon="5.5794667"> <time>2003-06-13T09:12:36Z</time> </trkpt>
1923 <trkpt lat="60.4281867" lon="5.5802255"> <time>2003-06-13T09:12:38Z</time> </trkpt>
1924 <!-- <trkpt lat="103.4034054" lon="129.7271053"> <time>2037-06-25T17:19:22Z</time> <extensions> <error>error</error> </extensions> </trkpt> -->
1925 <trkpt lat="60.4283320" lon="5.5813636"> <time>2003-06-13T09:12:41Z</time> </trkpt>
1926 <trkpt lat="60.4283806" lon="5.5817430"> <time>2003-06-13T09:12:42Z</time> </trkpt>
1927 </trkseg>
1928 </trk>
1929 </gpx>
1932 "Strip error from mayko format in gpx output",
1935 # }}}
1936 testcmd("../gpst -o gpstrans date_error.mayko", # {{{
1937 <<END,
1938 Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84
1939 T\t06/13/2003 09:12:36\t60\xB025'41.1"\t5\xB034'46.1"
1940 T\t06/13/2003 09:12:38\t60\xB025'41.5"\t5\xB034'48.8"
1941 T\t06/13/2003 09:12:41\t60\xB025'42.0"\t5\xB034'52.9"
1942 T\t06/13/2003 09:12:42\t60\xB025'42.2"\t5\xB034'54.3"
1945 "Strip error from mayko format in gpstrans output",
1948 # }}}
1949 testcmd("../gpst -o pgtab date_error.mayko", # {{{
1950 <<END,
1951 2003-06-13T09:12:36Z\t(60.4280897,5.5794667)\t\\N\t\\N\t\\N\t\\N
1952 2003-06-13T09:12:38Z\t(60.4281867,5.5802255)\t\\N\t\\N\t\\N\t\\N
1953 2003-06-13T09:12:41Z\t(60.4283320,5.5813636)\t\\N\t\\N\t\\N\t\\N
1954 2003-06-13T09:12:42Z\t(60.4283806,5.5817430)\t\\N\t\\N\t\\N\t\\N
1957 "Strip error from mayko format in pgtab output",
1960 # }}}
1961 testcmd("../gpst -o poscount date_error.mayko", # {{{
1962 <<END,
1963 5.5802255\t60.4281867\t1
1964 5.5817430\t60.4283806\t1
1965 5.5813636\t60.4283320\t1
1966 5.5794667\t60.4280897\t1
1969 "Strip error from mayko format in poscount output",
1972 # }}}
1973 testcmd("../gpst -o xgraph date_error.mayko", # {{{
1974 <<END,
1975 5.5794667 60.4280897
1976 5.5802255 60.4281867
1977 5.5813636 60.4283320
1978 5.5817430 60.4283806
1981 "Strip error from mayko format in xgraph output",
1984 # }}}
1985 testcmd("../gpst -o ygraph date_error.mayko", # {{{
1986 <<END,
1987 "Time = 0.0
1988 5.5794667 60.4280897
1990 "Time = 2.0
1991 5.5802255 60.4281867
1993 "Time = 5.0
1994 5.5813636 60.4283320
1996 "Time = 6.0
1997 5.5817430 60.4283806
2001 "Strip error from mayko format in ygraph output",
2004 # }}}
2006 # Strip error from Mayko format }}}
2008 todo_section:
2011 if ($Opt{'all'} || $Opt{'todo'}) {
2012 diag("Running TODO tests..."); # {{{
2014 TODO: {
2015 local $TODO = "Fix read/write of GPX name element";
2016 testcmd("../gpst -o gpx pause.gpx", # {{{
2017 <<END,
2018 $gpx_header
2019 <trk>
2020 <name>ACTIVE LOG164705</name>
2021 <trkseg>
2022 <trkpt lat="60.425494" lon="5.299534"> <ele>25.260</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
2023 <trkpt lat="60.425464" lon="5.299610"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
2024 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
2025 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
2026 <trkpt lat="60.425339" lon="5.299958"> <ele>30.980</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
2027 <trkpt lat="60.425238" lon="5.299640"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
2028 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
2029 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
2030 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
2031 </trkseg>
2032 </trk>
2033 </gpx>
2036 "Read and write name element from/to GPX",
2039 # }}}
2040 local $TODO = "Remove extra \\n in the beginning";
2041 testcmd("../gpst -o csv multitrack.gpx", # {{{
2042 <<END,
2043 2003-02-11T23:35:39Z\t-0.1448824\t51.4968266\t\t
2044 2003-02-11T23:35:49Z\t-0.1449938\t51.4968227\t\t
2045 2003-02-11T23:36:14Z\t-0.1453202\t51.4969040\t\t
2046 \t\t\t\t
2047 2003-02-11T23:36:16Z\t-0.1453398\t51.4969214\t\t
2048 2003-02-11T23:36:31Z\t-0.1455514\t51.4969816\t\t
2049 2003-02-11T23:36:43Z\t-0.1457489\t51.4970224\t1000\t
2050 2003-02-11T23:36:50Z\t-0.1457804\t51.4970452\t\t
2051 \t\t\t\t
2052 2003-02-11T23:37:05Z\t-0.1458608\t51.4970680\t\t
2053 2003-02-11T23:37:22Z\t-0.1460047\t51.4971658\t\t
2054 2003-02-11T23:37:36Z\t-0.1461614\t51.4972469\t\t
2055 \t\t\t\t
2056 2003-02-11T23:37:43Z\t-0.1462394\t51.4972731\t\t
2057 2003-02-11T23:38:04Z\t-0.1463232\t51.4973437\t\t
2058 2003-02-11T23:38:28Z\t-0.1462949\t51.4973337\t\t
2059 2003-02-11T23:38:34Z\t-0.1462825\t51.4973218\t\t
2060 2003-02-11T23:38:35Z\t-0.1462732\t51.4973145\t\t
2063 "Output csv format from multitrack.gpx",
2066 # }}}
2067 testcmd("../gpst -o csv pause.gpx", # {{{
2068 <<END,
2069 2006-05-21T16:49:11Z\t5.299534\t60.425494\t25.260\t
2070 2006-05-21T16:49:46Z\t5.299610\t60.425464\t24.931\t
2071 2006-05-21T16:52:04Z\t5.299694\t60.425314\t27.975\t
2072 2006-05-21T16:56:36Z\t5.299741\t60.425384\t31.017\t
2073 2006-05-21T16:56:47Z\t5.299958\t60.425339\t30.980\t
2074 2006-05-21T16:56:56Z\t5.299640\t60.425238\t30.538\t
2075 2006-05-21T16:57:03Z\t5.299686\t60.425246\t30.515\t
2076 2006-05-21T16:59:08Z\t5.299773\t60.425345\t31.936\t
2077 2006-05-21T17:00:54Z\t5.299419\t60.425457\t31.794\t
2080 "Output csv format from pause.gpx",
2083 # }}}
2084 testcmd("../gpst -e -o csv pause.gpx", # {{{
2085 <<END,
2086 1148230151\t5.299534\t60.425494\t25.260\t
2087 1148230186\t5.299610\t60.425464\t24.931\t
2088 1148230324\t5.299694\t60.425314\t27.975\t
2089 1148230596\t5.299741\t60.425384\t31.017\t
2090 1148230607\t5.299958\t60.425339\t30.980\t
2091 1148230616\t5.299640\t60.425238\t30.538\t
2092 1148230623\t5.299686\t60.425246\t30.515\t
2093 1148230748\t5.299773\t60.425345\t31.936\t
2094 1148230854\t5.299419\t60.425457\t31.794\t
2097 "csv format with epoch seconds from gpx",
2100 # }}}
2101 $TODO = "Tweak output";
2102 testcmd("../gpst -o gpx multitrack-pause.gpsml", # {{{
2103 file_data("multitrack-pause.gpx"),
2105 "Should be equal to multitrack-pause.gpx",
2108 # }}}
2109 $TODO = 'Fix it.';
2110 # list_nearest_waypoints() {{{
2112 like(list_nearest_waypoints(60.42541, 5.29959, 3),
2113 qr/^\(.*,.*,.*\)$/,
2114 "list_nearest_waypoints()"
2117 # }}}
2119 # TODO tests }}}
2122 diag("Testing finished.");
2124 sub testcmd {
2125 # {{{
2126 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
2127 my $stderr_cmd = "";
2128 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2129 my $Txt = join("",
2130 "\"$Cmd\"",
2131 defined($Desc)
2132 ? " - $Desc"
2133 : ""
2135 my $TMP_STDERR = "gpst-stderr.tmp";
2137 if (defined($Exp_stderr) && !length($deb_str)) {
2138 $stderr_cmd = " 2>$TMP_STDERR";
2140 is(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt);
2141 if (defined($Exp_stderr)) {
2142 if (!length($deb_str)) {
2143 is(file_data($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
2144 unlink($TMP_STDERR);
2146 } else {
2147 diag("Warning: stderr not defined for '$Txt'");
2149 # }}}
2150 } # testcmd()
2152 sub likecmd {
2153 # {{{
2154 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
2155 my $stderr_cmd = "";
2156 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2157 my $Txt = join("",
2158 "\"$Cmd\"",
2159 defined($Desc)
2160 ? " - $Desc"
2161 : ""
2163 my $TMP_STDERR = "gpst-stderr.tmp";
2165 if (defined($Exp_stderr) && !length($deb_str)) {
2166 $stderr_cmd = " 2>$TMP_STDERR";
2168 like(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
2169 if (defined($Exp_stderr)) {
2170 if (!length($deb_str)) {
2171 like(file_data($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
2172 unlink($TMP_STDERR);
2174 } else {
2175 diag("Warning: stderr not defined for '$Txt'");
2177 # }}}
2178 } # likecmd()
2180 sub file_data {
2181 # Return file content as a string {{{
2182 my $File = shift;
2183 my $Txt;
2184 if (open(FP, "<", $File)) {
2185 $Txt = join("", <FP>);
2186 close(FP);
2187 return($Txt);
2188 } else {
2189 return undef;
2191 # }}}
2192 } # file_data()
2194 sub print_version {
2195 # Print program version {{{
2196 print("$progname v$VERSION\n");
2197 # }}}
2198 } # print_version()
2200 sub usage {
2201 # Send the help message to stdout {{{
2202 my $Retval = shift;
2204 if ($Opt{'verbose'}) {
2205 print("\n");
2206 print_version();
2208 print(<<END);
2210 Usage: $progname [options] [file [files [...]]]
2212 Contains tests for the gpst(1) program.
2214 Options:
2216 -a, --all
2217 Run all tests, also TODOs.
2218 -h, --help
2219 Show this help.
2220 -t, --todo
2221 Run only the TODO tests.
2222 -v, --verbose
2223 Increase level of verbosity. Can be repeated.
2224 --version
2225 Print version information.
2226 --debug
2227 Print debugging messages.
2230 exit($Retval);
2231 # }}}
2232 } # usage()
2234 sub msg {
2235 # Print a status message to stderr based on verbosity level {{{
2236 my ($verbose_level, $Txt) = @_;
2238 if ($Opt{'verbose'} >= $verbose_level) {
2239 print(STDERR "$progname: $Txt\n");
2241 # }}}
2242 } # msg()
2244 __END__
2246 # Plain Old Documentation (POD) {{{
2248 =pod
2250 =head1 NAME
2252 run-tests.pl
2254 =head1 SYNOPSIS
2256 run-tests.pl [options] [file [files [...]]]
2258 =head1 DESCRIPTION
2260 Contains tests for the gpst(1) program.
2262 =head1 OPTIONS
2264 =over 4
2266 =item B<-a>, B<--all>
2268 Run all tests, also TODOs.
2270 =item B<-h>, B<--help>
2272 Print a brief help summary.
2274 =item B<-t>, B<--todo>
2276 Run only the TODO tests.
2278 =item B<-v>, B<--verbose>
2280 Increase level of verbosity. Can be repeated.
2282 =item B<--version>
2284 Print version information.
2286 =item B<--debug>
2288 Print debugging messages.
2290 =back
2292 =head1 AUTHOR
2294 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
2296 =head1 COPYRIGHT
2298 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
2299 This is free software; see the file F<COPYING> for legalese stuff.
2301 =head1 LICENCE
2303 This program is free software: you can redistribute it and/or modify it
2304 under the terms of the GNU General Public License as published by the
2305 Free Software Foundation, either version 3 of the License, or (at your
2306 option) any later version.
2308 This program is distributed in the hope that it will be useful, but
2309 WITHOUT ANY WARRANTY; without even the implied warranty of
2310 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2311 See the GNU General Public License for more details.
2313 You should have received a copy of the GNU General Public License along
2314 with this program.
2315 If not, see L<http://www.gnu.org/licenses/>.
2317 =head1 SEE ALSO
2319 gpst(1)
2321 =cut
2323 # }}}
2325 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :