Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed a small but with queries crossing meridian, and also fixed find…

…(:closest)

git-svn-id: http://geokit.rubyforge.org/svn/trunk@44 9265c765-0211-4c68-b2df-6d1bd6e20c4d
  • Loading branch information...
commit 86c1b12e58cc166a1d511f2a789a3b18f603b102 1 parent 20ba882
lewisac authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/geo_kit/acts_as_mappable.rb
View
4 lib/geo_kit/acts_as_mappable.rb
@@ -236,7 +236,7 @@ def handle_order_with_include(options, origin, units, formula)
# :first and ensures the limit is set to one.
def apply_find_scope(args, options)
case args.first
- when :nearest
+ when :nearest, :closest
args[0] = :first
options[:limit] = 1
options[:order] = "#{distance_column_name} ASC"
@@ -292,7 +292,7 @@ def augment_conditions(current_conditions,sql)
# Alters the conditions to include rectangular bounds conditions.
def apply_bounds_conditions(options,bounds)
sw,ne=bounds.sw,bounds.ne
- lng_sql= bounds.crosses_meridian? ? "#{qualified_lng_column_name}<#{sw.lng} OR #{qualified_lng_column_name}>#{ne.lng}" : "#{qualified_lng_column_name}>#{sw.lng} AND #{qualified_lng_column_name}<#{ne.lng}"
+ lng_sql= bounds.crosses_meridian? ? "(#{qualified_lng_column_name}<#{sw.lng} OR #{qualified_lng_column_name}>#{ne.lng})" : "#{qualified_lng_column_name}>#{sw.lng} AND #{qualified_lng_column_name}<#{ne.lng}"
bounds_sql="#{qualified_lat_column_name}>#{sw.lat} AND #{qualified_lat_column_name}<#{ne.lat} AND #{lng_sql}"
options[:conditions]=augment_conditions(options[:conditions],bounds_sql)
end
Please sign in to comment.
Something went wrong with that request. Please try again.