Skip to content

Commit

Permalink
Merge branch 'master' of github.com:alexreisner/geocoder
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreisner committed May 24, 2012
2 parents 31f9afb + e886fbf commit f7fbf23
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/geocoder/stores/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ def approx_near_scope_options(latitude, longitude, radius, options)
end
if options[:bearing]
bearing = "CASE " +
"WHEN (#{lat_attr} >= #{latitude} AND #{lon_attr} >= #{longitude}) THEN 45.0 " +
"WHEN (#{lat_attr} < #{latitude} AND #{lon_attr} >= #{longitude}) THEN 135.0 " +
"WHEN (#{lat_attr} < #{latitude} AND #{lon_attr} < #{longitude}) THEN 225.0 " +
"WHEN (#{lat_attr} >= #{latitude} AND #{lon_attr} < #{longitude}) THEN 315.0 " +
"WHEN (#{full_column_name(lat_attr)} >= #{latitude} AND #{full_column_name(lon_attr)} >= #{longitude}) THEN 45.0 " +
"WHEN (#{full_column_name(lat_attr)} < #{latitude} AND #{full_column_name(lon_attr)} >= #{longitude}) THEN 135.0 " +
"WHEN (#{full_column_name(lat_attr)} < #{latitude} AND #{full_column_name(lon_attr)} < #{longitude}) THEN 225.0 " +
"WHEN (#{full_column_name(lat_attr)} >= #{latitude} AND #{full_column_name(lon_attr)} < #{longitude}) THEN 315.0 " +
"END"
else
bearing = false
Expand All @@ -216,7 +216,7 @@ def approx_near_scope_options(latitude, longitude, radius, options)

b = Geocoder::Calculations.bounding_box([latitude, longitude], radius, options)
conditions = [
"#{lat_attr} BETWEEN ? AND ? AND #{lon_attr} BETWEEN ? AND ?"] +
"#{full_column_name(lat_attr)} BETWEEN ? AND ? AND #{full_column_name(lon_attr)} BETWEEN ? AND ?"] +
[b[0], b[2], b[1], b[3]
]
default_near_scope_options(latitude, longitude, radius, options).merge(
Expand Down

0 comments on commit f7fbf23

Please sign in to comment.