module Geocoder::Calculations
def bounding_box(point, radius, options = {})
See Geocoder::Configuration to know how configure default units.
* :units - :mi or :km.
ways of specifying the point. Also accepts an options hash:
See Geocoder::Calculations.distance_between for
(ActiveRecord queries use it thusly).
roughly limiting the possible solutions in a geo-spatial search
This is useful for finding corner points of a map viewport, or for
is twice the radius).
from the center point to any side of the box (the length of each side
with the given point at its center. The radius is the shortest distance
Returns coordinates of the lower-left and upper-right corners of a box
#
def bounding_box(point, radius, options = {}) lat,lon = extract_coordinates(point) radius = radius.to_f units = options[:units] || Geocoder::Configuration.units [ lat - (radius / latitude_degree_distance(units)), lon - (radius / longitude_degree_distance(lat, units)), lat + (radius / latitude_degree_distance(units)), lon + (radius / longitude_degree_distance(lat, units)) ] end