module Geocoder::Orm::ActiveRecord::ClassMethods

def full_near_scope_options(latitude, longitude, radius, options)


http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL
Taken from the excellent tutorial at:

SQRT(), PI(), and trigonometric functions (SIN(), COS(), and ASIN()).
Scope options hash for use with a database that supports POWER(),
#
def full_near_scope_options(latitude, longitude, radius, options)
  lat_attr = geocoder_options[:latitude]
  lon_attr = geocoder_options[:longitude]
  distance = "3956 * 2 * ASIN(SQRT(" +
    "POWER(SIN((#{latitude} - #{lat_attr}) * " +
    "PI() / 180 / 2), 2) + COS(#{latitude} * PI()/180) * " +
    "COS(#{lat_attr} * PI() / 180) * " +
    "POWER(SIN((#{longitude} - #{lon_attr}) * " +
    "PI() / 180 / 2), 2) ))"
  options[:order] ||= "#{distance} ASC"
  default_near_scope_options(latitude, longitude, radius, options).merge(
    :select => "#{options[:select] || '*'}, #{distance} AS distance",
    :having => "#{distance} <= #{radius}"
  )
end