Deleting Patch/xgraph-fix_plus_more.patch, have put it on its own branch
[gpstools.git] / branches / gpst.gpsman-format / tests / run-tests.pl
blob3c9edcfcb15eb91a0ceeaf7f969206bd96128cf5
1 #!/usr/bin/perl -w
3 #=======================================================================
4 # $Id$
5 # Test suite for gpst.
7 # Character set: UTF-8
8 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
9 # License: GNU General Public License version 2 or later, see end of
10 # file for legal stuff.
11 #=======================================================================
13 BEGIN {
14 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
15 our @version_array;
18 use strict;
19 use Getopt::Long;
20 use Test::More qw{no_plan};
22 use GPST;
23 use GPSTdate;
24 use GPSTdebug;
25 use GPSTgeo;
26 use GPSTxml;
28 $| = 1;
30 our $Debug = 0;
32 our %Opt = (
33 'all' => 0,
34 'debug' => 0,
35 'help' => 0,
36 'todo' => 0,
37 'verbose' => 0,
38 'version' => 0,
41 our $progname = $0;
42 $progname =~ s/^.*\/(.*?)$/$1/;
44 my $rcs_id = '$Id$';
45 my $id_date = $rcs_id;
46 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
48 push(@main::version_array, $rcs_id);
50 Getopt::Long::Configure("bundling");
51 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'},
58 ) || die("$progname: Option error. Use -h for help.\n");
60 our %Cmd = (
61 'gpsbabel' => '/usr/local/bin/gpsbabel',
64 $Opt{'debug'} && ($Debug = 1);
65 $Opt{'help'} && usage(0);
66 $Opt{'version'} && print_version();
68 chomp(my $gpx_header = <<END);
69 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
70 <gpx
71 version="1.1"
72 creator="gpst - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/"
73 xmlns="http://www.topografix.com/GPX/1/1"
74 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
75 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
77 END
78 my $stripped_gpx_header = $gpx_header;
79 $stripped_gpx_header =~ s/^\s*(.*)$/$1/mg;
81 if ($Opt{'todo'} && !$Opt{'all'}) {
82 goto todo_section;
85 diag("Testing conversion routines...");
87 # txt_to_xml() and xml_to_txt() {{{
89 is(txt_to_xml("abc"),
90 "abc",
91 "txt_to_xml(\"abc\")");
92 is(txt_to_xml("<&>"),
93 "&lt;&amp;&gt;",
94 "txt_to_xml(\"<&>\")");
95 is(txt_to_xml("first line\nsecond <\rthird\r\n<&>"),
96 "first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;",
97 "txt_to_xml() with multiline string");
99 is(xml_to_txt("abc"),
100 "abc",
101 "xml_to_txt(\"abc\")");
102 is(xml_to_txt("&lt;&amp;&gt;"),
103 "<&>",
104 "xml_to_txt(\"&lt;&amp;&gt;\")");
105 is(xml_to_txt("first line\nsecond &lt;\rthird\r\n&lt;&amp;&gt;"),
106 "first line\nsecond <\rthird\r\n<&>",
107 "xml_to_txt() with multiline string");
109 # txt_to_xml() and xml_to_txt() }}}
110 # postgresql_copy_safe() {{{
112 is(postgresql_copy_safe(""),
114 "postgresql_copy_safe() with empty string");
116 is(postgresql_copy_safe("abcæøåÆØÅ"),
117 "abcæøåÆØÅ",
118 "postgresql_copy_safe(\"abcæøåÆØÅ\")");
120 is(postgresql_copy_safe("abc\t'\r\n"),
121 "abc\\t'\\r\\n",
122 "postgresql_copy_safe(\"abc\\t'\\r\\n\")");
124 is(postgresql_copy_safe("¤%/&gurgle\t325\\wer\ndfv'\r!\"#\n%\twe\r\x00sdf\xFFsadc\n\t\x00sdc\n"),
125 "¤%/&gurgle\\t325\\\\wer\\ndfv'\\r!\"#\\n%\\twe\\r\x00sdf\xFFsadc\\n\\t\x00sdc\\n",
126 "postgresql_copy_safe() with multiline, nulls and stuff");
128 # postgresql_copy_safe() }}}
130 diag("Testing date routines...");
132 # sec_to_string() {{{
134 is(sec_to_string(1148220825),
135 "2006-05-21 14:13:45",
136 "sec_to_string() without separator");
137 is(sec_to_string(1148220825, "T"),
138 "2006-05-21T14:13:45",
139 "sec_to_string() with separator");
140 is(sec_to_string(-5000),
141 undef,
142 "sec_to_string(-5000) — negative numbers unsupported atm");
143 is(sec_to_string(""),
144 undef,
145 "sec_to_string(\"\")");
146 is(sec_to_string("pH()rtY tW0"),
147 undef,
148 "sec_to_string() with invalid string");
149 is(sec_to_string("00000000000000000000001148220825"),
150 "2006-05-21 14:13:45",
151 "sec_to_string() with a bunch of leading zeros");
152 is(sec_to_string("1148220825.93"),
153 "2006-05-21 14:13:45.93",
154 "sec_to_string() with decimals");
155 is(sec_to_string("000000000000000000000000000001148220825.7312"),
156 "2006-05-21 14:13:45.7312",
157 "sec_to_string() with decimals and prefixing zeros");
158 is(sec_to_string("1148220825.93000"),
159 "2006-05-21 14:13:45.93",
160 "sec_to_string() with decimals and extra trailing zeros");
161 is(sec_to_string(".863"),
162 "1970-01-01 00:00:00.863",
163 "sec_to_string() with missing zero before decimal point");
165 # sec_to_string() }}}
166 # sec_to_readable() {{{
168 is(sec_to_readable(0),
169 "0:00:00:00",
170 "sec_to_readable(0)");
171 is(sec_to_readable("pH()rtY tW0"),
172 undef,
173 "sec_to_readable() with invalid string");
174 is(sec_to_readable(86400),
175 "1:00:00:00",
176 "sec_to_readable(86400)");
177 is(sec_to_readable(86400*1000),
178 "1000:00:00:00",
179 "sec_to_readable(86400*1000)");
180 is(sec_to_readable(86400+7200+180+4),
181 "1:02:03:04",
182 "sec_to_readable(86400+7200+180+4)");
183 is(sec_to_readable("3.14"),
184 "0:00:00:03.14",
185 "sec_to_readable(\"3.14\")");
186 is(sec_to_readable("-124"),
187 undef,
188 "sec_to_readable() rejects negative numbers");
189 is(sec_to_readable("-2.34"),
190 undef,
191 "sec_to_readable() rejects negative decimal");
192 is(sec_to_readable(".87"),
193 "0:00:00:00.87",
194 "sec_to_readable(), missing zero before decimal point");
195 is(sec_to_readable(""),
196 "0:00:00:00",
197 "sec_to_readable() with empty string");
199 # sec_to_readable() }}}
201 diag("Testing geo routines...");
203 # ddd_to_dms() {{{
205 is(ddd_to_dms("12.34567"),
206 "12\xB020'44.4\"",
207 "ddd_to_dms(\"12.34567\")");
209 is(ddd_to_dms("0"),
210 "0\xB000'00.0\"",
211 "ddd_to_dms(\"0\")");
213 is(ddd_to_dms("0.00001"),
214 "0\xB000'00.0\"",
215 "ddd_to_dms(\"0.00001\") — Precision of DDD with five decimals");
217 is(ddd_to_dms(""),
218 "0\xB000'00.0\"",
219 "ddd_to_dms(\"\")");
221 is(ddd_to_dms("pH()rtY tW0"),
222 undef,
223 "ddd_to_dms(\"pH()rtY tW0\")");
225 is(ddd_to_dms("-12.34567"),
226 "-12\xB020'44.4\"",
227 "ddd_to_dms(\"-12.34567\")");
229 is(ddd_to_dms("0.34567"),
230 "0\xB020'44.4\"",
231 "ddd_to_dms(\"0.34567\")");
233 is(ddd_to_dms(".34567"),
234 "0\xB020'44.4\"",
235 "ddd_to_dms(\".34567\")");
237 is(ddd_to_dms("-.34567"),
238 "-0\xB020'44.4\"",
239 "ddd_to_dms(\"-.34567\")");
241 is(ddd_to_dms("-0.34567"),
242 "-0\xB020'44.4\"",
243 "ddd_to_dms(\"-0.34567\")");
245 is(ddd_to_dms("180"),
246 "180\xB000'00.0\"",
247 "ddd_to_dms(\"180\")");
249 is(ddd_to_dms("-180"),
250 "-180\xB000'00.0\"",
251 "ddd_to_dms(\"-180\")");
253 is(ddd_to_dms("-1"),
254 "-1\xB000'00.0\"",
255 "ddd_to_dms(\"-1\")");
257 is(ddd_to_dms("2-3"),
258 undef,
259 "ddd_to_dms(\"2-3\")");
261 # ddd_to_dms() }}}
262 # dms_to_ddd() {{{
263 is(dms_to_ddd(),
265 "dms_to_ddd() with no parameters");
266 is(dms_to_ddd(0, 0, 0),
268 "dms_to_ddd(0, 0, 0)");
269 is(dms_to_ddd(12, 30, 45),
270 12.5125,
271 "dms_to_ddd(12, 30, 45)");
272 is(dms_to_ddd("asd", 0, 0),
273 undef,
274 "dms_to_ddd() with invalid degrees");
275 is(dms_to_ddd(0, "asd", 0),
276 undef,
277 "dms_to_ddd() with invalid minutes");
278 is(dms_to_ddd(0, 0, "asd"),
279 undef,
280 "dms_to_ddd() with invalid seconds");
281 is(dms_to_ddd("", 0, 0),
283 "dms_to_ddd() with empty degree string");
284 is(dms_to_ddd(0, 0, ""),
286 "dms_to_ddd() with empty second string");
287 is(dms_to_ddd(-12, 30, 45),
288 undef,
289 "dms_to_ddd() doesn’t accept negative degrees atm");
290 is(dms_to_ddd(12, -30, 45),
291 undef,
292 "dms_to_ddd() doesn’t accept negative minutes atm");
293 is(dms_to_ddd(12, 30, -45),
294 undef,
295 "dms_to_ddd() doesn’t accept negative seconds atm");
296 # Weird behaviour, this scientific notation thing.
297 is(num_expand(sprintf("%.08f", dms_to_ddd(0, 0, 0.1))),
298 "0.00002778",
299 "dms_to_ddd(0, 0, 0.1) — Precision of DMS with one decimal");
300 is(dms_to_ddd(2, 30),
301 2.5,
302 "dms_to_ddd(2, 30)");
303 is(dms_to_ddd(4),
305 "dms_to_ddd(4)");
306 is(dms_to_ddd(4.3),
307 4.3,
308 "dms_to_ddd(4.3)");
309 is(dms_to_ddd(120.5, 0.3),
310 120.505,
311 "dms_to_ddd(120.5, 0.3)");
313 # dms_to_ddd() }}}
315 diag("Testing trackpoint()..."); # {{{
317 my %Dat = ();
319 is(trackpoint(%Dat),
320 undef,
321 "trackpoint() receives empty hash");
323 my %Bck = (
324 # {{{
325 'format' => 'gpsml',
326 'year' => '2003',
327 'month' => '06',
328 'day' => '13',
329 'hour' => '14',
330 'min' => '36',
331 'sec' => '10',
332 'lat' => '59.5214',
333 'lon' => '7.392133',
334 'ele' => '762',
335 'error' => "",
336 'type' => 'tp',
337 # }}}
340 # trackpoint() (gpsml) {{{
341 %Dat = %Bck;
343 trackpoint(%Dat),
344 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
345 "trackpoint() (gpsml)"
348 # trackpoint() (gpsml) }}}
349 # trackpoint() (gpx) {{{
350 %Dat = %Bck;
351 $Dat{'format'} = "gpx";
353 trackpoint(%Dat),
354 qq{ <trkpt lat="59.5214" lon="7.392133"> <ele>762</ele> <time>2003-06-13T14:36:10Z</time> </trkpt>\n},
355 "trackpoint() (gpx)"
358 # trackpoint() (gpx) }}}
360 # trackpoint(): Various loop tests {{{
362 for my $Elem (qw{format lat lon type}) {
363 my %Dat = %Bck;
365 $Dat{"$Elem"} = '2d';
366 is(trackpoint(%Dat),
367 undef,
368 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") returns undef"
373 for my $Elem (qw{year month day hour min sec}) {
374 # Date tests {{{
375 my %Dat;
377 %Dat = %Bck;
378 $Dat{"$Elem"} = '';
379 is(trackpoint(%Dat),
380 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
381 "trackpoint(): {'$Elem'} with empty value skips time"
384 %Dat = %Bck;
385 $Dat{"$Elem"} = '2d';
386 is(trackpoint(%Dat),
387 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
388 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") skips time"
391 %Dat = %Bck;
392 $Dat{$Elem} = "00000$Dat{$Elem}";
393 is(trackpoint(%Dat),
394 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
395 "trackpoint(): Strip prefixing zeros from {'$Elem'}"
398 %Dat = %Bck;
399 $Dat{"$Elem"} = 0-$Dat{$Elem};
400 is(trackpoint(%Dat),
401 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
402 "trackpoint(): {'$Elem'} is negative, skip time"
405 if ($Elem ne "sec") {
406 %Dat = %Bck;
407 $Dat{"$Elem"} = "$Dat{$Elem}.00";
408 is(trackpoint(%Dat),
409 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
410 "trackpoint(): Decimals in {'$Elem'}, skip time"
414 # Date tests }}}
417 %Dat = %Bck;
418 $Dat{'sec'} = "$Dat{'sec'}.00";
419 is(trackpoint(%Dat),
420 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
421 "trackpoint(): Remove trailing zeros in {'sec'} decimals"
424 for my $Elem (qw{format type error}) {
425 my %Dat = %Bck;
426 $Dat{$Elem} = undef;
427 is(trackpoint(%Dat),
428 undef,
429 "trackpoint(): Missing {'$Elem'}, return undef"
433 # Various loop tests }}}
435 # trackpoint() }}}
437 diag("Testing output from ../gpst");
439 diag("Read empty input (/dev/null)..."); # {{{
440 testcmd("../gpst </dev/null", # {{{
441 <<END,
442 <?xml version="1.0" encoding="UTF-8"?>
443 <gpsml>
444 <track>
445 </track>
446 </gpsml>
449 "Read from /dev/null",
452 # }}}
453 testcmd("../gpst -o gpx </dev/null", # {{{
454 <<END,
455 $gpx_header
456 <trk>
457 <trkseg>
458 </trkseg>
459 </trk>
460 </gpx>
463 "Output gpx from /dev/null",
466 # }}}
467 # empty input }}}
468 diag("Read empty files..."); # {{{
469 testcmd("echo '<tp> </tp>' | ../gpst", # {{{
470 <<END,
471 <?xml version="1.0" encoding="UTF-8"?>
472 <gpsml>
473 <track>
474 </track>
475 </gpsml>
478 "Don’t print empty trackpoints",
481 # }}}
482 # Read empty files }}}
483 diag("Testing --chronology option..."); # {{{
484 testcmd("../gpst --chronology chronology-error.gpsml", # {{{
485 <<END,
486 <?xml version="1.0" encoding="UTF-8"?>
487 <gpsml>
488 <track>
489 <title>Chronology errors</title>
490 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
491 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
492 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
493 <break/>
494 <tp> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </tp>
495 <break/>
496 <pause>0:00:37:54</pause>
497 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
498 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
499 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
500 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
501 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
502 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
503 </track>
504 </gpsml>
506 "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" .
507 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
508 "Check for chronology errors and duplicated times",
511 # }}}
512 # --chronology option }}}
513 diag("Testing --skip-dups option..."); # {{{
514 testcmd("../gpst -d no_signal.mayko", # {{{
515 <<END,
516 <?xml version="1.0" encoding="UTF-8"?>
517 <gpsml>
518 <track>
519 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
520 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
521 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
522 <etp err="dup"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
523 <etp err="dup"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
524 <etp err="dup"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
525 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
526 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
527 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
528 </track>
529 </gpsml>
532 "Remove duplicated positions from gpsml",
535 # }}}
536 testcmd("../gpst -d -o csv no_signal.mayko", # {{{
537 <<END,
538 2002-12-22T21:42:24Z\t23.6746151\t70.6800486\t\t
539 2002-12-22T21:42:32Z\t23.6740038\t70.6799322\t\t
540 2002-12-22T21:42:54Z\t23.6723991\t70.6796266\t\t
541 2002-12-22T21:44:45Z\t23.6757566\t70.6800774\t\t
542 2002-12-22T21:44:52Z\t23.6753442\t70.6801502\t\t
543 2002-12-22T21:45:04Z\t23.6757542\t70.6801905\t\t
546 "Remove duplicated positions from csv output format",
549 # }}}
550 testcmd("../gpst -d -o clean no_signal.mayko", # {{{
551 <<END,
552 23.6746151\t70.6800486\t
553 23.6740038\t70.6799322\t
554 23.6723991\t70.6796266\t
555 23.6757566\t70.6800774\t
556 23.6753442\t70.6801502\t
557 23.6757542\t70.6801905\t
560 "Remove duplicated positions from clean output format",
563 # }}}
564 testcmd("../gpst -d -o pgtab no_signal.mayko", # {{{
565 <<END,
566 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N\t\\N
567 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N\t\\N
568 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
569 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N\t\\N
570 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N\t\\N
571 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N\t\\N
574 "Remove duplicated positions from pgtab output format",
577 # }}}
578 # --skip-dups option }}}
579 diag("Testing --epoch option..."); # {{{
580 testcmd("../gpst -e pause.gpx", # {{{
581 <<END,
582 <?xml version="1.0" encoding="UTF-8"?>
583 <gpsml>
584 <track>
585 <title>ACTIVE LOG164705</title>
586 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
587 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
588 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
589 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
590 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
591 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
592 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
593 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
594 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
595 </track>
596 </gpsml>
599 "--epoch is ignored in gpsml output",
602 # }}}
603 testcmd("../gpst -e -o gpx pause.gpx", # {{{
604 <<END,
605 $gpx_header
606 <trk>
607 <trkseg>
608 <trkpt lat="60.425494" lon="5.299534"> <ele>25.260</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
609 <trkpt lat="60.425464" lon="5.299610"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
610 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
611 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
612 <trkpt lat="60.425339" lon="5.299958"> <ele>30.980</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
613 <trkpt lat="60.425238" lon="5.299640"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
614 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
615 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
616 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
617 </trkseg>
618 </trk>
619 </gpx>
622 "--epoch is ignored in gpx output",
625 # }}}
626 # --epoch option }}}
627 diag("Testing --fix option..."); # {{{
628 testcmd("../gpst --fix --chronology chronology-error.gpsml", # {{{
629 <<END,
630 <?xml version="1.0" encoding="UTF-8"?>
631 <gpsml>
632 <track>
633 <title>Chronology errors</title>
634 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
635 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
636 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
637 <break/>
638 <etp err="chrono"> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </etp>
639 <break/>
640 <pause>0:00:37:54</pause>
641 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
642 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
643 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
644 <etp err="duptime"> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </etp>
645 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
646 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
647 </track>
648 </gpsml>
650 "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" .
651 "gpst: chronology-error.gpsml: \"2006-05-02T10:18:09Z\": Duplicated time\n",
652 "Remove bad timestamps",
655 # }}}
656 # --fix option }}}
657 diag("Testing --from-date option..."); # {{{
658 # --from-date option }}}
659 diag("Testing --help option..."); # {{{
660 like(`../gpst -h`, # {{{
661 '/Converts between various GPS formats\./',
662 "Check -h (--help) option"
664 # }}}
665 # --help option }}}
666 diag("Testing --inside option..."); # {{{
667 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --inside multitrack-pause.gpx", # {{{
668 <<END,
669 <?xml version="1.0" encoding="UTF-8"?>
670 <gpsml>
671 <track>
672 <title>track1</title>
673 <break/>
674 <title>track2</title>
675 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
676 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
677 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
678 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
679 <break/>
680 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
681 <break/>
682 <title>track3</title>
683 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
684 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
685 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
686 </track>
687 </gpsml>
690 "Check --inside option (gpx to gpst)",
692 # }}}
694 # --inside option }}}
695 diag("Testing --undefined option..."); # {{{
696 # --undefined option }}}
697 diag("Testing --near option..."); # {{{
698 # --near option }}}
699 diag("Testing --output option..."); # {{{
700 # gpsml (Default)
701 testcmd("../gpst log.mcsv", # {{{
702 <<END,
703 <?xml version="1.0" encoding="UTF-8"?>
704 <gpsml>
705 <track>
706 <break/>
707 <title>ACTIVE LOG 125</title>
708 <tp> <time>2006-03-04T11:12:30Z</time> <lat>54.96883</lat> <lon>-1.62439</lon> <ele>77</ele> </tp>
709 <tp> <time>2006-03-04T11:12:47Z</time> <lat>54.96878</lat> <lon>-1.62413</lon> <ele>77</ele> </tp>
710 <tp> <time>2006-03-04T11:12:55Z</time> <lat>54.96913</lat> <lon>-1.62616</lon> <ele>77</ele> </tp>
711 <tp> <time>2006-03-04T11:13:04Z</time> <lat>54.96934</lat> <lon>-1.62624</lon> <ele>77.5</ele> </tp>
712 <tp> <time>2006-03-04T11:13:33Z</time> <lat>54.96934</lat> <lon>-1.62596</lon> <ele>78</ele> </tp>
713 <tp> <time>2006-03-04T11:13:48Z</time> <lat>54.96931</lat> <lon>-1.62645</lon> <ele>78</ele> </tp>
714 <tp> <time>2006-03-04T11:14:05Z</time> <lat>54.96918</lat> <lon>-1.62603</lon> <ele>79</ele> </tp>
715 <tp> <time>2006-03-04T11:14:33Z</time> <lat>54.96901</lat> <lon>-1.62364</lon> <ele>76.1</ele> </tp>
716 <tp> <time>2006-03-04T11:15:02Z</time> <lat>54.96922</lat> <lon>-1.6254</lon> <ele>76.1</ele> </tp>
717 <tp> <time>2006-03-04T11:15:27Z</time> <lat>54.96914</lat> <lon>-1.62526</lon> <ele>75.1</ele> </tp>
718 <tp> <time>2006-03-04T11:15:50Z</time> <lat>54.96911</lat> <lon>-1.62494</lon> <ele>75.1</ele> </tp>
719 <tp> <time>2006-03-04T11:16:03Z</time> <lat>54.9693</lat> <lon>-1.62489</lon> <ele>75.1</ele> </tp>
720 <tp> <time>2006-03-04T11:16:19Z</time> <lat>54.96901</lat> <lon>-1.62496</lon> <ele>75.1</ele> </tp>
721 <tp> <time>2006-03-04T11:16:52Z</time> <lat>54.96871</lat> <lon>-1.62466</lon> <ele>74.6</ele> </tp>
722 <tp> <time>2006-03-04T11:17:25Z</time> <lat>54.96908</lat> <lon>-1.62488</lon> <ele>72.7</ele> </tp>
723 <break/>
724 <title>ACTIVE LOG 126</title>
725 <tp> <time>2006-03-04T11:18:32Z</time> <lat>54.96904</lat> <lon>-1.62482</lon> <ele>72.7</ele> </tp>
726 <tp> <time>2006-03-04T11:18:35Z</time> <lat>54.96913</lat> <lon>-1.62499</lon> <ele>71.3</ele> </tp>
727 <tp> <time>2006-03-04T11:18:38Z</time> <lat>54.96904</lat> <lon>-1.62497</lon> <ele>70.8</ele> </tp>
728 <tp> <time>2006-03-04T11:18:48Z</time> <lat>54.96913</lat> <lon>-1.62496</lon> <ele>71.8</ele> </tp>
729 <tp> <time>2006-03-04T11:18:55Z</time> <lat>54.96924</lat> <lon>-1.62501</lon> <ele>72.2</ele> </tp>
730 <tp> <time>2006-03-04T11:19:11Z</time> <lat>54.9694</lat> <lon>-1.62521</lon> <ele>71.8</ele> </tp>
731 <tp> <time>2006-03-04T11:19:30Z</time> <lat>54.96916</lat> <lon>-1.62515</lon> <ele>71.3</ele> </tp>
732 <tp> <time>2006-03-04T11:19:53Z</time> <lat>54.96921</lat> <lon>-1.625</lon> <ele>71.3</ele> </tp>
733 <tp> <time>2006-03-04T11:20:21Z</time> <lat>54.96801</lat> <lon>-1.62417</lon> <ele>71.8</ele> </tp>
734 <break/>
735 <title>ACTIVE LOG 127</title>
736 <tp> <time>2006-03-04T11:21:16Z</time> <lat>54.96887</lat> <lon>-1.62504</lon> <ele>70.8</ele> </tp>
737 <tp> <time>2006-03-04T11:21:18Z</time> <lat>54.96898</lat> <lon>-1.62476</lon> <ele>69.8</ele> </tp>
738 <tp> <time>2006-03-04T11:21:29Z</time> <lat>54.9691</lat> <lon>-1.62475</lon> <ele>69.4</ele> </tp>
739 <tp> <time>2006-03-04T11:21:46Z</time> <lat>54.96918</lat> <lon>-1.62468</lon> <ele>70.3</ele> </tp>
740 <tp> <time>2006-03-04T11:22:39Z</time> <lat>54.9692</lat> <lon>-1.62465</lon> <ele>69.4</ele> </tp>
741 <tp> <time>2006-03-04T11:22:43Z</time> <lat>54.96924</lat> <lon>-1.62462</lon> <ele>71.8</ele> </tp>
742 <tp> <time>2006-03-04T11:22:45Z</time> <lat>54.96928</lat> <lon>-1.62463</lon> <ele>71.8</ele> </tp>
743 <tp> <time>2006-03-04T11:23:00Z</time> <lat>54.96945</lat> <lon>-1.62466</lon> <ele>69.4</ele> </tp>
744 </track>
745 </gpsml>
748 "Read Mapsource TAB-separated format",
751 # }}}
752 testcmd("../gpst two-digit_year.mcsv", # {{{
753 <<END,
754 <?xml version="1.0" encoding="UTF-8"?>
755 <gpsml>
756 <track>
757 <break/>
758 <title>ACTIVE LOG 032</title>
759 <tp> <time>2006-03-20T20:35:33Z</time> <lat>60.41324</lat> <lon>5.33352</lon> <ele>14</ele> </tp>
760 <tp> <time>2006-03-20T20:35:38Z</time> <lat>60.38802</lat> <lon>5.33845</lon> <ele>18</ele> </tp>
761 <tp> <time>2006-03-20T20:35:44Z</time> <lat>60.38709</lat> <lon>5.3379</lon> <ele>19</ele> </tp>
762 <tp> <time>2006-03-20T20:35:49Z</time> <lat>60.38641</lat> <lon>5.33732</lon> <ele>18</ele> </tp>
763 <tp> <time>2006-03-20T20:35:54Z</time> <lat>60.38581</lat> <lon>5.33647</lon> <ele>18</ele> </tp>
764 <tp> <time>2006-03-20T20:36:00Z</time> <lat>60.38516</lat> <lon>5.33528</lon> <ele>15</ele> </tp>
765 <tp> <time>2006-03-20T20:36:02Z</time> <lat>60.38495</lat> <lon>5.3349</lon> <ele>13</ele> </tp>
766 </track>
767 </gpsml>
770 "Read Mapsource TAB-separated format with two-digit year",
773 # }}}
774 testcmd("../gpst log.gpstxt", # {{{
775 <<END,
776 <?xml version="1.0" encoding="UTF-8"?>
777 <gpsml>
778 <track>
779 <tp> <time>2003-06-13T14:36:09Z</time> <lat>59.521517</lat> <lon>7.391867</lon> <ele>762</ele> </tp>
780 <tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>
781 <tp> <time>2003-06-13T14:36:11Z</time> <lat>59.5213</lat> <lon>7.392417</lon> <ele>761</ele> </tp>
782 <tp> <time>2003-06-13T14:36:12Z</time> <lat>59.521183</lat> <lon>7.3927</lon> <ele>761</ele> </tp>
783 <etp err="nosignal"> <time>2003-06-13T14:36:13Z</time> </etp>
784 <tp> <time>2003-06-13T14:36:15Z</time> <lat>59.52085</lat> <lon>7.393517</lon> <ele>760</ele> </tp>
785 <tp> <time>2003-06-13T14:36:16Z</time> <lat>59.520733</lat> <lon>7.393783</lon> <ele>760</ele> </tp>
786 <tp> <time>2003-06-13T14:36:17Z</time> <lat>59.52065</lat> <lon>7.39405</lon> <ele>760</ele> </tp>
787 <tp> <time>2003-06-13T14:36:18Z</time> <lat>59.520583</lat> <lon>7.394333</lon> <ele>760</ele> </tp>
788 <tp> <time>2003-06-13T14:36:19Z</time> <lat>59.520533</lat> <lon>7.394633</lon> <ele>759</ele> </tp>
789 <tp> <time>2003-06-13T14:36:20Z</time> <lat>59.520483</lat> <lon>7.394917</lon> <ele>759</ele> </tp>
790 <tp> <time>2003-06-13T14:36:21Z</time> <lat>59.520433</lat> <lon>7.395233</lon> <ele>759</ele> </tp>
791 <etp err="nosignal"> <time>2003-06-13T14:36:22Z</time> </etp>
792 <tp> <time>2003-06-13T14:36:24Z</time> <lat>59.520283</lat> <lon>7.396233</lon> <ele>758</ele> </tp>
793 <tp> <time>2003-06-13T14:36:25Z</time> <lat>59.520233</lat> <lon>7.39655</lon> <ele>758</ele> </tp>
794 <tp> <time>2003-06-13T14:36:26Z</time> <lat>59.520183</lat> <lon>7.396883</lon> <ele>757</ele> </tp>
795 <tp> <time>2003-06-13T14:36:27Z</time> <lat>59.520133</lat> <lon>7.397217</lon> <ele>757</ele> </tp>
796 <tp> <time>2003-06-13T14:36:28Z</time> <lat>59.5201</lat> <lon>7.397567</lon> <ele>757</ele> </tp>
797 </track>
798 </gpsml>
801 "Read Garmin serial text format",
804 # }}}
805 testcmd("../gpst log.dos.mayko", # {{{
806 <<END,
807 <?xml version="1.0" encoding="UTF-8"?>
808 <gpsml>
809 <track>
810 <tp> <time>2003-06-15T10:27:45Z</time> <lat>58.1818158</lat> <lon>8.1225077</lon> </tp>
811 <tp> <time>2003-06-15T10:27:53Z</time> <lat>58.1818712</lat> <lon>8.12532</lon> </tp>
812 <tp> <time>2003-06-15T10:27:57Z</time> <lat>58.1816347</lat> <lon>8.1266031</lon> </tp>
813 <tp> <time>2003-06-15T10:28:03Z</time> <lat>58.1812099</lat> <lon>8.1284612</lon> </tp>
814 <tp> <time>2003-06-15T10:28:06Z</time> <lat>58.1810315</lat> <lon>8.129395</lon> </tp>
815 <tp> <time>2003-06-15T10:28:10Z</time> <lat>58.1809621</lat> <lon>8.13074</lon> </tp>
816 </track>
817 </gpsml>
820 "Read DOS-formatted Mayko format",
823 # }}}
824 testcmd("../gpst log.dos.gpstxt", # {{{
825 <<END,
826 <?xml version="1.0" encoding="UTF-8"?>
827 <gpsml>
828 <track>
829 <tp> <time>2003-01-05T16:47:11Z</time> <lat>66.908167</lat> <lon>15.022983</lon> <ele>11472</ele> </tp>
830 <tp> <time>2003-01-05T16:47:12Z</time> <lat>66.90625</lat> <lon>15.020667</lon> <ele>11472</ele> </tp>
831 <tp> <time>2003-01-05T16:47:13Z</time> <lat>66.904317</lat> <lon>15.01835</lon> <ele>11472</ele> </tp>
832 <tp> <time>2003-01-05T16:47:14Z</time> <lat>66.9024</lat> <lon>15.016017</lon> <ele>11473</ele> </tp>
833 <tp> <time>2003-01-05T16:47:15Z</time> <lat>66.900483</lat> <lon>15.0137</lon> <ele>11474</ele> </tp>
834 <tp> <time>2003-01-05T16:47:16Z</time> <lat>66.898567</lat> <lon>15.011383</lon> <ele>11474</ele> </tp>
835 <tp> <time>2003-01-05T16:47:17Z</time> <lat>66.896633</lat> <lon>15.009067</lon> <ele>11475</ele> </tp>
836 <tp> <time>2003-01-05T16:47:18Z</time> <lat>66.894717</lat> <lon>15.006733</lon> <ele>11475</ele> </tp>
837 <tp> <time>2003-01-05T16:47:19Z</time> <lat>66.8928</lat> <lon>15.004417</lon> <ele>11475</ele> </tp>
838 <tp> <time>2003-01-05T16:47:20Z</time> <lat>66.890867</lat> <lon>15.0021</lon> <ele>11475</ele> </tp>
839 <tp> <time>2003-01-05T16:47:21Z</time> <lat>66.88895</lat> <lon>14.999783</lon> <ele>11475</ele> </tp>
840 </track>
841 </gpsml>
844 "Read DOS-formatted Garmin serial text format",
847 # }}}
848 testcmd("../gpst log.unix.mcsv", # {{{
849 <<END,
850 <?xml version="1.0" encoding="UTF-8"?>
851 <gpsml>
852 <track>
853 <break/>
854 <title>ACTIVE LOG 058</title>
855 <tp> <time>2006-02-21T15:14:25Z</time> <lat>60.36662</lat> <lon>5.24885</lon> <ele>31.9</ele> </tp>
856 <tp> <time>2006-02-21T15:14:30Z</time> <lat>60.37057</lat> <lon>5.22956</lon> <ele>35.2</ele> </tp>
857 <tp> <time>2006-02-21T15:14:35Z</time> <lat>60.37019</lat> <lon>5.22817</lon> <ele>39.6</ele> </tp>
858 <tp> <time>2006-02-21T15:14:36Z</time> <lat>60.37012</lat> <lon>5.2279</lon> <ele>41</ele> </tp>
859 <tp> <time>2006-02-21T15:14:40Z</time> <lat>60.37009</lat> <lon>5.22682</lon> <ele>47.2</ele> </tp>
860 <tp> <time>2006-02-21T15:14:42Z</time> <lat>60.37011</lat> <lon>5.22641</lon> <ele>49.2</ele> </tp>
861 <tp> <time>2006-02-21T15:14:44Z</time> <lat>60.37011</lat> <lon>5.22607</lon> <ele>50.1</ele> </tp>
862 <tp> <time>2006-02-21T15:14:48Z</time> <lat>60.37002</lat> <lon>5.22568</lon> <ele>51.1</ele> </tp>
863 <tp> <time>2006-02-21T15:14:51Z</time> <lat>60.3701</lat> <lon>5.22548</lon> <ele>52.5</ele> </tp>
864 </track>
865 </gpsml>
868 "Read UNIX-formatted Garmin Mapsource TAB-separated format",
871 # }}}
872 testcmd("../gpst multitrack.gpx", # {{{
873 <<END,
874 <?xml version="1.0" encoding="UTF-8"?>
875 <gpsml>
876 <track>
877 <title>Track 1</title>
878 <tp> <time>2003-02-11T23:35:39Z</time> <lat>51.4968266</lat> <lon>-0.1448824</lon> </tp>
879 <tp> <time>2003-02-11T23:35:49Z</time> <lat>51.4968227</lat> <lon>-0.1449938</lon> </tp>
880 <tp> <time>2003-02-11T23:36:14Z</time> <lat>51.496904</lat> <lon>-0.1453202</lon> </tp>
881 <break/>
882 <title>Track 2</title>
883 <tp> <time>2003-02-11T23:36:16Z</time> <lat>51.4969214</lat> <lon>-0.1453398</lon> </tp>
884 <tp> <time>2003-02-11T23:36:31Z</time> <lat>51.4969816</lat> <lon>-0.1455514</lon> </tp>
885 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
886 <tp> <time>2003-02-11T23:36:50Z</time> <lat>51.4970452</lat> <lon>-0.1457804</lon> </tp>
887 <break/>
888 <title>Track 3</title>
889 <tp> <time>2003-02-11T23:37:05Z</time> <lat>51.497068</lat> <lon>-0.1458608</lon> </tp>
890 <tp> <time>2003-02-11T23:37:22Z</time> <lat>51.4971658</lat> <lon>-0.1460047</lon> </tp>
891 <tp> <time>2003-02-11T23:37:36Z</time> <lat>51.4972469</lat> <lon>-0.1461614</lon> </tp>
892 <break/>
893 <title>Track 4</title>
894 <tp> <time>2003-02-11T23:37:43Z</time> <lat>51.4972731</lat> <lon>-0.1462394</lon> </tp>
895 <tp> <time>2003-02-11T23:38:04Z</time> <lat>51.4973437</lat> <lon>-0.1463232</lon> </tp>
896 <tp> <time>2003-02-11T23:38:28Z</time> <lat>51.4973337</lat> <lon>-0.1462949</lon> </tp>
897 <tp> <time>2003-02-11T23:38:34Z</time> <lat>51.4973218</lat> <lon>-0.1462825</lon> </tp>
898 <tp> <time>2003-02-11T23:38:35Z</time> <lat>51.4973145</lat> <lon>-0.1462732</lon> </tp>
899 </track>
900 </gpsml>
903 "Read GPX file with multiple tracks",
906 # }}}
907 testcmd("../gpst compact.gpx", # {{{
908 <<END,
909 <?xml version="1.0" encoding="UTF-8"?>
910 <gpsml>
911 <track>
912 <title>All whitespace stripped</title>
913 <tp> <time>2002-12-30T15:22:04Z</time> <lat>70.660932</lat> <lon>23.7028354</lon> </tp>
914 <tp> <time>2002-12-30T15:22:06Z</time> <lat>70.6609392</lat> <lon>23.7028468</lon> </tp>
915 <tp> <time>2002-12-30T15:22:08Z</time> <lat>70.6609429</lat> <lon>23.7028499</lon> </tp>
916 <tp> <time>2002-12-30T15:22:11Z</time> <lat>70.6609381</lat> <lon>23.702862</lon> </tp>
917 <tp> <time>2002-12-30T15:22:12Z</time> <lat>70.6609368</lat> <lon>23.7028648</lon> </tp>
918 <tp> <time>2002-12-30T15:22:13Z</time> <lat>70.6609344</lat> <lon>23.7028652</lon> </tp>
919 <tp> <time>2002-12-30T15:22:15Z</time> <lat>70.6609349</lat> <lon>23.7028707</lon> </tp>
920 <tp> <time>2002-12-30T15:22:17Z</time> <lat>70.6609348</lat> <lon>23.7028654</lon> </tp>
921 <tp> <time>2002-12-30T15:22:19Z</time> <lat>70.6609347</lat> <lon>23.7028599</lon> </tp>
922 <tp> <time>2002-12-30T15:22:20Z</time> <lat>70.6609348</lat> <lon>23.7028609</lon> </tp>
923 <tp> <time>2002-12-30T15:22:23Z</time> <lat>70.6609388</lat> <lon>23.7028653</lon> </tp>
924 <tp> <time>2002-12-30T15:22:25Z</time> <lat>70.6609426</lat> <lon>23.7028732</lon> </tp>
925 </track>
926 </gpsml>
929 "Read GPX one-liner",
932 # }}}
933 testcmd("../gpst missing.gpsml", # {{{
934 <<END,
935 <?xml version="1.0" encoding="UTF-8"?>
936 <gpsml>
937 <track>
938 <title>Missing various elements</title>
939 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
940 <tp> <time>2006-04-30T17:17:00Z</time> </tp>
941 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
942 <tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
943 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
944 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
945 <tp> <ele>484</ele> </tp>
946 <tp> <ele>486</ele> </tp>
947 <tp> <desc>Missing everything</desc> </tp>
948 <tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
949 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
950 </track>
951 </gpsml>
954 "Read gpsml with various data missing",
957 # }}}
958 testcmd("../gpst different_dateformats.gpsml", # {{{
959 <<END,
960 <?xml version="1.0" encoding="UTF-8"?>
961 <gpsml>
962 <track>
963 <title>Date format variations</title>
964 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1</lat> <lon>1</lon> </tp>
965 <tp> <time>2006-01-01T00:00:02Z</time> <lat>2</lat> <lon>2</lon> </tp>
966 <tp> <time>2006-01-01T00:00:03Z</time> <lat>3</lat> <lon>3</lon> </tp>
967 <tp> <time>2006-01-01T00:00:04Z</time> <lat>4</lat> <lon>4</lon> </tp>
968 </track>
969 </gpsml>
972 "Read different date formats from gpsml file",
975 # }}}
976 testcmd("../gpst multitrack-pause.gpx", # {{{
977 file_data("multitrack-pause.gpsml"),
979 "Should be equal to multitrack-pause.gpsml",
982 # }}}
983 # gpx
984 testcmd("../gpst -o gpx no_signal.mayko", # {{{
985 <<END,
986 $gpx_header
987 <trk>
988 <trkseg>
989 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
990 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
991 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
992 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> </trkpt>
993 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> </trkpt>
994 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> </trkpt>
995 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
996 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
997 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
998 </trkseg>
999 </trk>
1000 </gpx>
1003 "Output GPX from Mayko file with duplicates",
1006 # }}}
1007 testcmd("../gpst -o gpx comments.mayko", # {{{
1008 <<END,
1009 $gpx_header
1010 <trk>
1011 <trkseg>
1012 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
1013 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
1014 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
1015 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1016 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1017 <!-- <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> <extensions> <error>desc</error> </extensions> </trkpt> -->
1018 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
1019 </trkseg>
1020 <trkseg>
1021 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
1022 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
1023 </trkseg>
1024 </trk>
1025 </gpx>
1028 "Output GPX from Mayko file with commented-out lines",
1031 # }}}
1032 testcmd("../gpst -o gpx missing.gpsml", # {{{
1033 <<END,
1034 $gpx_header
1035 <trk>
1036 <trkseg>
1037 <trkpt lat="60.42353" lon="5.34185"> <time>2006-04-30T17:17:09Z</time> </trkpt>
1038 <trkpt> <ele>483</ele> <time>2006-04-30T17:17:11Z</time> </trkpt>
1039 <trkpt> <ele>485</ele> <time>2006-04-30T17:17:22Z</time> </trkpt>
1040 <trkpt lat="60.42347" lon="5.34212"> <ele>486</ele> </trkpt>
1041 <trkpt> <ele>484</ele> </trkpt>
1042 <trkpt> <ele>486</ele> </trkpt>
1043 <trkpt> <ele>490</ele> <time>2006-04-30T17:18:03Z</time> </trkpt>
1044 <trkpt lat="60.42338" lon="5.34269"> <ele>487</ele> <time>2006-04-30T17:18:05Z</time> </trkpt>
1045 </trkseg>
1046 </trk>
1047 </gpx>
1050 "Output GPX from gpsml with missing data",
1053 # }}}
1054 # xgraph
1055 testcmd("../gpst -o xgraph multitrack.gpx", # {{{
1056 <<END,
1057 -0.1448824 51.4968266
1058 -0.1449938 51.4968227
1059 -0.1453202 51.4969040
1060 move -0.1453398 51.4969214
1061 -0.1455514 51.4969816
1062 -0.1457489 51.4970224
1063 -0.1457804 51.4970452
1064 move -0.1458608 51.4970680
1065 -0.1460047 51.4971658
1066 -0.1461614 51.4972469
1067 move -0.1462394 51.4972731
1068 -0.1463232 51.4973437
1069 -0.1462949 51.4973337
1070 -0.1462825 51.4973218
1071 -0.1462732 51.4973145
1074 "Output xgraph format from GPX",
1077 # }}}
1078 # pgtab
1079 testcmd("../gpst -o pgtab compact.gpx", # {{{
1080 <<END,
1081 2002-12-30T15:22:04Z\t(70.6609320,23.7028354)\t\\N\t\\N\t\\N\t\\N\t\\N
1082 2002-12-30T15:22:06Z\t(70.6609392,23.7028468)\t\\N\t\\N\t\\N\t\\N\t\\N
1083 2002-12-30T15:22:08Z\t(70.6609429,23.7028499)\t\\N\t\\N\t\\N\t\\N\t\\N
1084 2002-12-30T15:22:11Z\t(70.6609381,23.7028620)\t\\N\t\\N\t\\N\t\\N\t\\N
1085 2002-12-30T15:22:12Z\t(70.6609368,23.7028648)\t\\N\t\\N\t\\N\t\\N\t\\N
1086 2002-12-30T15:22:13Z\t(70.6609344,23.7028652)\t\\N\t\\N\t\\N\t\\N\t\\N
1087 2002-12-30T15:22:15Z\t(70.6609349,23.7028707)\t\\N\t\\N\t\\N\t\\N\t\\N
1088 2002-12-30T15:22:17Z\t(70.6609348,23.7028654)\t\\N\t\\N\t\\N\t\\N\t\\N
1089 2002-12-30T15:22:19Z\t(70.6609347,23.7028599)\t\\N\t\\N\t\\N\t\\N\t\\N
1090 2002-12-30T15:22:20Z\t(70.6609348,23.7028609)\t\\N\t\\N\t\\N\t\\N\t\\N
1091 2002-12-30T15:22:23Z\t(70.6609388,23.7028653)\t\\N\t\\N\t\\N\t\\N\t\\N
1092 2002-12-30T15:22:25Z\t(70.6609426,23.7028732)\t\\N\t\\N\t\\N\t\\N\t\\N
1095 "Output pgtab from gpx format",
1098 # }}}
1099 testcmd("../gpst -o pgtab no_signal.mayko", # {{{
1100 <<END,
1101 2002-12-22T21:42:24Z\t(70.6800486,23.6746151)\t\\N\t\\N\t\\N\t\\N\t\\N
1102 2002-12-22T21:42:32Z\t(70.6799322,23.6740038)\t\\N\t\\N\t\\N\t\\N\t\\N
1103 2002-12-22T21:42:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
1104 2002-12-22T21:43:51Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
1105 2002-12-22T21:43:52Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
1106 2002-12-22T21:43:54Z\t(70.6796266,23.6723991)\t\\N\t\\N\t\\N\t\\N\t\\N
1107 2002-12-22T21:44:45Z\t(70.6800774,23.6757566)\t\\N\t\\N\t\\N\t\\N\t\\N
1108 2002-12-22T21:44:52Z\t(70.6801502,23.6753442)\t\\N\t\\N\t\\N\t\\N\t\\N
1109 2002-12-22T21:45:04Z\t(70.6801905,23.6757542)\t\\N\t\\N\t\\N\t\\N\t\\N
1112 "Output pgtab from mayko format",
1115 # }}}
1116 testcmd("../gpst -o pgtab missing.gpsml", # {{{
1117 <<END,
1118 2006-04-30T17:17:09Z\t(60.42353,5.34185)\t\\N\t\\N\t\\N\t\\N\t\\N
1119 \\N\t(60.42347,5.34212)\t486\t\\N\t\\N\t\\N\t\\N
1120 2006-04-30T17:18:05Z\t(60.42338,5.34269)\t487\t\\N\t\\N\t\\N\t\\N
1123 "Output pgtab from missing.gpsml",
1126 # }}}
1127 # csv
1128 testcmd("../gpst -o csv log.dos.mayko", # {{{
1129 <<END,
1130 2003-06-15T10:27:45Z\t8.1225077\t58.1818158\t\t
1131 2003-06-15T10:27:53Z\t8.1253200\t58.1818712\t\t
1132 2003-06-15T10:27:57Z\t8.1266031\t58.1816347\t\t
1133 2003-06-15T10:28:03Z\t8.1284612\t58.1812099\t\t
1134 2003-06-15T10:28:06Z\t8.1293950\t58.1810315\t\t
1135 2003-06-15T10:28:10Z\t8.1307400\t58.1809621\t\t
1138 "Output csv from DOS-formatted Mayko format",
1141 # }}}
1142 # pgwtab
1143 testcmd("../gpst -o pgwtab multitrack.gpx", # {{{
1144 <<END,
1145 (51.477880000,-0.001470000)\t0-Meridian\t\\N\t\\N\t\\N\t11-FEB-03 15:46\t11-FEB-03 15:46\t\\N\t\\N
1146 (51.532030,-0.177330)\tAbbey Road\t34.492798\t\\N\t\\N\tDet hellige gangfeltet der Beatles valsa over.\t26-FEB-06 17:29:46\t\\N\t\\N
1147 (61.636684,8.312254)\tGaldhøpiggen med ', &, < og >. ☺\t2469.012939\tmountain\t2006-05-08T18:27:59Z\tHer er det &, < og >. ☺\tSchwæra greie\thttp://www.example.org/\tWaypoint
1148 (60.397460000,5.350610000)\tHalfdan Griegs vei\t\\N\t\\N\t\\N\t04-AUG-02 19:42\t04-AUG-02 19:42\t\\N\t\\N
1149 (51.510130000,-0.130410000)\tLeicester Square\t\\N\t\\N\t\\N\t11-FEB-03 18:00\t11-FEB-03 18:00\t\\N\t\\N
1150 (60.968540000,9.285350000)\tLeira camping\t\\N\t\\N\t\\N\t03-OKT-02 21:58\t03-OKT-02 21:58\t\\N\t\\N
1153 "Test pgwtab format",
1156 # }}}
1157 # pgwupd
1158 testcmd("../gpst -o pgwupd multitrack.gpx", # {{{
1159 <<END,
1160 BEGIN;
1161 UPDATE logg SET sted = clname(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1162 UPDATE logg SET dist = cldist(coor) WHERE (point(51.477880000,-0.001470000) <-> coor) < 0.05;
1163 COMMIT;
1164 BEGIN;
1165 UPDATE logg SET sted = clname(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1166 UPDATE logg SET dist = cldist(coor) WHERE (point(51.532030,-0.177330) <-> coor) < 0.05;
1167 COMMIT;
1168 BEGIN;
1169 UPDATE logg SET sted = clname(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1170 UPDATE logg SET dist = cldist(coor) WHERE (point(61.636684,8.312254) <-> coor) < 0.05;
1171 COMMIT;
1172 BEGIN;
1173 UPDATE logg SET sted = clname(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1174 UPDATE logg SET dist = cldist(coor) WHERE (point(60.397460000,5.350610000) <-> coor) < 0.05;
1175 COMMIT;
1176 BEGIN;
1177 UPDATE logg SET sted = clname(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1178 UPDATE logg SET dist = cldist(coor) WHERE (point(51.510130000,-0.130410000) <-> coor) < 0.05;
1179 COMMIT;
1180 BEGIN;
1181 UPDATE logg SET sted = clname(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1182 UPDATE logg SET dist = cldist(coor) WHERE (point(60.968540000,9.285350000) <-> coor) < 0.05;
1183 COMMIT;
1186 "Test pgwupd format",
1189 # }}}
1190 # clean
1191 testcmd("../gpst -t -o clean pause.gpx", # {{{
1192 <<END,
1193 5.299534\t60.425494\t25.260
1194 5.299610\t60.425464\t24.931
1196 5.299694\t60.425314\t27.975
1198 5.299741\t60.425384\t31.017
1199 5.299958\t60.425339\t30.980
1200 5.299640\t60.425238\t30.538
1201 5.299686\t60.425246\t30.515
1203 5.299773\t60.425345\t31.936
1204 5.299419\t60.425457\t31.794
1207 "Output clean format with time breaks",
1209 # }}}
1210 # gpstrans
1211 # poscount
1212 # ps (Unfinished)
1213 # svg (Unfinished)
1214 # ygraph
1215 # --output option }}}
1216 diag("Testing --outside option..."); # {{{
1217 testcmd("../gpst --pos1 2.11,2.12 --pos2 3.31,3.32 --outside multitrack-pause.gpx", # {{{
1218 <<END,
1219 <?xml version="1.0" encoding="UTF-8"?>
1220 <gpsml>
1221 <track>
1222 <title>track1</title>
1223 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1224 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1225 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1226 <break/>
1227 <title>track2</title>
1228 <break/>
1229 <title>track3</title>
1230 <break/>
1231 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1232 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1233 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1234 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1235 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1236 </track>
1237 </gpsml>
1240 "Check --outside option (gpx to gpst)",
1243 # }}}
1244 # --outside option }}}
1245 diag("Testing --pos1 and --pos2 options..."); # {{{
1246 # --pos1 and --pos2 options }}}
1247 diag("Testing --require option..."); # {{{
1248 testcmd("../gpst -re multitrack.gpx", # {{{
1249 <<END,
1250 <?xml version="1.0" encoding="UTF-8"?>
1251 <gpsml>
1252 <track>
1253 <title>Track 1</title>
1254 <break/>
1255 <title>Track 2</title>
1256 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
1257 <break/>
1258 <title>Track 3</title>
1259 <break/>
1260 <title>Track 4</title>
1261 </track>
1262 </gpsml>
1265 "Require elevation from GPX data",
1267 # }}}
1268 testcmd("../gpst tracks.gpsman", # {{{
1269 <<END,
1270 <?xml version="1.0" encoding="UTF-8"?>
1271 <gpsml>
1272 <track>
1273 <title>ACTIVE LOG</title>
1274 <tp> <time>2003-12-01T04:21:09Z</time> <lat>60.2891111111111</lat> <lon>5.22761111111111</lon> <ele>54.4517822266</ele> </tp>
1275 <tp> <time>2003-12-01T04:21:26Z</time> <lat>60.2885833333333</lat> <lon>5.22616666666667</lon> <ele>54.4517822266</ele> </tp>
1276 <break/>
1277 <tp> <time>2003-12-01T09:27:21Z</time> <lat>52.1221666666667</lat> <lon>14.0295277777778</lon> <ele>1494.98730469</ele> </tp>
1278 <break/>
1279 <tp> <time>2003-12-01T09:27:42Z</time> <lat>52.0858888888889</lat> <lon>14.0401388888889</lon> <ele>1494.98730469</ele> </tp>
1280 <tp> <time>2003-12-01T09:27:43Z</time> <lat>52.0842777777778</lat> <lon>14.0406666666667</lon> <ele>1494.02612305</ele> </tp>
1281 <break/>
1282 <tp> <time>2003-12-01T21:26:07Z</time> <lat>50.0858333333333</lat> <lon>14.4290833333333</lon> <ele>183.268432617</ele> </tp>
1283 <tp> <time>2003-12-01T21:26:31Z</time> <lat>50.0859722222222</lat> <lon>14.4291111111111</lon> <ele>184.710571289</ele> </tp>
1284 <break/>
1285 <tp> <time>2003-12-01T21:47:30Z</time> <lat>50.092</lat> <lon>14.43625</lon> <ele>180.384521484</ele> </tp>
1286 <tp> <time>2003-12-01T21:47:47Z</time> <lat>50.092</lat> <lon>14.43625</lon> <ele>181.345825195</ele> </tp>
1287 <tp> <time>2003-12-01T21:47:53Z</time> <lat>50.092</lat> <lon>14.4362222222222</lon> <ele>182.307128906</ele> </tp>
1288 </track>
1289 </gpsml>
1292 "Output gpsml format from gpsman",
1295 # }}}
1296 testcmd("../gpst -o gpx -R lat=7,lon=7,ele=2 tracks.gpsman", # {{{
1297 <<END,
1298 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1299 <gpx
1300 version="1.1"
1301 creator="gpst - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/"
1302 xmlns="http://www.topografix.com/GPX/1/1"
1303 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1304 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
1306 <trk>
1307 <title>ACTIVE LOG</title>
1308 <trkseg>
1309 <trkpt lat="60.2891111" lon="5.2276111"> <ele>54.45</ele> <time>2003-12-01T04:21:09Z</time> </trkpt>
1310 <trkpt lat="60.2885833" lon="5.2261667"> <ele>54.45</ele> <time>2003-12-01T04:21:26Z</time> </trkpt>
1311 </trkseg>
1312 <trkseg>
1313 <trkpt lat="52.1221667" lon="14.0295278"> <ele>1494.99</ele> <time>2003-12-01T09:27:21Z</time> </trkpt>
1314 </trkseg>
1315 <trkseg>
1316 <trkpt lat="52.0858889" lon="14.0401389"> <ele>1494.99</ele> <time>2003-12-01T09:27:42Z</time> </trkpt>
1317 <trkpt lat="52.0842778" lon="14.0406667"> <ele>1494.03</ele> <time>2003-12-01T09:27:43Z</time> </trkpt>
1318 </trkseg>
1319 <trkseg>
1320 <trkpt lat="50.0858333" lon="14.4290833"> <ele>183.27</ele> <time>2003-12-01T21:26:07Z</time> </trkpt>
1321 <trkpt lat="50.0859722" lon="14.4291111"> <ele>184.71</ele> <time>2003-12-01T21:26:31Z</time> </trkpt>
1322 </trkseg>
1323 <trkseg>
1324 <trkpt lat="50.092" lon="14.43625"> <ele>180.38</ele> <time>2003-12-01T21:47:30Z</time> </trkpt>
1325 <trkpt lat="50.092" lon="14.43625"> <ele>181.35</ele> <time>2003-12-01T21:47:47Z</time> </trkpt>
1326 <trkpt lat="50.092" lon="14.4362222"> <ele>182.31</ele> <time>2003-12-01T21:47:53Z</time> </trkpt>
1327 </trkseg>
1328 </trk>
1329 </gpx>
1332 "Output GPX format from gpsman",
1334 # }}}
1335 testcmd("../gpst -re one_ele.dos.gpsml", # {{{
1336 <<END,
1337 <?xml version="1.0" encoding="UTF-8"?>
1338 <gpsml>
1339 <track>
1340 <title>Only one point has elevation</title>
1341 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1342 </track>
1343 </gpsml>
1346 "Require elevation from gpsml",
1349 # }}}
1351 TODO: {
1352 local $TODO = "Shall lat/lon be cleared if one is missing?";
1353 testcmd("../gpst -re missing.gpsml", # {{{
1354 <<END,
1355 <?xml version="1.0" encoding="UTF-8"?>
1356 <gpsml>
1357 <track>
1358 <title>Missing various elements</title>
1359 <tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
1360 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1361 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1362 <tp> <ele>484</ele> </tp>
1363 <tp> <ele>486</ele> </tp>
1364 <tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
1365 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1366 </track>
1367 </gpsml>
1370 "Require elevation",
1373 # }}}
1374 testcmd("../gpst -rt missing.gpsml", # {{{
1375 <<END,
1376 <?xml version="1.0" encoding="UTF-8"?>
1377 <gpsml>
1378 <track>
1379 <title>Missing various elements</title>
1380 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
1381 <tp> <time>2006-04-30T17:17:00Z</time> </tp>
1382 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1383 <tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
1384 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1385 <tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
1386 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1387 </track>
1388 </gpsml>
1391 "Require time",
1394 # }}}
1395 testcmd("../gpst -rp missing.gpsml", # {{{
1396 <<END,
1397 <?xml version="1.0" encoding="UTF-8"?>
1398 <gpsml>
1399 <track>
1400 <title>Missing various elements</title>
1401 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
1402 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1403 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1404 </track>
1405 </gpsml>
1408 "Require position",
1411 # }}}
1412 testcmd("../gpst -ret missing.gpsml", # {{{
1413 <<END,
1414 <?xml version="1.0" encoding="UTF-8"?>
1415 <gpsml>
1416 <track>
1417 <title>Missing various elements</title>
1418 <tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
1419 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
1420 <tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
1421 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1422 </track>
1423 </gpsml>
1426 "Require elevation and time",
1429 # }}}
1430 testcmd("../gpst -retp missing.gpsml", # {{{
1431 <<END,
1432 <?xml version="1.0" encoding="UTF-8"?>
1433 <gpsml>
1434 <track>
1435 <title>Missing various elements</title>
1436 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1437 </track>
1438 </gpsml>
1441 "Require elevation, time and position",
1444 # }}}
1445 testcmd("../gpst -rep missing.gpsml", # {{{
1446 <<END,
1447 <?xml version="1.0" encoding="UTF-8"?>
1448 <gpsml>
1449 <track>
1450 <title>Missing various elements</title>
1451 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
1452 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
1453 </track>
1454 </gpsml>
1457 "Require elevation and position",
1460 # }}}
1462 # --require option }}}
1463 diag("Testing --round option..."); # {{{
1464 testcmd("../gpst -R lat=4,lon=5,ele=1 pause.gpx", # {{{
1465 <<END,
1466 <?xml version="1.0" encoding="UTF-8"?>
1467 <gpsml>
1468 <track>
1469 <title>ACTIVE LOG164705</title>
1470 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.4255</lat> <lon>5.29953</lon> <ele>25.3</ele> </tp>
1471 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.4255</lat> <lon>5.29961</lon> <ele>24.9</ele> </tp>
1472 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.4253</lat> <lon>5.29969</lon> <ele>28</ele> </tp>
1473 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.4254</lat> <lon>5.29974</lon> <ele>31</ele> </tp>
1474 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.4253</lat> <lon>5.29996</lon> <ele>31</ele> </tp>
1475 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.4252</lat> <lon>5.29964</lon> <ele>30.5</ele> </tp>
1476 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.4252</lat> <lon>5.29969</lon> <ele>30.5</ele> </tp>
1477 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.4253</lat> <lon>5.29977</lon> <ele>31.9</ele> </tp>
1478 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.4255</lat> <lon>5.29942</lon> <ele>31.8</ele> </tp>
1479 </track>
1480 </gpsml>
1483 "--round works with lat, lon, ele from gpx",
1486 # }}}
1487 # --round option }}}
1488 diag("Testing --short-date option..."); # {{{
1489 # --short-date option }}}
1490 diag("Testing --save-to-file option..."); # {{{
1491 # --save-to-file option }}}
1492 diag("Testing --create-breaks option..."); # {{{
1493 testcmd("../gpst -t pause.gpx", # {{{
1494 <<END,
1495 <?xml version="1.0" encoding="UTF-8"?>
1496 <gpsml>
1497 <track>
1498 <title>ACTIVE LOG164705</title>
1499 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
1500 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
1501 <pause>0:00:02:18</pause>
1502 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1503 <pause>0:00:04:32</pause>
1504 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
1505 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
1506 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
1507 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
1508 <pause>0:00:02:05</pause>
1509 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
1510 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
1511 </track>
1512 </gpsml>
1515 "Output gpsml with <pause> elements from GPX files",
1518 # }}}
1519 testcmd("../gpst -t multitrack-pause.gpx", # {{{
1520 <<END,
1521 <?xml version="1.0" encoding="UTF-8"?>
1522 <gpsml>
1523 <track>
1524 <title>track1</title>
1525 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1526 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1527 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1528 <break/>
1529 <title>track2</title>
1530 <pause>0:23:59:58</pause>
1531 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1532 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1533 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1534 <pause>0:01:00:00</pause>
1535 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1536 <break/>
1537 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1538 <break/>
1539 <title>track3</title>
1540 <pause>1:01:00:03</pause>
1541 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1542 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1543 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1544 <break/>
1545 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1546 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1547 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1548 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1549 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1550 </track>
1551 </gpsml>
1554 "Insert <pause> between gpx tracks",
1557 # }}}
1558 testcmd("../gpst -t multitrack-pause.gpsml", # {{{
1559 <<END,
1560 <?xml version="1.0" encoding="UTF-8"?>
1561 <gpsml>
1562 <track>
1563 <title>track1</title>
1564 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1.11</lat> <lon>1.12</lon> </tp>
1565 <tp> <time>2006-01-01T00:00:01Z</time> <lat>1.21</lat> <lon>1.22</lon> </tp>
1566 <tp> <time>2006-01-01T00:00:02Z</time> <lat>1.31</lat> <lon>1.32</lon> </tp>
1567 <break/>
1568 <title>track2</title>
1569 <pause>0:23:59:58</pause>
1570 <tp> <time>2006-01-02T00:00:00Z</time> <lat>2.11</lat> <lon>2.12</lon> </tp>
1571 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2.21</lat> <lon>2.22</lon> </tp>
1572 <tp> <time>2006-01-02T00:00:16Z</time> <lat>2.31</lat> <lon>2.32</lon> </tp>
1573 <pause>0:01:00:00</pause>
1574 <tp> <time>2006-01-02T01:00:16Z</time> <lat>2.41</lat> <lon>2.42</lon> </tp>
1575 <break/>
1576 <tp> <time>2006-01-02T01:00:17Z</time> <lat>2.451</lat> <lon>2.452</lon> </tp>
1577 <break/>
1578 <title>track3</title>
1579 <pause>1:01:00:03</pause>
1580 <tp> <time>2006-01-03T02:00:20Z</time> <lat>3.11</lat> <lon>3.12</lon> </tp>
1581 <tp> <time>2006-01-03T02:00:21Z</time> <lat>3.21</lat> <lon>3.22</lon> </tp>
1582 <tp> <time>2006-01-03T02:00:22Z</time> <lat>3.31</lat> <lon>3.32</lon> </tp>
1583 <break/>
1584 <tp> <time>2006-01-03T02:00:23Z</time> <lat>3.41</lat> <lon>3.42</lon> </tp>
1585 <tp> <time>2006-01-03T02:00:24Z</time> <lat>3.51</lat> <lon>3.52</lon> </tp>
1586 <tp> <time>2006-01-03T02:00:25Z</time> <lat>3.61</lat> <lon>3.62</lon> </tp>
1587 <tp> <time>2006-01-03T02:00:26Z</time> <lat>3.71</lat> <lon>3.72</lon> </tp>
1588 <tp> <time>2006-01-03T02:00:27Z</time> <lat>3.81</lat> <lon>3.82</lon> </tp>
1589 </track>
1590 </gpsml>
1593 "Insert <pause> between gpsml titles",
1596 # }}}
1597 # --create-breaks option }}}
1598 diag("Testing --comment-out-dups option..."); # {{{
1599 testcmd("../gpst -u no_signal.mayko >nosignal.tmp", # {{{
1602 "Redirect stdout",
1605 # }}}
1606 testcmd("../gpst nosignal.tmp", # {{{
1607 <<END,
1608 <?xml version="1.0" encoding="UTF-8"?>
1609 <gpsml>
1610 <track>
1611 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
1612 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
1613 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
1614 <desc>20021222T214351-20021222T214354: CO: No signal \x7B\x7B\x7B</desc>
1615 <etp err="desc"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1616 <etp err="desc"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1617 <etp err="desc"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1618 <desc>20021222T214351-20021222T214354: CO: No signal \x7D\x7D\x7D</desc>
1619 <break/>
1620 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
1621 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
1622 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
1623 </track>
1624 </gpsml>
1627 "Read output from 'gpst -u *.mayko'",
1630 # }}}
1631 unlink("nosignal.tmp") || warn("nosignal.tmp: Cannot delete file: $!\n");
1632 testcmd("../gpst -u no_signal.mayko", # {{{
1633 <<END,
1634 xmaplog 1.0 Mon Dec 23 02:00:50 2002
1635 1 70.6800486 23.6746151 57.4 0 12/22/2002 21:42:24
1636 1 70.6799322 23.6740038 6.3 0 12/22/2002 21:42:32
1637 1 70.6796266 23.6723991 6.0 0 12/22/2002 21:42:54
1638 # 20021222T214351-20021222T214354: CO: No signal \x7B\x7B\x7B
1639 # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:51
1640 # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:52
1641 # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:54
1642 # 20021222T214351-20021222T214354: CO: No signal \x7D\x7D\x7D
1643 # move
1644 1 70.6800774 23.6757566 5.1 0 12/22/2002 21:44:45
1645 1 70.6801502 23.6753442 4.8 0 12/22/2002 21:44:52
1646 1 70.6801905 23.6757542 2.5 0 12/22/2002 21:45:04
1649 "Read Mayko format with no signal, output old Mayko format",
1652 # }}}
1653 # --comment-out-dups option }}}
1654 diag("Testing --verbose option..."); # {{{
1655 # --verbose option }}}
1656 diag("Testing --version option..."); # {{{
1657 like(`../gpst --version`, # {{{
1658 qr/^(\$Id: .*? \$\n)+$/s,
1659 '"../gpst --version" - The --version option outputs Id strings',
1662 # }}}
1663 # --version option }}}
1664 diag("Testing --strip-whitespace option..."); # {{{
1665 testcmd("../gpst -w -o gpx pause.gpx", # {{{
1666 <<END,
1667 $stripped_gpx_header
1668 <trk>
1669 <trkseg>
1670 <trkpt lat="60.425494" lon="5.299534"><ele>25.260</ele><time>2006-05-21T16:49:11Z</time></trkpt>
1671 <trkpt lat="60.425464" lon="5.299610"><ele>24.931</ele><time>2006-05-21T16:49:46Z</time></trkpt>
1672 <trkpt lat="60.425314" lon="5.299694"><ele>27.975</ele><time>2006-05-21T16:52:04Z</time></trkpt>
1673 <trkpt lat="60.425384" lon="5.299741"><ele>31.017</ele><time>2006-05-21T16:56:36Z</time></trkpt>
1674 <trkpt lat="60.425339" lon="5.299958"><ele>30.980</ele><time>2006-05-21T16:56:47Z</time></trkpt>
1675 <trkpt lat="60.425238" lon="5.299640"><ele>30.538</ele><time>2006-05-21T16:56:56Z</time></trkpt>
1676 <trkpt lat="60.425246" lon="5.299686"><ele>30.515</ele><time>2006-05-21T16:57:03Z</time></trkpt>
1677 <trkpt lat="60.425345" lon="5.299773"><ele>31.936</ele><time>2006-05-21T16:59:08Z</time></trkpt>
1678 <trkpt lat="60.425457" lon="5.299419"><ele>31.794</ele><time>2006-05-21T17:00:54Z</time></trkpt>
1679 </trkseg>
1680 </trk>
1681 </gpx>
1684 "Strip whitespace from GPX output",
1687 # }}}
1688 testcmd("../gpst -o gpx -w comments.mayko", # {{{
1689 <<END,
1690 $stripped_gpx_header
1691 <trk>
1692 <trkseg>
1693 <trkpt lat="70.6800486" lon="23.6746151"><time>2002-12-22T21:42:24Z</time></trkpt>
1694 <trkpt lat="70.6799322" lon="23.6740038"><time>2002-12-22T21:42:32Z</time></trkpt>
1695 <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:42:54Z</time></trkpt>
1696 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:51Z</time><extensions><error>desc</error></extensions></trkpt> -->
1697 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:52Z</time><extensions><error>desc</error></extensions></trkpt> -->
1698 <!-- <trkpt lat="70.6796266" lon="23.6723991"><time>2002-12-22T21:43:54Z</time><extensions><error>desc</error></extensions></trkpt> -->
1699 <trkpt lat="70.6800774" lon="23.6757566"><time>2002-12-22T21:44:45Z</time></trkpt>
1700 </trkseg>
1701 <trkseg>
1702 <trkpt lat="70.6801502" lon="23.6753442"><time>2002-12-22T21:44:52Z</time></trkpt>
1703 <trkpt lat="70.6801905" lon="23.6757542"><time>2002-12-22T21:45:04Z</time></trkpt>
1704 </trkseg>
1705 </trk>
1706 </gpx>
1709 "Output whitespace-stripped GPX from Mayko file with commented-out lines",
1712 # }}}
1713 # --strip-whitespace option }}}
1714 diag("Testing --double-y-scale option..."); # {{{
1715 testcmd("../gpst -y -o clean pause.gpx", # {{{
1716 <<END,
1717 5.299534\t120.850988\t25.260
1718 5.299610\t120.850928\t24.931
1719 5.299694\t120.850628\t27.975
1720 5.299741\t120.850768\t31.017
1721 5.299958\t120.850678\t30.980
1722 5.299640\t120.850476\t30.538
1723 5.299686\t120.850492\t30.515
1724 5.299773\t120.85069\t31.936
1725 5.299419\t120.850914\t31.794
1728 "Double y scale, clean output from gpx format",
1731 # }}}
1732 testcmd("../gpst -y -o clean log.dos.mayko", # {{{
1733 <<END,
1734 8.1225077\t116.3636316\t
1735 8.1253200\t116.3637424\t
1736 8.1266031\t116.3632694\t
1737 8.1284612\t116.3624198\t
1738 8.1293950\t116.362063\t
1739 8.1307400\t116.3619242\t
1742 "Double y scale, clean output from mayko format",
1745 # }}}
1746 # --double-y-scale option }}}
1747 diag("Testing --debug option..."); # {{{
1748 # --debug option }}}
1749 diag("Strip error from Mayko format..."); # {{{
1751 testcmd("../gpst -o csv date_error.mayko", # {{{
1752 <<END,
1753 2003-06-13T09:12:36Z\t5.5794667\t60.4280897\t\t
1754 2003-06-13T09:12:38Z\t5.5802255\t60.4281867\t\t
1755 2003-06-13T09:12:41Z\t5.5813636\t60.4283320\t\t
1756 2003-06-13T09:12:42Z\t5.5817430\t60.4283806\t\t
1759 "Strip error from mayko format in csv output",
1762 # }}}
1763 testcmd("../gpst -o clean date_error.mayko", # {{{
1764 <<END,
1765 5.5794667\t60.4280897\t
1766 5.5802255\t60.4281867\t
1767 5.5813636\t60.4283320\t
1768 5.5817430\t60.4283806\t
1771 "Strip error from mayko format in clean output",
1774 # }}}
1775 testcmd("../gpst -o gpsml date_error.mayko", # {{{
1776 <<END,
1777 <?xml version="1.0" encoding="UTF-8"?>
1778 <gpsml>
1779 <track>
1780 <tp> <time>2003-06-13T09:12:36Z</time> <lat>60.4280897</lat> <lon>5.5794667</lon> </tp>
1781 <tp> <time>2003-06-13T09:12:38Z</time> <lat>60.4281867</lat> <lon>5.5802255</lon> </tp>
1782 <etp err="error"> <time>2037-06-25T17:19:22Z</time> <lat>103.4034054</lat> <lon>129.7271053</lon> </etp>
1783 <tp> <time>2003-06-13T09:12:41Z</time> <lat>60.428332</lat> <lon>5.5813636</lon> </tp>
1784 <tp> <time>2003-06-13T09:12:42Z</time> <lat>60.4283806</lat> <lon>5.581743</lon> </tp>
1785 </track>
1786 </gpsml>
1789 "Strip error from mayko format in gpsml output",
1792 # }}}
1793 testcmd("../gpst -o gpx date_error.mayko", # {{{
1794 <<END,
1795 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1796 <gpx
1797 version="1.1"
1798 creator="gpst - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/"
1799 xmlns="http://www.topografix.com/GPX/1/1"
1800 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1801 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
1803 <trk>
1804 <trkseg>
1805 <trkpt lat="60.4280897" lon="5.5794667"> <time>2003-06-13T09:12:36Z</time> </trkpt>
1806 <trkpt lat="60.4281867" lon="5.5802255"> <time>2003-06-13T09:12:38Z</time> </trkpt>
1807 <!-- <trkpt lat="103.4034054" lon="129.7271053"> <time>2037-06-25T17:19:22Z</time> <extensions> <error>error</error> </extensions> </trkpt> -->
1808 <trkpt lat="60.4283320" lon="5.5813636"> <time>2003-06-13T09:12:41Z</time> </trkpt>
1809 <trkpt lat="60.4283806" lon="5.5817430"> <time>2003-06-13T09:12:42Z</time> </trkpt>
1810 </trkseg>
1811 </trk>
1812 </gpx>
1815 "Strip error from mayko format in gpx output",
1818 # }}}
1819 testcmd("../gpst -o gpstrans date_error.mayko", # {{{
1820 <<END,
1821 Format: DMS UTC Offset: 0.00 hrs Datum[100]: WGS 84
1822 T\t06/13/2003 09:12:36\t60\xB025'41.1"\t5\xB034'46.1"
1823 T\t06/13/2003 09:12:38\t60\xB025'41.5"\t5\xB034'48.8"
1824 T\t06/13/2003 09:12:41\t60\xB025'42.0"\t5\xB034'52.9"
1825 T\t06/13/2003 09:12:42\t60\xB025'42.2"\t5\xB034'54.3"
1828 "Strip error from mayko format in gpstrans output",
1831 # }}}
1832 testcmd("../gpst -o pgtab date_error.mayko", # {{{
1833 <<END,
1834 2003-06-13T09:12:36Z\t(60.4280897,5.5794667)\t\\N\t\\N\t\\N\t\\N\t\\N
1835 2003-06-13T09:12:38Z\t(60.4281867,5.5802255)\t\\N\t\\N\t\\N\t\\N\t\\N
1836 2003-06-13T09:12:41Z\t(60.4283320,5.5813636)\t\\N\t\\N\t\\N\t\\N\t\\N
1837 2003-06-13T09:12:42Z\t(60.4283806,5.5817430)\t\\N\t\\N\t\\N\t\\N\t\\N
1840 "Strip error from mayko format in pgtab output",
1843 # }}}
1844 testcmd("../gpst -o poscount date_error.mayko", # {{{
1845 <<END,
1846 5.5802255\t60.4281867\t1
1847 5.5817430\t60.4283806\t1
1848 5.5813636\t60.4283320\t1
1849 5.5794667\t60.4280897\t1
1852 "Strip error from mayko format in poscount output",
1855 # }}}
1856 testcmd("../gpst -o xgraph date_error.mayko", # {{{
1857 <<END,
1858 5.5794667 60.4280897
1859 5.5802255 60.4281867
1860 5.5813636 60.4283320
1861 5.5817430 60.4283806
1864 "Strip error from mayko format in xgraph output",
1867 # }}}
1868 testcmd("../gpst -o ygraph date_error.mayko", # {{{
1869 <<END,
1870 "Time = 0.0
1871 5.5794667 60.4280897
1873 "Time = 2.0
1874 5.5802255 60.4281867
1876 "Time = 5.0
1877 5.5813636 60.4283320
1879 "Time = 6.0
1880 5.5817430 60.4283806
1884 "Strip error from mayko format in ygraph output",
1887 # }}}
1889 # Strip error from Mayko format }}}
1891 todo_section:
1894 if ($Opt{'all'} || $Opt{'todo'}) {
1895 diag("Running TODO tests..."); # {{{
1897 TODO: {
1898 local $TODO = "Remove extra \\n in the beginning";
1899 testcmd("../gpst -o csv multitrack.gpx", # {{{
1900 <<END,
1901 2003-02-11T23:35:39Z\t-0.1448824\t51.4968266\t\t
1902 2003-02-11T23:35:49Z\t-0.1449938\t51.4968227\t\t
1903 2003-02-11T23:36:14Z\t-0.1453202\t51.4969040\t\t
1904 \t\t\t\t
1905 2003-02-11T23:36:16Z\t-0.1453398\t51.4969214\t\t
1906 2003-02-11T23:36:31Z\t-0.1455514\t51.4969816\t\t
1907 2003-02-11T23:36:43Z\t-0.1457489\t51.4970224\t1000\t
1908 2003-02-11T23:36:50Z\t-0.1457804\t51.4970452\t\t
1909 \t\t\t\t
1910 2003-02-11T23:37:05Z\t-0.1458608\t51.4970680\t\t
1911 2003-02-11T23:37:22Z\t-0.1460047\t51.4971658\t\t
1912 2003-02-11T23:37:36Z\t-0.1461614\t51.4972469\t\t
1913 \t\t\t\t
1914 2003-02-11T23:37:43Z\t-0.1462394\t51.4972731\t\t
1915 2003-02-11T23:38:04Z\t-0.1463232\t51.4973437\t\t
1916 2003-02-11T23:38:28Z\t-0.1462949\t51.4973337\t\t
1917 2003-02-11T23:38:34Z\t-0.1462825\t51.4973218\t\t
1918 2003-02-11T23:38:35Z\t-0.1462732\t51.4973145\t\t
1921 "Output csv format from gpx",
1924 # }}}
1925 testcmd("../gpst -o csv pause.gpx", # {{{
1926 <<END,
1927 2006-05-21 16:49:11\t5.299534\t60.425494\t25.260\t
1928 2006-05-21 16:49:46\t5.299610\t60.425464\t24.931\t
1929 2006-05-21 16:52:04\t5.299694\t60.425314\t27.975\t
1930 2006-05-21 16:56:36\t5.299741\t60.425384\t31.017\t
1931 2006-05-21 16:56:47\t5.299958\t60.425339\t30.980\t
1932 2006-05-21 16:56:56\t5.299640\t60.425238\t30.538\t
1933 2006-05-21 16:57:03\t5.299686\t60.425246\t30.515\t
1934 2006-05-21 16:59:08\t5.299773\t60.425345\t31.936\t
1935 2006-05-21 17:00:54\t5.299419\t60.425457\t31.794\t
1938 "csv format from gpx",
1941 # }}}
1942 testcmd("../gpst -e -o csv pause.gpx", # {{{
1943 <<END,
1944 1148230151\t5.299534\t60.425494\t25.260\t
1945 1148230186\t5.299610\t60.425464\t24.931\t
1946 1148230324\t5.299694\t60.425314\t27.975\t
1947 1148230596\t5.299741\t60.425384\t31.017\t
1948 1148230607\t5.299958\t60.425339\t30.980\t
1949 1148230616\t5.299640\t60.425238\t30.538\t
1950 1148230623\t5.299686\t60.425246\t30.515\t
1951 1148230748\t5.299773\t60.425345\t31.936\t
1952 1148230854\t5.299419\t60.425457\t31.794\t
1955 "csv format with epoch seconds from gpx",
1958 # }}}
1959 $TODO = "Use gpsml, this Mayko thing is obsolete.";
1960 testcmd("../gpst -u no_signal.mayko", # {{{
1961 <<END,
1962 <?xml version="1.0" encoding="UTF-8"?>
1963 <gpsml>
1964 <track>
1965 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
1966 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
1967 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
1968 <desc>20021222T214351-20021222T214354: CO: No signal \x7B\x7B\x7B</desc>
1969 <etp err="nosignal"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1970 <etp err="nosignal"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1971 <etp err="nosignal"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1972 <desc>20021222T214351-20021222T214354: CO: No signal \x7D\x7D\x7D</desc>
1973 <break/>
1974 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
1975 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
1976 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
1977 </track>
1978 </gpsml>
1981 "Output gpsml from the -u option",
1983 # }}}
1984 $TODO = "Tweak output";
1985 testcmd("../gpst -o gpx multitrack-pause.gpsml", # {{{
1986 file_data("multitrack-pause.gpx"),
1988 "Should be equal to multitrack-pause.gpx",
1991 # }}}
1992 $TODO = 'Fix it.';
1993 # list_nearest_waypoints() {{{
1995 like(list_nearest_waypoints(60.42541, 5.29959, 3),
1996 qr/^\(.*,.*,.*\)$/,
1997 "list_nearest_waypoints()"
2000 # }}}
2002 # TODO tests }}}
2005 diag("Testing finished.");
2007 sub testcmd {
2008 # {{{
2009 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
2010 my $stderr_cmd = "";
2011 my $deb_str = $Opt{'debug'} ? " --debug" : "";
2012 my $Txt = join("",
2013 "\"$Cmd\"",
2014 defined($Desc)
2015 ? " - $Desc"
2016 : ""
2018 my $TMP_STDERR = "gpst-stderr.tmp";
2020 if (defined($Exp_stderr) && !length($deb_str)) {
2021 $stderr_cmd = " 2>$TMP_STDERR";
2023 is(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt);
2024 if (defined($Exp_stderr)) {
2025 if (!length($deb_str)) {
2026 is(file_data($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
2027 unlink($TMP_STDERR);
2029 } else {
2030 diag("Warning: stderr not defined for '$Txt'");
2032 # }}}
2035 sub file_data {
2036 # Return file content as a string {{{
2037 my $File = shift;
2038 my $Txt;
2039 if (open(FP, "<", $File)) {
2040 $Txt = join("", <FP>);
2041 close(FP);
2042 return($Txt);
2043 } else {
2044 return undef;
2046 # }}}
2049 sub print_version {
2050 # Print program version {{{
2051 for (@main::version_array) {
2052 print("$_\n");
2054 exit(0);
2055 # }}}
2056 } # print_version()
2058 sub usage {
2059 # Send the help message to stdout {{{
2060 my $Retval = shift;
2062 print(<<END);
2064 $rcs_id
2066 Usage: $progname [options] [file [files [...]]]
2068 Contains tests for the gpst(1) program.
2070 Options:
2072 -a, --all
2073 Run all tests, also TODOs.
2074 -h, --help
2075 Show this help.
2076 -t, --todo
2077 Run only the TODO tests.
2078 -v, --verbose
2079 Increase level of verbosity. Can be repeated.
2080 --version
2081 Print version information.
2082 --debug
2083 Print debugging messages.
2086 exit($Retval);
2087 # }}}
2088 } # usage()
2090 sub msg {
2091 # Print a status message to stderr based on verbosity level {{{
2092 my ($verbose_level, $Txt) = @_;
2094 if ($Opt{'verbose'} >= $verbose_level) {
2095 print(STDERR "$progname: $Txt\n");
2097 # }}}
2098 } # msg()
2100 __END__
2102 # Plain Old Documentation (POD) {{{
2104 =pod
2106 =head1 NAME
2108 run-tests.pl
2110 =head1 REVISION
2112 $Id$
2114 =head1 SYNOPSIS
2116 run-tests.pl [options] [file [files [...]]]
2118 =head1 DESCRIPTION
2120 Contains tests for the gpst(1) program.
2122 =head1 OPTIONS
2124 =over 4
2126 =item B<-a>, B<--all>
2128 Run all tests, also TODOs.
2130 =item B<-h>, B<--help>
2132 Print a brief help summary.
2134 =item B<-t>, B<--todo>
2136 Run only the TODO tests.
2138 =item B<-v>, B<--verbose>
2140 Increase level of verbosity. Can be repeated.
2142 =item B<--version>
2144 Print version information.
2146 =item B<--debug>
2148 Print debugging messages.
2150 =back
2152 =head1 AUTHOR
2154 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
2156 =head1 COPYRIGHT
2158 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
2159 This is free software; see the file F<COPYING> for legalese stuff.
2161 =head1 LICENCE
2163 This program is free software; you can redistribute it and/or modify it
2164 under the terms of the GNU General Public License as published by the
2165 Free Software Foundation; either version 2 of the License, or (at your
2166 option) any later version.
2168 This program is distributed in the hope that it will be useful, but
2169 WITHOUT ANY WARRANTY; without even the implied warranty of
2170 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2171 See the GNU General Public License for more details.
2173 You should have received a copy of the GNU General Public License along
2174 with this program; if not, write to the Free Software Foundation, Inc.,
2175 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2177 =head1 SEE ALSO
2179 gpst(1)
2181 =cut
2183 # }}}
2185 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
2186 # End of file $Id$