存储&在 Rails 中查询位置数据(geo/gis/etc)
我需要在 Rails 应用程序中记录和跟踪某些实体的位置。简而言之,iPhone 将发布其位置(纬度/经度),Rails 将对其进行存档。然后,当查询时,Rails 需要通过接近某个任意位置来返回资源。最初的计算量很小(距点的距离)。
什么是最新、最棒的?最简单的方法来处理这个问题?我知道的选项...
- 我可以通过捕获来暴力破解它 纬度/经度和接近度 我自己计算
- 有这个 Geokit gem/plugin 虽然没有出现 自 2009 年以来已更新(!?!),并且未使用 Ruby 1.9.2 进行验证。
- 有 PostGIS 作为后端 数据库扩展虽然想知道什么价值 这增加了它是否值得可能需要的额外开销?
- 其他的?
I need to record and track location of some entities in a Rails app. Simply put, iPhone will post its location (lat/long) and Rails will archive it. Then when queried Rails will need to return resources by proximity to some arbitrary location. Calculations will be minimal (distance from point) initially.
What's the latest, greatest & easiest way to handle this? Options I'm aware of...
- I could brute force it by capturing
lat/long and doing proximity
calculations myself - There's this Geokit
gem/plugin though it doesn't appear
to have been updated since 2009(!?!) and isn't verified with Ruby 1.9.2. - There's PostGIS as a backend
database extension though wondering what value
this adds and if it merits the additional overhead it may require? - Others?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我投票给#2,GeoKit:因为它是最简单的,不需要部署额外的软件/搜索引擎/数据库。
Rails Geokit 可在 ruby 1.9.2 的 Rails 3 中运行
您只需按照有关此问题的说明进行操作即可:
https://github.com/andre/geokit-rails/issues#issue/15
按照tute和brianlong的建议去做。
此外,我提交了一个修复程序,使 sort_by_distance 适用于 :through 关联:
https:// github.com/andre/geokit-rails/issues#issue/26
I vote on #2, GeoKit: Since its the simplest and requires no deployment of additional software/search engine/database.
Rails Geokit DOES WORK in rails 3 with ruby 1.9.2
You just have to follow the instructions on this issue:
https://github.com/andre/geokit-rails/issues#issue/15
Do what tute and brianlong are suggesting.
Furthermore, I submitted a fix to make sort_by_distance work for :through associations:
https://github.com/andre/geokit-rails/issues#issue/26
使用 MongoDB 是一种选择吗?它支持开箱即用的 GIS 内容 - Mongoid 让您可以像这样查询它。
更多详细信息请参见 Mongoid 网站此处
Is using MongoDB an option? It supports GIS stuff out of the box - Mongoid lets you query it like
More details on the Mongoid site here
Thinking Sphinx 可以对纬度/经度进行索引并返回搜索半径内的结果。
Thinking Sphinx can index on lat/lon and return results within a search radius.