module Geocoder::Sql

def approx_distance(latitude, longitude, lat_attr, lon_attr, options = {})


are not intended for use in production!
clear: this only exists to provide interface consistency. Results
Distance and bearing calculations are *extremely inaccurate*. To be

objects outside the given radius).
rather than a circle, so results are very approximate (will include
functions, like SQLite. Approach is to find objects within a square
Distance calculation for use with a database without trigonometric
#
def approx_distance(latitude, longitude, lat_attr, lon_attr, options = {})
  units = options[:units] || Geocoder.config.units
  dx = Geocoder::Calculations.longitude_degree_distance(30, units)
  dy = Geocoder::Calculations.latitude_degree_distance(units)
  # sin of 45 degrees = average x or y component of vector
  factor = Math.sin(Math::PI / 4)
  "(#{dy} * ABS(#{lat_attr} - #{latitude.to_f}) * #{factor}) + " +
    "(#{dx} * ABS(#{lon_attr} - #{longitude.to_f}) * #{factor})"
end