3 #=======================================================================
8 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
9 # License: GNU General Public License, see end of file for legal stuff.
10 #=======================================================================
13 push(@INC, "$ENV{'HOME'}/bin/src/gpstools");
19 use Test
::More
qw{no_plan
};
40 $progname =~ s
#^.*/(.*?)$#$1#;
43 my $id_date = $rcs_id;
44 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
46 Getopt
::Long
::Configure
("bundling");
48 "all|a" => \
$Opt{'all'},
49 "debug" => \
$Opt{'debug'},
50 "help|h" => \
$Opt{'help'},
51 "todo|t" => \
$Opt{'todo'},
52 "version" => \
$Opt{'version'},
53 ) || die("$progname: Option error. Use -h for help.\n");
56 'gpsbabel' => '/usr/local/bin/gpsbabel',
59 $Opt{'debug'} && ($Debug = 1);
60 $Opt{'help'} && usage
(0);
61 $Opt{'version'} && print_version
();
63 chomp(my $gpx_header = <<END);
64 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
67 creator="gpst - http://svn.sunbase.org/repos/utils/trunk/src/gpstools/"
68 xmlns="http://www.topografix.com/GPX/1/1"
69 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
70 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
74 if ($Opt{'todo'} && !$Opt{'all'}) {
78 diag
("Testing XML routines...");
80 # txt_to_xml() and xml_to_txt() {{{
84 "txt_to_xml(\"abc\")");
87 "txt_to_xml(\"<&>\")");
88 is
(txt_to_xml
("first line\nsecond <\rthird\r\n<&>"),
89 "first line\nsecond <\rthird\r\n<&>",
90 "txt_to_xml() with multiline string");
94 "xml_to_txt(\"abc\")");
95 is
(xml_to_txt
("<&>"),
97 "xml_to_txt(\"<&>\")");
98 is
(xml_to_txt
("first line\nsecond <\rthird\r\n<&>"),
99 "first line\nsecond <\rthird\r\n<&>",
100 "xml_to_txt() with multiline string");
104 diag
("Testing date routines...");
106 # sec_to_string() {{{
108 is
(sec_to_string
(1148220825),
109 "2006-05-21 14:13:45",
110 "sec_to_string() without separator");
111 is
(sec_to_string
(1148220825, "T"),
112 "2006-05-21T14:13:45",
113 "sec_to_string() with separator");
114 is
(sec_to_string
(-5000),
116 "sec_to_string(-5000) — negative numbers unsupported atm");
117 is
(sec_to_string
(""),
119 "sec_to_string(\"\")");
120 is
(sec_to_string
("pH()rtY tW0"),
122 "sec_to_string() with invalid string");
123 is
(sec_to_string
("00000000000000000000001148220825"),
124 "2006-05-21 14:13:45",
125 "sec_to_string() with a bunch of leading zeros");
126 is
(sec_to_string
("1148220825.93"),
127 "2006-05-21 14:13:45.93",
128 "sec_to_string() with decimals");
129 is
(sec_to_string
("000000000000000000000000000001148220825.7312"),
130 "2006-05-21 14:13:45.7312",
131 "sec_to_string() with decimals and prefixing zeros");
132 is
(sec_to_string
("1148220825.93000"),
133 "2006-05-21 14:13:45.93",
134 "sec_to_string() with decimals and extra trailing zeros");
135 is
(sec_to_string
(".863"),
136 "1970-01-01 00:00:00.863",
137 "sec_to_string() with missing zero before decimal point");
140 # sec_to_readable() {{{
142 is
(sec_to_readable
(0),
144 "sec_to_readable(0)");
145 is
(sec_to_readable
("pH()rtY tW0"),
147 "sec_to_readable() with invalid string");
148 is
(sec_to_readable
(86400),
150 "sec_to_readable(86400)");
151 is
(sec_to_readable
(86400*1000),
153 "sec_to_readable(86400*1000)");
154 is
(sec_to_readable
(86400+7200+180+4),
156 "sec_to_readable(86400+7200+180+4)");
157 is
(sec_to_readable
("3.14"),
159 "sec_to_readable(\"3.14\")");
160 is
(sec_to_readable
("-124"),
162 "sec_to_readable() rejects negative numbers");
163 is
(sec_to_readable
("-2.34"),
165 "sec_to_readable() rejects negative decimal");
166 is
(sec_to_readable
(".87"),
168 "sec_to_readable(), missing zero before decimal point");
169 is
(sec_to_readable
(""),
171 "sec_to_readable() with empty string");
175 diag
("Testing geo routines...");
179 is
(ddd_to_dms
("12.34567"),
181 "ddd_to_dms(\"12.34567\")");
185 "ddd_to_dms(\"0\")");
191 is
(ddd_to_dms
("pH()rtY tW0"),
193 "ddd_to_dms(\"pH()rtY tW0\")");
195 is
(ddd_to_dms
("-12.34567"),
197 "ddd_to_dms(\"-12.34567\")");
199 is
(ddd_to_dms
("0.34567"),
201 "ddd_to_dms(\"0.34567\")");
203 is
(ddd_to_dms
(".34567"),
205 "ddd_to_dms(\".34567\")");
207 is
(ddd_to_dms
("-.34567"),
209 "ddd_to_dms(\"-.34567\")");
211 is
(ddd_to_dms
("-0.34567"),
213 "ddd_to_dms(\"-0.34567\")");
215 is
(ddd_to_dms
("180"),
217 "ddd_to_dms(\"180\")");
219 is
(ddd_to_dms
("-180"),
221 "ddd_to_dms(\"-180\")");
225 "ddd_to_dms(\"-1\")");
227 is
(ddd_to_dms
("2-3"),
229 "ddd_to_dms(\"2-3\")");
233 like
(distance
(60.42541, 5.29959, 60.42424, 5.30177, "metre"),
235 "distance() returns a decimal number"
239 # list_nearest_waypoints() {{{
241 like
(list_nearest_waypoints
(60.42541, 5.29959, 3),
243 "list_nearest_waypoints()");
247 diag
("Testing trackpoint()...");
255 "trackpoint() receives empty hash");
274 # trackpoint() (gpsml) {{{
278 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
279 "trackpoint() (gpsml)"
283 # trackpoint() (gpx) {{{
285 $Dat{'format'} = "gpx";
288 qq{ <trkpt lat
="59.5214" lon
="7.392133"> <ele
>762</ele> <time>2003-06-13T14:36:10Z</time> </trkpt
>\n},
294 # trackpoint(): Various loop tests {{{
296 for my $Elem (qw{format lat lon type
}) {
299 $Dat{"$Elem"} = '2d';
302 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") returns undef"
307 for my $Elem (qw{year month day hour min sec
}) {
314 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
315 "trackpoint(): {'$Elem'} with empty value skips time"
319 $Dat{"$Elem"} = '2d';
321 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
322 "trackpoint(): {'$Elem'} with invalid value (\"$Dat{$Elem}\") skips time"
326 $Dat{$Elem} = "00000$Dat{$Elem}";
328 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
329 "trackpoint(): Strip prefixing zeros from {'$Elem'}"
333 $Dat{"$Elem"} = 0-$Dat{$Elem};
335 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
336 "trackpoint(): {'$Elem'} is negative, skip time"
339 if ($Elem ne "sec") {
341 $Dat{"$Elem"} = "$Dat{$Elem}.00";
343 "<tp> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
344 "trackpoint(): Decimals in {'$Elem'}, skip time"
352 $Dat{'sec'} = "$Dat{'sec'}.00";
354 "<tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>\n",
355 "trackpoint(): Remove trailing zeros in {'sec'} decimals"
358 for my $Elem (qw{format type error
}) {
363 "trackpoint(): Missing {'$Elem'}, return undef"
367 # Various loop tests }}}
371 diag
("Testing output from ../gpst");
373 like
(`../gpst --version`, # {{{
374 qr/^(\$Id: .*? \$\n)+$/s,
375 "../gpst --version");
378 testcmd
("../gpst </dev/null", # {{{
380 <?xml version="1.0" encoding="UTF-8"?>
389 testcmd
("../gpst -o gpx </dev/null", # {{{
401 testcmd
("../gpst --fix --chronology chronology-error.gpsml 2>chronofix.tmp", # {{{
403 <?xml version="1.0" encoding="UTF-8"?>
406 <title>\$Id: chronology-error.gpsml 1774 2006-05-20 02:48:39Z sunny \$</title>
407 <tp> <time>2006-05-02T09:46:37Z</time> <lat>60.45369</lat> <lon>5.31559</lon> <ele>95</ele> </tp>
408 <tp> <time>2006-05-02T09:46:42Z</time> <lat>60.45353</lat> <lon>5.31548</lon> <ele>94</ele> </tp>
409 <tp> <time>2006-05-02T09:46:46Z</time> <lat>60.45353</lat> <lon>5.31561</lon> <ele>94</ele> </tp>
411 <etp err="chrono"> <time>2006-05-02T09:40:07Z</time> <lat>60.45369</lat> <lon>5.31597</lon> <desc>Out of chronology</desc> </etp>
413 <pause>0:00:37:54</pause>
414 <tp> <time>2006-05-02T10:18:01Z</time> <lat>60.45418</lat> <lon>5.31517</lon> <ele>92</ele> </tp>
415 <tp> <time>2006-05-02T10:18:06Z</time> <lat>60.45407</lat> <lon>5.31542</lon> <ele>91</ele> </tp>
416 <tp> <time>2006-05-02T10:18:09Z</time> <lat>60.45401</lat> <lon>5.31543</lon> <ele>98</ele> </tp>
417 <tp> <time>2006-05-02T10:18:10Z</time> <lat>60.45395</lat> <lon>5.31544</lon> <ele>103</ele> </tp>
418 <tp> <time>2006-05-02T10:18:11Z</time> <lat>60.45391</lat> <lon>5.31545</lon> <ele>107</ele> </tp>
422 "Remove bad timestamps",
426 is
(file_data
("chronofix.tmp"), # {{{
427 "gpst: \"2006-05-02T09:46:46Z\": Next date is 0:00:06:39 in the past (2006-05-02T09:40:07Z)\n",
428 "Warning from --chronology --fix");
429 unlink("chronofix.tmp") || warn("chronofix.tmp: Cannot delete file: $!\n");
432 testcmd
("../gpst -t pause.gpx", # {{{
434 <?xml version="1.0" encoding="UTF-8"?>
437 <title>ACTIVE LOG164705</title>
438 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
439 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
440 <pause>0:00:02:18</pause>
441 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
442 <pause>0:00:04:32</pause>
443 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
444 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
445 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
446 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
447 <pause>0:00:02:05</pause>
448 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
449 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
453 "Output gpsml with <pause> elements from GPX files",
457 testcmd
("../gpst -o gpx no_signal.mayko", # {{{
462 <trkpt lat="70.6800486" lon="23.6746151"> <time>2002-12-22T21:42:24Z</time> </trkpt>
463 <trkpt lat="70.6799322" lon="23.6740038"> <time>2002-12-22T21:42:32Z</time> </trkpt>
464 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:42:54Z</time> </trkpt>
465 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:51Z</time> </trkpt>
466 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:52Z</time> </trkpt>
467 <trkpt lat="70.6796266" lon="23.6723991"> <time>2002-12-22T21:43:54Z</time> </trkpt>
468 <trkpt lat="70.6800774" lon="23.6757566"> <time>2002-12-22T21:44:45Z</time> </trkpt>
469 <trkpt lat="70.6801502" lon="23.6753442"> <time>2002-12-22T21:44:52Z</time> </trkpt>
470 <trkpt lat="70.6801905" lon="23.6757542"> <time>2002-12-22T21:45:04Z</time> </trkpt>
475 "Output GPX from Mayko file with duplicates",
479 testcmd
("../gpst -d no_signal.mayko", # {{{
481 <?xml version="1.0" encoding="UTF-8"?>
484 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
485 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
486 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
487 <etp err="dup"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
488 <etp err="dup"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
489 <etp err="dup"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
490 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
491 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
492 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
496 "Remove duplicated positions",
500 testcmd
("../gpst --round lat=4,lon=5,ele=1 pause.gpx", # {{{
502 <?xml version="1.0" encoding="UTF-8"?>
505 <title>ACTIVE LOG164705</title>
506 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.4255</lat> <lon>5.29953</lon> <ele>25.3</ele> </tp>
507 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.4255</lat> <lon>5.29961</lon> <ele>24.9</ele> </tp>
508 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.4253</lat> <lon>5.29969</lon> <ele>28</ele> </tp>
509 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.4254</lat> <lon>5.29974</lon> <ele>31</ele> </tp>
510 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.4253</lat> <lon>5.29996</lon> <ele>31</ele> </tp>
511 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.4252</lat> <lon>5.29964</lon> <ele>30.5</ele> </tp>
512 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.4252</lat> <lon>5.29969</lon> <ele>30.5</ele> </tp>
513 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.4253</lat> <lon>5.29977</lon> <ele>31.9</ele> </tp>
514 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.4255</lat> <lon>5.29942</lon> <ele>31.8</ele> </tp>
521 testcmd
("../gpst -u no_signal.mayko >nosignal.tmp", # {{{
527 testcmd
("../gpst -u no_signal.mayko", # {{{
529 xmaplog 1.0 Mon Dec 23 02:00:50 2002
530 1 70.6800486 23.6746151 57.4 0 12/22/2002 21:42:24
531 1 70.6799322 23.6740038 6.3 0 12/22/2002 21:42:32
532 1 70.6796266 23.6723991 6.0 0 12/22/2002 21:42:54
533 # 20021222T214351-20021222T214354: CO: No signal \x7B\x7B\x7B
534 # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:51
535 # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:52
536 # 1 70.6796266 23.6723991 0.0 0 12/22/2002 21:43:54
537 # 20021222T214351-20021222T214354: CO: No signal \x7D\x7D\x7D
539 1 70.6800774 23.6757566 5.1 0 12/22/2002 21:44:45
540 1 70.6801502 23.6753442 4.8 0 12/22/2002 21:44:52
541 1 70.6801905 23.6757542 2.5 0 12/22/2002 21:45:04
543 "Read Mayko format with no signal, output old Mayko format",
547 testcmd
("../gpst nosignal.tmp", # {{{
549 <?xml version="1.0" encoding="UTF-8"?>
552 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
553 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
554 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
555 <desc>20021222T214351-20021222T214354: CO: No signal \x7B\x7B\x7B</desc>
556 <etp err="desc"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
557 <etp err="desc"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
558 <etp err="desc"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
559 <desc>20021222T214351-20021222T214354: CO: No signal \x7D\x7D\x7D</desc>
561 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
562 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
563 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
567 "Read output from 'gpst -u *.mayko'",
571 unlink("nosignal.tmp") || warn("nosignal.tmp: Cannot delete file: $!\n");
572 testcmd
("../gpst log.mcsv", # {{{
574 <?xml version="1.0" encoding="UTF-8"?>
578 <title>ACTIVE LOG 125</title>
579 <tp> <time>2006-03-04T11:12:30Z</time> <lat>54.96883</lat> <lon>-1.62439</lon> <ele>77</ele> </tp>
580 <tp> <time>2006-03-04T11:12:47Z</time> <lat>54.96878</lat> <lon>-1.62413</lon> <ele>77</ele> </tp>
581 <tp> <time>2006-03-04T11:12:55Z</time> <lat>54.96913</lat> <lon>-1.62616</lon> <ele>77</ele> </tp>
582 <tp> <time>2006-03-04T11:13:04Z</time> <lat>54.96934</lat> <lon>-1.62624</lon> <ele>77.5</ele> </tp>
583 <tp> <time>2006-03-04T11:13:33Z</time> <lat>54.96934</lat> <lon>-1.62596</lon> <ele>78</ele> </tp>
584 <tp> <time>2006-03-04T11:13:48Z</time> <lat>54.96931</lat> <lon>-1.62645</lon> <ele>78</ele> </tp>
585 <tp> <time>2006-03-04T11:14:05Z</time> <lat>54.96918</lat> <lon>-1.62603</lon> <ele>79</ele> </tp>
586 <tp> <time>2006-03-04T11:14:33Z</time> <lat>54.96901</lat> <lon>-1.62364</lon> <ele>76.1</ele> </tp>
587 <tp> <time>2006-03-04T11:15:02Z</time> <lat>54.96922</lat> <lon>-1.6254</lon> <ele>76.1</ele> </tp>
588 <tp> <time>2006-03-04T11:15:27Z</time> <lat>54.96914</lat> <lon>-1.62526</lon> <ele>75.1</ele> </tp>
589 <tp> <time>2006-03-04T11:15:50Z</time> <lat>54.96911</lat> <lon>-1.62494</lon> <ele>75.1</ele> </tp>
590 <tp> <time>2006-03-04T11:16:03Z</time> <lat>54.9693</lat> <lon>-1.62489</lon> <ele>75.1</ele> </tp>
591 <tp> <time>2006-03-04T11:16:19Z</time> <lat>54.96901</lat> <lon>-1.62496</lon> <ele>75.1</ele> </tp>
592 <tp> <time>2006-03-04T11:16:52Z</time> <lat>54.96871</lat> <lon>-1.62466</lon> <ele>74.6</ele> </tp>
593 <tp> <time>2006-03-04T11:17:25Z</time> <lat>54.96908</lat> <lon>-1.62488</lon> <ele>72.7</ele> </tp>
595 <title>ACTIVE LOG 126</title>
596 <tp> <time>2006-03-04T11:18:32Z</time> <lat>54.96904</lat> <lon>-1.62482</lon> <ele>72.7</ele> </tp>
597 <tp> <time>2006-03-04T11:18:35Z</time> <lat>54.96913</lat> <lon>-1.62499</lon> <ele>71.3</ele> </tp>
598 <tp> <time>2006-03-04T11:18:38Z</time> <lat>54.96904</lat> <lon>-1.62497</lon> <ele>70.8</ele> </tp>
599 <tp> <time>2006-03-04T11:18:48Z</time> <lat>54.96913</lat> <lon>-1.62496</lon> <ele>71.8</ele> </tp>
600 <tp> <time>2006-03-04T11:18:55Z</time> <lat>54.96924</lat> <lon>-1.62501</lon> <ele>72.2</ele> </tp>
601 <tp> <time>2006-03-04T11:19:11Z</time> <lat>54.9694</lat> <lon>-1.62521</lon> <ele>71.8</ele> </tp>
602 <tp> <time>2006-03-04T11:19:30Z</time> <lat>54.96916</lat> <lon>-1.62515</lon> <ele>71.3</ele> </tp>
603 <tp> <time>2006-03-04T11:19:53Z</time> <lat>54.96921</lat> <lon>-1.625</lon> <ele>71.3</ele> </tp>
604 <tp> <time>2006-03-04T11:20:21Z</time> <lat>54.96801</lat> <lon>-1.62417</lon> <ele>71.8</ele> </tp>
606 <title>ACTIVE LOG 127</title>
607 <tp> <time>2006-03-04T11:21:16Z</time> <lat>54.96887</lat> <lon>-1.62504</lon> <ele>70.8</ele> </tp>
608 <tp> <time>2006-03-04T11:21:18Z</time> <lat>54.96898</lat> <lon>-1.62476</lon> <ele>69.8</ele> </tp>
609 <tp> <time>2006-03-04T11:21:29Z</time> <lat>54.9691</lat> <lon>-1.62475</lon> <ele>69.4</ele> </tp>
610 <tp> <time>2006-03-04T11:21:46Z</time> <lat>54.96918</lat> <lon>-1.62468</lon> <ele>70.3</ele> </tp>
611 <tp> <time>2006-03-04T11:22:39Z</time> <lat>54.9692</lat> <lon>-1.62465</lon> <ele>69.4</ele> </tp>
612 <tp> <time>2006-03-04T11:22:43Z</time> <lat>54.96924</lat> <lon>-1.62462</lon> <ele>71.8</ele> </tp>
613 <tp> <time>2006-03-04T11:22:45Z</time> <lat>54.96928</lat> <lon>-1.62463</lon> <ele>71.8</ele> </tp>
614 <tp> <time>2006-03-04T11:23:00Z</time> <lat>54.96945</lat> <lon>-1.62466</lon> <ele>69.4</ele> </tp>
618 "Read Mapsource TAB-separated format",
622 testcmd
("../gpst two-digit_year.mcsv", # {{{
624 <?xml version="1.0" encoding="UTF-8"?>
628 <title>ACTIVE LOG 032</title>
629 <tp> <time>2006-03-20T20:35:33Z</time> <lat>60.41324</lat> <lon>5.33352</lon> <ele>14</ele> </tp>
630 <tp> <time>2006-03-20T20:35:38Z</time> <lat>60.38802</lat> <lon>5.33845</lon> <ele>18</ele> </tp>
631 <tp> <time>2006-03-20T20:35:44Z</time> <lat>60.38709</lat> <lon>5.3379</lon> <ele>19</ele> </tp>
632 <tp> <time>2006-03-20T20:35:49Z</time> <lat>60.38641</lat> <lon>5.33732</lon> <ele>18</ele> </tp>
633 <tp> <time>2006-03-20T20:35:54Z</time> <lat>60.38581</lat> <lon>5.33647</lon> <ele>18</ele> </tp>
634 <tp> <time>2006-03-20T20:36:00Z</time> <lat>60.38516</lat> <lon>5.33528</lon> <ele>15</ele> </tp>
635 <tp> <time>2006-03-20T20:36:02Z</time> <lat>60.38495</lat> <lon>5.3349</lon> <ele>13</ele> </tp>
639 "Read Mapsource TAB-separated format with two-digit year",
643 testcmd
("../gpst log.gpstxt", # {{{
645 <?xml version="1.0" encoding="UTF-8"?>
648 <tp> <time>2003-06-13T14:36:09Z</time> <lat>59.521517</lat> <lon>7.391867</lon> <ele>762</ele> </tp>
649 <tp> <time>2003-06-13T14:36:10Z</time> <lat>59.5214</lat> <lon>7.392133</lon> <ele>762</ele> </tp>
650 <tp> <time>2003-06-13T14:36:11Z</time> <lat>59.5213</lat> <lon>7.392417</lon> <ele>761</ele> </tp>
651 <tp> <time>2003-06-13T14:36:12Z</time> <lat>59.521183</lat> <lon>7.3927</lon> <ele>761</ele> </tp>
652 <etp err="nosignal"> <time>2003-06-13T14:36:13Z</time> </etp>
653 <tp> <time>2003-06-13T14:36:15Z</time> <lat>59.52085</lat> <lon>7.393517</lon> <ele>760</ele> </tp>
654 <tp> <time>2003-06-13T14:36:16Z</time> <lat>59.520733</lat> <lon>7.393783</lon> <ele>760</ele> </tp>
655 <tp> <time>2003-06-13T14:36:17Z</time> <lat>59.52065</lat> <lon>7.39405</lon> <ele>760</ele> </tp>
656 <tp> <time>2003-06-13T14:36:18Z</time> <lat>59.520583</lat> <lon>7.394333</lon> <ele>760</ele> </tp>
657 <tp> <time>2003-06-13T14:36:19Z</time> <lat>59.520533</lat> <lon>7.394633</lon> <ele>759</ele> </tp>
658 <tp> <time>2003-06-13T14:36:20Z</time> <lat>59.520483</lat> <lon>7.394917</lon> <ele>759</ele> </tp>
659 <tp> <time>2003-06-13T14:36:21Z</time> <lat>59.520433</lat> <lon>7.395233</lon> <ele>759</ele> </tp>
660 <etp err="nosignal"> <time>2003-06-13T14:36:22Z</time> </etp>
661 <tp> <time>2003-06-13T14:36:24Z</time> <lat>59.520283</lat> <lon>7.396233</lon> <ele>758</ele> </tp>
662 <tp> <time>2003-06-13T14:36:25Z</time> <lat>59.520233</lat> <lon>7.39655</lon> <ele>758</ele> </tp>
663 <tp> <time>2003-06-13T14:36:26Z</time> <lat>59.520183</lat> <lon>7.396883</lon> <ele>757</ele> </tp>
664 <tp> <time>2003-06-13T14:36:27Z</time> <lat>59.520133</lat> <lon>7.397217</lon> <ele>757</ele> </tp>
665 <tp> <time>2003-06-13T14:36:28Z</time> <lat>59.5201</lat> <lon>7.397567</lon> <ele>757</ele> </tp>
669 "Read Garmin serial text format",
673 testcmd
("../gpst log.dos.mayko", # {{{
675 <?xml version="1.0" encoding="UTF-8"?>
678 <tp> <time>2003-06-15T10:27:45Z</time> <lat>58.1818158</lat> <lon>8.1225077</lon> </tp>
679 <tp> <time>2003-06-15T10:27:53Z</time> <lat>58.1818712</lat> <lon>8.12532</lon> </tp>
680 <tp> <time>2003-06-15T10:27:57Z</time> <lat>58.1816347</lat> <lon>8.1266031</lon> </tp>
681 <tp> <time>2003-06-15T10:28:03Z</time> <lat>58.1812099</lat> <lon>8.1284612</lon> </tp>
682 <tp> <time>2003-06-15T10:28:06Z</time> <lat>58.1810315</lat> <lon>8.129395</lon> </tp>
683 <tp> <time>2003-06-15T10:28:10Z</time> <lat>58.1809621</lat> <lon>8.13074</lon> </tp>
687 "Read DOS-formatted Mayko format",
691 testcmd
("../gpst log.dos.gpstxt", # {{{
693 <?xml version="1.0" encoding="UTF-8"?>
696 <tp> <time>2003-01-05T16:47:11Z</time> <lat>66.908167</lat> <lon>15.022983</lon> <ele>11472</ele> </tp>
697 <tp> <time>2003-01-05T16:47:12Z</time> <lat>66.90625</lat> <lon>15.020667</lon> <ele>11472</ele> </tp>
698 <tp> <time>2003-01-05T16:47:13Z</time> <lat>66.904317</lat> <lon>15.01835</lon> <ele>11472</ele> </tp>
699 <tp> <time>2003-01-05T16:47:14Z</time> <lat>66.9024</lat> <lon>15.016017</lon> <ele>11473</ele> </tp>
700 <tp> <time>2003-01-05T16:47:15Z</time> <lat>66.900483</lat> <lon>15.0137</lon> <ele>11474</ele> </tp>
701 <tp> <time>2003-01-05T16:47:16Z</time> <lat>66.898567</lat> <lon>15.011383</lon> <ele>11474</ele> </tp>
702 <tp> <time>2003-01-05T16:47:17Z</time> <lat>66.896633</lat> <lon>15.009067</lon> <ele>11475</ele> </tp>
703 <tp> <time>2003-01-05T16:47:18Z</time> <lat>66.894717</lat> <lon>15.006733</lon> <ele>11475</ele> </tp>
704 <tp> <time>2003-01-05T16:47:19Z</time> <lat>66.8928</lat> <lon>15.004417</lon> <ele>11475</ele> </tp>
705 <tp> <time>2003-01-05T16:47:20Z</time> <lat>66.890867</lat> <lon>15.0021</lon> <ele>11475</ele> </tp>
706 <tp> <time>2003-01-05T16:47:21Z</time> <lat>66.88895</lat> <lon>14.999783</lon> <ele>11475</ele> </tp>
710 "Read DOS-formatted Garmin serial text format",
714 testcmd
("../gpst log.unix.mcsv", # {{{
716 <?xml version="1.0" encoding="UTF-8"?>
720 <title>ACTIVE LOG 058</title>
721 <tp> <time>2006-02-21T15:14:25Z</time> <lat>60.36662</lat> <lon>5.24885</lon> <ele>31.9</ele> </tp>
722 <tp> <time>2006-02-21T15:14:30Z</time> <lat>60.37057</lat> <lon>5.22956</lon> <ele>35.2</ele> </tp>
723 <tp> <time>2006-02-21T15:14:35Z</time> <lat>60.37019</lat> <lon>5.22817</lon> <ele>39.6</ele> </tp>
724 <tp> <time>2006-02-21T15:14:36Z</time> <lat>60.37012</lat> <lon>5.2279</lon> <ele>41</ele> </tp>
725 <tp> <time>2006-02-21T15:14:40Z</time> <lat>60.37009</lat> <lon>5.22682</lon> <ele>47.2</ele> </tp>
726 <tp> <time>2006-02-21T15:14:42Z</time> <lat>60.37011</lat> <lon>5.22641</lon> <ele>49.2</ele> </tp>
727 <tp> <time>2006-02-21T15:14:44Z</time> <lat>60.37011</lat> <lon>5.22607</lon> <ele>50.1</ele> </tp>
728 <tp> <time>2006-02-21T15:14:48Z</time> <lat>60.37002</lat> <lon>5.22568</lon> <ele>51.1</ele> </tp>
729 <tp> <time>2006-02-21T15:14:51Z</time> <lat>60.3701</lat> <lon>5.22548</lon> <ele>52.5</ele> </tp>
733 "Read UNIX-formatted Garmin Mapsource TAB-separated format",
737 testcmd
("../gpst multitrack.gpx", # {{{
739 <?xml version="1.0" encoding="UTF-8"?>
742 <title>Track 1</title>
743 <tp> <time>2003-02-11T23:35:39Z</time> <lat>51.4968266</lat> <lon>-0.1448824</lon> </tp>
744 <tp> <time>2003-02-11T23:35:49Z</time> <lat>51.4968227</lat> <lon>-0.1449938</lon> </tp>
745 <tp> <time>2003-02-11T23:36:14Z</time> <lat>51.496904</lat> <lon>-0.1453202</lon> </tp>
747 <title>Track 2</title>
748 <tp> <time>2003-02-11T23:36:16Z</time> <lat>51.4969214</lat> <lon>-0.1453398</lon> </tp>
749 <tp> <time>2003-02-11T23:36:31Z</time> <lat>51.4969816</lat> <lon>-0.1455514</lon> </tp>
750 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
751 <tp> <time>2003-02-11T23:36:50Z</time> <lat>51.4970452</lat> <lon>-0.1457804</lon> </tp>
753 <title>Track 3</title>
754 <tp> <time>2003-02-11T23:37:05Z</time> <lat>51.497068</lat> <lon>-0.1458608</lon> </tp>
755 <tp> <time>2003-02-11T23:37:22Z</time> <lat>51.4971658</lat> <lon>-0.1460047</lon> </tp>
756 <tp> <time>2003-02-11T23:37:36Z</time> <lat>51.4972469</lat> <lon>-0.1461614</lon> </tp>
758 <title>Track 4</title>
759 <tp> <time>2003-02-11T23:37:43Z</time> <lat>51.4972731</lat> <lon>-0.1462394</lon> </tp>
760 <tp> <time>2003-02-11T23:38:04Z</time> <lat>51.4973437</lat> <lon>-0.1463232</lon> </tp>
761 <tp> <time>2003-02-11T23:38:28Z</time> <lat>51.4973337</lat> <lon>-0.1462949</lon> </tp>
762 <tp> <time>2003-02-11T23:38:34Z</time> <lat>51.4973218</lat> <lon>-0.1462825</lon> </tp>
763 <tp> <time>2003-02-11T23:38:35Z</time> <lat>51.4973145</lat> <lon>-0.1462732</lon> </tp>
767 "Read GPX file with multiple tracks",
771 testcmd
("../gpst compact.gpx", # {{{
773 <?xml version="1.0" encoding="UTF-8"?>
776 <title>All whitespace stripped</title>
777 <tp> <time>2002-12-30T15:22:04Z</time> <lat>70.660932</lat> <lon>23.7028354</lon> </tp>
778 <tp> <time>2002-12-30T15:22:06Z</time> <lat>70.6609392</lat> <lon>23.7028468</lon> </tp>
779 <tp> <time>2002-12-30T15:22:08Z</time> <lat>70.6609429</lat> <lon>23.7028499</lon> </tp>
780 <tp> <time>2002-12-30T15:22:11Z</time> <lat>70.6609381</lat> <lon>23.702862</lon> </tp>
781 <tp> <time>2002-12-30T15:22:12Z</time> <lat>70.6609368</lat> <lon>23.7028648</lon> </tp>
782 <tp> <time>2002-12-30T15:22:13Z</time> <lat>70.6609344</lat> <lon>23.7028652</lon> </tp>
783 <tp> <time>2002-12-30T15:22:15Z</time> <lat>70.6609349</lat> <lon>23.7028707</lon> </tp>
784 <tp> <time>2002-12-30T15:22:17Z</time> <lat>70.6609348</lat> <lon>23.7028654</lon> </tp>
785 <tp> <time>2002-12-30T15:22:19Z</time> <lat>70.6609347</lat> <lon>23.7028599</lon> </tp>
786 <tp> <time>2002-12-30T15:22:20Z</time> <lat>70.6609348</lat> <lon>23.7028609</lon> </tp>
787 <tp> <time>2002-12-30T15:22:23Z</time> <lat>70.6609388</lat> <lon>23.7028653</lon> </tp>
788 <tp> <time>2002-12-30T15:22:25Z</time> <lat>70.6609426</lat> <lon>23.7028732</lon> </tp>
792 "Read GPX one-liner",
796 testcmd
("../gpst -re multitrack.gpx", # {{{
798 <?xml version="1.0" encoding="UTF-8"?>
801 <title>Track 1</title>
803 <title>Track 2</title>
804 <tp> <time>2003-02-11T23:36:43Z</time> <lat>51.4970224</lat> <lon>-0.1457489</lon> <ele>1000</ele> </tp>
806 <title>Track 3</title>
808 <title>Track 4</title>
812 "Require elevation from GPX data",
816 testcmd
("../gpst -re one_ele.dos.gpsml", # {{{
818 <?xml version="1.0" encoding="UTF-8"?>
821 <title>Only one point has elevation</title>
822 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
826 "Require elevation from gpsml",
830 testcmd
("../gpst missing.gpsml", # {{{
832 <?xml version="1.0" encoding="UTF-8"?>
835 <title>Missing various elements</title>
836 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
837 <tp> <time>2006-04-30T17:17:00Z</time> </tp>
838 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
839 <tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
840 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
841 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
842 <tp> <ele>484</ele> </tp>
843 <tp> <ele>486</ele> </tp>
844 <tp> <desc>Missing everything</desc> </tp>
845 <tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
846 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
850 "Read gpsml with various data missing",
854 my $stripped_gpx_header = $gpx_header;
855 $stripped_gpx_header =~ s/^\s*(.*)$/$1/mg;
856 testcmd
("../gpst -w -o gpx pause.gpx", # {{{
861 <trkpt lat="60.425494" lon="5.299534"><ele>25.260</ele><time>2006-05-21T16:49:11Z</time></trkpt>
862 <trkpt lat="60.425464" lon="5.299610"><ele>24.931</ele><time>2006-05-21T16:49:46Z</time></trkpt>
863 <trkpt lat="60.425314" lon="5.299694"><ele>27.975</ele><time>2006-05-21T16:52:04Z</time></trkpt>
864 <trkpt lat="60.425384" lon="5.299741"><ele>31.017</ele><time>2006-05-21T16:56:36Z</time></trkpt>
865 <trkpt lat="60.425339" lon="5.299958"><ele>30.980</ele><time>2006-05-21T16:56:47Z</time></trkpt>
866 <trkpt lat="60.425238" lon="5.299640"><ele>30.538</ele><time>2006-05-21T16:56:56Z</time></trkpt>
867 <trkpt lat="60.425246" lon="5.299686"><ele>30.515</ele><time>2006-05-21T16:57:03Z</time></trkpt>
868 <trkpt lat="60.425345" lon="5.299773"><ele>31.936</ele><time>2006-05-21T16:59:08Z</time></trkpt>
869 <trkpt lat="60.425457" lon="5.299419"><ele>31.794</ele><time>2006-05-21T17:00:54Z</time></trkpt>
874 "Strip whitespace from GPX output",
880 local $TODO = "Shall lat/lon be cleared if one is missing?";
881 testcmd
("../gpst -re missing.gpsml", # {{{
883 <?xml version="1.0" encoding="UTF-8"?>
886 <title>Missing various elements</title>
887 <tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
888 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
889 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
890 <tp> <ele>484</ele> </tp>
891 <tp> <ele>486</ele> </tp>
892 <tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
893 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
901 testcmd
("../gpst -rt missing.gpsml", # {{{
903 <?xml version="1.0" encoding="UTF-8"?>
906 <title>Missing various elements</title>
907 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
908 <tp> <time>2006-04-30T17:17:00Z</time> </tp>
909 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
910 <tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
911 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
912 <tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
913 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
921 testcmd
("../gpst -rp missing.gpsml", # {{{
923 <?xml version="1.0" encoding="UTF-8"?>
926 <title>Missing various elements</title>
927 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
928 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
929 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
937 testcmd
("../gpst -ret missing.gpsml", # {{{
939 <?xml version="1.0" encoding="UTF-8"?>
942 <title>Missing various elements</title>
943 <tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
944 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
945 <tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
946 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
950 "Require elevation and time",
954 testcmd
("../gpst -retp missing.gpsml", # {{{
956 <?xml version="1.0" encoding="UTF-8"?>
959 <title>Missing various elements</title>
960 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
964 "Require elevation, time and position",
968 testcmd
("../gpst -rep missing.gpsml", # {{{
970 <?xml version="1.0" encoding="UTF-8"?>
973 <title>Missing various elements</title>
974 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
975 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
979 "Require elevation and position",
985 testcmd
("../gpst -o gpx missing.gpsml", # {{{
990 <trkpt lat="60.42353" lon="5.34185"> <time>2006-04-30T17:17:09Z</time> </trkpt>
991 <trkpt> <ele>483</ele> <time>2006-04-30T17:17:11Z</time> </trkpt>
992 <trkpt> <ele>485</ele> <time>2006-04-30T17:17:22Z</time> </trkpt>
993 <trkpt lat="60.42347" lon="5.34212"> <ele>486</ele> </trkpt>
994 <trkpt> <ele>484</ele> </trkpt>
995 <trkpt> <ele>486</ele> </trkpt>
996 <trkpt> <ele>490</ele> <time>2006-04-30T17:18:03Z</time> </trkpt>
997 <trkpt lat="60.42338" lon="5.34269"> <ele>487</ele> <time>2006-04-30T17:18:05Z</time> </trkpt>
1002 "Output GPX from gpsml with missing data",
1006 testcmd
("echo '<tp> </tp>' | ../gpst", # {{{
1008 <?xml version="1.0" encoding="UTF-8"?>
1014 "Don’t print empty trackpoints");
1017 testcmd
("../gpst --epoch pause.gpx", # {{{
1019 <?xml version="1.0" encoding="UTF-8"?>
1022 <title>ACTIVE LOG164705</title>
1023 <tp> <time>2006-05-21T16:49:11Z</time> <lat>60.425494</lat> <lon>5.299534</lon> <ele>25.26</ele> </tp>
1024 <tp> <time>2006-05-21T16:49:46Z</time> <lat>60.425464</lat> <lon>5.29961</lon> <ele>24.931</ele> </tp>
1025 <tp> <time>2006-05-21T16:52:04Z</time> <lat>60.425314</lat> <lon>5.299694</lon> <ele>27.975</ele> </tp>
1026 <tp> <time>2006-05-21T16:56:36Z</time> <lat>60.425384</lat> <lon>5.299741</lon> <ele>31.017</ele> </tp>
1027 <tp> <time>2006-05-21T16:56:47Z</time> <lat>60.425339</lat> <lon>5.299958</lon> <ele>30.98</ele> </tp>
1028 <tp> <time>2006-05-21T16:56:56Z</time> <lat>60.425238</lat> <lon>5.29964</lon> <ele>30.538</ele> </tp>
1029 <tp> <time>2006-05-21T16:57:03Z</time> <lat>60.425246</lat> <lon>5.299686</lon> <ele>30.515</ele> </tp>
1030 <tp> <time>2006-05-21T16:59:08Z</time> <lat>60.425345</lat> <lon>5.299773</lon> <ele>31.936</ele> </tp>
1031 <tp> <time>2006-05-21T17:00:54Z</time> <lat>60.425457</lat> <lon>5.299419</lon> <ele>31.794</ele> </tp>
1035 "--epoch is ignored in gpsml output",
1039 testcmd
("../gpst --epoch -o gpx pause.gpx", # {{{
1044 <trkpt lat="60.425494" lon="5.299534"> <ele>25.260</ele> <time>2006-05-21T16:49:11Z</time> </trkpt>
1045 <trkpt lat="60.425464" lon="5.299610"> <ele>24.931</ele> <time>2006-05-21T16:49:46Z</time> </trkpt>
1046 <trkpt lat="60.425314" lon="5.299694"> <ele>27.975</ele> <time>2006-05-21T16:52:04Z</time> </trkpt>
1047 <trkpt lat="60.425384" lon="5.299741"> <ele>31.017</ele> <time>2006-05-21T16:56:36Z</time> </trkpt>
1048 <trkpt lat="60.425339" lon="5.299958"> <ele>30.980</ele> <time>2006-05-21T16:56:47Z</time> </trkpt>
1049 <trkpt lat="60.425238" lon="5.299640"> <ele>30.538</ele> <time>2006-05-21T16:56:56Z</time> </trkpt>
1050 <trkpt lat="60.425246" lon="5.299686"> <ele>30.515</ele> <time>2006-05-21T16:57:03Z</time> </trkpt>
1051 <trkpt lat="60.425345" lon="5.299773"> <ele>31.936</ele> <time>2006-05-21T16:59:08Z</time> </trkpt>
1052 <trkpt lat="60.425457" lon="5.299419"> <ele>31.794</ele> <time>2006-05-21T17:00:54Z</time> </trkpt>
1057 "--epoch is ignored in gpx output",
1062 testcmd
("../gpst multitrack-pause.gpx", # {{{
1063 file_data
("multitrack-pause.gpsml"),
1064 "Should be equal to multitrack-pause.gpsml"
1068 testcmd
("../gpst -t multitrack-pause.gpx", # {{{
1070 <?xml version="1.0" encoding="UTF-8"?>
1073 <title>track1</title>
1074 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1</lat> <lon>1</lon> </tp>
1075 <tp> <time>2006-01-01T00:00:01Z</time> <lat>2</lat> <lon>2</lon> </tp>
1076 <tp> <time>2006-01-01T00:00:02Z</time> <lat>3</lat> <lon>3</lon> </tp>
1078 <title>track2</title>
1079 <pause>0:23:59:58</pause>
1080 <tp> <time>2006-01-02T00:00:00Z</time> <lat>1</lat> <lon>1</lon> </tp>
1081 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2</lat> <lon>2</lon> </tp>
1082 <tp> <time>2006-01-02T00:00:16Z</time> <lat>3</lat> <lon>3</lon> </tp>
1083 <pause>0:01:00:00</pause>
1084 <tp> <time>2006-01-02T01:00:16Z</time> <lat>4</lat> <lon>4</lon> </tp>
1086 <title>track3</title>
1087 <pause>1:01:00:04</pause>
1088 <tp> <time>2006-01-03T02:00:20Z</time> <lat>5</lat> <lon>5</lon> </tp>
1092 "Insert <pause> between gpx tracks"
1096 testcmd
("../gpst -t multitrack-pause.gpsml", # {{{
1098 <?xml version="1.0" encoding="UTF-8"?>
1101 <title>track1</title>
1102 <tp> <time>2006-01-01T00:00:00Z</time> <lat>1</lat> <lon>1</lon> </tp>
1103 <tp> <time>2006-01-01T00:00:01Z</time> <lat>2</lat> <lon>2</lon> </tp>
1104 <tp> <time>2006-01-01T00:00:02Z</time> <lat>3</lat> <lon>3</lon> </tp>
1106 <title>track2</title>
1107 <pause>0:23:59:58</pause>
1108 <tp> <time>2006-01-02T00:00:00Z</time> <lat>1</lat> <lon>1</lon> </tp>
1109 <tp> <time>2006-01-02T00:00:04Z</time> <lat>2</lat> <lon>2</lon> </tp>
1110 <tp> <time>2006-01-02T00:00:16Z</time> <lat>3</lat> <lon>3</lon> </tp>
1111 <pause>0:01:00:00</pause>
1112 <tp> <time>2006-01-02T01:00:16Z</time> <lat>4</lat> <lon>4</lon> </tp>
1114 <title>track3</title>
1115 <pause>1:01:00:04</pause>
1116 <tp> <time>2006-01-03T02:00:20Z</time> <lat>5</lat> <lon>5</lon> </tp>
1120 "Insert <pause> between gpsml titles"
1128 if ($Opt{'all'} || $Opt{'todo'}) {
1129 diag
("Running TODO tests...");
1132 local $TODO = "Remove extra \\n in the beginning";
1133 testcmd
("../gpst -t -o clean pause.gpx", # {{{
1135 5.299534\t60.425494\t25.260
1136 5.299610\t60.425464\t24.931
1138 5.299694\t60.425314\t27.975
1140 5.299741\t60.425384\t31.017
1141 5.299958\t60.425339\t30.980
1142 5.299640\t60.425238\t30.538
1143 5.299686\t60.425246\t30.515
1145 5.299773\t60.425345\t31.936
1146 5.299419\t60.425457\t31.794
1148 "Output clean format with time breaks"
1151 testcmd
("../gpst -o csv pause.gpx", # {{{
1153 2006-05-21 16:49:11\t5.299534\t60.425494\t25.260\t
1154 2006-05-21 16:49:46\t5.299610\t60.425464\t24.931\t
1155 2006-05-21 16:52:04\t5.299694\t60.425314\t27.975\t
1156 2006-05-21 16:56:36\t5.299741\t60.425384\t31.017\t
1157 2006-05-21 16:56:47\t5.299958\t60.425339\t30.980\t
1158 2006-05-21 16:56:56\t5.299640\t60.425238\t30.538\t
1159 2006-05-21 16:57:03\t5.299686\t60.425246\t30.515\t
1160 2006-05-21 16:59:08\t5.299773\t60.425345\t31.936\t
1161 2006-05-21 17:00:54\t5.299419\t60.425457\t31.794\t
1163 "csv format from gpx",
1167 testcmd
("../gpst --epoch -o csv pause.gpx", # {{{
1169 1148230151\t5.299534\t60.425494\t25.260\t
1170 1148230186\t5.299610\t60.425464\t24.931\t
1171 1148230324\t5.299694\t60.425314\t27.975\t
1172 1148230596\t5.299741\t60.425384\t31.017\t
1173 1148230607\t5.299958\t60.425339\t30.980\t
1174 1148230616\t5.299640\t60.425238\t30.538\t
1175 1148230623\t5.299686\t60.425246\t30.515\t
1176 1148230748\t5.299773\t60.425345\t31.936\t
1177 1148230854\t5.299419\t60.425457\t31.794\t
1179 "csv format with epoch seconds from gpx",
1183 $TODO = "Use gpsml, this Mayko thing is obsolete.";
1184 testcmd
("../gpst -u no_signal.mayko", # {{{
1186 <?xml version="1.0" encoding="UTF-8"?>
1189 <tp> <time>2002-12-22T21:42:24Z</time> <lat>70.6800486</lat> <lon>23.6746151</lon> </tp>
1190 <tp> <time>2002-12-22T21:42:32Z</time> <lat>70.6799322</lat> <lon>23.6740038</lon> </tp>
1191 <tp> <time>2002-12-22T21:42:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </tp>
1192 <desc>20021222T214351-20021222T214354: CO: No signal \x7B\x7B\x7B</desc>
1193 <etp err="nosignal"> <time>2002-12-22T21:43:51Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1194 <etp err="nosignal"> <time>2002-12-22T21:43:52Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1195 <etp err="nosignal"> <time>2002-12-22T21:43:54Z</time> <lat>70.6796266</lat> <lon>23.6723991</lon> </etp>
1196 <desc>20021222T214351-20021222T214354: CO: No signal \x7D\x7D\x7D</desc>
1198 <tp> <time>2002-12-22T21:44:45Z</time> <lat>70.6800774</lat> <lon>23.6757566</lon> </tp>
1199 <tp> <time>2002-12-22T21:44:52Z</time> <lat>70.6801502</lat> <lon>23.6753442</lon> </tp>
1200 <tp> <time>2002-12-22T21:45:04Z</time> <lat>70.6801905</lat> <lon>23.6757542</lon> </tp>
1204 "Output gpsml from the -u option",
1207 $TODO = "Tweak output";
1208 testcmd
("../gpst -o gpx multitrack-pause.gpsml", # {{{
1209 file_data
("multitrack-pause.gpx"),
1210 "Should be equal to multitrack-pause.gpx"
1217 diag
("Testing finished.");
1221 my ($Cmd, $Exp, $Desc) = @_;
1229 is
(`$Cmd`, $Exp, $Txt);
1234 # Return file content as a string {{{
1237 if (open(FP
, "<", $File)) {
1238 $Txt = join("", <FP
>);
1248 # Print program version {{{
1255 # Send the help message to stdout {{{
1262 Usage: $progname [options] [file [files [...]]]
1264 Contains tests for the gpst(1) program.
1269 Run all tests, also TODOs.
1273 Run only the TODO tests.
1275 Print version information.
1277 Print debugging messages.
1286 # Plain Old Documentation (POD) {{{
1300 [options] [file [files [...]]]
1310 =item B<-a>, B<--all>
1312 Run all tests, also TODOs.
1314 =item B<-h>, B<--help>
1316 Print a brief help summary.
1318 =item B<-t>, B<--todo>
1320 Run only the TODO tests.
1324 Print version information.
1328 Print debugging messages.
1338 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
1342 Copyleft © Øyvind A. Holm <sunny@sunbase.org>
1343 This is free software; see the file F<COPYING> for legalese stuff.
1347 This program is free software; you can redistribute it and/or modify it
1348 under the terms of the GNU General Public License as published by the
1349 Free Software Foundation; either version 2 of the License, or (at your
1350 option) any later version.
1352 This program is distributed in the hope that it will be useful, but
1353 WITHOUT ANY WARRANTY; without even the implied warranty of
1354 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1355 See the GNU General Public License for more details.
1357 You should have received a copy of the GNU General Public License along
1358 with this program; if not, write to the Free Software Foundation, Inc.,
1359 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1367 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :