Branch Coverage

blib/lib/Image/ExifTool/Geotag.pm
Criterion Covered Total %
branch 306 624 49.0


line true false branch
139 0 9 unless (eval { do { require Time::Local } })
147 7 2 unless $points
151 7 2 unless $has
155 0 9 if ($val =~ /^(\xef\xbb\xbf)?<(\?xml|gpx)[\s>]/) { }
0 9 elsif ($val =~ /(\x0d\x0a|\x0d|\x0a)/) { }
162 8 1 if ($et->Open(\*EXIFTOOL_TRKFILE, $val)) { }
1 0 elsif ($val eq 'DATETIMEONLY') { }
165 0 8 unless ($raf->Read($_, 256))
170 3 5 if (/^(\xef\xbb\xbf)?<(\?xml|gpx)[\s>]/) { }
5 0 elsif (/(\x0d\x0a|\x0d|\x0a)/) { }
190 0 8 unless ($from)
207 8 0 unless defined $csvDelim
210 8 322 unless $raf->ReadLine($_)
212 7 315 unless ($format)
214 0 7 if (/^<(\?xml|gpx)[\s>]/) { }
2 5 elsif (/^.*\$([A-Z]{2}(RMC|GGA|GLL|ZDA)|PMGNTRK),/) { }
0 5 elsif (/^A(FLA|XSY|FIL)/) { }
1 4 elsif (/^HFDTE(?:DATE:)?(\d{2})(\d{2})(\d{2})/) { }
0 4 elsif ($nmeaStart and /^B/) { }
0 4 elsif (/^TP,D,/) { }
1 3 elsif (/^\s*\d+\s+.*\sypr\s*$/ and (@tmp = split(' ', $_, 0)) == 12) { }
1 2 elsif (/\b(GPS)?Date/i && /\b(GPS)?(Date)?Time/i || /\bTime\(seconds\)/i and /\Q$csvDelim\E/) { }
226 0 1 $3 >= 70 ? :
246 1 4 if (/^Time ?\(seconds\)$/i) { }
0 4 elsif (/^Date ?Time/i) { }
0 4 elsif (/^Date/i) { }
0 4 elsif (/^Time(?! ?\(text\))/i) { }
1 3 elsif (/^(Pos)?Lat/i) { }
1 2 elsif (/^(Pos)?Lon/i) { }
0 2 elsif (/^(Pos)?Alt/i) { }
0 2 elsif (/^(Angle)?(Heading|Track)/i) { }
0 2 elsif (/^(Angle)?Pitch/i or /^Camera ?Elevation ?Angle/i) { }
0 2 elsif (/^(Angle)?Roll/i) { }
250 1 0 if ($trackFile and $trackFile =~ m[(\d{4})-(\d{2})-(\d{2})[^/]+(\d{2})-(\d{2})-(\d{2})[^/]*$]) { }
266 0 1 if /ref$/i
269 0 1 if /ref$/i
279 3 2 if ($param) { }
290 0 2 if ++$skipped > 50
297 177 141 if ($format eq 'XML') { }
0 141 elsif ($format eq 'Winplus') { }
7 134 elsif ($format eq 'Bramor') { }
93 41 elsif ($format eq 'CSV') { }
306 38 199 if ($arg =~ /^(\w+:)?(\w+)=(['"])(.*?)\3/g)
308 18 20 if ($tag)
310 0 18 if ($isOrient{$tag}) { }
0 18 elsif ($tag eq 'alt') { }
0 18 elsif ($tag eq 'atemp') { }
314 0 0 if defined $fix->{'alt'} and not $fix->{'alt'} =~ /^[+-]?\d+\.?\d*/
315 0 0 if $fix->{'alt'}
325 24 146 if (defined $tag and not $tag)
327 12 12 if (not $2) { }
11 1 elsif ($fix and $lastFix and %$fix) { }
335 0 44 unless defined $lastFix->{$_}
340 51 107 if (length $1) { }
0 107 elsif ($tok eq 'td') { }
341 32 19 if ($tag)
342 3 29 if ($tag eq 'coords') { }
344 0 0 if (defined $fix->{'lon'} and defined $fix->{'lat'} and defined $fix->{'alt'})
351 0 29 if ($isOrient{$tag}) { }
11 18 elsif ($tag eq 'alt') { }
0 18 elsif ($tag eq 'atemp') { }
355 0 11 if defined $fix->{'alt'} and not $fix->{'alt'} =~ /^[+-]?\d+\.?\d*/
356 11 0 if $fix->{'alt'}
367 26 14 unless defined $fix->{'lat'} and defined $fix->{'lon'} and $fix->{'time'}
368 0 14 unless ($fix->{'lat'} =~ /^[+-]?\d+\.?\d*/ and $fix->{'lon'} =~ /^[+-]?\d+\.?\d*/)
369 0 0 unless $e0
372 0 14 unless (defined($time = &GetTime($fix->{'time'})))
373 0 0 unless $e1
377 0 14 if defined $fix->{'pdop'} or defined $fix->{'hdop'} or defined $fix->{'nsats'}
379 0 14 if ($fix->{'begin'})
382 0 0 if (defined $begin and $begin < $time)
387 0 0 unless @saveFix
392 0 0 if not $i and $points->{$t}
407 0 0 if $td and not $fix->{'time'} and /[\s>](\d{4}-\d{2}-\d{2})[T ](\d{2}:\d{2}:\d{2}(\.\d+)?)/
416 0 0 unless m[^TP,D,\s*([-+]?\d+\.\d*),\s*([-+]?\d+\.\d*),\s*(\d+)/(\d+)/(\d{4}),\s*(\d+):(\d+):(\d+)]
433 3 4 unless @parts == 12 and $parts[11] eq "ypr"
436 0 4 unless @d == 3 and @t == 3
462 1 460 unless defined $val
463 184 276 unless $param
464 0 276 if ($param eq 'datetime') { }
0 276 elsif ($param eq 'date') { }
0 276 elsif ($param eq 'time') { }
184 92 elsif ($param eq 'lat' or $param eq 'lon') { }
0 92 elsif ($param eq 'latref') { }
0 92 elsif ($param eq 'lonref') { }
92 0 elsif ($param eq 'runtime') { }
467 0 0 if ($dateTime)
472 0 0 if ($val =~ m[^(\d{2})/(\d{2})/(\d{4})$]) { }
0 0 elsif ($val =~ /(\d{4}).*?(\d{2}).*?(\d{2})/) { }
478 0 0 if ($val =~ /^(\d{1,2}):(\d{2}):(\d{2}(\.\d+)?).*?(([-+])(\d{1,2}):?(\d{2}))?/)
481 0 0 $6 eq '-' ? :
0 0 if $5
486 0 0 if $val =~ /^S/i
488 0 0 if $val =~ /^W/i
498 0 0 unless defined $fix->{$param}
501 92 0 if ($date and defined $secs and defined $fix->{'lat'} and defined $fix->{'lon'})
503 0 92 if defined $fix->{'alt'}
504 0 92 if defined $fix->{'track'}
505 0 92 if defined $fix->{'pitch'}
511 19 22 if ($format eq "NMEA")
514 1 18 unless /^(.*)\$([A-Z]{2}(RMC|GGA|GLL|GSA|ZDA)|PMGNTRK|PTNTHPR),/
516 0 18 if length $1
521 22 18 if ($format eq 'IGC') { }
3 15 elsif ($nmea eq 'RMC') { }
0 15 elsif ($nmea eq 'GGA') { }
0 15 elsif ($nmea eq 'GLL') { }
0 15 elsif ($nmea eq 'GSA') { }
0 15 elsif ($nmea eq 'ZDA') { }
12 3 elsif ($nmea eq 'PMGNTRK') { }
3 0 elsif ($nmea eq 'PTNTHPR') { }
526 12 10 unless /^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{3})([NS])(\d{3})(\d{2})(\d{3})([EW])([AV])(\d{5})(\d{5})/
527 10 0 $7 eq 'N' ? :
528 10 0 $11 eq 'E' ? :
529 10 0 $12 eq 'A' ? :
532 10 0 if ($dateFlarm)
533 0 10 if $secs < $lastSecs - &JITTER()
544 0 3 unless /^\$[A-Z]{2}RMC,(\d{2})(\d{2})(\d+(\.\d*)?),A?,(\d*?)(\d{1,2}\.\d+),([NS]),(\d*?)(\d{1,2}\.\d+),([EW]),(\d*\.?\d*),(\d*\.?\d*),(\d{2})(\d{2})(\d+)/
545 0 3 if $13 > 31 or $14 > 12 or $15 > 99
546 3 0 $7 eq 'N' ? :
547 3 0 $10 eq 'E' ? :
548 3 0 if length $11
549 3 0 if length $12
550 0 3 $15 >= 70 ? :
560 0 0 unless /^\$[A-Z]{2}GGA,(\d{2})(\d{2})(\d+(\.\d*)?),(\d*?)(\d{1,2}\.\d+),([NS]),(\d*?)(\d{1,2}\.\d+),([EW]),[1-6]?,(\d+)?,(\.\d+|\d+\.?\d*)?,(-?\d+\.?\d*)?,M?/
561 0 0 $7 eq 'N' ? :
562 0 0 $10 eq 'E' ? :
572 0 0 unless /^\$[A-Z]{2}GLL,(\d*?)(\d{1,2}\.\d+),([NS]),(\d*?)(\d{1,2}\.\d+),([EW]),(\d{2})(\d{2})(\d+(\.\d*)?),A/
573 0 0 $3 eq 'N' ? :
574 0 0 $6 eq 'E' ? :
581 0 0 unless /^\$[A-Z]{2}GSA,[AM],([23]),((?:\d*,){11}(?:\d*)),(\d+\.?\d*|\.\d+)?,(\d+\.?\d*|\.\d+)?,(\d+\.?\d*|\.\d+)?\*/
593 0 0 unless /^\$[A-Z]{2}ZDA,(\d{2})(\d{2})(\d{2}(\.\d*)?),(\d+),(\d+),(\d+)/
602 0 12 unless /^\$PMGNTRK,(\d+)(\d{2}\.\d+),([NS]),(\d+)(\d{2}\.\d+),([EW]),(-?\d+\.?\d*),([MF]),(\d{2})(\d{2})(\d+(\.\d*)?),A,(?:[^,]*,(\d{2})(\d{2})(\d+))?/
603 12 0 $3 eq 'N' ? :
604 0 12 $6 eq 'E' ? :
605 12 0 $8 eq 'M' ? :
607 12 0 if (defined $15)
608 0 12 if $13 > 31 or $14 > 12 or $15 > 99
610 0 12 $15 >= 70 ? :
623 0 3 unless /^\$PTNTHPR,(-?[\d.]+),[MNO],(-?[\d.]+),[MNO],(-?[\d.]+),[MNO]/
632 0 25 if (defined $secs and not defined $date and defined $lastDate)
634 0 0 if ($secs < $lastSecs - &JITTER())
639 0 0 if ($secs - $lastSecs < 10) { }
649 25 3 if (defined $date)
661 25 3 if ($nmea eq $nmeaStart or defined $secs and !defined($fixSecs) || $secs >= $fixSecs && $secs - $fixSecs >= 10 || $secs < $fixSecs && $secs + $secPerDay - $fixSecs >= 10) { }
671 25 0 if (defined $date) { }
0 0 elsif (defined $secs) { }
684 9 0 unless defined $fix->{$_}
686 0 3 if (defined $date) { }
0 3 elsif (defined $secs and not defined $fixSecs) { }
687 0 0 if $fix->{'isDate'}
689 0 0 if (defined $fixSecs) { }
691 0 0 if @fixTimes and $fixTimes[-1] == $fixSecs
695 0 0 if $secs < $fixSecs
702 0 0 if $noDateChanged
718 0 8 if ($noDate and not $geotag->{'NoDate'})
719 0 0 if ($isDate) { }
726 8 0 if $isDate
729 0 8 if ($isCut and $canCut)
733 0 0 unless $fix = $points->{$_}
734 0 0 if ($maxPDOP and $fix->{'pdop'} and $fix->{'pdop'} > $maxPDOP) { }
0 0 elsif ($maxHDOP and $fix->{'hdop'} and $fix->{'hdop'} > $maxHDOP) { }
0 0 elsif ($minSats and defined $fix->{'nsats'} and $fix->{'nsats'} ne '' and $fix->{'nsats'} < $minSats) { }
756 0 8 unless $fix = $$points{$fixTimes[0]}
761 1 7 if ($verbose)
763 0 1 unless $format
765 0 1 if $cutPDOP
766 0 1 if $cutHDOP
767 0 1 if $cutSats
768 1 0 if ($numPoints and $verbose > 1)
771 0 1 if $fixTimes[0] > $fixTimes[-1]
773 0 1 if ($verbose > 3)
779 8 0 if ($numPoints)
783 2 6 if $nmea{'GGA'} or $nmea{'PMGNTRK'} or $nmea{'B'}
784 1 7 if $nmea{'RMC'}
785 1 7 if $nmea{'PTNTHPR'}
799 0 14 unless $timeStr =~ /^(\d{4})-(\d+)-(\d+)T(\d+):(\d+):(\d+)(\.\d+)?(.*)/
801 3 11 if $7
806 3 11 if ($tz =~ /^([-+])(\d+):(\d{2})\b/ or $tz =~ /^([-+])(\d{2})(\d{2})?\b/)
808 0 3 if $1 eq "+"
822 3 7 if (ref $sync eq 'HASH') { }
824 2 1 if ($syncTimes) { }
829 0 0 $time < $syncTimes->[$pt] ? :
834 0 2 $t1 == $t0 ? :
859 0 4 if $i < 0 or $i >= scalar @$times
861 3 1 if abs $t - $t0 > $maxSecs
864 0 1 if defined $v
879 0 0 if ($dir) { }
884 0 0 if (defined $t1) { }
0 0 elsif (defined $t2) { }
885 0 0 if (defined $t2) { }
887 0 0 $t - $t1 < $t2 - $t ? :
895 0 0 if (defined $p and $et->{'OPTIONS'}{'Verbose'} > 2)
916 0 10 if $val and $geotag and not $geotag->{'IsDate'}
923 0 13 unless defined $geoMaxIntSecs
924 0 13 unless defined $geoMaxExtSecs
932 0 10 unless (defined $geotag)
936 9 1 unless ($times)
941 0 1 unless ($times and @$times or $geotag->{'DateTimeOnly'})
945 0 10 unless (eval { do { require Time::Local } })
951 10 0 if ($val =~ /^(\d{4}):(\d+):(\d+)\s+(\d+):(\d+):(\d+)(\.\d*)?(Z|([-+])(\d+):(\d+))?/) { }
0 0 elsif ($val =~ /^(\d{2}):(\d+):(\d+)(\.\d*)?(Z|([-+])(\d+):(\d+))?/) { }
964 9 1 if ($tz) { }
967 5 4 if ($tz ne "Z")
969 4 1 $t0 eq '-' ? :
976 1 9 if $fs and $fs ne "."
980 0 10 if $noDate
986 2 8 $time =~ /(\.\d+)$/ ? :
988 1 9 if ($et->Options("Verbose") > 1 and not $secondTry)
991 1 0 if defined $sync
992 0 1 unless ($tz)
998 1 9 if (not $times && @$times) { }
0 9 elsif ($time < $times->[0]) { }
1 8 elsif ($time > $times->[-1]) { }
1002 0 0 if ($time < $times->[0] - $geoMaxExtSecs) { }
1003 0 0 unless $err
1004 0 0 if $verbose > 2
1005 0 0 if $geotag->{'DateTimeOnly'}
1009 0 0 if $verbose > 2
1013 1 0 if ($time > $times->[-1] + $geoMaxExtSecs) { }
1014 1 0 unless $err
1015 0 1 if $verbose > 2
1016 0 1 if $geotag->{'DateTimeOnly'}
1020 0 0 if $verbose > 2
1028 10 14 $time < $times->[$pt] ? :
1035 0 8 $p1->{'first'} && $geoMaxIntSecs ? :
1038 0 8 if ($t1 - $t0 > $maxSecs and !($p1->{'span'} && $points->{$t0}{'span'}) || $p1->{'span'} != $points->{$t0}{'span'}) { }
1043 0 0 if ($time - $t0 < $t1 - $time) { }
1050 0 0 if (abs $time - $tn > $geoMaxExtSecs) { }
1051 0 0 unless $err
1052 0 0 if $verbose > 2
1053 0 0 if $geotag->{'DateTimeOnly'}
1056 0 0 if $verbose > 2
1060 0 8 $t1 == $t0 ? :
1062 0 8 if $verbose > 2
1069 21 19 unless $has->{$category}
1076 30 3 if (defined $v0 and defined $v1) { }
0 3 elsif (defined $f0b) { }
1081 0 0 unless defined $v0 and defined $v1
1087 0 3 if (defined $v0) { }
1091 3 0 unless defined $t0b
1093 0 0 if (defined $v1) { }
1097 0 0 unless defined $t1b
1100 0 0 $t1b == $t0b ? :
1101 0 0 if $verbose > 2
1105 0 30 if ($cyclical{$key} and abs $v1 - $v0 > 180) { }
1108 0 0 $v0 < $v1 ? :
1111 0 0 $key eq 'lon' || $key eq 'roll' ? :
1112 0 0 if $fix->{$key} >= $max
1121 9 1 if ($fix) { }
0 1 elsif ($geotag->{'NoDate'} and not $noDate and $val =~ s/^\S+\s+//) { }
1130 9 4 if ($fix) { }
1135 9 0 unless $noDate
1137 5 4 if (defined $fix->{'alt'}) { }
0 8 elsif ($has->{'alt'} and defined $iExt) { }
1139 0 5 $fix->{'alt'} < 0 ? :
1142 0 0 if ($tFix)
1144 0 0 $tFix->{'alt'} < 0 ? :
1150 1 8 if ($writeGroup)
1160 3 6 if ($has->{'track'})
1162 0 3 if (not defined $fix->{'track'} and defined $iExt)
1164 0 0 if $p
1167 2 1 defined $tFix->{'track'} ? :
1169 1 2 if (defined($spd = $tFix->{'speed'}))
1171 0 1 if ($ref and defined $speedConv{$ref}) { }
1172 0 0 if $speedConv{$speedConv{$ref}}
1181 3 6 if ($has->{'orient'})
1183 0 3 if (not defined $fix->{'dir'} and defined $iExt)
1185 0 0 if $p
1188 2 1 defined $tFix->{'dir'} ? :
1194 0 9 if ($has->{'atemp'})
1196 0 0 if (not defined $fix->{'atemp'} and defined $iExt)
1199 0 0 if $p
1203 8 1 unless ($xmp)
1205 6 1 $fix->{'lat'} > 0 ? :
7 1 if defined $fix->{'lat'}
1206 4 3 $fix->{'lon'} > 0 ? :
7 1 if defined $fix->{'lon'}
1215 9 0 unless ($exif)
1220 1 3 if defined $val
1221 2 2 if $writeGroup
1253 4 1 if ($val =~ /(.*?)\@(.*)/) { }
0 1 elsif (not $val =~ /^\d/ && $val =~ /:/) { }
1255 0 4 -f $2 ? :
1258 0 0 if -f $val
1260 4 1 if ($gpsTime or defined $syncFile) { }
1262 0 4 if (defined $syncFile)
1268 0 0 if $info->{'Error'}
1269 0 0 unless ($gpsTime)
1271 0 0 if $gpsTime and not $info->{'GPSDateTime'}
1273 0 0 unless $gpsTime
1276 0 0 if ($info->{$tag})
1282 0 0 unless $imgTime
1286 4 0 if ($imgTime =~ /^(\d+:\d+:\d+)\s+\d+/) { }
0 0 elsif ($gpsTime =~ /^(\d+:\d+:\d+)\s+\d+/) { }
1289 4 0 if ($gpsTime =~ /^\d+:\d+:\d+\s+\d+/) { }
1307 0 4 unless defined $imgSecs
1309 0 4 unless defined $gpsSecs
1311 0 4 if $gpsTime =~ /(\.\d+)/
1312 0 4 if $imgTime =~ /(\.\d+)/
1314 0 4 if ($gpsDateTime ne $gpsTime or $imgDateTime ne $imgTime)
1316 0 0 if $diff > 43200
1317 0 0 if $diff < -43200
1318 0 0 if ($gpsDateTime ne $gpsTime) { }
1327 4 0 unless ($noDate)
1328 2 2 unless $sync->{'Points'}
1331 2 2 if ($et->Options("Verbose") > 1)
1339 2 2 if (@times > 1)
1347 0 1 unless @vals
1352 1 1 unless @vals
1355 0 1 $val =~ /^\s*-/ ? :
1384 0 0 if ($fix)
1386 0 0 unless $_ eq "time" or not defined $fix->{$_}