【发布时间】:2017-05-20 05:52:37
【问题描述】:
我正在查询一个多边形,以检查一个点是否在其中,但没有返回任何结果。我在mongo shell中:(MongoDB shell版本:3.2.6)
db.restPolygons.find();
{
"_id" : ObjectId("586e663175c32828be59e3a9"),
"zoneCoordinates" : {
"type" : "Polygon",
"coordinates" : [
[ 2, 0 ],
[ 6, 0 ],
[ 6, 2 ],
[ 2, 2 ],
[ 2, 0 ]
]
}
}
db.restPolygons.find({
"zoneCoordinates": {
"$geoIntersects": {
"$geometry": {
"type": "Point",
"coordinates": [3 ,1]
}
}
}
}).count();
0
【问题讨论】:
-
minimongo 仅在流星客户端中,不执行
$geo- 您在服务器上的 mongo shell 中。 -
将 [ ] 添加到坐标值,如下所示解决了问题,即使我在本地 mini mongodb shell 中使用它。谢谢。
标签: mongodb geospatial