1

我正在尝试找出 MongoDB 查询使用的单元...

我有以下查询:

User.objects(address__point__geo_within_center=[[lat, long],maxDistance])

我想在 maxDistance 内使用米,例如 10 米。

但是在文档(https://docs.mongodb.com/manual/reference/operator/query/center/#op._S_center)中它说

“圆的半径,以坐标系使用的单位测量”

我在任何地方都找不到对“单位”的引用?

我一直在使用http://docs.mongoengine.org/guide/querying.html作为参考。

有哪些单位?

我可以设置单位吗?

谢谢

4

1 回答 1

-1

您正在尝试使用仅受 2d 索引支持的 $center 。您应该使用 2dshpere 索引及其支持的操作。为此,2dsphere 文档是一个很好的起点。

$nearSphere地理空间查询运算符应该做你想做的事。请注意,运算符使用以为单位的距离。

mongoengine文档显示了 geo_within_sphere 运算符,这可能是您想要的。

于 2016-07-23T14:07:40.233 回答