Skip to content

Commit 37541c3

Browse files
committed
More robust parsing of lat/lon
1 parent e7bc79b commit 37541c3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/opencage/geocoder/location.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def coordinates
1818
end
1919

2020
def lat
21-
@result['geometry']['lat'].to_f
21+
@result.dig('geometry', 'lat')&.to_f
2222
end
2323

2424
alias latitude lat
2525

2626
def lng
27-
@result['geometry']['lng'].to_f
27+
@result.dig('geometry', 'lng')&.to_f
2828
end
2929

3030
alias longitude lng

0 commit comments

Comments
 (0)