Skip to content

Instantly share code, notes, and snippets.

@simoncozens
Created September 30, 2012 15:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simoncozens/3807060 to your computer and use it in GitHub Desktop.
Save simoncozens/3807060 to your computer and use it in GitHub Desktop.
scope :located_near, lambda { |distance, long, lat|
geoFactory = RGeo::Geographic.spherical_factory
circle = geoFactory.point(long, lat).buffer(distance.to_f * 1609.34) # METERS PER MILE
where("Intersects(location, GeomFromText(\"#{circle}\"))")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment