Skip to content

Commit 36698f7

Browse files
committed
Check lat_lon range
1 parent 9164854 commit 36698f7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

app/models/sample_set.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def nice_key(raw_key)
193193
end
194194

195195
def parse_location_coordinate(string, type)
196+
type = type.to_s.downcase.to_sym
196197
# A simple (positive) number, no captures
197198
num = /[\d\.,]+/
198199
# A sexagesimal coordinate (without direction), captures:
@@ -218,6 +219,11 @@ def parse_location_coordinate(string, type)
218219
m[1].gsub(',', '.').to_f
219220
end
220221

222+
if decimal.abs > 180.0 || (type == :lat && decimal.abs > 90.0)
223+
warn 'unexpectedly large value for %s: %.2f' % [type, decimal]
224+
return nil
225+
end
226+
221227
allowed_dir = { lat: %w[S s N n], lon: %w[W w E e] }
222228
if m[2].present? && !allowed_dir[type.to_sym].include?(m[2])
223229
warn 'unexpected direction for %s: %s' % [type, m[2]]

0 commit comments

Comments
 (0)