【发布时间】:2014-12-17 08:25:54
【问题描述】:
目前在 Mongoid 中构建了任何方法来使用 $geoWithin 而不在数据库中存储任何内容?
希望能够只使用$geoWithin(或其他类似方法),只需在具有坐标的某个对象上调用它并随后通过多边形边界。
想法?
【问题讨论】:
标签: ruby mongodb mongoid nosql
目前在 Mongoid 中构建了任何方法来使用 $geoWithin 而不在数据库中存储任何内容?
希望能够只使用$geoWithin(或其他类似方法),只需在具有坐标的某个对象上调用它并随后通过多边形边界。
想法?
【问题讨论】:
标签: ruby mongodb mongoid nosql
你用过 geo_near 吗?
这对我有用
center = [lat.to_f, lon.to_f]
User.geo_near(center).max_distance(10)
用户模型定义:
field :location, type:Array # [lat,lng]
index( { location: "2d" }, { min: -180, max: 180 })
【讨论】: