1 Index: tests/run-tests.pl
2 ===================================================================
3 --- tests/run-tests.pl (revision 1843)
4 +++ tests/run-tests.pl (working copy)
7 <title>Missing various elements</title>
8 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
9 -<tp> <time>2006-04-30T17:17:00Z</time> </tp>
10 +<tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
11 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
12 -<tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
13 +<tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
14 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
15 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
16 -<tp> <ele>484</ele> </tp>
17 +<tp> <lon>5.34224</lon> <ele>484</ele> </tp>
18 <tp> <ele>486</ele> </tp>
19 <tp> <desc>Missing everything</desc> </tp>
20 -<tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
21 +<tp> <lat>60.42339</lat> </tp>
22 +<tp> <lon>5.34262</lon> </tp>
23 +<tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
24 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
30 local $TODO = "Shall lat/lon be cleared if one is missing?";
31 + diag("Testing --require...");
32 testcmd("../gpst -re missing.gpsml", # {{{
34 <?xml version="1.0" encoding="UTF-8"?>
37 <title>Missing various elements</title>
38 -<tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
39 +<tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
40 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
41 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
42 -<tp> <ele>484</ele> </tp>
43 +<tp> <lon>5.34224</lon> <ele>484</ele> </tp>
44 <tp> <ele>486</ele> </tp>
45 -<tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
46 +<tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
47 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
52 <title>Missing various elements</title>
53 <tp> <time>2006-04-30T17:16:59Z</time> </tp>
54 -<tp> <time>2006-04-30T17:17:00Z</time> </tp>
55 +<tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
56 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
57 -<tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
58 +<tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
59 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
60 -<tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
61 +<tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
62 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
68 <title>Missing various elements</title>
69 +<tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
70 <tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
71 +<tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
72 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
73 +<tp> <lon>5.34224</lon> <ele>484</ele> </tp>
74 +<tp> <lat>60.42339</lat> </tp>
75 +<tp> <lon>5.34262</lon> </tp>
76 +<tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
77 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
83 <title>Missing various elements</title>
84 -<tp> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </tp>
85 +<tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
86 <tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
87 -<tp> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </tp>
88 +<tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
89 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
95 <title>Missing various elements</title>
96 +<tp> <time>2006-04-30T17:16:59Z</time> </tp>
97 +<tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
98 +<tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
99 +<tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
100 +<tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
101 +<tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
102 +<tp> <lon>5.34224</lon> <ele>484</ele> </tp>
103 +<tp> <ele>486</ele> </tp>
104 +<tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
105 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
111 <title>Missing various elements</title>
112 +<tp> <time>2006-04-30T17:17:00Z</time> <lat>60.42352</lat> </tp>
113 +<tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
114 +<tp> <time>2006-04-30T17:17:11Z</time> <lon>5.34187</lon> <ele>483</ele> </tp>
115 +<tp> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </tp>
116 <tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
117 +<tp> <lon>5.34224</lon> <ele>484</ele> </tp>
118 +<tp> <ele>486</ele> </tp>
119 +<tp> <time>2006-04-30T17:18:03Z</time> <lat>60.42339</lat> <ele>490</ele> </tp>
120 <tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
123 @@ -975,37 +1000,85 @@
127 + testcmd("../gpst -o gpx missing.gpsml | ../gpst", # {{{
129 +<?xml version="1.0" encoding="UTF-8"?>
132 +<title>Missing various elements</title>
133 +<tp> <time>2006-04-30T17:17:09Z</time> <lat>60.42353</lat> <lon>5.34185</lon> </tp>
134 +<tp> <lat>60.42347</lat> <lon>5.34212</lon> <ele>486</ele> </tp>
135 +<tp> <time>2006-04-30T17:18:05Z</time> <lat>60.42338</lat> <lon>5.34269</lon> <ele>487</ele> </tp>
139 + "Via GPX from gpsml with missing data",
142 -testcmd("../gpst -o gpx missing.gpsml", # {{{
144 +testcmd("echo '<tp> </tp>' | ../gpst", # {{{
146 +<?xml version="1.0" encoding="UTF-8"?>
152 + "Don’t print empty trackpoints"
156 +testcmd("echo '<tp> <lat>5</lat> </tp>' | ../gpst", # {{{
158 +<?xml version="1.0" encoding="UTF-8"?>
161 +<etp err="incomplete"> <lat>5</lat> </etp>
165 + "Only latitude, no longitude (gpsml)"
169 +testcmd("echo '<tp> <lon>5</lon> </tp>' | ../gpst", # {{{
171 +<?xml version="1.0" encoding="UTF-8"?>
174 +<etp err="incomplete"> <lon>5</lon> </etp>
178 + "Only longitude, no latitude (gpsml)"
182 +testcmd("echo '<tp> <lat>5</lat> </tp>' | ../gpst -o gpx", # {{{
187 - <trkpt lat="60.42353" lon="5.34185"> <time>2006-04-30T17:17:09Z</time> </trkpt>
188 - <trkpt> <time>2006-04-30T17:17:11Z</time> <ele>483</ele> </trkpt>
189 - <trkpt> <time>2006-04-30T17:17:22Z</time> <ele>485</ele> </trkpt>
190 - <trkpt lat="60.42347" lon="5.34212"> <ele>486</ele> </trkpt>
191 - <trkpt> <ele>484</ele> </trkpt>
192 - <trkpt> <ele>486</ele> </trkpt>
193 - <trkpt> <time>2006-04-30T17:18:03Z</time> <ele>490</ele> </trkpt>
194 - <trkpt lat="60.42338" lon="5.34269"> <time>2006-04-30T17:18:05Z</time> <ele>487</ele> </trkpt>
199 - "Output GPX from gpsml with missing data",
201 + "Only latitude, no longitude (gpx)"
205 -testcmd("echo '<tp> </tp>' | ../gpst", # {{{
206 +testcmd("echo '<tp> <lon>5</lon> </tp>' | ../gpst -o gpx", # {{{
208 -<?xml version="1.0" encoding="UTF-8"?>
213 +<?xml version="1.0" standalone="no"?>
221 - "Don’t print empty trackpoints");
222 + "Only longitude, no latitude (gpx)"
226 testcmd("../gpst --epoch pause.gpx", # {{{
228 ===================================================================
229 --- GPST.pm (revision 1843)
230 +++ GPST.pm (working copy)
231 @@ -104,26 +104,23 @@
233 } elsif($Dat{'format'} eq "gpx") {
235 - my $lat_str = length($Dat{'lat'}) ? " lat=\"$Dat{'lat'}\"" : "";
236 - my $lon_str = length($Dat{'lon'}) ? " lon=\"$Dat{'lon'}\"" : "";
237 - if (length("$lat_str$lon_str$Dat{'ele'}")) {
240 - "$Spc$Spc$Spc$Spc$Spc$Spc",
241 - "<trkpt$lat_str$lon_str>",
245 - "$Dat{'year'}-$Dat{'month'}-$Dat{'day'}T" .
246 - "$Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}Z" .
249 - length($Dat{'ele'})
250 - ? "<ele>$Dat{'ele'}</ele>$Spc"
255 + (length($Dat{'lat'}) && length($Dat{'lon'})) || return("");
258 + "$Spc$Spc$Spc$Spc$Spc$Spc",
259 + "<trkpt lat=\"$Dat{'lat'}\" lon=\"$Dat{'lon'}\">",
263 + "$Dat{'year'}-$Dat{'month'}-$Dat{'day'}T" .
264 + "$Dat{'hour'}:$Dat{'min'}:$Dat{'sec'}Z" .
267 + length($Dat{'ele'})
268 + ? "<ele>$Dat{'ele'}</ele>$Spc"
276 ===================================================================
277 --- gpst (revision 1843)
278 +++ gpst (working copy)
280 defined($Dat{'lon'}) || ($Dat{'lon'} = "");
281 defined($Dat{'year'}) || ($Dat{'year'} = "");
282 my $print_time = length($Dat{'year'}) ? 1 : 0;
283 - my $print_pos = (length($Dat{'lat'}) && length($Dat{'lon'})) ? 1 : 0;
285 - $Dat{'lat'} = $Dat{'lon'} = "";
287 + if (length($Dat{'lat'}) && length($Dat{'lon'})) {
290 + if (length($Dat{'lat'}) || length($Dat{'lon'})) {
291 + $Dat{'error'} = "incomplete";
292 + $print_pos = ($Opt{'output-format'} eq "gpsml") ? 1 : 0;
295 my $print_ele = length($Dat{'ele'}) ? 1 : 0;
296 my $print_desc = length($Dat{'desc'}) ? 1 : 0;
299 if ($Dat{'type'} eq "tp") {
301 - if ($Opt{'require'}) {
302 - $Req{'time'} && !$print_time && return;
303 - $Req{'position'} && !$print_pos && return;
304 - $Req{'ele'} && !$print_ele && return;
306 + ($Req{'time'} && !$print_time) && return("");
307 + ($Req{'position'} && length("$Dat{'lat'}$Dat{'lon'}")) && return("");
308 + ($Req{'ele'} && !$print_ele) && return("");
310 if ($Opt{'inside'} || $Opt{'outside'}) {