【发布时间】:2014-05-16 21:47:01
【问题描述】:
我有一个问题要咨询 $geoIntersects-Operator。 我有以下搜索框和集合内容:
> BOX
{
"type" : "Polygon",
"coordinates" : [
[
[
0,
0
],
[
3,
0
],
[
3,
3
],
[
0,
3
],
[
0,
0
]
]
]
}
> db.polygon.find()
{ "_id" : "Poly1", "shape" : { "type" : "Polygon", "coordinates" : [ [ [ 0, 0 ], [ 3, 0 ], [ 3, 3 ], [ 0, 3 ], [ 0, 0 ] ] ] } }
{ "_id" : "Poly2", "shape" : { "type" : "Polygon", "coordinates" : [ [ [ 3, 0 ], [ 6, 0 ], [ 6, 3 ], [ 3, 3 ], [ 3, 0 ] ] ] } }
> db.polygon.find( {shape: {$geoIntersects: {$geometry: BOX}}}, {_id:1})
{ "_id" : "Poly1" }
如您所见,BOX 和 Poly1 是相同的。 Poly2 与 BOX 共享一条边。 因此,当我执行 $geoIntersects-Query 时,我期待两个多边形的 where 由于共享边而返回,但只找到了 Poly1。 有人可以向我解释一下吗?还是我犯了一个我看不到的愚蠢错误:(
Auf Wiedersehen,安德烈
【问题讨论】:
标签: mongodb geospatial geo