Skip to content
Snippets Groups Projects
Commit adba1b5c authored by dbloete's avatar dbloete Committed by Gavin Hughes
Browse files

Allow for bounds to be nil or already flattened

parent 14fc2605
Branches
Tags
No related merge requests found
......@@ -48,9 +48,8 @@ module Geocoder::Store
# (<tt>[[sw_lat, sw_lon], [ne_lat, ne_lon]]</tt>).
#
scope :within_bounding_box, lambda{ |bounds|
sw_lat, sw_lng, ne_lat, ne_lng = bounds.flatten!
sw_lat, sw_lng, ne_lat, ne_lng = bounds.flatten if bounds
return where(:id => false) unless sw_lat && sw_lng && ne_lat && ne_lng
spans = "latitude BETWEEN #{sw_lat} AND #{ne_lat} AND "
spans << if sw_lng > ne_lng # Handle a box that spans 180
"longitude BETWEEN #{sw_lng} AND 180 OR longitude BETWEEN #{ne_lng} and -180"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment