Skip to content

Commit add8ec4

Browse files
author
Sergey Morozov
committed
Do not attempt to split raw numeric GPS coordinates
Fixes exiftool-rb#7 If `-n` option is used, GPS coordinates come as numeric values and there is no need to attempt to split cardinal directions from the value. Also added a test for this scenario.
1 parent 179e60b commit add8ec4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/exiftool/field_parser.rb

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def lat_long?
4646
end
4747

4848
def as_lat_long
49+
return raw_value if raw_value.is_a? Numeric
4950
value, direction = raw_value.split(' ')
5051
if value =~ /\A\d+\.?\d*\z/
5152
value.to_f * (['S', 'W'].include?(direction) ? -1 : 1)

test/field_parser_test.rb

+5
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,9 @@
8585
p = Exiftool::FieldParser.new('GPSLongitude', '122.47566667 W')
8686
p.value.must_be_close_to(-122.47566667)
8787
end
88+
89+
it 'parses numerical only GPS coordinates' do
90+
p = Exiftool::FieldParser.new('GPSLongitude', -122.475666666667)
91+
p.value.must_be_close_to(-122.475666666667)
92+
end
8893
end

0 commit comments

Comments
 (0)