Permalink
Browse files

:origin now takes a two-element array of latitude and lontigude in ad…

…dition to GeoLocs and strings

git-svn-id: http://geokit.rubyforge.org/svn/trunk@15 9265c765-0211-4c68-b2df-6d1bd6e20c4d
  • Loading branch information...
1 parent 11aaff7 commit 7acbbb53148597ac1e4cd3280b8ba043a8796dab lewisac committed Feb 14, 2007
Showing with 7 additions and 1 deletion.
  1. +1 −0 lib/geo_kit/acts_as_mappable.rb
  2. +6 −1 test/acts_as_mappable_test.rb
View
1 lib/geo_kit/acts_as_mappable.rb
@@ -118,6 +118,7 @@ def distance_sql(origin, units=default_units, formula=default_formula)
def extract_origin_from_options(options)
origin = options[:origin]
origin = geocode_origin(origin) if origin && origin.is_a?(String)
+ origin = GeoKit::LatLng.new(options[:origin][0], options[:origin][1]) if origin && origin.is_a?(Array)
unless origin
origin = GeoKit::LatLng.new(options[:lat], options[:lng]) if options[:lat] && options[:lng]
end
View
7 test/acts_as_mappable_test.rb
@@ -287,5 +287,10 @@ def test_find_farthest_with_custom
def test_find_farthest_with_coordinates_with_custom
assert_equal @custom_loc_e, CustomLocation.find_farthest(:lat => @loc_a.lat, :lng => @loc_a.lng)
- end
+ end
+
+ def test_find_with_array_origin
+ locations = Location.find(:all, :origin =>[@loc_a.lat,@loc_a.lng], :conditions => "distance < 3.97")
+ assert_equal 5, locations.size
+ end
end

0 comments on commit 7acbbb5

Please sign in to comment.