2016-07-23 34 views
0

我試圖找出MongoDB的查詢使用什麼單位?蒙戈DB半徑單位爲GeoQuerys

我有以下查詢:

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

我想用戶米例如最大距離內10米。

但在機制的文檔(https://docs.mongodb.com/manual/reference/operator/query/center/#op._S_center)它說

「圓的半徑,如所使用的單位測量座標 系統」

我找不到一提到「單位「在哪裏?

我一直在使用http://docs.mongoengine.org/guide/querying.html作爲ref。

單位是什麼?

我可以設置單位嗎?

謝謝

回答

-1

您正在嘗試使用僅由2d索引支持的$ center。您應該使用2dshpere索引及其支持的操作。爲此,2dsphere docs是一個很好的開始。

$nearSphere地理空間查詢運算符應該做你想做的。請注意,操作員使用中的距離。

mongoengine docs顯示一個geo_within_sphere運算符,這可能是您想要的。