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