Revert "Merge branch 'use-trunc-rounding' into rounding-fixes"
[gpstools.git] / tests / run-tests.pl
blob5734261950c769cf0173a4462f0240b7dd3e98f7
1 #!/usr/bin/perl
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 use strict;
15 use warnings;
17 BEGIN {
18 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
19 use Test::More qw{no_plan};
20 use_ok('GPST');
21 use_ok('GPSTdate');
22 use_ok('GPSTdebug');
23 use_ok('GPSTgeo');
24 use_ok('GPSTxml');
27 use Getopt::Long;
29 $| = 1;
31 our $Debug = 0;
32 our $CMD = "../gpst";
34 our %Opt = (
36 'all' => 0,
37 'debug' => 0,
38 'help' => 0,
39 'todo' => 0,
40 'verbose' => 0,
41 'version' => 0,
45 our $progname = $0;
46 $progname =~ s/^.*\/(.*?)$/$1/;
47 our $VERSION = "0.00";
49 Getopt::Long::Configure("bundling");
50 GetOptions(
52 "all|a" => \$Opt{'all'},
53 "debug" => \$Opt{'debug'},
54 "help|h" => \$Opt{'help'},
55 "todo|t" => \$Opt{'todo'},
56 "verbose|v+" => \$Opt{'verbose'},
57 "version" => \$Opt{'version'},
59 ) || die("$progname: Option error. Use -h for help.\n");
61 our %Cmd = (
62 'gpsbabel' => 'gpsbabel',
65 $Opt{'debug'} && ($Debug = 1);
66 $Opt{'help'} && usage(0);
67 if ($Opt{'version'}) {
68 print_version();
69 exit(0);
72 diag(sprintf("========== Executing %s v%s ==========",
73 $progname,
74 $VERSION));
76 chomp(my $gpx_header = <<END);
77 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
78 <gpx
79 version="1.1"
80 creator="gpst - http://sunny256.github.com/gpstools/"
81 xmlns="http://www.topografix.com/GPX/1/1"
82 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
83 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
85 END
86 my $stripped_gpx_header = $gpx_header;
87 $stripped_gpx_header =~ s/^\s*(.*)$/$1/mg;
89 if ($Opt{'todo'} && !$Opt{'all'}) {
90 goto todo_section;
93 =pod
95 testcmd("$CMD command", # {{{
96 <<END,
97 [expected stdin]
98 END
99 "",
100 "description",
101 is_gpx,
104 # }}}
106 =cut
108 diag("Testing conversion routines...");
110 # txt_to_xml() and xml_to_txt() {{{
112 is(txt_to_xml("abc"),
113 "abc",
114 "txt_to_xml(\"abc\")");
115 is(txt_to_xml("<&>"),
116 "&lt;&amp;&gt;",
117 "txt_to_xml(\"<&>\")");
118 is(txt_to_xml("first line\nsecond <\rthird\r\n<&>"),
119 "first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;",
120 "txt_to_xml() with multiline string");
122 is(xml_to_txt("abc"),
123 "abc",
124 "xml_to_txt(\"abc\")");
125 is(xml_to_txt("&lt;&amp;&gt;"),
126 "<&>",
127 "xml_to_txt(\"&lt;&amp;&gt;\")");
128 is(xml_to_txt("first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;"),
129 "first line\nsecond <\rthird\r\n<&>",
130 "xml_to_txt() with multiline string");
132 # txt_to_xml() and xml_to_txt() }}}
133 # postgresql_copy_safe() {{{
135 is(postgresql_copy_safe(""),
137 "postgresql_copy_safe() with empty string");
139 is(postgresql_copy_safe("abcæøåÆØÅ"),
140 "abcæøåÆØÅ",
141 "postgresql_copy_safe(\"abcæøåÆØÅ\")");
143 is(postgresql_copy_safe("abc\t'\r\n"),
144 "abc\\t'\\r\\n",
145 "postgresql_copy_safe(\"abc\\t'\\r\\n\")");
147 is(postgresql_copy_safe("¤%/&gurgle\t325\\wer\ndfv'\r!\"#\n%\twe\r\x00sdf\xFFsadc\n\t\x00sdc\n"),
148 "¤%/&gurgle\\t325\\\\wer\\ndfv'\\r!\"#\\n%\\twe\\r\x00sdf\xFFsadc\\n\\t\x00sdc\\n",
149 "postgresql_copy_safe() with multiline, nulls and stuff");
151 # postgresql_copy_safe() }}}
152 # num_expand() {{{
154 is(num_expand(""),
156 "num_expand(\"\") returns empty string");
158 is(num_expand("6.5"),
159 "6.5",
160 "num_expand(\"6.5\") returns same value");
161 is(num_expand("-6.5"),
162 "-6.5",
163 "num_expand(\"-6.5\") returns same value");
164 is(num_expand("+6.5"),
165 "6.5",
166 "num_expand(\"+6.5\") removes leading plus sign");
168 is(num_expand("0.0000000000123"),
169 "0.0000000000123",
170 "num_expand(\"0.0000000000123\") returns same value");
171 is(num_expand("-0.0000000000123"),
172 "-0.0000000000123",
173 "num_expand(\"-0.0000000000123\") returns same value");
174 is(num_expand("+0.0000000000123"),
175 "0.0000000000123",
176 "num_expand(\"+0.0000000000123\") removes leading plus sign");
178 is(num_expand("1e-06"),
179 "0.000001",
180 "num_expand(\"1e-06\") returns 0.000001");
181 is(num_expand("-1e-06"),
182 "-0.000001",
183 "num_expand(\"-1e-06\") returns -0.000001");
184 is(num_expand("+1e-06"),
185 "0.000001",
186 "num_expand(\"+1e-06\") removes leading plus sign");
188 is(num_expand("1e-6"),
189 "0.000001",
190 "num_expand(\"1e-6\") returns 0.000001");
191 is(num_expand("1e+6"),
192 "1000000",
193 "num_expand(\"1e+6\") returns 1000000");
195 is(num_expand("3.14159265358979e-10"),
196 "0.000000000314159265358979",
197 "num_expand(\"3.14159265358979e-10\") returns 0.000000000314159265358979");
199 is(num_expand("1.2000e-10"),
200 "0.00000000012",
201 "Strip trailing zeroes from num_expand(\"1.2000e-10\")");
202 is(num_expand("1.2000e+10"),
203 "12000000000",
204 "num_expand(\"1.2000e+10\") returns 12000000000");
206 is(num_expand("0000000000000"),
207 "0",
208 "num_expand(\"0000000000000\") returns 0");
209 is(num_expand("-0000000000000"),
210 "0",
211 "num_expand(\"-0000000000000\") returns 0");
212 is(num_expand("+0000000000000"),
213 "0",
214 "num_expand(\"+0000000000000\") returns 0");
216 is(num_expand("000000.0000000"),
217 "0",
218 "num_expand(\"000000.0000000\") returns 0");
219 is(num_expand("-000000.0000000"),
220 "0",
221 "num_expand(\"-000000.0000000\") returns 0");
222 is(num_expand("+000000.0000000"),
223 "0",
224 "num_expand(\"+000000.0000000\") returns 0");
226 is(num_expand("1e+20"),
227 "100000000000000000000",
228 "num_expand(\"1e+20\") returns 100000000000000000000");
230 is(num_expand("3.14159e+10"),
231 "31415900000",
232 "num_expand(\"314159e+10\") returns 31415900000");
234 is(num_expand("2.50000"),
235 "2.5",
236 "num_expand(\"2.50000\") removes trailing zeroes");
238 is(num_expand("0002.5"),
239 "2.5",
240 "num_expand(\"0002.5\") removes leading zeroes");
241 is(num_expand("-0002.5"),
242 "-2.5",
243 "num_expand(\"-0002.5\") removes leading zeroes");
244 is(num_expand("+0002.5"),
245 "2.5",
246 "num_expand(\"+0002.5\") removes leading zeroes and leading plus sign");
248 is(num_expand("0002.50000"),
249 "2.5",
250 "num_expand(\"0002.50000\") removes both leading and trailing zeroes");
252 is(num_expand("300"),
253 "300",
254 "Don’t remove trailing zeroes from integers");
256 is(num_expand("0004"),
257 "4",
258 "num_expand(\"0004\") removes leading zeroes from integer");
259 is(num_expand("-0004"),
260 "-4",
261 "num_expand(\"-0004\") removes leading zeroes from negative integer");
262 is(num_expand("+0004"),
263 "4",
264 "num_expand(\"+0004\") removes leading plus sign and zeroes from integer");
266 # num_expand() }}}
268 diag("Testing date routines...");
270 # sec_to_string() {{{
272 is(sec_to_string(1148220825),
273 "2006-05-21 14:13:45",
274 "sec_to_string() without separator");
275 is(sec_to_string(1148220825, "T"),
276 "2006-05-21T14:13:45",
277 "sec_to_string() with separator");
278 is(sec_to_string(-5000),
279 undef,
280 "sec_to_string(-5000) — negative numbers unsupported atm");
281 is(sec_to_string(""),
282 undef,
283 "sec_to_string(\"\")");
284 is(sec_to_string("pH()rtY tW0"),
285 undef,
286 "sec_to_string() with invalid string");
287 is(sec_to_string("00000000000000000000001148220825"),
288 "2006-05-21 14:13:45",
289 "sec_to_string() with a bunch of leading zeros");
290 is(sec_to_string("1148220825.93"),
291 "2006-05-21 14:13:45.93",
292 "sec_to_string() with decimals");
293 is(sec_to_string("000000000000000000000000000001148220825.7312"),
294 "2006-05-21 14:13:45.7312",
295 "sec_to_string() with decimals and prefixing zeros");
296 is(sec_to_string("1148220825.93000"),
297 "2006-05-21 14:13:45.93",
298 "sec_to_string() with decimals and extra trailing zeros");
299 is(sec_to_string(".863"),
300 "1970-01-01 00:00:00.863",
301 "sec_to_string() with missing zero before decimal point");
303 # sec_to_string() }}}
304 # sec_to_readable() {{{
306 is(sec_to_readable(0),
307 "0:00:00:00",
308 "sec_to_readable(0)");
309 is(sec_to_readable("pH()rtY tW0"),
310 undef,
311 "sec_to_readable() with invalid string");
312 is(sec_to_readable(86400),
313 "1:00:00:00",
314 "sec_to_readable(86400)");
315 is(sec_to_readable(86400*1000),
316 "1000:00:00:00",
317 "sec_to_readable(86400*1000)");
318 is(sec_to_readable(86400+7200+180+4),
319 "1:02:03:04",
320 "sec_to_readable(86400+7200+180+4)");
321 is(sec_to_readable("3.14"),
322 "0:00:00:03.14",
323 "sec_to_readable(\"3.14\")");
324 is(sec_to_readable("-124"),
325 undef,
326 "sec_to_readable() rejects negative numbers");
327 is(sec_to_readable("-2.34"),
328 undef,
329 "sec_to_readable() rejects negative decimal");
330 is(sec_to_readable(".87"),
331 "0:00:00:00.87",
332 "sec_to_readable(), missing zero before decimal point");
333 is(sec_to_readable(""),
334 "0:00:00:00",
335 "sec_to_readable() with empty string");
337 # sec_to_readable() }}}
339 diag("Testing geo routines...");
341 # ddd_to_dms() {{{
343 is(ddd_to_dms("12.34567"),
344 "12\xB020'44.4\"",
345 "ddd_to_dms(\"12.34567\")");
347 is(ddd_to_dms("0"),
348 "0\xB000'00.0\"",
349 "ddd_to_dms(\"0\")");
351 is(ddd_to_dms(""),
352 "0\xB000'00.0\"",
353 "ddd_to_dms(\"\")");
355 is(ddd_to_dms("pH()rtY tW0"),
356 undef,
357 "ddd_to_dms(\"pH()rtY tW0\")");
359 is(ddd_to_dms("-12.34567"),
360 "-12\xB020'44.4\"",
361 "ddd_to_dms(\"-12.34567\")");
363 is(ddd_to_dms("0.34567"),
364 "0\xB020'44.4\"",
365 "ddd_to_dms(\"0.34567\")");
367 is(ddd_to_dms(".34567"),
368 "0\xB020'44.4\"",
369 "ddd_to_dms(\".34567\")");
371 is(ddd_to_dms("-.34567"),
372 "-0\xB020'44.4\"",
373 "ddd_to_dms(\"-.34567\")");
375 is(ddd_to_dms("-0.34567"),
376 "-0\xB020'44.4\"",
377 "ddd_to_dms(\"-0.34567\")");
379 is(ddd_to_dms("180"),
380 "180\xB000'00.0\"",
381 "ddd_to_dms(\"180\")");
383 is(ddd_to_dms("-180"),
384 "-180\xB000'00.0\"",
385 "ddd_to_dms(\"-180\")");
387 is(ddd_to_dms("-1"),
388 "-1\xB000'00.0\"",
389 "ddd_to_dms(\"-1\")");
391 is(ddd_to_dms("2-3"),
392 undef,
393 "ddd_to_dms(\"2-3\")");
395 # ddd_to_dms() }}}
396 diag("Testing trackpoint()..."); # {{{
398 my %Dat = ();
400 is(trackpoint(%Dat),
401 undef,
402 "trackpoint() receives empty hash");
404 my %Bck = (
405 # {{{
406 'format' => 'gpsml',
407 'year' => '2003',
408 'month' => '06',
409 'day' => '13',
410 'hour' => '14',
411 'min' => '36',
412 'sec' => '10',
413 'lat' => '59.5214',
414 'lon' => '7.392133',
415 'ele' => '762',
416 'error' => "",
417 'what' => 'tp',
418 # }}}
421 # trackpoint() (gpsml) {{{
422 %Dat = %Bck;
424 trackpoint(%Dat),
425 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
426 "trackpoint() (gpsml)"
429 # trackpoint() (gpsml) }}}
430 # trackpoint() (gpx) {{{
431 %Dat = %Bck;
432 $Dat{'format'} = "gpx";
434 trackpoint(%Dat),
435 qq{ <trkpt lat="59.5214" lon="7.392133"> <ele>762</ele> <time>2003-06-13T14:36:10Z</time> </trkpt>\n},
436 "trackpoint() (gpx)"
439 # trackpoint() (gpx) }}}
441 # trackpoint(): Various loop tests {{{
443 for my $Elem (qw{format lat lon what}) {
444 my %Dat = %Bck;
446 $Dat{"$Elem"} = '2d';
447 is(trackpoint(%Dat),
448 undef,
449 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") returns undef"
454 for my $Elem (qw{year month day hour min sec}) {
455 # Date tests {{{
456 my %Dat;
458 %Dat = %Bck;
459 $Dat{"$Elem"} = '';
460 is(trackpoint(%Dat),
461 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
462 "trackpoint(): {'$Elem'} with empty value skips time"
465 %Dat = %Bck;
466 $Dat{"$Elem"} = '2d';
467 is(trackpoint(%Dat),
468 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
469 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") skips time"
472 %Dat = %Bck;
473 $Dat{$Elem} = "00000$Dat{$Elem}";
474 is(trackpoint(%Dat),
475 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
476 "trackpoint(): Strip prefixing zeros from {'$Elem'}"
479 %Dat = %Bck;
480 $Dat{"$Elem"} = 0-$Dat{$Elem};
481 is(trackpoint(%Dat),
482 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
483 "trackpoint(): {'$Elem'} is negative, skip time"
486 if ($Elem ne "sec") {
487 %Dat = %Bck;
488 $Dat{"$Elem"} = "$Dat{$Elem}.00";
489 is(trackpoint(%Dat),
490 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
491 "trackpoint(): Decimals in {'$Elem'}, skip time"
495 # Date tests }}}
498 %Dat = %Bck;
499 $Dat{'sec'} = "$Dat{'sec'}.00";
500 is(trackpoint(%Dat),
501 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
502 "trackpoint(): Remove trailing zeros in {'sec'} decimals"
505 for my $Elem (qw{format what error}) {
506 my %Dat = %Bck;
507 $Dat{$Elem} = undef;
508 is(trackpoint(%Dat),
509 undef,
510 "trackpoint(): Missing {'$Elem'}, return undef"
514 # Various loop tests }}}
516 # trackpoint() }}}
518 diag("Testing output from ../gpst");
520 diag("Read empty input (/dev/null)..."); # {{{
521 testcmd("../gpst </dev/null", # {{{
522 <<END,
523 <?xml version="1.0" encoding="UTF-8"?>
524 <gpsml>
525 <track>
526 </track>
527 </gpsml>
530 "Read from /dev/null",
534 # }}}
535 testcmd("../gpst -o gpx </dev/null", # {{{
536 <<END,
537 $gpx_header
538 <trk>
539 <trkseg>
540 </trkseg>
541 </trk>
542 </gpx>
545 "Output gpx from /dev/null",
549 # }}}
550 # empty input }}}
551 diag("Read empty files..."); # {{{
552 testcmd("echo '<tp> </tp>' | ../gpst", # {{{
553 <<END,
554 <?xml version="1.0" encoding="UTF-8"?>
555 <gpsml>
556 <track>
557 </track>
558 </gpsml>
561 "Don’t print empty trackpoints",
565 # }}}
566 # Read empty files }}}
567 diag("Testing --chronology option..."); # {{{
568 testcmd("../gpst --chronology chronology-error.gpsml", # {{{
569 <<END,
570 <?xml version="1.0" encoding="UTF-8"?>
571 <gpsml>
572 <track>
573 <title>Chronology errors</title>
574 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
575 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
576 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
577 <break/>
578 <tp> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </tp>
579 <break/>
580 <pause>0:00:37:54</pause>
581 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
582 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
583 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
584 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
585 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
586 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
587 </track>
588 </gpsml>
590 "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" .
591 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
592 "Check for chronology errors and duplicated times",
596 # }}}
597 # --chronology option }}}
598 diag("Testing --skip-dups option..."); # {{{
599 testcmd("../gpst -d no_signal.mayko", # {{{
600 <<END,
601 <?xml version="1.0" encoding="UTF-8"?>
602 <gpsml>
603 <track>
604 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
605 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
606 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
607 <etp err="dup"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
608 <etp err="dup"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
609 <etp err="dup"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
610 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
611 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
612 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
613 </track>
614 </gpsml>
617 "Remove duplicated positions from gpsml",
621 # }}}
622 testcmd("../gpst -d -o csv no_signal.mayko", # {{{
623 <<END,
624 2002-12-22T21:42:24Z\t23.6746151\t70.6800486\t\t
625 2002-12-22T21:42:32Z\t23.6740038\t70.6799322\t\t
626 2002-12-22T21:42:54Z\t23.6723991\t70.6796266\t\t
627 2002-12-22T21:44:45Z\t23.6757566\t70.6800774\t\t
628 2002-12-22T21:44:52Z\t23.6753442\t70.6801502\t\t
629 2002-12-22T21:45:04Z\t23.6757542\t70.6801905\t\t
632 "Remove duplicated positions from csv output format",
636 # }}}
637 testcmd("../gpst -d -o clean no_signal.mayko", # {{{
638 <<END,
639 23.6746151\t70.6800486\t
640 23.6740038\t70.6799322\t
641 23.6723991\t70.6796266\t
642 23.6757566\t70.6800774\t
643 23.6753442\t70.6801502\t
644 23.6757542\t70.6801905\t
647 "Remove duplicated positions from clean output format",
651 # }}}
652 testcmd("../gpst -d -o pgtab no_signal.mayko", # {{{
653 <<END,
654 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N
655 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N
656 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
657 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N
658 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N
659 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N
662 "Remove duplicated positions from pgtab output format",
666 # }}}
667 # --skip-dups option }}}
668 diag("Testing --epoch option..."); # {{{
669 testcmd("../gpst -e pause.gpx", # {{{
670 <<END,
671 <?xml version="1.0" encoding="UTF-8"?>
672 <gpsml>
673 <track>
674 <title>ACTIVE LOG164705</title>
675 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
676 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
677 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
678 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
679 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
680 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
681 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
682 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
683 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
684 </track>
685 </gpsml>
688 "--epoch is ignored in gpsml output",
692 # }}}
693 testcmd("../gpst -e -o gpx pause-noname.gpx", # {{{
694 <<END,
695 $gpx_header
696 <trk>
697 <trkseg>
698 <trkpt lat="60.425494" lon="5.299534"> <ele>25.26</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
699 <trkpt lat="60.425464" lon="5.29961"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
700 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
701 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
702 <trkpt lat="60.425339" lon="5.299958"> <ele>30.98</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
703 <trkpt lat="60.425238" lon="5.29964"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
704 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
705 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
706 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
707 </trkseg>
708 </trk>
709 </gpx>
712 "--epoch is ignored in gpx output",
716 # }}}
717 testcmd("../gpst -e -o csv multitrack.gpx", # {{{
718 # FIXME: Get rid of the empty line in the beginning
719 <<END,
720 \t\t\t\t
721 1045006539\t-0.1448824\t51.4968266\t\t
722 1045006549\t-0.1449938\t51.4968227\t\t
723 1045006574\t-0.1453202\t51.496904\t\t
724 \t\t\t\t
725 1045006576\t-0.1453398\t51.4969214\t\t
726 1045006591\t-0.1455514\t51.4969816\t\t
727 1045006603\t-0.1457489\t51.4970224\t1000\t
728 1045006610\t-0.1457804\t51.4970452\t\t
729 \t\t\t\t
730 1045006625\t-0.1458608\t51.497068\t\t
731 1045006642\t-0.1460047\t51.4971658\t\t
732 1045006656\t-0.1461614\t51.4972469\t\t
733 \t\t\t\t
734 1045006663\t-0.1462394\t51.4972731\t\t
735 1045006684\t-0.1463232\t51.4973437\t\t
736 1045006708\t-0.1462949\t51.4973337\t\t
737 1045006714\t-0.1462825\t51.4973218\t\t
738 1045006715\t-0.1462732\t51.4973145\t\t
741 "Use --epoch with csv output",
745 # }}}
746 # --epoch option }}}
747 diag("Testing --fix option..."); # {{{
748 testcmd("../gpst --fix --chronology chronology-error.gpsml", # {{{
749 <<END,
750 <?xml version="1.0" encoding="UTF-8"?>
751 <gpsml>
752 <track>
753 <title>Chronology errors</title>
754 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
755 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
756 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
757 <break/>
758 <etp err="chrono"> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </etp>
759 <break/>
760 <pause>0:00:37:54</pause>
761 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
762 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
763 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
764 <etp err="duptime"> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </etp>
765 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
766 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
767 </track>
768 </gpsml>
770 "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" .
771 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
772 "Remove bad timestamps",
776 # }}}
777 # --fix option }}}
778 diag("Testing --from-date option..."); # {{{
779 # --from-date option }}}
780 diag("Testing -h (--help) option..."); # {{{
781 likecmd("$CMD -h", # {{{
782 '/ Show this help\./',
783 '/^$/',
784 "Option -h prints help screen",
787 # }}}
788 # --help option }}}
789 diag("Testing --inside option..."); # {{{
790 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx", # {{{
791 <<END,
792 <?xml version="1.0" encoding="UTF-8"?>
793 <gpsml>
794 <track>
795 <title>track1</title>
796 <break/>
797 <title>track2</title>
798 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
799 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
800 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
801 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
802 <break/>
803 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
804 <break/>
805 <title>track3</title>
806 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
807 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
808 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
809 </track>
810 </gpsml>
813 "Check --inside option (gpx to gpst)",
816 # }}}
818 # --inside option }}}
819 diag("Testing --undefined option..."); # {{{
820 # --undefined option }}}
821 diag("Testing --output option..."); # {{{
822 # gpsml (Default)
823 testcmd("../gpst log.mcsv", # {{{
824 <<END,
825 <?xml version="1.0" encoding="UTF-8"?>
826 <gpsml>
827 <track>
828 <break/>
829 <title>ACTIVE LOG 125</title>
830 <tp> <time>2006-03-04T11:12:30Z</time> <lat>54.96883</lat> <lon>-1.62439</lon> <ele>77</ele> </tp>
831 <tp> <time>2006-03-04T11:12:47Z</time> <lat>54.96878</lat> <lon>-1.62413</lon> <ele>77</ele> </tp>
832 <tp> <time>2006-03-04T11:12:55Z</time> <lat>54.96913</lat> <lon>-1.62616</lon> <ele>77</ele> </tp>
833 <tp> <time>2006-03-04T11:13:04Z</time> <lat>54.96934</lat> <lon>-1.62624</lon> <ele>77.5</ele> </tp>
834 <tp> <time>2006-03-04T11:13:33Z</time> <lat>54.96934</lat> <lon>-1.62596</lon> <ele>78</ele> </tp>
835 <tp> <time>2006-03-04T11:13:48Z</time> <lat>54.96931</lat> <lon>-1.62645</lon> <ele>78</ele> </tp>
836 <tp> <time>2006-03-04T11:14:05Z</time> <lat>54.96918</lat> <lon>-1.62603</lon> <ele>79</ele> </tp>
837 <tp> <time>2006-03-04T11:14:33Z</time> <lat>54.96901</lat> <lon>-1.62364</lon> <ele>76.1</ele> </tp>
838 <tp> <time>2006-03-04T11:15:02Z</time> <lat>54.96922</lat> <lon>-1.6254</lon> <ele>76.1</ele> </tp>
839 <tp> <time>2006-03-04T11:15:27Z</time> <lat>54.96914</lat> <lon>-1.62526</lon> <ele>75.1</ele> </tp>
840 <tp> <time>2006-03-04T11:15:50Z</time> <lat>54.96911</lat> <lon>-1.62494</lon> <ele>75.1</ele> </tp>
841 <tp> <time>2006-03-04T11:16:03Z</time> <lat>54.9693</lat> <lon>-1.62489</lon> <ele>75.1</ele> </tp>
842 <tp> <time>2006-03-04T11:16:19Z</time> <lat>54.96901</lat> <lon>-1.62496</lon> <ele>75.1</ele> </tp>
843 <tp> <time>2006-03-04T11:16:52Z</time> <lat>54.96871</lat> <lon>-1.62466</lon> <ele>74.6</ele> </tp>
844 <tp> <time>2006-03-04T11:17:25Z</time> <lat>54.96908</lat> <lon>-1.62488</lon> <ele>72.7</ele> </tp>
845 <break/>
846 <title>ACTIVE LOG 126</title>
847 <tp> <time>2006-03-04T11:18:32Z</time> <lat>54.96904</lat> <lon>-1.62482</lon> <ele>72.7</ele> </tp>
848 <tp> <time>2006-03-04T11:18:35Z</time> <lat>54.96913</lat> <lon>-1.62499</lon> <ele>71.3</ele> </tp>
849 <tp> <time>2006-03-04T11:18:38Z</time> <lat>54.96904</lat> <lon>-1.62497</lon> <ele>70.8</ele> </tp>
850 <tp> <time>2006-03-04T11:18:48Z</time> <lat>54.96913</lat> <lon>-1.62496</lon> <ele>71.8</ele> </tp>
851 <tp> <time>2006-03-04T11:18:55Z</time> <lat>54.96924</lat> <lon>-1.62501</lon> <ele>72.2</ele> </tp>
852 <tp> <time>2006-03-04T11:19:11Z</time> <lat>54.9694</lat> <lon>-1.62521</lon> <ele>71.8</ele> </tp>
853 <tp> <time>2006-03-04T11:19:30Z</time> <lat>54.96916</lat> <lon>-1.62515</lon> <ele>71.3</ele> </tp>
854 <tp> <time>2006-03-04T11:19:53Z</time> <lat>54.96921</lat> <lon>-1.625</lon> <ele>71.3</ele> </tp>
855 <tp> <time>2006-03-04T11:20:21Z</time> <lat>54.96801</lat> <lon>-1.62417</lon> <ele>71.8</ele> </tp>
856 <break/>
857 <title>ACTIVE LOG 127</title>
858 <tp> <time>2006-03-04T11:21:16Z</time> <lat>54.96887</lat> <lon>-1.62504</lon> <ele>70.8</ele> </tp>
859 <tp> <time>2006-03-04T11:21:18Z</time> <lat>54.96898</lat> <lon>-1.62476</lon> <ele>69.8</ele> </tp>
860 <tp> <time>2006-03-04T11:21:29Z</time> <lat>54.9691</lat> <lon>-1.62475</lon> <ele>69.4</ele> </tp>
861 <tp> <time>2006-03-04T11:21:46Z</time> <lat>54.96918</lat> <lon>-1.62468</lon> <ele>70.3</ele> </tp>
862 <tp> <time>2006-03-04T11:22:39Z</time> <lat>54.9692</lat> <lon>-1.62465</lon> <ele>69.4</ele> </tp>
863 <tp> <time>2006-03-04T11:22:43Z</time> <lat>54.96924</lat> <lon>-1.62462</lon> <ele>71.8</ele> </tp>
864 <tp> <time>2006-03-04T11:22:45Z</time> <lat>54.96928</lat> <lon>-1.62463</lon> <ele>71.8</ele> </tp>
865 <tp> <time>2006-03-04T11:23:00Z</time> <lat>54.96945</lat> <lon>-1.62466</lon> <ele>69.4</ele> </tp>
866 </track>
867 </gpsml>
870 "Read Mapsource TAB-separated format",
874 # }}}
875 testcmd("../gpst two-digit_year.mcsv", # {{{
876 <<END,
877 <?xml version="1.0" encoding="UTF-8"?>
878 <gpsml>
879 <track>
880 <break/>
881 <title>ACTIVE LOG 032</title>
882 <tp> <time>2006-03-20T20:35:33Z</time> <lat>60.41324</lat> <lon>5.33352</lon> <ele>14</ele> </tp>
883 <tp> <time>2006-03-20T20:35:38Z</time> <lat>60.38802</lat> <lon>5.33845</lon> <ele>18</ele> </tp>
884 <tp> <time>2006-03-20T20:35:44Z</time> <lat>60.38709</lat> <lon>5.3379</lon> <ele>19</ele> </tp>
885 <tp> <time>2006-03-20T20:35:49Z</time> <lat>60.38641</lat> <lon>5.33732</lon> <ele>18</ele> </tp>
886 <tp> <time>2006-03-20T20:35:54Z</time> <lat>60.38581</lat> <lon>5.33647</lon> <ele>18</ele> </tp>
887 <tp> <time>2006-03-20T20:36:00Z</time> <lat>60.38516</lat> <lon>5.33528</lon> <ele>15</ele> </tp>
888 <tp> <time>2006-03-20T20:36:02Z</time> <lat>60.38495</lat> <lon>5.3349</lon> <ele>13</ele> </tp>
889 </track>
890 </gpsml>
893 "Read Mapsource TAB-separated format with two-digit year",
897 # }}}
898 testcmd("../gpst log.gpstxt", # {{{
899 <<END,
900 <?xml version="1.0" encoding="UTF-8"?>
901 <gpsml>
902 <track>
903 <tp> <time>2003-06-13T14:36:09Z</time> <lat>59.5215166666667</lat> <lon>7.39186666666667</lon> <ele>762</ele> </tp>
904 <tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.39213333333333</lon> <ele>762</ele> </tp>
905 <tp> <time>2003-06-13T14:36:11Z</time> <lat>59.5213</lat> <lon>7.39241666666667</lon> <ele>761</ele> </tp>
906 <tp> <time>2003-06-13T14:36:12Z</time> <lat>59.5211833333333</lat> <lon>7.3927</lon> <ele>761</ele> </tp>
907 <etp err="nosignal"> <time>2003-06-13T14:36:13Z</time> </etp>
908 <tp> <time>2003-06-13T14:36:15Z</time> <lat>59.52085</lat> <lon>7.39351666666667</lon> <ele>760</ele> </tp>
909 <tp> <time>2003-06-13T14:36:16Z</time> <lat>59.5207333333333</lat> <lon>7.39378333333333</lon> <ele>760</ele> </tp>
910 <tp> <time>2003-06-13T14:36:17Z</time> <lat>59.52065</lat> <lon>7.39405</lon> <ele>760</ele> </tp>
911 <tp> <time>2003-06-13T14:36:18Z</time> <lat>59.5205833333333</lat> <lon>7.39433333333333</lon> <ele>760</ele> </tp>
912 <tp> <time>2003-06-13T14:36:19Z</time> <lat>59.5205333333333</lat> <lon>7.39463333333333</lon> <ele>759</ele> </tp>
913 <tp> <time>2003-06-13T14:36:20Z</time> <lat>59.5204833333333</lat> <lon>7.39491666666667</lon> <ele>759</ele> </tp>
914 <tp> <time>2003-06-13T14:36:21Z</time> <lat>59.5204333333333</lat> <lon>7.39523333333333</lon> <ele>759</ele> </tp>
915 <etp err="nosignal"> <time>2003-06-13T14:36:22Z</time> </etp>
916 <tp> <time>2003-06-13T14:36:24Z</time> <lat>59.5202833333333</lat> <lon>7.39623333333333</lon> <ele>758</ele> </tp>
917 <tp> <time>2003-06-13T14:36:25Z</time> <lat>59.5202333333333</lat> <lon>7.39655</lon> <ele>758</ele> </tp>
918 <tp> <time>2003-06-13T14:36:26Z</time> <lat>59.5201833333333</lat> <lon>7.39688333333333</lon> <ele>757</ele> </tp>
919 <tp> <time>2003-06-13T14:36:27Z</time> <lat>59.5201333333333</lat> <lon>7.39721666666667</lon> <ele>757</ele> </tp>
920 <tp> <time>2003-06-13T14:36:28Z</time> <lat>59.5201</lat> <lon>7.39756666666667</lon> <ele>757</ele> </tp>
921 </track>
922 </gpsml>
925 "Read Garmin serial text format",
929 # }}}
930 testcmd("../gpst log.dos.mayko", # {{{
931 <<END,
932 <?xml version="1.0" encoding="UTF-8"?>
933 <gpsml>
934 <track>
935 <tp> <time>2003-06-15T10:27:45Z</time> <lat>58.1818158</lat> <lon>8.1225077</lon> </tp>
936 <tp> <time>2003-06-15T10:27:53Z</time> <lat>58.1818712</lat> <lon>8.12532</lon> </tp>
937 <tp> <time>2003-06-15T10:27:57Z</time> <lat>58.1816347</lat> <lon>8.1266031</lon> </tp>
938 <tp> <time>2003-06-15T10:28:03Z</time> <lat>58.1812099</lat> <lon>8.1284612</lon> </tp>
939 <tp> <time>2003-06-15T10:28:06Z</time> <lat>58.1810315</lat> <lon>8.129395</lon> </tp>
940 <tp> <time>2003-06-15T10:28:10Z</time> <lat>58.1809621</lat> <lon>8.13074</lon> </tp>
941 </track>
942 </gpsml>
945 "Read DOS-formatted Mayko format",
949 # }}}
950 testcmd("../gpst log.dos.gpstxt", # {{{
951 <<END,
952 <?xml version="1.0" encoding="UTF-8"?>
953 <gpsml>
954 <track>
955 <tp> <time>2003-01-05T16:47:11Z</time> <lat>66.9081666666667</lat> <lon>15.0229833333333</lon> <ele>11472</ele> </tp>
956 <tp> <time>2003-01-05T16:47:12Z</time> <lat>66.90625</lat> <lon>15.0206666666667</lon> <ele>11472</ele> </tp>
957 <tp> <time>2003-01-05T16:47:13Z</time> <lat>66.9043166666667</lat> <lon>15.01835</lon> <ele>11472</ele> </tp>
958 <tp> <time>2003-01-05T16:47:14Z</time> <lat>66.9024</lat> <lon>15.0160166666667</lon> <ele>11473</ele> </tp>
959 <tp> <time>2003-01-05T16:47:15Z</time> <lat>66.9004833333333</lat> <lon>15.0137</lon> <ele>11474</ele> </tp>
960 <tp> <time>2003-01-05T16:47:16Z</time> <lat>66.8985666666667</lat> <lon>15.0113833333333</lon> <ele>11474</ele> </tp>
961 <tp> <time>2003-01-05T16:47:17Z</time> <lat>66.8966333333333</lat> <lon>15.0090666666667</lon> <ele>11475</ele> </tp>
962 <tp> <time>2003-01-05T16:47:18Z</time> <lat>66.8947166666667</lat> <lon>15.0067333333333</lon> <ele>11475</ele> </tp>
963 <tp> <time>2003-01-05T16:47:19Z</time> <lat>66.8928</lat> <lon>15.0044166666667</lon> <ele>11475</ele> </tp>
964 <tp> <time>2003-01-05T16:47:20Z</time> <lat>66.8908666666667</lat> <lon>15.0021</lon> <ele>11475</ele> </tp>
965 <tp> <time>2003-01-05T16:47:21Z</time> <lat>66.88895</lat> <lon>14.9997833333333</lon> <ele>11475</ele> </tp>
966 </track>
967 </gpsml>
970 "Read DOS-formatted Garmin serial text format",
974 # }}}
975 testcmd("../gpst log.unix.mcsv", # {{{
976 <<END,
977 <?xml version="1.0" encoding="UTF-8"?>
978 <gpsml>
979 <track>
980 <break/>
981 <title>ACTIVE LOG 058</title>
982 <tp> <time>2006-02-21T15:14:25Z</time> <lat>60.36662</lat> <lon>5.24885</lon> <ele>31.9</ele> </tp>
983 <tp> <time>2006-02-21T15:14:30Z</time> <lat>60.37057</lat> <lon>5.22956</lon> <ele>35.2</ele> </tp>
984 <tp> <time>2006-02-21T15:14:35Z</time> <lat>60.37019</lat> <lon>5.22817</lon> <ele>39.6</ele> </tp>
985 <tp> <time>2006-02-21T15:14:36Z</time> <lat>60.37012</lat> <lon>5.2279</lon> <ele>41</ele> </tp>
986 <tp> <time>2006-02-21T15:14:40Z</time> <lat>60.37009</lat> <lon>5.22682</lon> <ele>47.2</ele> </tp>
987 <tp> <time>2006-02-21T15:14:42Z</time> <lat>60.37011</lat> <lon>5.22641</lon> <ele>49.2</ele> </tp>
988 <tp> <time>2006-02-21T15:14:44Z</time> <lat>60.37011</lat> <lon>5.22607</lon> <ele>50.1</ele> </tp>
989 <tp> <time>2006-02-21T15:14:48Z</time> <lat>60.37002</lat> <lon>5.22568</lon> <ele>51.1</ele> </tp>
990 <tp> <time>2006-02-21T15:14:51Z</time> <lat>60.3701</lat> <lon>5.22548</lon> <ele>52.5</ele> </tp>
991 </track>
992 </gpsml>
995 "Read UNIX-formatted Garmin Mapsource TAB-separated format",
999 # }}}
1000 testcmd("../gpst multitrack.gpx", # {{{
1001 <<END,
1002 <?xml version="1.0" encoding="UTF-8"?>
1003 <gpsml>
1004 <track>
1005 <title>Track 1</title>
1006 <tp> <time>2003-02-11T23:35:39Z</time> <lat>51.4968266</lat> <lon>-0.1448824</lon> </tp>
1007 <tp> <time>2003-02-11T23:35:49Z</time> <lat>51.4968227</lat> <lon>-0.1449938</lon> </tp>
1008 <tp> <time>2003-02-11T23:36:14Z</time> <lat>51.496904</lat> <lon>-0.1453202</lon> </tp>
1009 <break/>
1010 <title>Track 2</title>
1011 <tp> <time>2003-02-11T23:36:16Z</time> <lat>51.4969214</lat> <lon>-0.1453398</lon> </tp>
1012 <tp> <time>2003-02-11T23:36:31Z</time> <lat>51.4969816</lat> <lon>-0.1455514</lon> </tp>
1013 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
1014 <tp> <time>2003-02-11T23:36:50Z</time> <lat>51.4970452</lat> <lon>-0.1457804</lon> </tp>
1015 <break/>
1016 <title>Track 3</title>
1017 <tp> <time>2003-02-11T23:37:05Z</time> <lat>51.497068</lat> <lon>-0.1458608</lon> </tp>
1018 <tp> <time>2003-02-11T23:37:22Z</time> <lat>51.4971658</lat> <lon>-0.1460047</lon> </tp>
1019 <tp> <time>2003-02-11T23:37:36Z</time> <lat>51.4972469</lat> <lon>-0.1461614</lon> </tp>
1020 <break/>
1021 <title>Track 4</title>
1022 <tp> <time>2003-02-11T23:37:43Z</time> <lat>51.4972731</lat> <lon>-0.1462394</lon> </tp>
1023 <tp> <time>2003-02-11T23:38:04Z</time> <lat>51.4973437</lat> <lon>-0.1463232</lon> </tp>
1024 <tp> <time>2003-02-11T23:38:28Z</time> <lat>51.4973337</lat> <lon>-0.1462949</lon> </tp>
1025 <tp> <time>2003-02-11T23:38:34Z</time> <lat>51.4973218</lat> <lon>-0.1462825</lon> </tp>
1026 <tp> <time>2003-02-11T23:38:35Z</time> <lat>51.4973145</lat> <lon>-0.1462732</lon> </tp>
1027 </track>
1028 </gpsml>
1031 "Read GPX file with multiple tracks",
1035 # }}}
1036 testcmd("../gpst compact.gpx", # {{{
1037 <<END,
1038 <?xml version="1.0" encoding="UTF-8"?>
1039 <gpsml>
1040 <track>
1041 <title>All whitespace stripped</title>
1042 <tp> <time>2002-12-30T15:22:04Z</time> <lat>70.660932</lat> <lon>23.7028354</lon> </tp>
1043 <tp> <time>2002-12-30T15:22:06Z</time> <lat>70.6609392</lat> <lon>23.7028468</lon> </tp>
1044 <tp> <time>2002-12-30T15:22:08Z</time> <lat>70.6609429</lat> <lon>23.7028499</lon> </tp>
1045 <tp> <time>2002-12-30T15:22:11Z</time> <lat>70.6609381</lat> <lon>23.702862</lon> </tp>
1046 <tp> <time>2002-12-30T15:22:12Z</time> <lat>70.6609368</lat> <lon>23.7028648</lon> </tp>
1047 <tp> <time>2002-12-30T15:22:13Z</time> <lat>70.6609344</lat> <lon>23.7028652</lon> </tp>
1048 <tp> <time>2002-12-30T15:22:15Z</time> <lat>70.6609349</lat> <lon>23.7028707</lon> </tp>
1049 <tp> <time>2002-12-30T15:22:17Z</time> <lat>70.6609348</lat> <lon>23.7028654</lon> </tp>
1050 <tp> <time>2002-12-30T15:22:19Z</time> <lat>70.6609347</lat> <lon>23.7028599</lon> </tp>
1051 <tp> <time>2002-12-30T15:22:20Z</time> <lat>70.6609348</lat> <lon>23.7028609</lon> </tp>
1052 <tp> <time>2002-12-30T15:22:23Z</time> <lat>70.6609388</lat> <lon>23.7028653</lon> </tp>
1053 <tp> <time>2002-12-30T15:22:25Z</time> <lat>70.6609426</lat> <lon>23.7028732</lon> </tp>
1054 </track>
1055 </gpsml>
1058 "Read GPX one-liner",
1062 # }}}
1063 testcmd("../gpst missing.gpsml", # {{{
1064 <<END,
1065 <?xml version="1.0" encoding="UTF-8"?>
1066 <gpsml>
1067 <track>
1068 <title>Missing various elements</title>
1069 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
1070 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
1071 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1072 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1073 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1074 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1075 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
1076 <tp> <ele>486</ele> </tp>
1077 <tp> <desc>Missing everything</desc> </tp>
1078 <tp> <lat>60.42339</lat> </tp>
1079 <tp> <lon>5.34262</lon> </tp>
1080 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1081 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1082 </track>
1083 </gpsml>
1086 "Read gpsml with various data missing",
1090 # }}}
1091 testcmd("../gpst different_dateformats.gpsml", # {{{
1092 <<END,
1093 <?xml version="1.0" encoding="UTF-8"?>
1094 <gpsml>
1095 <track>
1096 <title>Date format variations</title>
1097 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1</lat> <lon>1</lon> </tp>
1098 <tp> <time>2006-01-01T00:00:02Z</time> <lat>2</lat> <lon>2</lon> </tp>
1099 <tp> <time>2006-01-01T00:00:03Z</time> <lat>3</lat> <lon>3</lon> </tp>
1100 <tp> <time>2006-01-01T00:00:04Z</time> <lat>4</lat> <lon>4</lon> </tp>
1101 </track>
1102 </gpsml>
1105 "Read different date formats from gpsml file",
1109 # }}}
1110 testcmd("../gpst multitrack-pause.gpx", # {{{
1111 file_data("multitrack-pause.gpsml"),
1113 "Should be equal to multitrack-pause.gpsml",
1117 # }}}
1118 # gpx
1119 testcmd("../gpst -o gpx no_signal.mayko", # {{{
1120 <<END,
1121 $gpx_header
1122 <trk>
1123 <trkseg>
1124 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
1125 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
1126 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
1127 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> </trkpt>
1128 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> </trkpt>
1129 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> </trkpt>
1130 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
1131 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
1132 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
1133 </trkseg>
1134 </trk>
1135 </gpx>
1138 "Output GPX from Mayko file with duplicates",
1142 # }}}
1143 testcmd("../gpst -o gpx comments.mayko", # {{{
1144 <<END,
1145 $gpx_header
1146 <trk>
1147 <trkseg>
1148 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
1149 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
1150 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
1151 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1152 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1153 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1154 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
1155 </trkseg>
1156 <trkseg>
1157 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
1158 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
1159 </trkseg>
1160 </trk>
1161 </gpx>
1164 "Output GPX from Mayko file with commented-out lines",
1168 # }}}
1169 testcmd("../gpst -o gpx missing-noname.gpsml", # {{{
1170 <<END,
1171 $gpx_header
1172 <trk>
1173 <trkseg>
1174 <trkpt lat="60.42353" lon="5.34185"> <time>2006-04-30T17:17:09Z</time> </trkpt>
1175 <trkpt lat="60.42347" lon="5.34212"> <ele>486</ele> </trkpt>
1176 <trkpt lat="60.42338" lon="5.34269"> <ele>487</ele> <time>2006-04-30T17:18:05Z</time> </trkpt>
1177 </trkseg>
1178 </trk>
1179 </gpx>
1182 "Output GPX from gpsml with missing data",
1186 # }}}
1187 # xgraph
1188 testcmd("../gpst -o xgraph multitrack.gpx", # {{{
1189 <<END,
1190 -0.1448824 51.4968266
1191 -0.1449938 51.4968227
1192 -0.1453202 51.496904
1193 move -0.1453398 51.4969214
1194 -0.1455514 51.4969816
1195 -0.1457489 51.4970224
1196 -0.1457804 51.4970452
1197 move -0.1458608 51.497068
1198 -0.1460047 51.4971658
1199 -0.1461614 51.4972469
1200 move -0.1462394 51.4972731
1201 -0.1463232 51.4973437
1202 -0.1462949 51.4973337
1203 -0.1462825 51.4973218
1204 -0.1462732 51.4973145
1207 "Output xgraph format from GPX",
1211 # }}}
1212 # pgtab
1213 testcmd("../gpst -o pgtab compact.gpx", # {{{
1214 <<END,
1215 2002-12-30T15:22:04Z\t(70.660932,23.7028354)\t\\N\t\\N\t\\N\t\\N
1216 2002-12-30T15:22:06Z\t(70.6609392,23.7028468)\t\\N\t\\N\t\\N\t\\N
1217 2002-12-30T15:22:08Z\t(70.6609429,23.7028499)\t\\N\t\\N\t\\N\t\\N
1218 2002-12-30T15:22:11Z\t(70.6609381,23.702862)\t\\N\t\\N\t\\N\t\\N
1219 2002-12-30T15:22:12Z\t(70.6609368,23.7028648)\t\\N\t\\N\t\\N\t\\N
1220 2002-12-30T15:22:13Z\t(70.6609344,23.7028652)\t\\N\t\\N\t\\N\t\\N
1221 2002-12-30T15:22:15Z\t(70.6609349,23.7028707)\t\\N\t\\N\t\\N\t\\N
1222 2002-12-30T15:22:17Z\t(70.6609348,23.7028654)\t\\N\t\\N\t\\N\t\\N
1223 2002-12-30T15:22:19Z\t(70.6609347,23.7028599)\t\\N\t\\N\t\\N\t\\N
1224 2002-12-30T15:22:20Z\t(70.6609348,23.7028609)\t\\N\t\\N\t\\N\t\\N
1225 2002-12-30T15:22:23Z\t(70.6609388,23.7028653)\t\\N\t\\N\t\\N\t\\N
1226 2002-12-30T15:22:25Z\t(70.6609426,23.7028732)\t\\N\t\\N\t\\N\t\\N
1229 "Output pgtab from gpx format",
1233 # }}}
1234 testcmd("../gpst -o pgtab no_signal.mayko", # {{{
1235 <<END,
1236 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N
1237 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N
1238 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1239 2002-12-22T21:43:51Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1240 2002-12-22T21:43:52Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1241 2002-12-22T21:43:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N
1242 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N
1243 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N
1244 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N
1247 "Output pgtab from mayko format",
1251 # }}}
1252 testcmd("../gpst -o pgtab missing.gpsml", # {{{
1253 <<END,
1254 2006-04-30T17:17:09Z\t(60.42353,5.34185)\t\\N\t\\N\t\\N\t\\N
1255 \\N\t(60.42347,5.34212)\t486\t\\N\t\\N\t\\N
1256 2006-04-30T17:18:05Z\t(60.42338,5.34269)\t487\t\\N\t\\N\t\\N
1259 "Output pgtab from missing.gpsml",
1263 # }}}
1264 # csv
1265 testcmd("../gpst -o csv log.dos.mayko", # {{{
1266 <<END,
1267 2003-06-15T10:27:45Z\t8.1225077\t58.1818158\t\t
1268 2003-06-15T10:27:53Z\t8.12532\t58.1818712\t\t
1269 2003-06-15T10:27:57Z\t8.1266031\t58.1816347\t\t
1270 2003-06-15T10:28:03Z\t8.1284612\t58.1812099\t\t
1271 2003-06-15T10:28:06Z\t8.129395\t58.1810315\t\t
1272 2003-06-15T10:28:10Z\t8.13074\t58.1809621\t\t
1275 "Output csv from DOS-formatted Mayko format",
1279 # }}}
1280 testcmd("../gpst -o csv multitrack.gpx", # {{{
1281 # FIXME: Get rid of the empty line in the beginning
1282 <<END,
1283 \t\t\t\t
1284 2003-02-11T23:35:39Z\t-0.1448824\t51.4968266\t\t
1285 2003-02-11T23:35:49Z\t-0.1449938\t51.4968227\t\t
1286 2003-02-11T23:36:14Z\t-0.1453202\t51.496904\t\t
1287 \t\t\t\t
1288 2003-02-11T23:36:16Z\t-0.1453398\t51.4969214\t\t
1289 2003-02-11T23:36:31Z\t-0.1455514\t51.4969816\t\t
1290 2003-02-11T23:36:43Z\t-0.1457489\t51.4970224\t1000\t
1291 2003-02-11T23:36:50Z\t-0.1457804\t51.4970452\t\t
1292 \t\t\t\t
1293 2003-02-11T23:37:05Z\t-0.1458608\t51.497068\t\t
1294 2003-02-11T23:37:22Z\t-0.1460047\t51.4971658\t\t
1295 2003-02-11T23:37:36Z\t-0.1461614\t51.4972469\t\t
1296 \t\t\t\t
1297 2003-02-11T23:37:43Z\t-0.1462394\t51.4972731\t\t
1298 2003-02-11T23:38:04Z\t-0.1463232\t51.4973437\t\t
1299 2003-02-11T23:38:28Z\t-0.1462949\t51.4973337\t\t
1300 2003-02-11T23:38:34Z\t-0.1462825\t51.4973218\t\t
1301 2003-02-11T23:38:35Z\t-0.1462732\t51.4973145\t\t
1304 "Output csv from DOS-formatted Mayko format",
1308 # }}}
1309 # pgwtab
1310 testcmd("../gpst -o pgwtab multitrack.gpx", # {{{
1311 <<END,
1312 (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
1313 (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
1314 (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
1315 (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
1316 (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
1317 (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
1320 "Test pgwtab format",
1324 # }}}
1325 # pgwupd
1326 testcmd("../gpst -o pgwupd multitrack.gpx", # {{{
1327 <<END,
1328 BEGIN;
1329 UPDATE logg SET name = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1330 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1331 COMMIT;
1332 BEGIN;
1333 UPDATE logg SET name = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1334 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1335 COMMIT;
1336 BEGIN;
1337 UPDATE logg SET name = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1338 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1339 COMMIT;
1340 BEGIN;
1341 UPDATE logg SET name = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1342 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1343 COMMIT;
1344 BEGIN;
1345 UPDATE logg SET name = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1346 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1347 COMMIT;
1348 BEGIN;
1349 UPDATE logg SET name = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1350 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1351 COMMIT;
1354 "Test pgwupd format",
1358 # }}}
1359 # clean
1360 testcmd("../gpst -t -o clean pause.gpx", # {{{
1361 <<END,
1362 5.299534\t60.425494\t25.26
1363 5.29961\t60.425464\t24.931
1365 5.299694\t60.425314\t27.975
1367 5.299741\t60.425384\t31.017
1368 5.299958\t60.425339\t30.98
1369 5.29964\t60.425238\t30.538
1370 5.299686\t60.425246\t30.515
1372 5.299773\t60.425345\t31.936
1373 5.299419\t60.425457\t31.794
1376 "Output clean format with time breaks",
1379 # }}}
1380 # gpstrans
1381 # poscount
1382 # ps (Unfinished)
1383 # svg (Unfinished)
1384 # ygraph
1385 # --output option }}}
1386 diag("Testing --outside option..."); # {{{
1387 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --outside multitrack-pause.gpx", # {{{
1388 <<END,
1389 <?xml version="1.0" encoding="UTF-8"?>
1390 <gpsml>
1391 <track>
1392 <title>track1</title>
1393 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1394 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1395 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1396 <break/>
1397 <title>track2</title>
1398 <break/>
1399 <title>track3</title>
1400 <break/>
1401 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1402 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1403 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1404 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1405 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1406 </track>
1407 </gpsml>
1410 "Check --outside option (gpx to gpst)",
1414 # }}}
1415 # --outside option }}}
1416 diag("Testing --pos1 and --pos2 options..."); # {{{
1417 # --pos1 and --pos2 options }}}
1418 diag("Testing --require option..."); # {{{
1419 testcmd("../gpst -re multitrack.gpx", # {{{
1420 <<END,
1421 <?xml version="1.0" encoding="UTF-8"?>
1422 <gpsml>
1423 <track>
1424 <title>Track 1</title>
1425 <break/>
1426 <title>Track 2</title>
1427 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
1428 <break/>
1429 <title>Track 3</title>
1430 <break/>
1431 <title>Track 4</title>
1432 </track>
1433 </gpsml>
1436 "Require elevation from GPX data",
1440 # }}}
1441 testcmd("../gpst -re one_ele.dos.gpsml", # {{{
1442 <<END,
1443 <?xml version="1.0" encoding="UTF-8"?>
1444 <gpsml>
1445 <track>
1446 <title>Only one point has elevation</title>
1447 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1448 </track>
1449 </gpsml>
1452 "Require elevation from gpsml",
1456 # }}}
1457 testcmd("../gpst -re missing.gpsml", # {{{
1458 <<END,
1459 <?xml version="1.0" encoding="UTF-8"?>
1460 <gpsml>
1461 <track>
1462 <title>Missing various elements</title>
1463 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1464 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1465 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1466 <tp> <lon>5.34224</lon> <ele>484</ele> </tp>
1467 <tp> <ele>486</ele> </tp>
1468 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1469 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1470 </track>
1471 </gpsml>
1474 "Require elevation",
1478 # }}}
1479 testcmd("../gpst -rt missing.gpsml", # {{{
1480 <<END,
1481 <?xml version="1.0" encoding="UTF-8"?>
1482 <gpsml>
1483 <track>
1484 <title>Missing various elements</title>
1485 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
1486 <tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
1487 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1488 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1489 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1490 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1491 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1492 </track>
1493 </gpsml>
1496 "Require time",
1500 # }}}
1501 testcmd("../gpst -rp missing.gpsml", # {{{
1502 <<END,
1503 <?xml version="1.0" encoding="UTF-8"?>
1504 <gpsml>
1505 <track>
1506 <title>Missing various elements</title>
1507 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1508 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1509 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1510 </track>
1511 </gpsml>
1514 "Require position",
1518 # }}}
1519 testcmd("../gpst -ret missing.gpsml", # {{{
1520 <<END,
1521 <?xml version="1.0" encoding="UTF-8"?>
1522 <gpsml>
1523 <track>
1524 <title>Missing various elements</title>
1525 <tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
1526 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1527 <tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
1528 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1529 </track>
1530 </gpsml>
1533 "Require elevation and time",
1537 # }}}
1538 testcmd("../gpst -retp missing.gpsml", # {{{
1539 <<END,
1540 <?xml version="1.0" encoding="UTF-8"?>
1541 <gpsml>
1542 <track>
1543 <title>Missing various elements</title>
1544 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1545 </track>
1546 </gpsml>
1549 "Require elevation, time and position",
1553 # }}}
1554 testcmd("../gpst -rep missing.gpsml", # {{{
1555 <<END,
1556 <?xml version="1.0" encoding="UTF-8"?>
1557 <gpsml>
1558 <track>
1559 <title>Missing various elements</title>
1560 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1561 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1562 </track>
1563 </gpsml>
1566 "Require elevation and position",
1570 # }}}
1571 # --require option }}}
1572 diag("Testing --round option..."); # {{{
1573 testcmd("../gpst -R lat=4,lon=5,ele=1 pause.gpx", # {{{
1574 <<END,
1575 <?xml version="1.0" encoding="UTF-8"?>
1576 <gpsml>
1577 <track>
1578 <title>ACTIVE LOG164705</title>
1579 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.4255</lat> <lon>5.29953</lon> <ele>25.3</ele> </tp>
1580 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.4255</lat> <lon>5.29961</lon> <ele>24.9</ele> </tp>
1581 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.4253</lat> <lon>5.29969</lon> <ele>28</ele> </tp>
1582 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.4254</lat> <lon>5.29974</lon> <ele>31</ele> </tp>
1583 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.4253</lat> <lon>5.29996</lon> <ele>31</ele> </tp>
1584 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.4252</lat> <lon>5.29964</lon> <ele>30.5</ele> </tp>
1585 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.4252</lat> <lon>5.29969</lon> <ele>30.5</ele> </tp>
1586 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.4253</lat> <lon>5.29977</lon> <ele>31.9</ele> </tp>
1587 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.4255</lat> <lon>5.29942</lon> <ele>31.8</ele> </tp>
1588 </track>
1589 </gpsml>
1592 "--round works with lat, lon, ele from gpx",
1596 # }}}
1597 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgtab pause.gpx", # {{{
1598 <<END,
1599 2006-05-21T16:49:11Z\t(60.425,5.3)\t25.3\t\\N\t\\N\t\\N
1600 2006-05-21T16:49:46Z\t(60.425,5.3)\t24.9\t\\N\t\\N\t\\N
1601 2006-05-21T16:52:04Z\t(60.425,5.3)\t28\t\\N\t\\N\t\\N
1602 2006-05-21T16:56:36Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N
1603 2006-05-21T16:56:47Z\t(60.425,5.3)\t31\t\\N\t\\N\t\\N
1604 2006-05-21T16:56:56Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N
1605 2006-05-21T16:57:03Z\t(60.425,5.3)\t30.5\t\\N\t\\N\t\\N
1606 2006-05-21T16:59:08Z\t(60.425,5.3)\t31.9\t\\N\t\\N\t\\N
1607 2006-05-21T17:00:54Z\t(60.425,5.299)\t31.8\t\\N\t\\N\t\\N
1610 "pgtab output from gpx works with --round lat, lon, ele",
1614 # }}}
1615 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwtab multitrack.gpx", # {{{
1616 <<END,
1617 (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
1618 (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
1619 (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
1620 (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
1621 (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
1622 (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
1625 "--round works with lat, lon, ele from gpx, pgwtab output",
1629 # }}}
1630 testcmd("../gpst -R lat=3,lon=3,ele=1 -o pgwupd multitrack.gpx", # {{{
1631 <<END,
1632 BEGIN;
1633 UPDATE logg SET name = clname(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1634 UPDATE logg SET dist = cldist(coor) WHERE (point(51.478,-0.001) <-> coor) < 0.05;
1635 COMMIT;
1636 BEGIN;
1637 UPDATE logg SET name = clname(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1638 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532,-0.177) <-> coor) < 0.05;
1639 COMMIT;
1640 BEGIN;
1641 UPDATE logg SET name = clname(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1642 UPDATE logg SET dist = cldist(coor) WHERE (point(61.637,8.312) <-> coor) < 0.05;
1643 COMMIT;
1644 BEGIN;
1645 UPDATE logg SET name = clname(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1646 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397,5.351) <-> coor) < 0.05;
1647 COMMIT;
1648 BEGIN;
1649 UPDATE logg SET name = clname(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1650 UPDATE logg SET dist = cldist(coor) WHERE (point(51.51,-0.13) <-> coor) < 0.05;
1651 COMMIT;
1652 BEGIN;
1653 UPDATE logg SET name = clname(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1654 UPDATE logg SET dist = cldist(coor) WHERE (point(60.969,9.285) <-> coor) < 0.05;
1655 COMMIT;
1658 "pgwupd output and --round works with lat, lon, ele from gpx",
1662 # }}}
1663 testcmd("../gpst -R lat=8,lon=8 -o gpx rounding.mayko", # {{{
1664 <<END,
1665 $gpx_header
1666 <trk>
1667 <trkseg>
1668 <trkpt lat="51.4838161" lon="0.0000533"> <time>2003-02-11T12:17:05Z</time> </trkpt>
1669 <trkpt lat="51.483777" lon="-0.0000211"> <time>2003-02-11T12:17:15Z</time> </trkpt>
1670 <trkpt lat="51.4837543" lon="-0.0000894"> <time>2003-02-11T12:17:21Z</time> </trkpt>
1671 <trkpt lat="51.4836222" lon="0.0000272"> <time>2003-02-11T12:27:41Z</time> </trkpt>
1672 </trkseg>
1673 </trk>
1674 </gpx>
1677 "Suppress braindead scientific notation when using --round (from mayko)",
1681 # }}}
1682 testcmd("../gpst -R lat=8,lon=8 -o gpx rounding.gpx", # {{{
1683 <<END,
1684 $gpx_header
1685 <trk>
1686 <trkseg>
1687 <trkpt lat="51.4838161" lon="0.0000533"> <time>2003-02-11T12:17:05Z</time> </trkpt>
1688 <trkpt lat="51.483777" lon="-0.0000211"> <time>2003-02-11T12:17:15Z</time> </trkpt>
1689 <trkpt lat="51.4837543" lon="-0.0000894"> <time>2003-02-11T12:17:21Z</time> </trkpt>
1690 <trkpt lat="51.4836222" lon="0.0000272"> <time>2003-02-11T12:27:41Z</time> </trkpt>
1691 </trkseg>
1692 </trk>
1693 </gpx>
1696 "Suppress braindead scientific notation when using --round (from gpx)",
1700 # }}}
1701 testcmd("../gpst -R lat=6,lon=6 -o gpx rounding.gpx", # {{{
1702 <<END,
1703 $gpx_header
1704 <trk>
1705 <trkseg>
1706 <trkpt lat="51.483816" lon="0.000053"> <time>2003-02-11T12:17:05Z</time> </trkpt>
1707 <trkpt lat="51.483777" lon="-0.000021"> <time>2003-02-11T12:17:15Z</time> </trkpt>
1708 <trkpt lat="51.483754" lon="-0.000089"> <time>2003-02-11T12:17:21Z</time> </trkpt>
1709 <trkpt lat="51.483622" lon="0.000027"> <time>2003-02-11T12:27:41Z</time> </trkpt>
1710 </trkseg>
1711 </trk>
1712 </gpx>
1715 "Suppress scientific notation, six decimals (from gpx)",
1719 # }}}
1720 testcmd("../gpst -R lat=2,lon=2 -o gpx rounding.gpx", # {{{
1721 <<END,
1722 $gpx_header
1723 <trk>
1724 <trkseg>
1725 <trkpt lat="51.48" lon="0"> <time>2003-02-11T12:17:05Z</time> </trkpt>
1726 <trkpt lat="51.48" lon="0"> <time>2003-02-11T12:17:15Z</time> </trkpt>
1727 <trkpt lat="51.48" lon="0"> <time>2003-02-11T12:17:21Z</time> </trkpt>
1728 <trkpt lat="51.48" lon="0"> <time>2003-02-11T12:27:41Z</time> </trkpt>
1729 </trkseg>
1730 </trk>
1731 </gpx>
1734 "Suppress scientific notation, two decimals (from gpx)",
1738 # }}}
1739 testcmd("../gpst -R lat=2,lon=2 -o gpx rounding.mayko", # {{{
1740 <<END,
1741 $gpx_header
1742 <trk>
1743 <trkseg>
1744 <trkpt lat="51.48" lon="0"> <time>2003-02-11T12:17:05Z</time> </trkpt>
1745 <trkpt lat="51.48" lon="0"> <time>2003-02-11T12:17:15Z</time> </trkpt>
1746 <trkpt lat="51.48" lon="0"> <time>2003-02-11T12:17:21Z</time> </trkpt>
1747 <trkpt lat="51.48" lon="0"> <time>2003-02-11T12:27:41Z</time> </trkpt>
1748 </trkseg>
1749 </trk>
1750 </gpx>
1753 "Suppress scientific notation, two decimals (from mayko)",
1757 # }}}
1758 # --round option }}}
1759 diag("Testing --short-date option..."); # {{{
1760 # --short-date option }}}
1761 diag("Testing --save-to-file option..."); # {{{
1762 # --save-to-file option }}}
1763 diag("Testing --create-breaks option..."); # {{{
1764 testcmd("../gpst -t pause.gpx", # {{{
1765 <<END,
1766 <?xml version="1.0" encoding="UTF-8"?>
1767 <gpsml>
1768 <track>
1769 <title>ACTIVE LOG164705</title>
1770 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
1771 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
1772 <pause>0:00:02:18</pause>
1773 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1774 <pause>0:00:04:32</pause>
1775 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
1776 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
1777 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
1778 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
1779 <pause>0:00:02:05</pause>
1780 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
1781 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
1782 </track>
1783 </gpsml>
1786 "Output gpsml with <pause> elements from GPX files",
1790 # }}}
1791 testcmd("../gpst -t multitrack-pause.gpx", # {{{
1792 <<END,
1793 <?xml version="1.0" encoding="UTF-8"?>
1794 <gpsml>
1795 <track>
1796 <title>track1</title>
1797 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1798 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1799 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1800 <break/>
1801 <title>track2</title>
1802 <pause>0:23:59:58</pause>
1803 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1804 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1805 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1806 <pause>0:01:00:00</pause>
1807 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1808 <break/>
1809 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1810 <break/>
1811 <title>track3</title>
1812 <pause>1:01:00:03</pause>
1813 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1814 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1815 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1816 <break/>
1817 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1818 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1819 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1820 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1821 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1822 </track>
1823 </gpsml>
1826 "Insert <pause> between gpx tracks",
1830 # }}}
1831 testcmd("../gpst -t multitrack-pause.gpsml", # {{{
1832 <<END,
1833 <?xml version="1.0" encoding="UTF-8"?>
1834 <gpsml>
1835 <track>
1836 <title>track1</title>
1837 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1838 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1839 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1840 <break/>
1841 <title>track2</title>
1842 <pause>0:23:59:58</pause>
1843 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1844 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1845 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1846 <pause>0:01:00:00</pause>
1847 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1848 <break/>
1849 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1850 <break/>
1851 <title>track3</title>
1852 <pause>1:01:00:03</pause>
1853 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1854 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1855 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1856 <break/>
1857 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1858 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1859 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1860 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1861 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1862 </track>
1863 </gpsml>
1866 "Insert <pause> between gpsml titles",
1870 # }}}
1871 # --create-breaks option }}}
1872 diag("Testing -T (--time-shift) option..."); # {{{
1873 testcmd("$CMD -T 3600 multitrack-pause.gpx", # {{{
1874 <<END,
1875 <?xml version="1.0" encoding="UTF-8"?>
1876 <gpsml>
1877 <track>
1878 <title>track1</title>
1879 <tp> <time>2006-01-01T01:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1880 <tp> <time>2006-01-01T01:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1881 <tp> <time>2006-01-01T01:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1882 <break/>
1883 <title>track2</title>
1884 <tp> <time>2006-01-02T01:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1885 <tp> <time>2006-01-02T01:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1886 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1887 <tp> <time>2006-01-02T02:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1888 <break/>
1889 <tp> <time>2006-01-02T02:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1890 <break/>
1891 <title>track3</title>
1892 <tp> <time>2006-01-03T03:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1893 <tp> <time>2006-01-03T03:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1894 <tp> <time>2006-01-03T03:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1895 <break/>
1896 <tp> <time>2006-01-03T03:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1897 <tp> <time>2006-01-03T03:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1898 <tp> <time>2006-01-03T03:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1899 <tp> <time>2006-01-03T03:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1900 <tp> <time>2006-01-03T03:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1901 </track>
1902 </gpsml>
1905 "Add one hour to GPX input, output gpsml",
1909 # }}}
1910 testcmd("$CMD -T -3600 multitrack-pause.gpx", # {{{
1911 <<END,
1912 <?xml version="1.0" encoding="UTF-8"?>
1913 <gpsml>
1914 <track>
1915 <title>track1</title>
1916 <tp> <time>2005-12-31T23:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1917 <tp> <time>2005-12-31T23:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1918 <tp> <time>2005-12-31T23:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1919 <break/>
1920 <title>track2</title>
1921 <tp> <time>2006-01-01T23:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1922 <tp> <time>2006-01-01T23:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1923 <tp> <time>2006-01-01T23:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1924 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1925 <break/>
1926 <tp> <time>2006-01-02T00:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1927 <break/>
1928 <title>track3</title>
1929 <tp> <time>2006-01-03T01:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1930 <tp> <time>2006-01-03T01:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1931 <tp> <time>2006-01-03T01:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1932 <break/>
1933 <tp> <time>2006-01-03T01:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1934 <tp> <time>2006-01-03T01:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1935 <tp> <time>2006-01-03T01:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1936 <tp> <time>2006-01-03T01:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1937 <tp> <time>2006-01-03T01:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1938 </track>
1939 </gpsml>
1942 "Subtract one hour from GPX input, output gpsml",
1946 # }}}
1947 testcmd("$CMD -T 1 -o gpx multitrack-pause.gpx", # {{{
1948 <<END,
1949 $gpx_header
1950 <trk>
1951 <trkseg>
1952 <trkpt lat="1.11" lon="1.12"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1953 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:02Z</time> </trkpt>
1954 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:03Z</time> </trkpt>
1955 </trkseg>
1956 <trkseg>
1957 <trkpt lat="2.11" lon="2.12"> <time>2006-01-02T00:00:01Z</time> </trkpt>
1958 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:05Z</time> </trkpt>
1959 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:17Z</time> </trkpt>
1960 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:17Z</time> </trkpt>
1961 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:18Z</time> </trkpt>
1962 </trkseg>
1963 <trkseg>
1964 </trkseg>
1965 <trkseg>
1966 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:21Z</time> </trkpt>
1967 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:22Z</time> </trkpt>
1968 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:23Z</time> </trkpt>
1969 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:24Z</time> </trkpt>
1970 </trkseg>
1971 <trkseg>
1972 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:25Z</time> </trkpt>
1973 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:26Z</time> </trkpt>
1974 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:27Z</time> </trkpt>
1975 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:28Z</time> </trkpt>
1976 </trkseg>
1977 </trk>
1978 </gpx>
1981 "Add one second to GPX input, output GPX",
1985 # }}}
1986 testcmd("$CMD --time-shift -1 -o gpx multitrack-pause.gpsml", # {{{
1987 <<END,
1988 $gpx_header
1989 <trk>
1990 <trkseg>
1991 <trkpt lat="1.11" lon="1.12"> <time>2005-12-31T23:59:59Z</time> </trkpt>
1992 <trkpt lat="1.21" lon="1.22"> <time>2006-01-01T00:00:00Z</time> </trkpt>
1993 <trkpt lat="1.31" lon="1.32"> <time>2006-01-01T00:00:01Z</time> </trkpt>
1994 </trkseg>
1995 <trkseg>
1996 <trkpt lat="2.11" lon="2.12"> <time>2006-01-01T23:59:59Z</time> </trkpt>
1997 <trkpt lat="2.21" lon="2.22"> <time>2006-01-02T00:00:03Z</time> </trkpt>
1998 <trkpt lat="2.31" lon="2.32"> <time>2006-01-02T00:00:15Z</time> </trkpt>
1999 <trkpt lat="2.41" lon="2.42"> <time>2006-01-02T01:00:15Z</time> </trkpt>
2000 <trkpt lat="2.451" lon="2.452"> <time>2006-01-02T01:00:16Z</time> </trkpt>
2001 </trkseg>
2002 <trkseg>
2003 </trkseg>
2004 <trkseg>
2005 <trkpt lat="3.11" lon="3.12"> <time>2006-01-03T02:00:19Z</time> </trkpt>
2006 <trkpt lat="3.21" lon="3.22"> <time>2006-01-03T02:00:20Z</time> </trkpt>
2007 <trkpt lat="3.31" lon="3.32"> <time>2006-01-03T02:00:21Z</time> </trkpt>
2008 <trkpt lat="3.41" lon="3.42"> <time>2006-01-03T02:00:22Z</time> </trkpt>
2009 </trkseg>
2010 <trkseg>
2011 <trkpt lat="3.51" lon="3.52"> <time>2006-01-03T02:00:23Z</time> </trkpt>
2012 <trkpt lat="3.61" lon="3.62"> <time>2006-01-03T02:00:24Z</time> </trkpt>
2013 <trkpt lat="3.71" lon="3.72"> <time>2006-01-03T02:00:25Z</time> </trkpt>
2014 <trkpt lat="3.81" lon="3.82"> <time>2006-01-03T02:00:26Z</time> </trkpt>
2015 </trkseg>
2016 </trk>
2017 </gpx>
2020 "Subtract one second from gpsml input, output GPX, use long option",
2024 # }}}
2025 testcmd("$CMD -T 0 -o pgtab multitrack-pause.gpx", # {{{
2026 <<END,
2027 2006-01-01T00:00:00Z\t(1.11,1.12)\t\\N\t\\N\t\\N\t\\N
2028 2006-01-01T00:00:01Z\t(1.21,1.22)\t\\N\t\\N\t\\N\t\\N
2029 2006-01-01T00:00:02Z\t(1.31,1.32)\t\\N\t\\N\t\\N\t\\N
2030 2006-01-02T00:00:00Z\t(2.11,2.12)\t\\N\t\\N\t\\N\t\\N
2031 2006-01-02T00:00:04Z\t(2.21,2.22)\t\\N\t\\N\t\\N\t\\N
2032 2006-01-02T00:00:16Z\t(2.31,2.32)\t\\N\t\\N\t\\N\t\\N
2033 2006-01-02T01:00:16Z\t(2.41,2.42)\t\\N\t\\N\t\\N\t\\N
2034 2006-01-02T01:00:17Z\t(2.451,2.452)\t\\N\t\\N\t\\N\t\\N
2035 2006-01-03T02:00:20Z\t(3.11,3.12)\t\\N\t\\N\t\\N\t\\N
2036 2006-01-03T02:00:21Z\t(3.21,3.22)\t\\N\t\\N\t\\N\t\\N
2037 2006-01-03T02:00:22Z\t(3.31,3.32)\t\\N\t\\N\t\\N\t\\N
2038 2006-01-03T02:00:23Z\t(3.41,3.42)\t\\N\t\\N\t\\N\t\\N
2039 2006-01-03T02:00:24Z\t(3.51,3.52)\t\\N\t\\N\t\\N\t\\N
2040 2006-01-03T02:00:25Z\t(3.61,3.62)\t\\N\t\\N\t\\N\t\\N
2041 2006-01-03T02:00:26Z\t(3.71,3.72)\t\\N\t\\N\t\\N\t\\N
2042 2006-01-03T02:00:27Z\t(3.81,3.82)\t\\N\t\\N\t\\N\t\\N
2045 "Read GPX, time-shift 0 seconds, output pgtab",
2049 # }}}
2050 # --time-shift option }}}
2051 diag("Testing -v (--verbose) option..."); # {{{
2052 likecmd("$CMD -hv", # {{{
2053 '/^\n\S+ v\d\.\d\d\n/s',
2054 '/^$/',
2055 "Option -v (--verbose) with -h returns version number and help screen",
2058 # }}}
2059 # --verbose option }}}
2060 diag("Testing --version option..."); # {{{
2061 likecmd("$CMD --version", # {{{
2062 '/^\S+ v\d\.\d\d\n/',
2063 '/^$/',
2064 "Option --version returns version number",
2067 # }}}
2068 # --version option }}}
2069 diag("Testing --strip-whitespace option..."); # {{{
2070 testcmd("../gpst -w -o gpx pause-noname.gpx", # {{{
2071 <<END,
2072 $stripped_gpx_header
2073 <trk>
2074 <trkseg>
2075 <trkpt lat="60.425494" lon="5.299534"><ele>25.26</ele><time>2006-05-21T16:49:11Z</time></trkpt>
2076 <trkpt lat="60.425464" lon="5.29961"><ele>24.931</ele><time>2006-05-21T16:49:46Z</time></trkpt>
2077 <trkpt lat="60.425314" lon="5.299694"><ele>27.975</ele><time>2006-05-21T16:52:04Z</time></trkpt>
2078 <trkpt lat="60.425384" lon="5.299741"><ele>31.017</ele><time>2006-05-21T16:56:36Z</time></trkpt>
2079 <trkpt lat="60.425339" lon="5.299958"><ele>30.98</ele><time>2006-05-21T16:56:47Z</time></trkpt>
2080 <trkpt lat="60.425238" lon="5.29964"><ele>30.538</ele><time>2006-05-21T16:56:56Z</time></trkpt>
2081 <trkpt lat="60.425246" lon="5.299686"><ele>30.515</ele><time>2006-05-21T16:57:03Z</time></trkpt>
2082 <trkpt lat="60.425345" lon="5.299773"><ele>31.936</ele><time>2006-05-21T16:59:08Z</time></trkpt>
2083 <trkpt lat="60.425457" lon="5.299419"><ele>31.794</ele><time>2006-05-21T17:00:54Z</time></trkpt>
2084 </trkseg>
2085 </trk>
2086 </gpx>
2089 "Strip whitespace from GPX output",
2093 # }}}
2094 testcmd("../gpst -o gpx -w comments.mayko", # {{{
2095 <<END,
2096 $stripped_gpx_header
2097 <trk>
2098 <trkseg>
2099 <trkpt lat="70.6800486" lon="23.6746151"><time>2002-12-22T21:42:24Z</time></trkpt>
2100 <trkpt lat="70.6799322" lon="23.6740038"><time>2002-12-22T21:42:32Z</time></trkpt>
2101 <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:42:54Z</time></trkpt>
2102 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:51Z</time><extensions><error>desc</error></extensions></trkpt> -->
2103 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:52Z</time><extensions><error>desc</error></extensions></trkpt> -->
2104 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:54Z</time><extensions><error>desc</error></extensions></trkpt> -->
2105 <trkpt lat="70.6800774" lon="23.6757566"><time>2002-12-22T21:44:45Z</time></trkpt>
2106 </trkseg>
2107 <trkseg>
2108 <trkpt lat="70.6801502" lon="23.6753442"><time>2002-12-22T21:44:52Z</time></trkpt>
2109 <trkpt lat="70.6801905" lon="23.6757542"><time>2002-12-22T21:45:04Z</time></trkpt>
2110 </trkseg>
2111 </trk>
2112 </gpx>
2115 "Output whitespace-stripped GPX from Mayko file with commented-out lines",
2119 # }}}
2120 testcmd("../gpst -w -o pgwupd multitrack.gpx", # {{{
2121 <<END,
2122 BEGIN;
2123 UPDATE logg SET name = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
2124 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
2125 COMMIT;
2126 BEGIN;
2127 UPDATE logg SET name = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
2128 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
2129 COMMIT;
2130 BEGIN;
2131 UPDATE logg SET name = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
2132 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
2133 COMMIT;
2134 BEGIN;
2135 UPDATE logg SET name = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
2136 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
2137 COMMIT;
2138 BEGIN;
2139 UPDATE logg SET name = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
2140 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
2141 COMMIT;
2142 BEGIN;
2143 UPDATE logg SET name = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
2144 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
2145 COMMIT;
2148 "Strip whitespace from pgwupd output",
2152 # }}}
2153 # --strip-whitespace option }}}
2154 diag("Testing --double-y-scale option..."); # {{{
2155 testcmd("../gpst -y -o clean pause.gpx", # {{{
2156 <<END,
2157 5.299534\t120.850988\t25.26
2158 5.29961\t120.850928\t24.931
2159 5.299694\t120.850628\t27.975
2160 5.299741\t120.850768\t31.017
2161 5.299958\t120.850678\t30.98
2162 5.29964\t120.850476\t30.538
2163 5.299686\t120.850492\t30.515
2164 5.299773\t120.85069\t31.936
2165 5.299419\t120.850914\t31.794
2168 "Double y scale, clean output from gpx format",
2172 # }}}
2173 testcmd("../gpst -y -o clean log.dos.mayko", # {{{
2174 <<END,
2175 8.1225077\t116.3636316\t
2176 8.12532\t116.3637424\t
2177 8.1266031\t116.3632694\t
2178 8.1284612\t116.3624198\t
2179 8.129395\t116.362063\t
2180 8.13074\t116.3619242\t
2183 "Double y scale, clean output from mayko format",
2187 # }}}
2188 # --double-y-scale option }}}
2189 diag("Testing --debug option..."); # {{{
2190 # --debug option }}}
2191 diag("Strip error from Mayko format..."); # {{{
2193 testcmd("../gpst -o csv date_error.mayko", # {{{
2194 <<END,
2195 2003-06-13T09:12:36Z\t5.5794667\t60.4280897\t\t
2196 2003-06-13T09:12:38Z\t5.5802255\t60.4281867\t\t
2197 2003-06-13T09:12:41Z\t5.5813636\t60.428332\t\t
2198 2003-06-13T09:12:42Z\t5.581743\t60.4283806\t\t
2201 "Strip error from mayko format in csv output",
2205 # }}}
2206 testcmd("../gpst -o clean date_error.mayko", # {{{
2207 <<END,
2208 5.5794667\t60.4280897\t
2209 5.5802255\t60.4281867\t
2210 5.5813636\t60.428332\t
2211 5.581743\t60.4283806\t
2214 "Strip error from mayko format in clean output",
2218 # }}}
2219 testcmd("../gpst -o gpsml date_error.mayko", # {{{
2220 <<END,
2221 <?xml version="1.0" encoding="UTF-8"?>
2222 <gpsml>
2223 <track>
2224 <tp> <time>2003-06-13T09:12:36Z</time> <lat>60.4280897</lat> <lon>5.5794667</lon> </tp>
2225 <tp> <time>2003-06-13T09:12:38Z</time> <lat>60.4281867</lat> <lon>5.5802255</lon> </tp>
2226 <etp err="error"> <time>2037-06-25T17:19:22Z</time> <lat>103.4034054</lat> <lon>129.7271053</lon> </etp>
2227 <tp> <time>2003-06-13T09:12:41Z</time> <lat>60.428332</lat> <lon>5.5813636</lon> </tp>
2228 <tp> <time>2003-06-13T09:12:42Z</time> <lat>60.4283806</lat> <lon>5.581743</lon> </tp>
2229 </track>
2230 </gpsml>
2233 "Strip error from mayko format in gpsml output",
2237 # }}}
2238 testcmd("../gpst -o gpx date_error.mayko", # {{{
2239 <<END,
2240 $gpx_header
2241 <trk>
2242 <trkseg>
2243 <trkpt lat="60.4280897" lon="5.5794667"> <time>2003-06-13T09:12:36Z</time> </trkpt>
2244 <trkpt lat="60.4281867" lon="5.5802255"> <time>2003-06-13T09:12:38Z</time> </trkpt>
2245 <!-- <trkpt lat="103.4034054" lon="129.7271053"> <time>2037-06-25T17:19:22Z</time> <extensions> <error>error</error> </extensions> </trkpt> -->
2246 <trkpt lat="60.428332" lon="5.5813636"> <time>2003-06-13T09:12:41Z</time> </trkpt>
2247 <trkpt lat="60.4283806" lon="5.581743"> <time>2003-06-13T09:12:42Z</time> </trkpt>
2248 </trkseg>
2249 </trk>
2250 </gpx>
2253 "Strip error from mayko format in gpx output",
2257 # }}}
2258 testcmd("../gpst -o gpstrans date_error.mayko", # {{{
2259 <<END,
2260 Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84
2261 T\t06/13/2003 09:12:36\t60\xB025'41.1"\t5\xB034'46.1"
2262 T\t06/13/2003 09:12:38\t60\xB025'41.5"\t5\xB034'48.8"
2263 T\t06/13/2003 09:12:41\t60\xB025'42.0"\t5\xB034'52.9"
2264 T\t06/13/2003 09:12:42\t60\xB025'42.2"\t5\xB034'54.3"
2267 "Strip error from mayko format in gpstrans output",
2271 # }}}
2272 testcmd("../gpst -o pgtab date_error.mayko", # {{{
2273 <<END,
2274 2003-06-13T09:12:36Z\t(60.4280897,5.5794667)\t\\N\t\\N\t\\N\t\\N
2275 2003-06-13T09:12:38Z\t(60.4281867,5.5802255)\t\\N\t\\N\t\\N\t\\N
2276 2003-06-13T09:12:41Z\t(60.428332,5.5813636)\t\\N\t\\N\t\\N\t\\N
2277 2003-06-13T09:12:42Z\t(60.4283806,5.581743)\t\\N\t\\N\t\\N\t\\N
2280 "Strip error from mayko format in pgtab output",
2284 # }}}
2285 testcmd("../gpst -o poscount date_error.mayko", # {{{
2286 <<END,
2287 5.5802255\t60.4281867\t1
2288 5.581743\t60.4283806\t1
2289 5.5794667\t60.4280897\t1
2290 5.5813636\t60.428332\t1
2293 "Strip error from mayko format in poscount output",
2297 # }}}
2298 testcmd("../gpst -o xgraph date_error.mayko", # {{{
2299 <<END,
2300 5.5794667 60.4280897
2301 5.5802255 60.4281867
2302 5.5813636 60.428332
2303 5.581743 60.4283806
2306 "Strip error from mayko format in xgraph output",
2310 # }}}
2311 testcmd("../gpst -o ygraph date_error.mayko", # {{{
2312 <<END,
2313 "Time = 0.0
2314 5.5794667 60.4280897
2316 "Time = 2.0
2317 5.5802255 60.4281867
2319 "Time = 5.0
2320 5.5813636 60.428332
2322 "Time = 6.0
2323 5.581743 60.4283806
2327 "Strip error from mayko format in ygraph output",
2331 # }}}
2333 # Strip error from Mayko format }}}
2335 todo_section:
2338 if ($Opt{'all'} || $Opt{'todo'}) {
2339 diag("Running TODO tests..."); # {{{
2341 TODO: {
2342 local $TODO = "Fix read/write of GPX name element";
2343 testcmd("../gpst -o gpx pause.gpx", # {{{
2344 <<END,
2345 $gpx_header
2346 <trk>
2347 <name>ACTIVE LOG164705</name>
2348 <trkseg>
2349 <trkpt lat="60.425494" lon="5.299534"> <ele>25.26</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
2350 <trkpt lat="60.425464" lon="5.29961"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
2351 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
2352 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
2353 <trkpt lat="60.425339" lon="5.299958"> <ele>30.98</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
2354 <trkpt lat="60.425238" lon="5.29964"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
2355 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
2356 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
2357 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
2358 </trkseg>
2359 </trk>
2360 </gpx>
2363 "Read and write name element from/to GPX",
2367 # }}}
2368 local $TODO = "Remove extra \\n in the beginning";
2369 testcmd("../gpst -o csv multitrack.gpx", # {{{
2370 <<END,
2371 2003-02-11T23:35:39Z\t-0.1448824\t51.4968266\t\t
2372 2003-02-11T23:35:49Z\t-0.1449938\t51.4968227\t\t
2373 2003-02-11T23:36:14Z\t-0.1453202\t51.496904\t\t
2374 \t\t\t\t
2375 2003-02-11T23:36:16Z\t-0.1453398\t51.4969214\t\t
2376 2003-02-11T23:36:31Z\t-0.1455514\t51.4969816\t\t
2377 2003-02-11T23:36:43Z\t-0.1457489\t51.4970224\t1000\t
2378 2003-02-11T23:36:50Z\t-0.1457804\t51.4970452\t\t
2379 \t\t\t\t
2380 2003-02-11T23:37:05Z\t-0.1458608\t51.497068\t\t
2381 2003-02-11T23:37:22Z\t-0.1460047\t51.4971658\t\t
2382 2003-02-11T23:37:36Z\t-0.1461614\t51.4972469\t\t
2383 \t\t\t\t
2384 2003-02-11T23:37:43Z\t-0.1462394\t51.4972731\t\t
2385 2003-02-11T23:38:04Z\t-0.1463232\t51.4973437\t\t
2386 2003-02-11T23:38:28Z\t-0.1462949\t51.4973337\t\t
2387 2003-02-11T23:38:34Z\t-0.1462825\t51.4973218\t\t
2388 2003-02-11T23:38:35Z\t-0.1462732\t51.4973145\t\t
2391 "Output csv format from multitrack.gpx",
2395 # }}}
2396 testcmd("../gpst -o csv pause.gpx", # {{{
2397 <<END,
2398 2006-05-21T16:49:11Z\t5.299534\t60.425494\t25.26\t
2399 2006-05-21T16:49:46Z\t5.29961\t60.425464\t24.931\t
2400 2006-05-21T16:52:04Z\t5.299694\t60.425314\t27.975\t
2401 2006-05-21T16:56:36Z\t5.299741\t60.425384\t31.017\t
2402 2006-05-21T16:56:47Z\t5.299958\t60.425339\t30.98\t
2403 2006-05-21T16:56:56Z\t5.29964\t60.425238\t30.538\t
2404 2006-05-21T16:57:03Z\t5.299686\t60.425246\t30.515\t
2405 2006-05-21T16:59:08Z\t5.299773\t60.425345\t31.936\t
2406 2006-05-21T17:00:54Z\t5.299419\t60.425457\t31.794\t
2409 "Output csv format from pause.gpx",
2413 # }}}
2414 testcmd("../gpst -e -o csv pause.gpx", # {{{
2415 <<END,
2416 1148230151\t5.299534\t60.425494\t25.26\t
2417 1148230186\t5.29961\t60.425464\t24.931\t
2418 1148230324\t5.299694\t60.425314\t27.975\t
2419 1148230596\t5.299741\t60.425384\t31.017\t
2420 1148230607\t5.299958\t60.425339\t30.98\t
2421 1148230616\t5.29964\t60.425238\t30.538\t
2422 1148230623\t5.299686\t60.425246\t30.515\t
2423 1148230748\t5.299773\t60.425345\t31.936\t
2424 1148230854\t5.299419\t60.425457\t31.794\t
2427 "csv format with epoch seconds from gpx",
2431 # }}}
2432 $TODO = "Tweak output";
2433 testcmd("../gpst -o gpx multitrack-pause.gpsml", # {{{
2434 file_data("multitrack-pause.gpx"),
2436 "Should be equal to multitrack-pause.gpx",
2440 # }}}
2442 # TODO tests }}}
2445 diag("Testing finished.");
2447 sub testcmd {
2448 # {{{
2449 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc, $is_gpx) = @_;
2450 my $stderr_cmd = "";
2451 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2452 my $Txt = join("",
2453 "\"$Cmd\"",
2454 defined($Desc)
2455 ? " - $Desc"
2456 : ""
2458 my $TMP_STDERR = "gpst-stderr.tmp";
2459 my $TMP_STDOUT = "gpst-stdout.tmp";
2460 defined($is_gpx) || die("$progname: testcmd(): $Desc: \$is_gpx not defined\n");
2462 if (defined($Exp_stderr) && !length($deb_str)) {
2463 $stderr_cmd = " 2>$TMP_STDERR";
2465 system("$Cmd$deb_str$stderr_cmd >$TMP_STDOUT");
2466 is(file_data($TMP_STDOUT), $Exp_stdout, $Txt);
2467 if ($is_gpx) {
2468 validate_gpx($TMP_STDOUT, $Desc);
2470 if (defined($Exp_stderr)) {
2471 if (!length($deb_str)) {
2472 is(file_data($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
2473 unlink($TMP_STDERR);
2475 } else {
2476 diag("Warning: stderr not defined for '$Txt'");
2478 unlink($TMP_STDOUT);
2479 # }}}
2480 } # testcmd()
2482 sub likecmd {
2483 # {{{
2484 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
2485 my $stderr_cmd = "";
2486 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2487 my $Txt = join("",
2488 "\"$Cmd\"",
2489 defined($Desc)
2490 ? " - $Desc"
2491 : ""
2493 my $TMP_STDERR = "gpst-stderr.tmp";
2495 if (defined($Exp_stderr) && !length($deb_str)) {
2496 $stderr_cmd = " 2>$TMP_STDERR";
2498 like(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
2499 if (defined($Exp_stderr)) {
2500 if (!length($deb_str)) {
2501 like(file_data($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
2502 unlink($TMP_STDERR);
2504 } else {
2505 diag("Warning: stderr not defined for '$Txt'");
2507 # }}}
2508 } # likecmd()
2510 sub file_data {
2511 # Return file content as a string {{{
2512 my $File = shift;
2513 my $Txt;
2514 if (open(my $fp, "<", $File)) {
2515 $Txt = join("", <$fp>);
2516 close($fp);
2517 return($Txt);
2518 } else {
2519 return;
2521 # }}}
2522 } # file_data()
2524 sub validate_gpx {
2525 # Check that a file is valid GPX {{{
2526 my ($File, $Txt) = @_;
2527 my $TMP_VALID = "validate_result.tmp";
2528 my $Result = system("xmllint --noout --schema ../Tools/xsd/gpx/gpx-1.1.xsd $File 2>$TMP_VALID");
2529 is($Result, 0, "GPX for \"$Txt\" validates");
2530 if ($Result) {
2531 diag(file_data($TMP_VALID));
2533 unlink($TMP_VALID);
2534 # }}}
2535 } # validate_gpx()
2537 sub print_version {
2538 # Print program version {{{
2539 print("$progname v$VERSION\n");
2540 # }}}
2541 } # print_version()
2543 sub usage {
2544 # Send the help message to stdout {{{
2545 my $Retval = shift;
2547 if ($Opt{'verbose'}) {
2548 print("\n");
2549 print_version();
2551 print(<<END);
2553 Usage: $progname [options] [file [files [...]]]
2555 Contains tests for the gpst(1) program.
2557 Options:
2559 -a, --all
2560 Run all tests, also TODOs.
2561 -h, --help
2562 Show this help.
2563 -t, --todo
2564 Run only the TODO tests.
2565 -v, --verbose
2566 Increase level of verbosity. Can be repeated.
2567 --version
2568 Print version information.
2569 --debug
2570 Print debugging messages.
2573 exit($Retval);
2574 # }}}
2575 } # usage()
2577 sub msg {
2578 # Print a status message to stderr based on verbosity level {{{
2579 my ($verbose_level, $Txt) = @_;
2581 if ($Opt{'verbose'} >= $verbose_level) {
2582 print(STDERR "$progname: $Txt\n");
2584 # }}}
2585 } # msg()
2587 __END__
2589 # Plain Old Documentation (POD) {{{
2591 =pod
2593 =head1 NAME
2595 run-tests.pl
2597 =head1 SYNOPSIS
2599 run-tests.pl [options] [file [files [...]]]
2601 =head1 DESCRIPTION
2603 Contains tests for the gpst(1) program.
2605 =head1 OPTIONS
2607 =over 4
2609 =item B<-a>, B<--all>
2611 Run all tests, also TODOs.
2613 =item B<-h>, B<--help>
2615 Print a brief help summary.
2617 =item B<-t>, B<--todo>
2619 Run only the TODO tests.
2621 =item B<-v>, B<--verbose>
2623 Increase level of verbosity. Can be repeated.
2625 =item B<--version>
2627 Print version information.
2629 =item B<--debug>
2631 Print debugging messages.
2633 =back
2635 =head1 AUTHOR
2637 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
2639 =head1 COPYRIGHT
2641 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
2642 This is free software; see the file F<COPYING> for legalese stuff.
2644 =head1 LICENCE
2646 This program is free software: you can redistribute it and/or modify it
2647 under the terms of the GNU General Public License as published by the
2648 Free Software Foundation, either version 3 of the License, or (at your
2649 option) any later version.
2651 This program is distributed in the hope that it will be useful, but
2652 WITHOUT ANY WARRANTY; without even the implied warranty of
2653 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2654 See the GNU General Public License for more details.
2656 You should have received a copy of the GNU General Public License along
2657 with this program.
2658 If not, see L<http://www.gnu.org/licenses/>.
2660 =head1 SEE ALSO
2662 gpst(1)
2664 =cut
2666 # }}}
2668 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :