开发者

Geocoder vs Geokit for finding objects within X miles of a latitude/longitude coordinate?

开发者 https://www.devze.com 2023-03-01 10:20 出处:网络
Newbie to Rails. I am building an app where users create events at a certain location, and plan to host on heroku. Other users can view events taking place with开发者_如何学JAVAin x miles of their lat

Newbie to Rails. I am building an app where users create events at a certain location, and plan to host on heroku. Other users can view events taking place with开发者_如何学JAVAin x miles of their latitude/longitude. I'm looking for a solution that would help me fetch all events happening in an x mile radius. The options seem to be Geocoder and Geokit. Geokit seems to be more popular but doesn't seem to be ready for Rails 3. Is there an obvious choice for what I'm trying to do?


You should use MongoDB, which is provided via a Heroku addon. With Mongo you then have access to spacial queries ("find me all the events within this circle"): http://www.mongodb.org/display/DOCS/Geospatial+Indexing

Unfortunately if you try to use Postgres's geospacial indexing you will find that Heroku does not offer it by default.

Take a look at Mongoid which enables you to do ActiveRecord-style representations of your documents in Mongo, and is very easy to get going with.

0

精彩评论

暂无评论...
验证码 换一张
取 消