Remove trailing zeroes from expected GPX in a TODO test
[gpstools.git] / tests / run-tests.pl
blob428556781cdcfadb1cbd4d93a94bd6af366edf07
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() }}}
150 # num_expand() {{{
152 is(num_expand(""),
154 "num_expand(\"\") returns empty string");
156 is(num_expand("6.5"),
157 "6.5",
158 "num_expand(\"6.5\") returns same value");
159 is(num_expand("-6.5"),
160 "-6.5",
161 "num_expand(\"-6.5\") returns same value");
162 is(num_expand("+6.5"),
163 "6.5",
164 "num_expand(\"+6.5\") removes leading plus sign");
166 is(num_expand("0.0000000000123"),
167 "0.0000000000123",
168 "num_expand(\"0.0000000000123\") returns same value");
169 is(num_expand("-0.0000000000123"),
170 "-0.0000000000123",
171 "num_expand(\"-0.0000000000123\") returns same value");
172 is(num_expand("+0.0000000000123"),
173 "0.0000000000123",
174 "num_expand(\"+0.0000000000123\") removes leading plus sign");
176 is(num_expand("1e-06"),
177 "0.000001",
178 "num_expand(\"1e-06\") returns 0.000001");
179 is(num_expand("-1e-06"),
180 "-0.000001",
181 "num_expand(\"-1e-06\") returns -0.000001");
182 is(num_expand("+1e-06"),
183 "0.000001",
184 "num_expand(\"+1e-06\") removes leading plus sign");
186 is(num_expand("1e-6"),
187 "0.000001",
188 "num_expand(\"1e-6\") returns 0.000001");
189 is(num_expand("1e+6"),
190 "1000000",
191 "num_expand(\"1e+6\") returns 1000000");
193 is(num_expand("3.14159265358979e-10"),
194 "0.000000000314159265358979",
195 "num_expand(\"3.14159265358979e-10\") returns 0.000000000314159265358979");
197 is(num_expand("1.2000e-10"),
198 "0.00000000012",
199 "Strip trailing zeroes from num_expand(\"1.2000e-10\")");
200 is(num_expand("1.2000e+10"),
201 "12000000000",
202 "num_expand(\"1.2000e+10\") returns 12000000000");
204 is(num_expand("0000000000000"),
205 "0",
206 "num_expand(\"0000000000000\") returns 0");
207 is(num_expand("-0000000000000"),
208 "0",
209 "num_expand(\"-0000000000000\") returns 0");
210 is(num_expand("+0000000000000"),
211 "0",
212 "num_expand(\"+0000000000000\") returns 0");
214 is(num_expand("000000.0000000"),
215 "0",
216 "num_expand(\"000000.0000000\") returns 0");
217 is(num_expand("-000000.0000000"),
218 "0",
219 "num_expand(\"-000000.0000000\") returns 0");
220 is(num_expand("+000000.0000000"),
221 "0",
222 "num_expand(\"+000000.0000000\") returns 0");
224 is(num_expand("1e+20"),
225 "100000000000000000000",
226 "num_expand(\"1e+20\") returns 100000000000000000000");
228 is(num_expand("3.14159e+10"),
229 "31415900000",
230 "num_expand(\"314159e+10\") returns 31415900000");
232 is(num_expand("2.50000"),
233 "2.5",
234 "num_expand(\"2.50000\") removes trailing zeroes");
236 is(num_expand("0002.5"),
237 "2.5",
238 "num_expand(\"0002.5\") removes leading zeroes");
239 is(num_expand("-0002.5"),
240 "-2.5",
241 "num_expand(\"-0002.5\") removes leading zeroes");
242 is(num_expand("+0002.5"),
243 "2.5",
244 "num_expand(\"+0002.5\") removes leading zeroes and leading plus sign");
246 is(num_expand("0002.50000"),
247 "2.5",
248 "num_expand(\"0002.50000\") removes both leading and trailing zeroes");
250 is(num_expand("300"),
251 "300",
252 "Don’t remove trailing zeroes from integers");
254 is(num_expand("0004"),
255 "4",
256 "num_expand(\"0004\") removes leading zeroes from integer");
257 is(num_expand("-0004"),
258 "-4",
259 "num_expand(\"-0004\") removes leading zeroes from negative integer");
260 is(num_expand("+0004"),
261 "4",
262 "num_expand(\"+0004\") removes leading plus sign and zeroes from integer");
264 # num_expand() }}}
266 diag("Testing date routines...");
268 # sec_to_string() {{{
270 is(sec_to_string(1148220825),
271 "2006-05-21 14:13:45",
272 "sec_to_string() without separator");
273 is(sec_to_string(1148220825, "T"),
274 "2006-05-21T14:13:45",
275 "sec_to_string() with separator");
276 is(sec_to_string(-5000),
277 undef,
278 "sec_to_string(-5000) — negative numbers unsupported atm");
279 is(sec_to_string(""),
280 undef,
281 "sec_to_string(\"\")");
282 is(sec_to_string("pH()rtY tW0"),
283 undef,
284 "sec_to_string() with invalid string");
285 is(sec_to_string("00000000000000000000001148220825"),
286 "2006-05-21 14:13:45",
287 "sec_to_string() with a bunch of leading zeros");
288 is(sec_to_string("1148220825.93"),
289 "2006-05-21 14:13:45.93",
290 "sec_to_string() with decimals");
291 is(sec_to_string("000000000000000000000000000001148220825.7312"),
292 "2006-05-21 14:13:45.7312",
293 "sec_to_string() with decimals and prefixing zeros");
294 is(sec_to_string("1148220825.93000"),
295 "2006-05-21 14:13:45.93",
296 "sec_to_string() with decimals and extra trailing zeros");
297 is(sec_to_string(".863"),
298 "1970-01-01 00:00:00.863",
299 "sec_to_string() with missing zero before decimal point");
301 # sec_to_string() }}}
302 # sec_to_readable() {{{
304 is(sec_to_readable(0),
305 "0:00:00:00",
306 "sec_to_readable(0)");
307 is(sec_to_readable("pH()rtY tW0"),
308 undef,
309 "sec_to_readable() with invalid string");
310 is(sec_to_readable(86400),
311 "1:00:00:00",
312 "sec_to_readable(86400)");
313 is(sec_to_readable(86400*1000),
314 "1000:00:00:00",
315 "sec_to_readable(86400*1000)");
316 is(sec_to_readable(86400+7200+180+4),
317 "1:02:03:04",
318 "sec_to_readable(86400+7200+180+4)");
319 is(sec_to_readable("3.14"),
320 "0:00:00:03.14",
321 "sec_to_readable(\"3.14\")");
322 is(sec_to_readable("-124"),
323 undef,
324 "sec_to_readable() rejects negative numbers");
325 is(sec_to_readable("-2.34"),
326 undef,
327 "sec_to_readable() rejects negative decimal");
328 is(sec_to_readable(".87"),
329 "0:00:00:00.87",
330 "sec_to_readable(), missing zero before decimal point");
331 is(sec_to_readable(""),
332 "0:00:00:00",
333 "sec_to_readable() with empty string");
335 # sec_to_readable() }}}
337 diag("Testing geo routines...");
339 # ddd_to_dms() {{{
341 is(ddd_to_dms("12.34567"),
342 "12\xB020'44.4\"",
343 "ddd_to_dms(\"12.34567\")");
345 is(ddd_to_dms("0"),
346 "0\xB000'00.0\"",
347 "ddd_to_dms(\"0\")");
349 is(ddd_to_dms(""),
350 "0\xB000'00.0\"",
351 "ddd_to_dms(\"\")");
353 is(ddd_to_dms("pH()rtY tW0"),
354 undef,
355 "ddd_to_dms(\"pH()rtY tW0\")");
357 is(ddd_to_dms("-12.34567"),
358 "-12\xB020'44.4\"",
359 "ddd_to_dms(\"-12.34567\")");
361 is(ddd_to_dms("0.34567"),
362 "0\xB020'44.4\"",
363 "ddd_to_dms(\"0.34567\")");
365 is(ddd_to_dms(".34567"),
366 "0\xB020'44.4\"",
367 "ddd_to_dms(\".34567\")");
369 is(ddd_to_dms("-.34567"),
370 "-0\xB020'44.4\"",
371 "ddd_to_dms(\"-.34567\")");
373 is(ddd_to_dms("-0.34567"),
374 "-0\xB020'44.4\"",
375 "ddd_to_dms(\"-0.34567\")");
377 is(ddd_to_dms("180"),
378 "180\xB000'00.0\"",
379 "ddd_to_dms(\"180\")");
381 is(ddd_to_dms("-180"),
382 "-180\xB000'00.0\"",
383 "ddd_to_dms(\"-180\")");
385 is(ddd_to_dms("-1"),
386 "-1\xB000'00.0\"",
387 "ddd_to_dms(\"-1\")");
389 is(ddd_to_dms("2-3"),
390 undef,
391 "ddd_to_dms(\"2-3\")");
393 # ddd_to_dms() }}}
394 diag("Testing trackpoint()..."); # {{{
396 my %Dat = ();
398 is(trackpoint(%Dat),
399 undef,
400 "trackpoint() receives empty hash");
402 my %Bck = (
403 # {{{
404 'format' => 'gpsml',
405 'year' => '2003',
406 'month' => '06',
407 'day' => '13',
408 'hour' => '14',
409 'min' => '36',
410 'sec' => '10',
411 'lat' => '59.5214',
412 'lon' => '7.392133',
413 'ele' => '762',
414 'error' => "",
415 'what' => 'tp',
416 # }}}
419 # trackpoint() (gpsml) {{{
420 %Dat = %Bck;
422 trackpoint(%Dat),
423 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
424 "trackpoint() (gpsml)"
427 # trackpoint() (gpsml) }}}
428 # trackpoint() (gpx) {{{
429 %Dat = %Bck;
430 $Dat{'format'} = "gpx";
432 trackpoint(%Dat),
433 qq{ <trkpt lat="59.5214" lon="7.392133"> <ele>762</ele> <time>2003-06-13T14:36:10Z</time> </trkpt>\n},
434 "trackpoint() (gpx)"
437 # trackpoint() (gpx) }}}
439 # trackpoint(): Various loop tests {{{
441 for my $Elem (qw{format lat lon what}) {
442 my %Dat = %Bck;
444 $Dat{"$Elem"} = '2d';
445 is(trackpoint(%Dat),
446 undef,
447 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") returns undef"
452 for my $Elem (qw{year month day hour min sec}) {
453 # Date tests {{{
454 my %Dat;
456 %Dat = %Bck;
457 $Dat{"$Elem"} = '';
458 is(trackpoint(%Dat),
459 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
460 "trackpoint(): {'$Elem'} with empty value skips time"
463 %Dat = %Bck;
464 $Dat{"$Elem"} = '2d';
465 is(trackpoint(%Dat),
466 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
467 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") skips time"
470 %Dat = %Bck;
471 $Dat{$Elem} = "00000$Dat{$Elem}";
472 is(trackpoint(%Dat),
473 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
474 "trackpoint(): Strip prefixing zeros from {'$Elem'}"
477 %Dat = %Bck;
478 $Dat{"$Elem"} = 0-$Dat{$Elem};
479 is(trackpoint(%Dat),
480 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
481 "trackpoint(): {'$Elem'} is negative, skip time"
484 if ($Elem ne "sec") {
485 %Dat = %Bck;
486 $Dat{"$Elem"} = "$Dat{$Elem}.00";
487 is(trackpoint(%Dat),
488 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
489 "trackpoint(): Decimals in {'$Elem'}, skip time"
493 # Date tests }}}
496 %Dat = %Bck;
497 $Dat{'sec'} = "$Dat{'sec'}.00";
498 is(trackpoint(%Dat),
499 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
500 "trackpoint(): Remove trailing zeros in {'sec'} decimals"
503 for my $Elem (qw{format what error}) {
504 my %Dat = %Bck;
505 $Dat{$Elem} = undef;
506 is(trackpoint(%Dat),
507 undef,
508 "trackpoint(): Missing {'$Elem'}, return undef"
512 # Various loop tests }}}
514 # trackpoint() }}}
516 diag("Testing output from ../gpst");
518 diag("Read empty input (/dev/null)..."); # {{{
519 testcmd("../gpst </dev/null", # {{{
520 <<END,
521 <?xml version="1.0" encoding="UTF-8"?>
522 <gpsml>
523 <track>
524 </track>
525 </gpsml>
528 "Read from /dev/null",
532 # }}}
533 testcmd("../gpst -o gpx </dev/null", # {{{
534 <<END,
535 $gpx_header
536 <trk>
537 <trkseg>
538 </trkseg>
539 </trk>
540 </gpx>
543 "Output gpx from /dev/null",
547 # }}}
548 # empty input }}}
549 diag("Read empty files..."); # {{{
550 testcmd("echo '<tp> </tp>' | ../gpst", # {{{
551 <<END,
552 <?xml version="1.0" encoding="UTF-8"?>
553 <gpsml>
554 <track>
555 </track>
556 </gpsml>
559 "Don’t print empty trackpoints",
563 # }}}
564 # Read empty files }}}
565 diag("Testing --chronology option..."); # {{{
566 testcmd("../gpst --chronology chronology-error.gpsml", # {{{
567 <<END,
568 <?xml version="1.0" encoding="UTF-8"?>
569 <gpsml>
570 <track>
571 <title>Chronology errors</title>
572 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
573 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
574 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
575 <break/>
576 <tp> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </tp>
577 <break/>
578 <pause>0:00:37:54</pause>
579 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
580 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
581 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
582 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
583 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
584 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
585 </track>
586 </gpsml>
588 "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" .
589 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
590 "Check for chronology errors and duplicated times",
594 # }}}
595 # --chronology option }}}
596 diag("Testing --skip-dups option..."); # {{{
597 testcmd("../gpst -d no_signal.mayko", # {{{
598 <<END,
599 <?xml version="1.0" encoding="UTF-8"?>
600 <gpsml>
601 <track>
602 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
603 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
604 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
605 <etp err="dup"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
606 <etp err="dup"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
607 <etp err="dup"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
608 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
609 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
610 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
611 </track>
612 </gpsml>
615 "Remove duplicated positions from gpsml",
619 # }}}
620 testcmd("../gpst -d -o csv no_signal.mayko", # {{{
621 <<END,
622 2002-12-22T21:42:24Z\t23.6746151\t70.6800486\t\t
623 2002-12-22T21:42:32Z\t23.6740038\t70.6799322\t\t
624 2002-12-22T21:42:54Z\t23.6723991\t70.6796266\t\t
625 2002-12-22T21:44:45Z\t23.6757566\t70.6800774\t\t
626 2002-12-22T21:44:52Z\t23.6753442\t70.6801502\t\t
627 2002-12-22T21:45:04Z\t23.6757542\t70.6801905\t\t
630 "Remove duplicated positions from csv output format",
634 # }}}
635 testcmd("../gpst -d -o clean no_signal.mayko", # {{{
636 <<END,
637 23.6746151\t70.6800486\t
638 23.6740038\t70.6799322\t
639 23.6723991\t70.6796266\t
640 23.6757566\t70.6800774\t
641 23.6753442\t70.6801502\t
642 23.6757542\t70.6801905\t
645 "Remove duplicated positions from clean output format",
649 # }}}
650 testcmd("../gpst -d -o pgtab no_signal.mayko", # {{{
651 <<END,
652 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N
653 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N
654 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
655 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N
656 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N
657 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N
660 "Remove duplicated positions from pgtab output format",
664 # }}}
665 # --skip-dups option }}}
666 diag("Testing --epoch option..."); # {{{
667 testcmd("../gpst -e pause.gpx", # {{{
668 <<END,
669 <?xml version="1.0" encoding="UTF-8"?>
670 <gpsml>
671 <track>
672 <title>ACTIVE LOG164705</title>
673 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
674 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
675 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
676 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
677 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
678 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
679 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
680 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
681 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
682 </track>
683 </gpsml>
686 "--epoch is ignored in gpsml output",
690 # }}}
691 testcmd("../gpst -e -o gpx pause-noname.gpx", # {{{
692 <<END,
693 $gpx_header
694 <trk>
695 <trkseg>
696 <trkpt lat="60.425494" lon="5.299534"> <ele>25.26</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
697 <trkpt lat="60.425464" lon="5.29961"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
698 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
699 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
700 <trkpt lat="60.425339" lon="5.299958"> <ele>30.98</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
701 <trkpt lat="60.425238" lon="5.29964"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
702 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
703 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
704 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
705 </trkseg>
706 </trk>
707 </gpx>
710 "--epoch is ignored in gpx output",
714 # }}}
715 testcmd("../gpst -e -o csv multitrack.gpx", # {{{
716 # FIXME: Get rid of the empty line in the beginning
717 <<END,
718 \t\t\t\t
719 1045006539\t-0.1448824\t51.4968266\t\t
720 1045006549\t-0.1449938\t51.4968227\t\t
721 1045006574\t-0.1453202\t51.496904\t\t
722 \t\t\t\t
723 1045006576\t-0.1453398\t51.4969214\t\t
724 1045006591\t-0.1455514\t51.4969816\t\t
725 1045006603\t-0.1457489\t51.4970224\t1000\t
726 1045006610\t-0.1457804\t51.4970452\t\t
727 \t\t\t\t
728 1045006625\t-0.1458608\t51.497068\t\t
729 1045006642\t-0.1460047\t51.4971658\t\t
730 1045006656\t-0.1461614\t51.4972469\t\t
731 \t\t\t\t
732 1045006663\t-0.1462394\t51.4972731\t\t
733 1045006684\t-0.1463232\t51.4973437\t\t
734 1045006708\t-0.1462949\t51.4973337\t\t
735 1045006714\t-0.1462825\t51.4973218\t\t
736 1045006715\t-0.1462732\t51.4973145\t\t
739 "Use --epoch with csv output",
743 # }}}
744 # --epoch option }}}
745 diag("Testing --fix option..."); # {{{
746 testcmd("../gpst --fix --chronology chronology-error.gpsml", # {{{
747 <<END,
748 <?xml version="1.0" encoding="UTF-8"?>
749 <gpsml>
750 <track>
751 <title>Chronology errors</title>
752 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
753 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
754 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
755 <break/>
756 <etp err="chrono"> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </etp>
757 <break/>
758 <pause>0:00:37:54</pause>
759 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
760 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
761 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
762 <etp err="duptime"> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </etp>
763 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
764 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
765 </track>
766 </gpsml>
768 "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" .
769 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
770 "Remove bad timestamps",
774 # }}}
775 # --fix option }}}
776 diag("Testing --from-date option..."); # {{{
777 # --from-date option }}}
778 diag("Testing -h (--help) option..."); # {{{
779 likecmd("$CMD -h", # {{{
780 '/ Show this help\./',
781 '/^$/',
782 "Option -h prints help screen",
785 # }}}
786 # --help option }}}
787 diag("Testing --inside option..."); # {{{
788 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx", # {{{
789 <<END,
790 <?xml version="1.0" encoding="UTF-8"?>
791 <gpsml>
792 <track>
793 <title>track1</title>
794 <break/>
795 <title>track2</title>
796 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
797 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
798 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
799 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
800 <break/>
801 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
802 <break/>
803 <title>track3</title>
804 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
805 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
806 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
807 </track>
808 </gpsml>
811 "Check --inside option (gpx to gpst)",
814 # }}}
816 # --inside option }}}
817 diag("Testing --undefined option..."); # {{{
818 # --undefined option }}}
819 diag("Testing --output option..."); # {{{
820 # gpsml (Default)
821 testcmd("../gpst log.mcsv", # {{{
822 <<END,
823 <?xml version="1.0" encoding="UTF-8"?>
824 <gpsml>
825 <track>
826 <break/>
827 <title>ACTIVE LOG 125</title>
828 <tp> <time>2006-03-04T11:12:30Z</time> <lat>54.96883</lat> <lon>-1.62439</lon> <ele>77</ele> </tp>
829 <tp> <time>2006-03-04T11:12:47Z</time> <lat>54.96878</lat> <lon>-1.62413</lon> <ele>77</ele> </tp>
830 <tp> <time>2006-03-04T11:12:55Z</time> <lat>54.96913</lat> <lon>-1.62616</lon> <ele>77</ele> </tp>
831 <tp> <time>2006-03-04T11:13:04Z</time> <lat>54.96934</lat> <lon>-1.62624</lon> <ele>77.5</ele> </tp>
832 <tp> <time>2006-03-04T11:13:33Z</time> <lat>54.96934</lat> <lon>-1.62596</lon> <ele>78</ele> </tp>
833 <tp> <time>2006-03-04T11:13:48Z</time> <lat>54.96931</lat> <lon>-1.62645</lon> <ele>78</ele> </tp>
834 <tp> <time>2006-03-04T11:14:05Z</time> <lat>54.96918</lat> <lon>-1.62603</lon> <ele>79</ele> </tp>
835 <tp> <time>2006-03-04T11:14:33Z</time> <lat>54.96901</lat> <lon>-1.62364</lon> <ele>76.1</ele> </tp>
836 <tp> <time>2006-03-04T11:15:02Z</time> <lat>54.96922</lat> <lon>-1.6254</lon> <ele>76.1</ele> </tp>
837 <tp> <time>2006-03-04T11:15:27Z</time> <lat>54.96914</lat> <lon>-1.62526</lon> <ele>75.1</ele> </tp>
838 <tp> <time>2006-03-04T11:15:50Z</time> <lat>54.96911</lat> <lon>-1.62494</lon> <ele>75.1</ele> </tp>
839 <tp> <time>2006-03-04T11:16:03Z</time> <lat>54.9693</lat> <lon>-1.62489</lon> <ele>75.1</ele> </tp>
840 <tp> <time>2006-03-04T11:16:19Z</time> <lat>54.96901</lat> <lon>-1.62496</lon> <ele>75.1</ele> </tp>
841 <tp> <time>2006-03-04T11:16:52Z</time> <lat>54.96871</lat> <lon>-1.62466</lon> <ele>74.6</ele> </tp>
842 <tp> <time>2006-03-04T11:17:25Z</time> <lat>54.96908</lat> <lon>-1.62488</lon> <ele>72.7</ele> </tp>
843 <break/>
844 <title>ACTIVE LOG 126</title>
845 <tp> <time>2006-03-04T11:18:32Z</time> <lat>54.96904</lat> <lon>-1.62482</lon> <ele>72.7</ele> </tp>
846 <tp> <time>2006-03-04T11:18:35Z</time> <lat>54.96913</lat> <lon>-1.62499</lon> <ele>71.3</ele> </tp>
847 <tp> <time>2006-03-04T11:18:38Z</time> <lat>54.96904</lat> <lon>-1.62497</lon> <ele>70.8</ele> </tp>
848 <tp> <time>2006-03-04T11:18:48Z</time> <lat>54.96913</lat> <lon>-1.62496</lon> <ele>71.8</ele> </tp>
849 <tp> <time>2006-03-04T11:18:55Z</time> <lat>54.96924</lat> <lon>-1.62501</lon> <ele>72.2</ele> </tp>
850 <tp> <time>2006-03-04T11:19:11Z</time> <lat>54.9694</lat> <lon>-1.62521</lon> <ele>71.8</ele> </tp>
851 <tp> <time>2006-03-04T11:19:30Z</time> <lat>54.96916</lat> <lon>-1.62515</lon> <ele>71.3</ele> </tp>
852 <tp> <time>2006-03-04T11:19:53Z</time> <lat>54.96921</lat> <lon>-1.625</lon> <ele>71.3</ele> </tp>
853 <tp> <time>2006-03-04T11:20:21Z</time> <lat>54.96801</lat> <lon>-1.62417</lon> <ele>71.8</ele> </tp>
854 <break/>
855 <title>ACTIVE LOG 127</title>
856 <tp> <time>2006-03-04T11:21:16Z</time> <lat>54.96887</lat> <lon>-1.62504</lon> <ele>70.8</ele> </tp>
857 <tp> <time>2006-03-04T11:21:18Z</time> <lat>54.96898</lat> <lon>-1.62476</lon> <ele>69.8</ele> </tp>
858 <tp> <time>2006-03-04T11:21:29Z</time> <lat>54.9691</lat> <lon>-1.62475</lon> <ele>69.4</ele> </tp>
859 <tp> <time>2006-03-04T11:21:46Z</time> <lat>54.96918</lat> <lon>-1.62468</lon> <ele>70.3</ele> </tp>
860 <tp> <time>2006-03-04T11:22:39Z</time> <lat>54.9692</lat> <lon>-1.62465</lon> <ele>69.4</ele> </tp>
861 <tp> <time>2006-03-04T11:22:43Z</time> <lat>54.96924</lat> <lon>-1.62462</lon> <ele>71.8</ele> </tp>
862 <tp> <time>2006-03-04T11:22:45Z</time> <lat>54.96928</lat> <lon>-1.62463</lon> <ele>71.8</ele> </tp>
863 <tp> <time>2006-03-04T11:23:00Z</time> <lat>54.96945</lat> <lon>-1.62466</lon> <ele>69.4</ele> </tp>
864 </track>
865 </gpsml>
868 "Read Mapsource TAB-separated format",
872 # }}}
873 testcmd("../gpst two-digit_year.mcsv", # {{{
874 <<END,
875 <?xml version="1.0" encoding="UTF-8"?>
876 <gpsml>
877 <track>
878 <break/>
879 <title>ACTIVE LOG 032</title>
880 <tp> <time>2006-03-20T20:35:33Z</time> <lat>60.41324</lat> <lon>5.33352</lon> <ele>14</ele> </tp>
881 <tp> <time>2006-03-20T20:35:38Z</time> <lat>60.38802</lat> <lon>5.33845</lon> <ele>18</ele> </tp>
882 <tp> <time>2006-03-20T20:35:44Z</time> <lat>60.38709</lat> <lon>5.3379</lon> <ele>19</ele> </tp>
883 <tp> <time>2006-03-20T20:35:49Z</time> <lat>60.38641</lat> <lon>5.33732</lon> <ele>18</ele> </tp>
884 <tp> <time>2006-03-20T20:35:54Z</time> <lat>60.38581</lat> <lon>5.33647</lon> <ele>18</ele> </tp>
885 <tp> <time>2006-03-20T20:36:00Z</time> <lat>60.38516</lat> <lon>5.33528</lon> <ele>15</ele> </tp>
886 <tp> <time>2006-03-20T20:36:02Z</time> <lat>60.38495</lat> <lon>5.3349</lon> <ele>13</ele> </tp>
887 </track>
888 </gpsml>
891 "Read Mapsource TAB-separated format with two-digit year",
895 # }}}
896 testcmd("../gpst log.gpstxt", # {{{
897 <<END,
898 <?xml version="1.0" encoding="UTF-8"?>
899 <gpsml>
900 <track>
901 <tp> <time>2003-06-13T14:36:09Z</time> <lat>59.521517</lat> <lon>7.391867</lon> <ele>762</ele> </tp>
902 <tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>
903 <tp> <time>2003-06-13T14:36:11Z</time> <lat>59.5213</lat> <lon>7.392417</lon> <ele>761</ele> </tp>
904 <tp> <time>2003-06-13T14:36:12Z</time> <lat>59.521183</lat> <lon>7.3927</lon> <ele>761</ele> </tp>
905 <etp err="nosignal"> <time>2003-06-13T14:36:13Z</time> </etp>
906 <tp> <time>2003-06-13T14:36:15Z</time> <lat>59.52085</lat> <lon>7.393517</lon> <ele>760</ele> </tp>
907 <tp> <time>2003-06-13T14:36:16Z</time> <lat>59.520733</lat> <lon>7.393783</lon> <ele>760</ele> </tp>
908 <tp> <time>2003-06-13T14:36:17Z</time> <lat>59.52065</lat> <lon>7.39405</lon> <ele>760</ele> </tp>
909 <tp> <time>2003-06-13T14:36:18Z</time> <lat>59.520583</lat> <lon>7.394333</lon> <ele>760</ele> </tp>
910 <tp> <time>2003-06-13T14:36:19Z</time> <lat>59.520533</lat> <lon>7.394633</lon> <ele>759</ele> </tp>
911 <tp> <time>2003-06-13T14:36:20Z</time> <lat>59.520483</lat> <lon>7.394917</lon> <ele>759</ele> </tp>
912 <tp> <time>2003-06-13T14:36:21Z</time> <lat>59.520433</lat> <lon>7.395233</lon> <ele>759</ele> </tp>
913 <etp err="nosignal"> <time>2003-06-13T14:36:22Z</time> </etp>
914 <tp> <time>2003-06-13T14:36:24Z</time> <lat>59.520283</lat> <lon>7.396233</lon> <ele>758</ele> </tp>
915 <tp> <time>2003-06-13T14:36:25Z</time> <lat>59.520233</lat> <lon>7.39655</lon> <ele>758</ele> </tp>
916 <tp> <time>2003-06-13T14:36:26Z</time> <lat>59.520183</lat> <lon>7.396883</lon> <ele>757</ele> </tp>
917 <tp> <time>2003-06-13T14:36:27Z</time> <lat>59.520133</lat> <lon>7.397217</lon> <ele>757</ele> </tp>
918 <tp> <time>2003-06-13T14:36:28Z</time> <lat>59.5201</lat> <lon>7.397567</lon> <ele>757</ele> </tp>
919 </track>
920 </gpsml>
923 "Read Garmin serial text format",
927 # }}}
928 testcmd("../gpst log.dos.mayko", # {{{
929 <<END,
930 <?xml version="1.0" encoding="UTF-8"?>
931 <gpsml>
932 <track>
933 <tp> <time>2003-06-15T10:27:45Z</time> <lat>58.1818158</lat> <lon>8.1225077</lon> </tp>
934 <tp> <time>2003-06-15T10:27:53Z</time> <lat>58.1818712</lat> <lon>8.12532</lon> </tp>
935 <tp> <time>2003-06-15T10:27:57Z</time> <lat>58.1816347</lat> <lon>8.1266031</lon> </tp>
936 <tp> <time>2003-06-15T10:28:03Z</time> <lat>58.1812099</lat> <lon>8.1284612</lon> </tp>
937 <tp> <time>2003-06-15T10:28:06Z</time> <lat>58.1810315</lat> <lon>8.129395</lon> </tp>
938 <tp> <time>2003-06-15T10:28:10Z</time> <lat>58.1809621</lat> <lon>8.13074</lon> </tp>
939 </track>
940 </gpsml>
943 "Read DOS-formatted Mayko format",
947 # }}}
948 testcmd("../gpst log.dos.gpstxt", # {{{
949 <<END,
950 <?xml version="1.0" encoding="UTF-8"?>
951 <gpsml>
952 <track>
953 <tp> <time>2003-01-05T16:47:11Z</time> <lat>66.908167</lat> <lon>15.022983</lon> <ele>11472</ele> </tp>
954 <tp> <time>2003-01-05T16:47:12Z</time> <lat>66.90625</lat> <lon>15.020667</lon> <ele>11472</ele> </tp>
955 <tp> <time>2003-01-05T16:47:13Z</time> <lat>66.904317</lat> <lon>15.01835</lon> <ele>11472</ele> </tp>
956 <tp> <time>2003-01-05T16:47:14Z</time> <lat>66.9024</lat> <lon>15.016017</lon> <ele>11473</ele> </tp>
957 <tp> <time>2003-01-05T16:47:15Z</time> <lat>66.900483</lat> <lon>15.0137</lon> <ele>11474</ele> </tp>
958 <tp> <time>2003-01-05T16:47:16Z</time> <lat>66.898567</lat> <lon>15.011383</lon> <ele>11474</ele> </tp>
959 <tp> <time>2003-01-05T16:47:17Z</time> <lat>66.896633</lat> <lon>15.009067</lon> <ele>11475</ele> </tp>
960 <tp> <time>2003-01-05T16:47:18Z</time> <lat>66.894717</lat> <lon>15.006733</lon> <ele>11475</ele> </tp>
961 <tp> <time>2003-01-05T16:47:19Z</time> <lat>66.8928</lat> <lon>15.004417</lon> <ele>11475</ele> </tp>
962 <tp> <time>2003-01-05T16:47:20Z</time> <lat>66.890867</lat> <lon>15.0021</lon> <ele>11475</ele> </tp>
963 <tp> <time>2003-01-05T16:47:21Z</time> <lat>66.88895</lat> <lon>14.999783</lon> <ele>11475</ele> </tp>
964 </track>
965 </gpsml>
968 "Read DOS-formatted Garmin serial text format",
972 # }}}
973 testcmd("../gpst log.unix.mcsv", # {{{
974 <<END,
975 <?xml version="1.0" encoding="UTF-8"?>
976 <gpsml>
977 <track>
978 <break/>
979 <title>ACTIVE LOG 058</title>
980 <tp> <time>2006-02-21T15:14:25Z</time> <lat>60.36662</lat> <lon>5.24885</lon> <ele>31.9</ele> </tp>
981 <tp> <time>2006-02-21T15:14:30Z</time> <lat>60.37057</lat> <lon>5.22956</lon> <ele>35.2</ele> </tp>
982 <tp> <time>2006-02-21T15:14:35Z</time> <lat>60.37019</lat> <lon>5.22817</lon> <ele>39.6</ele> </tp>
983 <tp> <time>2006-02-21T15:14:36Z</time> <lat>60.37012</lat> <lon>5.2279</lon> <ele>41</ele> </tp>
984 <tp> <time>2006-02-21T15:14:40Z</time> <lat>60.37009</lat> <lon>5.22682</lon> <ele>47.2</ele> </tp>
985 <tp> <time>2006-02-21T15:14:42Z</time> <lat>60.37011</lat> <lon>5.22641</lon> <ele>49.2</ele> </tp>
986 <tp> <time>2006-02-21T15:14:44Z</time> <lat>60.37011</lat> <lon>5.22607</lon> <ele>50.1</ele> </tp>
987 <tp> <time>2006-02-21T15:14:48Z</time> <lat>60.37002</lat> <lon>5.22568</lon> <ele>51.1</ele> </tp>
988 <tp> <time>2006-02-21T15:14:51Z</time> <lat>60.3701</lat> <lon>5.22548</lon> <ele>52.5</ele> </tp>
989 </track>
990 </gpsml>
993 "Read UNIX-formatted Garmin Mapsource TAB-separated format",
997 # }}}
998 testcmd("../gpst multitrack.gpx", # {{{
999 <<END,
1000 <?xml version="1.0" encoding="UTF-8"?>
1001 <gpsml>
1002 <track>
1003 <title>Track 1</title>
1004 <tp> <time>2003-02-11T23:35:39Z</time> <lat>51.4968266</lat> <lon>-0.1448824</lon> </tp>
1005 <tp> <time>2003-02-11T23:35:49Z</time> <lat>51.4968227</lat> <lon>-0.1449938</lon> </tp>
1006 <tp> <time>2003-02-11T23:36:14Z</time> <lat>51.496904</lat> <lon>-0.1453202</lon> </tp>
1007 <break/>
1008 <title>Track 2</title>
1009 <tp> <time>2003-02-11T23:36:16Z</time> <lat>51.4969214</lat> <lon>-0.1453398</lon> </tp>
1010 <tp> <time>2003-02-11T23:36:31Z</time> <lat>51.4969816</lat> <lon>-0.1455514</lon> </tp>
1011 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
1012 <tp> <time>2003-02-11T23:36:50Z</time> <lat>51.4970452</lat> <lon>-0.1457804</lon> </tp>
1013 <break/>
1014 <title>Track 3</title>
1015 <tp> <time>2003-02-11T23:37:05Z</time> <lat>51.497068</lat> <lon>-0.1458608</lon> </tp>
1016 <tp> <time>2003-02-11T23:37:22Z</time> <lat>51.4971658</lat> <lon>-0.1460047</lon> </tp>
1017 <tp> <time>2003-02-11T23:37:36Z</time> <lat>51.4972469</lat> <lon>-0.1461614</lon> </tp>
1018 <break/>
1019 <title>Track 4</title>
1020 <tp> <time>2003-02-11T23:37:43Z</time> <lat>51.4972731</lat> <lon>-0.1462394</lon> </tp>
1021 <tp> <time>2003-02-11T23:38:04Z</time> <lat>51.4973437</lat> <lon>-0.1463232</lon> </tp>
1022 <tp> <time>2003-02-11T23:38:28Z</time> <lat>51.4973337</lat> <lon>-0.1462949</lon> </tp>
1023 <tp> <time>2003-02-11T23:38:34Z</time> <lat>51.4973218</lat> <lon>-0.1462825</lon> </tp>
1024 <tp> <time>2003-02-11T23:38:35Z</time> <lat>51.4973145</lat> <lon>-0.1462732</lon> </tp>
1025 </track>
1026 </gpsml>
1029 "Read GPX file with multiple tracks",
1033 # }}}
1034 testcmd("../gpst compact.gpx", # {{{
1035 <<END,
1036 <?xml version="1.0" encoding="UTF-8"?>
1037 <gpsml>
1038 <track>
1039 <title>All whitespace stripped</title>
1040 <tp> <time>2002-12-30T15:22:04Z</time> <lat>70.660932</lat> <lon>23.7028354</lon> </tp>
1041 <tp> <time>2002-12-30T15:22:06Z</time> <lat>70.6609392</lat> <lon>23.7028468</lon> </tp>
1042 <tp> <time>2002-12-30T15:22:08Z</time> <lat>70.6609429</lat> <lon>23.7028499</lon> </tp>
1043 <tp> <time>2002-12-30T15:22:11Z</time> <lat>70.6609381</lat> <lon>23.702862</lon> </tp>
1044 <tp> <time>2002-12-30T15:22:12Z</time> <lat>70.6609368</lat> <lon>23.7028648</lon> </tp>
1045 <tp> <time>2002-12-30T15:22:13Z</time> <lat>70.6609344</lat> <lon>23.7028652</lon> </tp>
1046 <tp> <time>2002-12-30T15:22:15Z</time> <lat>70.6609349</lat> <lon>23.7028707</lon> </tp>
1047 <tp> <time>2002-12-30T15:22:17Z</time> <lat>70.6609348</lat> <lon>23.7028654</lon> </tp>
1048 <tp> <time>2002-12-30T15:22:19Z</time> <lat>70.6609347</lat> <lon>23.7028599</lon> </tp>
1049 <tp> <time>2002-12-30T15:22:20Z</time> <lat>70.6609348</lat> <lon>23.7028609</lon> </tp>
1050 <tp> <time>2002-12-30T15:22:23Z</time> <lat>70.6609388</lat> <lon>23.7028653</lon> </tp>
1051 <tp> <time>2002-12-30T15:22:25Z</time> <lat>70.6609426</lat> <lon>23.7028732</lon> </tp>
1052 </track>
1053 </gpsml>
1056 "Read GPX one-liner",
1060 # }}}
1061 testcmd("../gpst missing.gpsml", # {{{
1062 <<END,
1063 <?xml version="1.0" encoding="UTF-8"?>
1064 <gpsml>
1065 <track>
1066 <title>Missing various elements</title>
1067 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
1068 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
1069 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1070 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1071 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1072 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1073 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
1074 <tp> <ele>486</ele> </tp>
1075 <tp> <desc>Missing everything</desc> </tp>
1076 <tp> <lat>60.42339</lat> </tp>
1077 <tp> <lon>5.34262</lon> </tp>
1078 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1079 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1080 </track>
1081 </gpsml>
1084 "Read gpsml with various data missing",
1088 # }}}
1089 testcmd("../gpst different_dateformats.gpsml", # {{{
1090 <<END,
1091 <?xml version="1.0" encoding="UTF-8"?>
1092 <gpsml>
1093 <track>
1094 <title>Date format variations</title>
1095 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1</lat> <lon>1</lon> </tp>
1096 <tp> <time>2006-01-01T00:00:02Z</time> <lat>2</lat> <lon>2</lon> </tp>
1097 <tp> <time>2006-01-01T00:00:03Z</time> <lat>3</lat> <lon>3</lon> </tp>
1098 <tp> <time>2006-01-01T00:00:04Z</time> <lat>4</lat> <lon>4</lon> </tp>
1099 </track>
1100 </gpsml>
1103 "Read different date formats from gpsml file",
1107 # }}}
1108 testcmd("../gpst multitrack-pause.gpx", # {{{
1109 file_data("multitrack-pause.gpsml"),
1111 "Should be equal to multitrack-pause.gpsml",
1115 # }}}
1116 # gpx
1117 testcmd("../gpst -o gpx no_signal.mayko", # {{{
1118 <<END,
1119 $gpx_header
1120 <trk>
1121 <trkseg>
1122 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
1123 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
1124 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
1125 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> </trkpt>
1126 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> </trkpt>
1127 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> </trkpt>
1128 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
1129 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
1130 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
1131 </trkseg>
1132 </trk>
1133 </gpx>
1136 "Output GPX from Mayko file with duplicates",
1140 # }}}
1141 testcmd("../gpst -o gpx comments.mayko", # {{{
1142 <<END,
1143 $gpx_header
1144 <trk>
1145 <trkseg>
1146 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
1147 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
1148 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
1149 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1150 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1151 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1152 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
1153 </trkseg>
1154 <trkseg>
1155 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
1156 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
1157 </trkseg>
1158 </trk>
1159 </gpx>
1162 "Output GPX from Mayko file with commented-out lines",
1166 # }}}
1167 testcmd("../gpst -o gpx missing-noname.gpsml", # {{{
1168 <<END,
1169 $gpx_header
1170 <trk>
1171 <trkseg>
1172 <trkpt lat="60.42353" lon="5.34185"> <time>2006-04-30T17:17:09Z</time> </trkpt>
1173 <trkpt lat="60.42347" lon="5.34212"> <ele>486</ele> </trkpt>
1174 <trkpt lat="60.42338" lon="5.34269"> <ele>487</ele> <time>2006-04-30T17:18:05Z</time> </trkpt>
1175 </trkseg>
1176 </trk>
1177 </gpx>
1180 "Output GPX from gpsml with missing data",
1184 # }}}
1185 # xgraph
1186 testcmd("../gpst -o xgraph multitrack.gpx", # {{{
1187 <<END,
1188 -0.1448824 51.4968266
1189 -0.1449938 51.4968227
1190 -0.1453202 51.496904
1191 move -0.1453398 51.4969214
1192 -0.1455514 51.4969816
1193 -0.1457489 51.4970224
1194 -0.1457804 51.4970452
1195 move -0.1458608 51.497068
1196 -0.1460047 51.4971658
1197 -0.1461614 51.4972469
1198 move -0.1462394 51.4972731
1199 -0.1463232 51.4973437
1200 -0.1462949 51.4973337
1201 -0.1462825 51.4973218
1202 -0.1462732 51.4973145
1205 "Output xgraph format from GPX",
1209 # }}}
1210 # pgtab
1211 testcmd("../gpst -o pgtab compact.gpx", # {{{
1212 <<END,
1213 2002-12-30T15:22:04Z\t(70.660932,23.7028354)\t\\N\t\\N\t\\N\t\\N
1214 2002-12-30T15:22:06Z\t(70.6609392,23.7028468)\t\\N\t\\N\t\\N\t\\N
1215 2002-12-30T15:22:08Z\t(70.6609429,23.7028499)\t\\N\t\\N\t\\N\t\\N
1216 2002-12-30T15:22:11Z\t(70.6609381,23.702862)\t\\N\t\\N\t\\N\t\\N
1217 2002-12-30T15:22:12Z\t(70.6609368,23.7028648)\t\\N\t\\N\t\\N\t\\N
1218 2002-12-30T15:22:13Z\t(70.6609344,23.7028652)\t\\N\t\\N\t\\N\t\\N
1219 2002-12-30T15:22:15Z\t(70.6609349,23.7028707)\t\\N\t\\N\t\\N\t\\N
1220 2002-12-30T15:22:17Z\t(70.6609348,23.7028654)\t\\N\t\\N\t\\N\t\\N
1221 2002-12-30T15:22:19Z\t(70.6609347,23.7028599)\t\\N\t\\N\t\\N\t\\N
1222 2002-12-30T15:22:20Z\t(70.6609348,23.7028609)\t\\N\t\\N\t\\N\t\\N
1223 2002-12-30T15:22:23Z\t(70.6609388,23.7028653)\t\\N\t\\N\t\\N\t\\N
1224 2002-12-30T15:22:25Z\t(70.6609426,23.7028732)\t\\N\t\\N\t\\N\t\\N
1227 "Output pgtab from gpx format",
1231 # }}}
1232 testcmd("../gpst -o pgtab no_signal.mayko", # {{{
1233 <<END,
1234 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N
1235 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N
1236 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1237 2002-12-22T21:43:51Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1238 2002-12-22T21:43:52Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1239 2002-12-22T21:43:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1240 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N
1241 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N
1242 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N
1245 "Output pgtab from mayko format",
1249 # }}}
1250 testcmd("../gpst -o pgtab missing.gpsml", # {{{
1251 <<END,
1252 2006-04-30T17:17:09Z\t(60.42353,5.34185)\t\\N\t\\N\t\\N\t\\N
1253 \\N\t(60.42347,5.34212)\t486\t\\N\t\\N\t\\N
1254 2006-04-30T17:18:05Z\t(60.42338,5.34269)\t487\t\\N\t\\N\t\\N
1257 "Output pgtab from missing.gpsml",
1261 # }}}
1262 # csv
1263 testcmd("../gpst -o csv log.dos.mayko", # {{{
1264 <<END,
1265 2003-06-15T10:27:45Z\t8.1225077\t58.1818158\t\t
1266 2003-06-15T10:27:53Z\t8.12532\t58.1818712\t\t
1267 2003-06-15T10:27:57Z\t8.1266031\t58.1816347\t\t
1268 2003-06-15T10:28:03Z\t8.1284612\t58.1812099\t\t
1269 2003-06-15T10:28:06Z\t8.129395\t58.1810315\t\t
1270 2003-06-15T10:28:10Z\t8.13074\t58.1809621\t\t
1273 "Output csv from DOS-formatted Mayko format",
1277 # }}}
1278 testcmd("../gpst -o csv multitrack.gpx", # {{{
1279 # FIXME: Get rid of the empty line in the beginning
1280 <<END,
1281 \t\t\t\t
1282 2003-02-11T23:35:39Z\t-0.1448824\t51.4968266\t\t
1283 2003-02-11T23:35:49Z\t-0.1449938\t51.4968227\t\t
1284 2003-02-11T23:36:14Z\t-0.1453202\t51.496904\t\t
1285 \t\t\t\t
1286 2003-02-11T23:36:16Z\t-0.1453398\t51.4969214\t\t
1287 2003-02-11T23:36:31Z\t-0.1455514\t51.4969816\t\t
1288 2003-02-11T23:36:43Z\t-0.1457489\t51.4970224\t1000\t
1289 2003-02-11T23:36:50Z\t-0.1457804\t51.4970452\t\t
1290 \t\t\t\t
1291 2003-02-11T23:37:05Z\t-0.1458608\t51.497068\t\t
1292 2003-02-11T23:37:22Z\t-0.1460047\t51.4971658\t\t
1293 2003-02-11T23:37:36Z\t-0.1461614\t51.4972469\t\t
1294 \t\t\t\t
1295 2003-02-11T23:37:43Z\t-0.1462394\t51.4972731\t\t
1296 2003-02-11T23:38:04Z\t-0.1463232\t51.4973437\t\t
1297 2003-02-11T23:38:28Z\t-0.1462949\t51.4973337\t\t
1298 2003-02-11T23:38:34Z\t-0.1462825\t51.4973218\t\t
1299 2003-02-11T23:38:35Z\t-0.1462732\t51.4973145\t\t
1302 "Output csv from DOS-formatted Mayko format",
1306 # }}}
1307 # pgwtab
1308 testcmd("../gpst -o pgwtab multitrack.gpx", # {{{
1309 <<END,
1310 (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
1311 (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
1312 (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
1313 (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
1314 (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
1315 (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
1318 "Test pgwtab format",
1322 # }}}
1323 # pgwupd
1324 testcmd("../gpst -o pgwupd multitrack.gpx", # {{{
1325 <<END,
1326 BEGIN;
1327 UPDATE logg SET name = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1328 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1329 COMMIT;
1330 BEGIN;
1331 UPDATE logg SET name = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1332 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1333 COMMIT;
1334 BEGIN;
1335 UPDATE logg SET name = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1336 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1337 COMMIT;
1338 BEGIN;
1339 UPDATE logg SET name = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1340 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1341 COMMIT;
1342 BEGIN;
1343 UPDATE logg SET name = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1344 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1345 COMMIT;
1346 BEGIN;
1347 UPDATE logg SET name = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1348 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1349 COMMIT;
1352 "Test pgwupd format",
1356 # }}}
1357 # clean
1358 testcmd("../gpst -t -o clean pause.gpx", # {{{
1359 <<END,
1360 5.299534\t60.425494\t25.26
1361 5.29961\t60.425464\t24.931
1363 5.299694\t60.425314\t27.975
1365 5.299741\t60.425384\t31.017
1366 5.299958\t60.425339\t30.98
1367 5.29964\t60.425238\t30.538
1368 5.299686\t60.425246\t30.515
1370 5.299773\t60.425345\t31.936
1371 5.299419\t60.425457\t31.794
1374 "Output clean format with time breaks",
1377 # }}}
1378 # gpstrans
1379 # poscount
1380 # ps (Unfinished)
1381 # svg (Unfinished)
1382 # ygraph
1383 # --output option }}}
1384 diag("Testing --outside option..."); # {{{
1385 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --outside multitrack-pause.gpx", # {{{
1386 <<END,
1387 <?xml version="1.0" encoding="UTF-8"?>
1388 <gpsml>
1389 <track>
1390 <title>track1</title>
1391 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1392 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1393 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1394 <break/>
1395 <title>track2</title>
1396 <break/>
1397 <title>track3</title>
1398 <break/>
1399 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1400 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1401 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1402 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1403 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1404 </track>
1405 </gpsml>
1408 "Check --outside option (gpx to gpst)",
1412 # }}}
1413 # --outside option }}}
1414 diag("Testing --pos1 and --pos2 options..."); # {{{
1415 # --pos1 and --pos2 options }}}
1416 diag("Testing --require option..."); # {{{
1417 testcmd("../gpst -re multitrack.gpx", # {{{
1418 <<END,
1419 <?xml version="1.0" encoding="UTF-8"?>
1420 <gpsml>
1421 <track>
1422 <title>Track 1</title>
1423 <break/>
1424 <title>Track 2</title>
1425 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
1426 <break/>
1427 <title>Track 3</title>
1428 <break/>
1429 <title>Track 4</title>
1430 </track>
1431 </gpsml>
1434 "Require elevation from GPX data",
1438 # }}}
1439 testcmd("../gpst -re one_ele.dos.gpsml", # {{{
1440 <<END,
1441 <?xml version="1.0" encoding="UTF-8"?>
1442 <gpsml>
1443 <track>
1444 <title>Only one point has elevation</title>
1445 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1446 </track>
1447 </gpsml>
1450 "Require elevation from gpsml",
1454 # }}}
1455 testcmd("../gpst -re missing.gpsml", # {{{
1456 <<END,
1457 <?xml version="1.0" encoding="UTF-8"?>
1458 <gpsml>
1459 <track>
1460 <title>Missing various elements</title>
1461 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1462 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1463 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1464 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
1465 <tp> <ele>486</ele> </tp>
1466 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1467 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1468 </track>
1469 </gpsml>
1472 "Require elevation",
1476 # }}}
1477 testcmd("../gpst -rt missing.gpsml", # {{{
1478 <<END,
1479 <?xml version="1.0" encoding="UTF-8"?>
1480 <gpsml>
1481 <track>
1482 <title>Missing various elements</title>
1483 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
1484 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
1485 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1486 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1487 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1488 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1489 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1490 </track>
1491 </gpsml>
1494 "Require time",
1498 # }}}
1499 testcmd("../gpst -rp missing.gpsml", # {{{
1500 <<END,
1501 <?xml version="1.0" encoding="UTF-8"?>
1502 <gpsml>
1503 <track>
1504 <title>Missing various elements</title>
1505 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1506 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1507 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1508 </track>
1509 </gpsml>
1512 "Require position",
1516 # }}}
1517 testcmd("../gpst -ret missing.gpsml", # {{{
1518 <<END,
1519 <?xml version="1.0" encoding="UTF-8"?>
1520 <gpsml>
1521 <track>
1522 <title>Missing various elements</title>
1523 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1524 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1525 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1526 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1527 </track>
1528 </gpsml>
1531 "Require elevation and time",
1535 # }}}
1536 testcmd("../gpst -retp missing.gpsml", # {{{
1537 <<END,
1538 <?xml version="1.0" encoding="UTF-8"?>
1539 <gpsml>
1540 <track>
1541 <title>Missing various elements</title>
1542 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1543 </track>
1544 </gpsml>
1547 "Require elevation, time and position",
1551 # }}}
1552 testcmd("../gpst -rep missing.gpsml", # {{{
1553 <<END,
1554 <?xml version="1.0" encoding="UTF-8"?>
1555 <gpsml>
1556 <track>
1557 <title>Missing various elements</title>
1558 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1559 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1560 </track>
1561 </gpsml>
1564 "Require elevation and position",
1568 # }}}
1569 # --require option }}}
1570 diag("Testing --round option..."); # {{{
1571 testcmd("../gpst -R lat=4,lon=5,ele=1 pause.gpx", # {{{
1572 <<END,
1573 <?xml version="1.0" encoding="UTF-8"?>
1574 <gpsml>
1575 <track>
1576 <title>ACTIVE LOG164705</title>
1577 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.4255</lat> <lon>5.29953</lon> <ele>25.3</ele> </tp>
1578 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.4255</lat> <lon>5.29961</lon> <ele>24.9</ele> </tp>
1579 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.4253</lat> <lon>5.29969</lon> <ele>28</ele> </tp>
1580 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.4254</lat> <lon>5.29974</lon> <ele>31</ele> </tp>
1581 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.4253</lat> <lon>5.29996</lon> <ele>31</ele> </tp>
1582 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.4252</lat> <lon>5.29964</lon> <ele>30.5</ele> </tp>
1583 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.4252</lat> <lon>5.29969</lon> <ele>30.5</ele> </tp>
1584 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.4253</lat> <lon>5.29977</lon> <ele>31.9</ele> </tp>
1585 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.4255</lat> <lon>5.29942</lon> <ele>31.8</ele> </tp>
1586 </track>
1587 </gpsml>
1590 "--round works with lat, lon, ele from gpx",
1594 # }}}
1595 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgtab pause.gpx", # {{{
1596 <<END,
1597 2006-05-21T16:49:11Z\t(60.425,5.3)\t25.3\t\\N\t\\N\t\\N
1598 2006-05-21T16:49:46Z\t(60.425,5.3)\t24.9\t\\N\t\\N\t\\N
1599 2006-05-21T16:52:04Z\t(60.425,5.3)\t28\t\\N\t\\N\t\\N
1600 2006-05-21T16:56:36Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N
1601 2006-05-21T16:56:47Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N
1602 2006-05-21T16:56:56Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N
1603 2006-05-21T16:57:03Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N
1604 2006-05-21T16:59:08Z\t(60.425,5.3)\t31.9\t\\N\t\\N\t\\N
1605 2006-05-21T17:00:54Z\t(60.425,5.299)\t31.8\t\\N\t\\N\t\\N
1608 "pgtab output from gpx works with --round lat, lon, ele",
1612 # }}}
1613 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwtab multitrack.gpx", # {{{
1614 <<END,
1615 (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
1616 (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
1617 (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
1618 (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
1619 (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
1620 (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
1623 "--round works with lat, lon, ele from gpx, pgwtab output",
1627 # }}}
1628 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwupd multitrack.gpx", # {{{
1629 <<END,
1630 BEGIN;
1631 UPDATE logg SET name = clname(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1632 UPDATE logg SET dist = cldist(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1633 COMMIT;
1634 BEGIN;
1635 UPDATE logg SET name = clname(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1636 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1637 COMMIT;
1638 BEGIN;
1639 UPDATE logg SET name = clname(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1640 UPDATE logg SET dist = cldist(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1641 COMMIT;
1642 BEGIN;
1643 UPDATE logg SET name = clname(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1644 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1645 COMMIT;
1646 BEGIN;
1647 UPDATE logg SET name = clname(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1648 UPDATE logg SET dist = cldist(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1649 COMMIT;
1650 BEGIN;
1651 UPDATE logg SET name = clname(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1652 UPDATE logg SET dist = cldist(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1653 COMMIT;
1656 "pgwupd output and --round works with lat, lon, ele from gpx",
1660 # }}}
1661 testcmd("../gpst -R lat=8,lon=8 -o gpx rounding.mayko", # {{{
1662 <<END,
1663 $gpx_header
1664 <trk>
1665 <trkseg>
1666 <trkpt lat="51.4838161" lon="0.0000533"> <time>2003-02-11T12:17:05Z</time> </trkpt>
1667 <trkpt lat="51.483777" lon="-0.0000211"> <time>2003-02-11T12:17:15Z</time> </trkpt>
1668 <trkpt lat="51.4837543" lon="-0.0000894"> <time>2003-02-11T12:17:21Z</time> </trkpt>
1669 <trkpt lat="51.4836222" lon="0.0000272"> <time>2003-02-11T12:27:41Z</time> </trkpt>
1670 </trkseg>
1671 </trk>
1672 </gpx>
1675 "Suppress braindead scientific notation when using --round (from mayko)",
1679 # }}}
1680 testcmd("../gpst -R lat=8,lon=8 -o gpx rounding.gpx", # {{{
1681 <<END,
1682 $gpx_header
1683 <trk>
1684 <trkseg>
1685 <trkpt lat="51.4838161" lon="0.0000533"> <time>2003-02-11T12:17:05Z</time> </trkpt>
1686 <trkpt lat="51.483777" lon="-0.0000211"> <time>2003-02-11T12:17:15Z</time> </trkpt>
1687 <trkpt lat="51.4837543" lon="-0.0000894"> <time>2003-02-11T12:17:21Z</time> </trkpt>
1688 <trkpt lat="51.4836222" lon="0.0000272"> <time>2003-02-11T12:27:41Z</time> </trkpt>
1689 </trkseg>
1690 </trk>
1691 </gpx>
1694 "Suppress braindead scientific notation when using --round (from gpx)",
1698 # }}}
1699 # --round option }}}
1700 diag("Testing --short-date option..."); # {{{
1701 # --short-date option }}}
1702 diag("Testing --save-to-file option..."); # {{{
1703 # --save-to-file option }}}
1704 diag("Testing --create-breaks option..."); # {{{
1705 testcmd("../gpst -t pause.gpx", # {{{
1706 <<END,
1707 <?xml version="1.0" encoding="UTF-8"?>
1708 <gpsml>
1709 <track>
1710 <title>ACTIVE LOG164705</title>
1711 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
1712 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
1713 <pause>0:00:02:18</pause>
1714 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1715 <pause>0:00:04:32</pause>
1716 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
1717 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
1718 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
1719 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
1720 <pause>0:00:02:05</pause>
1721 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
1722 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
1723 </track>
1724 </gpsml>
1727 "Output gpsml with <pause> elements from GPX files",
1731 # }}}
1732 testcmd("../gpst -t multitrack-pause.gpx", # {{{
1733 <<END,
1734 <?xml version="1.0" encoding="UTF-8"?>
1735 <gpsml>
1736 <track>
1737 <title>track1</title>
1738 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1739 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1740 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1741 <break/>
1742 <title>track2</title>
1743 <pause>0:23:59:58</pause>
1744 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1745 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1746 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1747 <pause>0:01:00:00</pause>
1748 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1749 <break/>
1750 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1751 <break/>
1752 <title>track3</title>
1753 <pause>1:01:00:03</pause>
1754 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1755 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1756 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1757 <break/>
1758 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1759 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1760 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1761 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1762 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1763 </track>
1764 </gpsml>
1767 "Insert <pause> between gpx tracks",
1771 # }}}
1772 testcmd("../gpst -t multitrack-pause.gpsml", # {{{
1773 <<END,
1774 <?xml version="1.0" encoding="UTF-8"?>
1775 <gpsml>
1776 <track>
1777 <title>track1</title>
1778 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1779 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1780 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1781 <break/>
1782 <title>track2</title>
1783 <pause>0:23:59:58</pause>
1784 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1785 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1786 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1787 <pause>0:01:00:00</pause>
1788 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1789 <break/>
1790 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1791 <break/>
1792 <title>track3</title>
1793 <pause>1:01:00:03</pause>
1794 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1795 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1796 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1797 <break/>
1798 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1799 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1800 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1801 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1802 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1803 </track>
1804 </gpsml>
1807 "Insert <pause> between gpsml titles",
1811 # }}}
1812 # --create-breaks option }}}
1813 diag("Testing -T (--time-shift) option..."); # {{{
1814 testcmd("$CMD -T 3600 multitrack-pause.gpx", # {{{
1815 <<END,
1816 <?xml version="1.0" encoding="UTF-8"?>
1817 <gpsml>
1818 <track>
1819 <title>track1</title>
1820 <tp> <time>2006-01-01T01:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1821 <tp> <time>2006-01-01T01:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1822 <tp> <time>2006-01-01T01:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1823 <break/>
1824 <title>track2</title>
1825 <tp> <time>2006-01-02T01:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1826 <tp> <time>2006-01-02T01:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1827 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1828 <tp> <time>2006-01-02T02:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1829 <break/>
1830 <tp> <time>2006-01-02T02:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1831 <break/>
1832 <title>track3</title>
1833 <tp> <time>2006-01-03T03:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1834 <tp> <time>2006-01-03T03:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1835 <tp> <time>2006-01-03T03:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1836 <break/>
1837 <tp> <time>2006-01-03T03:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1838 <tp> <time>2006-01-03T03:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1839 <tp> <time>2006-01-03T03:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1840 <tp> <time>2006-01-03T03:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1841 <tp> <time>2006-01-03T03:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1842 </track>
1843 </gpsml>
1846 "Add one hour to GPX input, output gpsml",
1850 # }}}
1851 testcmd("$CMD -T -3600 multitrack-pause.gpx", # {{{
1852 <<END,
1853 <?xml version="1.0" encoding="UTF-8"?>
1854 <gpsml>
1855 <track>
1856 <title>track1</title>
1857 <tp> <time>2005-12-31T23:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1858 <tp> <time>2005-12-31T23:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1859 <tp> <time>2005-12-31T23:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1860 <break/>
1861 <title>track2</title>
1862 <tp> <time>2006-01-01T23:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1863 <tp> <time>2006-01-01T23:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1864 <tp> <time>2006-01-01T23:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1865 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1866 <break/>
1867 <tp> <time>2006-01-02T00:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1868 <break/>
1869 <title>track3</title>
1870 <tp> <time>2006-01-03T01:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1871 <tp> <time>2006-01-03T01:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1872 <tp> <time>2006-01-03T01:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1873 <break/>
1874 <tp> <time>2006-01-03T01:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1875 <tp> <time>2006-01-03T01:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1876 <tp> <time>2006-01-03T01:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1877 <tp> <time>2006-01-03T01:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1878 <tp> <time>2006-01-03T01:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1879 </track>
1880 </gpsml>
1883 "Subtract one hour from GPX input, output gpsml",
1887 # }}}
1888 testcmd("$CMD -T 1 -o gpx multitrack-pause.gpx", # {{{
1889 <<END,
1890 $gpx_header
1891 <trk>
1892 <trkseg>
1893 <trkpt lat="1.11" lon="1.12"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1894 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:02Z</time> </trkpt>
1895 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:03Z</time> </trkpt>
1896 </trkseg>
1897 <trkseg>
1898 <trkpt lat="2.11" lon="2.12"> <time>2006-01-02T00:00:01Z</time> </trkpt>
1899 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:05Z</time> </trkpt>
1900 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:17Z</time> </trkpt>
1901 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:17Z</time> </trkpt>
1902 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:18Z</time> </trkpt>
1903 </trkseg>
1904 <trkseg>
1905 </trkseg>
1906 <trkseg>
1907 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1908 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1909 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1910 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1911 </trkseg>
1912 <trkseg>
1913 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1914 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1915 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:27Z</time> </trkpt>
1916 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:28Z</time> </trkpt>
1917 </trkseg>
1918 </trk>
1919 </gpx>
1922 "Add one second to GPX input, output GPX",
1926 # }}}
1927 testcmd("$CMD --time-shift -1 -o gpx multitrack-pause.gpsml", # {{{
1928 <<END,
1929 $gpx_header
1930 <trk>
1931 <trkseg>
1932 <trkpt lat="1.11" lon="1.12"> <time>2005-12-31T23:59:59Z</time> </trkpt>
1933 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:00Z</time> </trkpt>
1934 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1935 </trkseg>
1936 <trkseg>
1937 <trkpt lat="2.11" lon="2.12"> <time>2006-01-01T23:59:59Z</time> </trkpt>
1938 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:03Z</time> </trkpt>
1939 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:15Z</time> </trkpt>
1940 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:15Z</time> </trkpt>
1941 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:16Z</time> </trkpt>
1942 </trkseg>
1943 <trkseg>
1944 </trkseg>
1945 <trkseg>
1946 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:19Z</time> </trkpt>
1947 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:20Z</time> </trkpt>
1948 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1949 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1950 </trkseg>
1951 <trkseg>
1952 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1953 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1954 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1955 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1956 </trkseg>
1957 </trk>
1958 </gpx>
1961 "Subtract one second from gpsml input, output GPX, use long option",
1965 # }}}
1966 testcmd("$CMD -T 0 -o pgtab multitrack-pause.gpx", # {{{
1967 <<END,
1968 2006-01-01T00:00:00Z\t(1.11,1.12)\t\\N\t\\N\t\\N\t\\N
1969 2006-01-01T00:00:01Z\t(1.21,1.22)\t\\N\t\\N\t\\N\t\\N
1970 2006-01-01T00:00:02Z\t(1.31,1.32)\t\\N\t\\N\t\\N\t\\N
1971 2006-01-02T00:00:00Z\t(2.11,2.12)\t\\N\t\\N\t\\N\t\\N
1972 2006-01-02T00:00:04Z\t(2.21,2.22)\t\\N\t\\N\t\\N\t\\N
1973 2006-01-02T00:00:16Z\t(2.31,2.32)\t\\N\t\\N\t\\N\t\\N
1974 2006-01-02T01:00:16Z\t(2.41,2.42)\t\\N\t\\N\t\\N\t\\N
1975 2006-01-02T01:00:17Z\t(2.451,2.452)\t\\N\t\\N\t\\N\t\\N
1976 2006-01-03T02:00:20Z\t(3.11,3.12)\t\\N\t\\N\t\\N\t\\N
1977 2006-01-03T02:00:21Z\t(3.21,3.22)\t\\N\t\\N\t\\N\t\\N
1978 2006-01-03T02:00:22Z\t(3.31,3.32)\t\\N\t\\N\t\\N\t\\N
1979 2006-01-03T02:00:23Z\t(3.41,3.42)\t\\N\t\\N\t\\N\t\\N
1980 2006-01-03T02:00:24Z\t(3.51,3.52)\t\\N\t\\N\t\\N\t\\N
1981 2006-01-03T02:00:25Z\t(3.61,3.62)\t\\N\t\\N\t\\N\t\\N
1982 2006-01-03T02:00:26Z\t(3.71,3.72)\t\\N\t\\N\t\\N\t\\N
1983 2006-01-03T02:00:27Z\t(3.81,3.82)\t\\N\t\\N\t\\N\t\\N
1986 "Read GPX, time-shift 0 seconds, output pgtab",
1990 # }}}
1991 # --time-shift option }}}
1992 diag("Testing -v (--verbose) option..."); # {{{
1993 likecmd("$CMD -hv", # {{{
1994 '/^\n\S+ v\d\.\d\d\n/s',
1995 '/^$/',
1996 "Option --version with -h returns version number and help screen",
1999 # }}}
2000 diag("Testing --version option..."); # {{{
2001 likecmd("$CMD --version", # {{{
2002 '/^\S+ v\d\.\d\d\n/',
2003 '/^$/',
2004 "Option --version returns version number",
2007 # }}}
2008 # --version option }}}
2009 # ---version option }}}
2010 diag("Testing --strip-whitespace option..."); # {{{
2011 testcmd("../gpst -w -o gpx pause-noname.gpx", # {{{
2012 <<END,
2013 $stripped_gpx_header
2014 <trk>
2015 <trkseg>
2016 <trkpt lat="60.425494" lon="5.299534"><ele>25.26</ele><time>2006-05-21T16:49:11Z</time></trkpt>
2017 <trkpt lat="60.425464" lon="5.29961"><ele>24.931</ele><time>2006-05-21T16:49:46Z</time></trkpt>
2018 <trkpt lat="60.425314" lon="5.299694"><ele>27.975</ele><time>2006-05-21T16:52:04Z</time></trkpt>
2019 <trkpt lat="60.425384" lon="5.299741"><ele>31.017</ele><time>2006-05-21T16:56:36Z</time></trkpt>
2020 <trkpt lat="60.425339" lon="5.299958"><ele>30.98</ele><time>2006-05-21T16:56:47Z</time></trkpt>
2021 <trkpt lat="60.425238" lon="5.29964"><ele>30.538</ele><time>2006-05-21T16:56:56Z</time></trkpt>
2022 <trkpt lat="60.425246" lon="5.299686"><ele>30.515</ele><time>2006-05-21T16:57:03Z</time></trkpt>
2023 <trkpt lat="60.425345" lon="5.299773"><ele>31.936</ele><time>2006-05-21T16:59:08Z</time></trkpt>
2024 <trkpt lat="60.425457" lon="5.299419"><ele>31.794</ele><time>2006-05-21T17:00:54Z</time></trkpt>
2025 </trkseg>
2026 </trk>
2027 </gpx>
2030 "Strip whitespace from GPX output",
2034 # }}}
2035 testcmd("../gpst -o gpx -w comments.mayko", # {{{
2036 <<END,
2037 $stripped_gpx_header
2038 <trk>
2039 <trkseg>
2040 <trkpt lat="70.6800486" lon="23.6746151"><time>2002-12-22T21:42:24Z</time></trkpt>
2041 <trkpt lat="70.6799322" lon="23.6740038"><time>2002-12-22T21:42:32Z</time></trkpt>
2042 <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:42:54Z</time></trkpt>
2043 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:51Z</time><extensions><error>desc</error></extensions></trkpt> -->
2044 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:52Z</time><extensions><error>desc</error></extensions></trkpt> -->
2045 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:54Z</time><extensions><error>desc</error></extensions></trkpt> -->
2046 <trkpt lat="70.6800774" lon="23.6757566"><time>2002-12-22T21:44:45Z</time></trkpt>
2047 </trkseg>
2048 <trkseg>
2049 <trkpt lat="70.6801502" lon="23.6753442"><time>2002-12-22T21:44:52Z</time></trkpt>
2050 <trkpt lat="70.6801905" lon="23.6757542"><time>2002-12-22T21:45:04Z</time></trkpt>
2051 </trkseg>
2052 </trk>
2053 </gpx>
2056 "Output whitespace-stripped GPX from Mayko file with commented-out lines",
2060 # }}}
2061 testcmd("../gpst -w -o pgwupd multitrack.gpx", # {{{
2062 <<END,
2063 BEGIN;
2064 UPDATE logg SET name = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
2065 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
2066 COMMIT;
2067 BEGIN;
2068 UPDATE logg SET name = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
2069 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
2070 COMMIT;
2071 BEGIN;
2072 UPDATE logg SET name = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
2073 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
2074 COMMIT;
2075 BEGIN;
2076 UPDATE logg SET name = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
2077 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
2078 COMMIT;
2079 BEGIN;
2080 UPDATE logg SET name = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
2081 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
2082 COMMIT;
2083 BEGIN;
2084 UPDATE logg SET name = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
2085 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
2086 COMMIT;
2089 "Strip whitespace from pgwupd output",
2093 # }}}
2094 # --strip-whitespace option }}}
2095 diag("Testing --double-y-scale option..."); # {{{
2096 testcmd("../gpst -y -o clean pause.gpx", # {{{
2097 <<END,
2098 5.299534\t120.850988\t25.26
2099 5.29961\t120.850928\t24.931
2100 5.299694\t120.850628\t27.975
2101 5.299741\t120.850768\t31.017
2102 5.299958\t120.850678\t30.98
2103 5.29964\t120.850476\t30.538
2104 5.299686\t120.850492\t30.515
2105 5.299773\t120.85069\t31.936
2106 5.299419\t120.850914\t31.794
2109 "Double y scale, clean output from gpx format",
2113 # }}}
2114 testcmd("../gpst -y -o clean log.dos.mayko", # {{{
2115 <<END,
2116 8.1225077\t116.3636316\t
2117 8.12532\t116.3637424\t
2118 8.1266031\t116.3632694\t
2119 8.1284612\t116.3624198\t
2120 8.129395\t116.362063\t
2121 8.13074\t116.3619242\t
2124 "Double y scale, clean output from mayko format",
2128 # }}}
2129 # --double-y-scale option }}}
2130 diag("Testing --debug option..."); # {{{
2131 # --debug option }}}
2132 diag("Strip error from Mayko format..."); # {{{
2134 testcmd("../gpst -o csv date_error.mayko", # {{{
2135 <<END,
2136 2003-06-13T09:12:36Z\t5.5794667\t60.4280897\t\t
2137 2003-06-13T09:12:38Z\t5.5802255\t60.4281867\t\t
2138 2003-06-13T09:12:41Z\t5.5813636\t60.428332\t\t
2139 2003-06-13T09:12:42Z\t5.581743\t60.4283806\t\t
2142 "Strip error from mayko format in csv output",
2146 # }}}
2147 testcmd("../gpst -o clean date_error.mayko", # {{{
2148 <<END,
2149 5.5794667\t60.4280897\t
2150 5.5802255\t60.4281867\t
2151 5.5813636\t60.428332\t
2152 5.581743\t60.4283806\t
2155 "Strip error from mayko format in clean output",
2159 # }}}
2160 testcmd("../gpst -o gpsml date_error.mayko", # {{{
2161 <<END,
2162 <?xml version="1.0" encoding="UTF-8"?>
2163 <gpsml>
2164 <track>
2165 <tp> <time>2003-06-13T09:12:36Z</time> <lat>60.4280897</lat> <lon>5.5794667</lon> </tp>
2166 <tp> <time>2003-06-13T09:12:38Z</time> <lat>60.4281867</lat> <lon>5.5802255</lon> </tp>
2167 <etp err="error"> <time>2037-06-25T17:19:22Z</time> <lat>103.4034054</lat> <lon>129.7271053</lon> </etp>
2168 <tp> <time>2003-06-13T09:12:41Z</time> <lat>60.428332</lat> <lon>5.5813636</lon> </tp>
2169 <tp> <time>2003-06-13T09:12:42Z</time> <lat>60.4283806</lat> <lon>5.581743</lon> </tp>
2170 </track>
2171 </gpsml>
2174 "Strip error from mayko format in gpsml output",
2178 # }}}
2179 testcmd("../gpst -o gpx date_error.mayko", # {{{
2180 <<END,
2181 $gpx_header
2182 <trk>
2183 <trkseg>
2184 <trkpt lat="60.4280897" lon="5.5794667"> <time>2003-06-13T09:12:36Z</time> </trkpt>
2185 <trkpt lat="60.4281867" lon="5.5802255"> <time>2003-06-13T09:12:38Z</time> </trkpt>
2186 <!-- <trkpt lat="103.4034054" lon="129.7271053"> <time>2037-06-25T17:19:22Z</time> <extensions> <error>error</error> </extensions> </trkpt> -->
2187 <trkpt lat="60.428332" lon="5.5813636"> <time>2003-06-13T09:12:41Z</time> </trkpt>
2188 <trkpt lat="60.4283806" lon="5.581743"> <time>2003-06-13T09:12:42Z</time> </trkpt>
2189 </trkseg>
2190 </trk>
2191 </gpx>
2194 "Strip error from mayko format in gpx output",
2198 # }}}
2199 testcmd("../gpst -o gpstrans date_error.mayko", # {{{
2200 <<END,
2201 Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84
2202 T\t06/13/2003 09:12:36\t60\xB025'41.1"\t5\xB034'46.1"
2203 T\t06/13/2003 09:12:38\t60\xB025'41.5"\t5\xB034'48.8"
2204 T\t06/13/2003 09:12:41\t60\xB025'42.0"\t5\xB034'52.9"
2205 T\t06/13/2003 09:12:42\t60\xB025'42.2"\t5\xB034'54.3"
2208 "Strip error from mayko format in gpstrans output",
2212 # }}}
2213 testcmd("../gpst -o pgtab date_error.mayko", # {{{
2214 <<END,
2215 2003-06-13T09:12:36Z\t(60.4280897,5.5794667)\t\\N\t\\N\t\\N\t\\N
2216 2003-06-13T09:12:38Z\t(60.4281867,5.5802255)\t\\N\t\\N\t\\N\t\\N
2217 2003-06-13T09:12:41Z\t(60.428332,5.5813636)\t\\N\t\\N\t\\N\t\\N
2218 2003-06-13T09:12:42Z\t(60.4283806,5.581743)\t\\N\t\\N\t\\N\t\\N
2221 "Strip error from mayko format in pgtab output",
2225 # }}}
2226 testcmd("../gpst -o poscount date_error.mayko", # {{{
2227 <<END,
2228 5.5802255\t60.4281867\t1
2229 5.581743\t60.4283806\t1
2230 5.5794667\t60.4280897\t1
2231 5.5813636\t60.428332\t1
2234 "Strip error from mayko format in poscount output",
2238 # }}}
2239 testcmd("../gpst -o xgraph date_error.mayko", # {{{
2240 <<END,
2241 5.5794667 60.4280897
2242 5.5802255 60.4281867
2243 5.5813636 60.428332
2244 5.581743 60.4283806
2247 "Strip error from mayko format in xgraph output",
2251 # }}}
2252 testcmd("../gpst -o ygraph date_error.mayko", # {{{
2253 <<END,
2254 "Time = 0.0
2255 5.5794667 60.4280897
2257 "Time = 2.0
2258 5.5802255 60.4281867
2260 "Time = 5.0
2261 5.5813636 60.428332
2263 "Time = 6.0
2264 5.581743 60.4283806
2268 "Strip error from mayko format in ygraph output",
2272 # }}}
2274 # Strip error from Mayko format }}}
2276 todo_section:
2279 if ($Opt{'all'} || $Opt{'todo'}) {
2280 diag("Running TODO tests..."); # {{{
2282 TODO: {
2283 local $TODO = "Fix read/write of GPX name element";
2284 testcmd("../gpst -o gpx pause.gpx", # {{{
2285 <<END,
2286 $gpx_header
2287 <trk>
2288 <name>ACTIVE LOG164705</name>
2289 <trkseg>
2290 <trkpt lat="60.425494" lon="5.299534"> <ele>25.26</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
2291 <trkpt lat="60.425464" lon="5.29961"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
2292 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
2293 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
2294 <trkpt lat="60.425339" lon="5.299958"> <ele>30.98</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
2295 <trkpt lat="60.425238" lon="5.29964"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
2296 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
2297 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
2298 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
2299 </trkseg>
2300 </trk>
2301 </gpx>
2304 "Read and write name element from/to GPX",
2308 # }}}
2309 local $TODO = "Remove extra \\n in the beginning";
2310 testcmd("../gpst -o csv multitrack.gpx", # {{{
2311 <<END,
2312 2003-02-11T23:35:39Z\t-0.1448824\t51.4968266\t\t
2313 2003-02-11T23:35:49Z\t-0.1449938\t51.4968227\t\t
2314 2003-02-11T23:36:14Z\t-0.1453202\t51.496904\t\t
2315 \t\t\t\t
2316 2003-02-11T23:36:16Z\t-0.1453398\t51.4969214\t\t
2317 2003-02-11T23:36:31Z\t-0.1455514\t51.4969816\t\t
2318 2003-02-11T23:36:43Z\t-0.1457489\t51.4970224\t1000\t
2319 2003-02-11T23:36:50Z\t-0.1457804\t51.4970452\t\t
2320 \t\t\t\t
2321 2003-02-11T23:37:05Z\t-0.1458608\t51.497068\t\t
2322 2003-02-11T23:37:22Z\t-0.1460047\t51.4971658\t\t
2323 2003-02-11T23:37:36Z\t-0.1461614\t51.4972469\t\t
2324 \t\t\t\t
2325 2003-02-11T23:37:43Z\t-0.1462394\t51.4972731\t\t
2326 2003-02-11T23:38:04Z\t-0.1463232\t51.4973437\t\t
2327 2003-02-11T23:38:28Z\t-0.1462949\t51.4973337\t\t
2328 2003-02-11T23:38:34Z\t-0.1462825\t51.4973218\t\t
2329 2003-02-11T23:38:35Z\t-0.1462732\t51.4973145\t\t
2332 "Output csv format from multitrack.gpx",
2336 # }}}
2337 testcmd("../gpst -o csv pause.gpx", # {{{
2338 <<END,
2339 2006-05-21T16:49:11Z\t5.299534\t60.425494\t25.26\t
2340 2006-05-21T16:49:46Z\t5.29961\t60.425464\t24.931\t
2341 2006-05-21T16:52:04Z\t5.299694\t60.425314\t27.975\t
2342 2006-05-21T16:56:36Z\t5.299741\t60.425384\t31.017\t
2343 2006-05-21T16:56:47Z\t5.299958\t60.425339\t30.98\t
2344 2006-05-21T16:56:56Z\t5.29964\t60.425238\t30.538\t
2345 2006-05-21T16:57:03Z\t5.299686\t60.425246\t30.515\t
2346 2006-05-21T16:59:08Z\t5.299773\t60.425345\t31.936\t
2347 2006-05-21T17:00:54Z\t5.299419\t60.425457\t31.794\t
2350 "Output csv format from pause.gpx",
2354 # }}}
2355 testcmd("../gpst -e -o csv pause.gpx", # {{{
2356 <<END,
2357 1148230151\t5.299534\t60.425494\t25.26\t
2358 1148230186\t5.29961\t60.425464\t24.931\t
2359 1148230324\t5.299694\t60.425314\t27.975\t
2360 1148230596\t5.299741\t60.425384\t31.017\t
2361 1148230607\t5.299958\t60.425339\t30.98\t
2362 1148230616\t5.29964\t60.425238\t30.538\t
2363 1148230623\t5.299686\t60.425246\t30.515\t
2364 1148230748\t5.299773\t60.425345\t31.936\t
2365 1148230854\t5.299419\t60.425457\t31.794\t
2368 "csv format with epoch seconds from gpx",
2372 # }}}
2373 $TODO = "Tweak output";
2374 testcmd("../gpst -o gpx multitrack-pause.gpsml", # {{{
2375 file_data("multitrack-pause.gpx"),
2377 "Should be equal to multitrack-pause.gpx",
2381 # }}}
2383 # TODO tests }}}
2386 diag("Testing finished.");
2388 sub testcmd {
2389 # {{{
2390 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc, $is_gpx) = @_;
2391 my $stderr_cmd = "";
2392 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2393 my $Txt = join("",
2394 "\"$Cmd\"",
2395 defined($Desc)
2396 ? " - $Desc"
2397 : ""
2399 my $TMP_STDERR = "gpst-stderr.tmp";
2400 my $TMP_STDOUT = "gpst-stdout.tmp";
2401 defined($is_gpx) || die("$progname: testcmd(): $Desc: \$is_gpx not defined\n");
2403 if (defined($Exp_stderr) && !length($deb_str)) {
2404 $stderr_cmd = " 2>$TMP_STDERR";
2406 system("$Cmd$deb_str$stderr_cmd >$TMP_STDOUT");
2407 is(file_data($TMP_STDOUT), $Exp_stdout, $Txt);
2408 if ($is_gpx) {
2409 validate_gpx($TMP_STDOUT, $Desc);
2411 if (defined($Exp_stderr)) {
2412 if (!length($deb_str)) {
2413 is(file_data($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
2414 unlink($TMP_STDERR);
2416 } else {
2417 diag("Warning: stderr not defined for '$Txt'");
2419 unlink($TMP_STDOUT);
2420 # }}}
2421 } # testcmd()
2423 sub likecmd {
2424 # {{{
2425 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
2426 my $stderr_cmd = "";
2427 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2428 my $Txt = join("",
2429 "\"$Cmd\"",
2430 defined($Desc)
2431 ? " - $Desc"
2432 : ""
2434 my $TMP_STDERR = "gpst-stderr.tmp";
2436 if (defined($Exp_stderr) && !length($deb_str)) {
2437 $stderr_cmd = " 2>$TMP_STDERR";
2439 like(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
2440 if (defined($Exp_stderr)) {
2441 if (!length($deb_str)) {
2442 like(file_data($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
2443 unlink($TMP_STDERR);
2445 } else {
2446 diag("Warning: stderr not defined for '$Txt'");
2448 # }}}
2449 } # likecmd()
2451 sub file_data {
2452 # Return file content as a string {{{
2453 my $File = shift;
2454 my $Txt;
2455 if (open(FP, "<", $File)) {
2456 $Txt = join("", <FP>);
2457 close(FP);
2458 return($Txt);
2459 } else {
2460 return undef;
2462 # }}}
2463 } # file_data()
2465 sub validate_gpx {
2466 # Check that a file is valid GPX {{{
2467 my ($File, $Txt) = @_;
2468 my $TMP_VALID = "validate_result.tmp";
2469 my $Result = system("xmllint --noout --schema ../Tools/xsd/gpx/gpx-1.1.xsd $File 2>$TMP_VALID");
2470 is($Result, 0, "GPX for \"$Txt\" validates");
2471 if ($Result) {
2472 diag(file_data($TMP_VALID));
2474 unlink($TMP_VALID);
2475 # }}}
2476 } # validate_gpx()
2478 sub print_version {
2479 # Print program version {{{
2480 print("$progname v$VERSION\n");
2481 # }}}
2482 } # print_version()
2484 sub usage {
2485 # Send the help message to stdout {{{
2486 my $Retval = shift;
2488 if ($Opt{'verbose'}) {
2489 print("\n");
2490 print_version();
2492 print(<<END);
2494 Usage: $progname [options] [file [files [...]]]
2496 Contains tests for the gpst(1) program.
2498 Options:
2500 -a, --all
2501 Run all tests, also TODOs.
2502 -h, --help
2503 Show this help.
2504 -t, --todo
2505 Run only the TODO tests.
2506 -v, --verbose
2507 Increase level of verbosity. Can be repeated.
2508 --version
2509 Print version information.
2510 --debug
2511 Print debugging messages.
2514 exit($Retval);
2515 # }}}
2516 } # usage()
2518 sub msg {
2519 # Print a status message to stderr based on verbosity level {{{
2520 my ($verbose_level, $Txt) = @_;
2522 if ($Opt{'verbose'} >= $verbose_level) {
2523 print(STDERR "$progname: $Txt\n");
2525 # }}}
2526 } # msg()
2528 __END__
2530 # Plain Old Documentation (POD) {{{
2532 =pod
2534 =head1 NAME
2536 run-tests.pl
2538 =head1 SYNOPSIS
2540 run-tests.pl [options] [file [files [...]]]
2542 =head1 DESCRIPTION
2544 Contains tests for the gpst(1) program.
2546 =head1 OPTIONS
2548 =over 4
2550 =item B<-a>, B<--all>
2552 Run all tests, also TODOs.
2554 =item B<-h>, B<--help>
2556 Print a brief help summary.
2558 =item B<-t>, B<--todo>
2560 Run only the TODO tests.
2562 =item B<-v>, B<--verbose>
2564 Increase level of verbosity. Can be repeated.
2566 =item B<--version>
2568 Print version information.
2570 =item B<--debug>
2572 Print debugging messages.
2574 =back
2576 =head1 AUTHOR
2578 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
2580 =head1 COPYRIGHT
2582 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
2583 This is free software; see the file F<COPYING> for legalese stuff.
2585 =head1 LICENCE
2587 This program is free software: you can redistribute it and/or modify it
2588 under the terms of the GNU General Public License as published by the
2589 Free Software Foundation, either version 3 of the License, or (at your
2590 option) any later version.
2592 This program is distributed in the hope that it will be useful, but
2593 WITHOUT ANY WARRANTY; without even the implied warranty of
2594 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2595 See the GNU General Public License for more details.
2597 You should have received a copy of the GNU General Public License along
2598 with this program.
2599 If not, see L<http://www.gnu.org/licenses/>.
2601 =head1 SEE ALSO
2603 gpst(1)
2605 =cut
2607 # }}}
2609 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :