mongodb$geointersects不工作

mongodb$geointersects不工作,mongodb,Mongodb,我试图在mongodb中使用$geocursects查找点所在的多边形 在php中,我创建了测试数据: $collection = $db->selectCollection('countries'); $result = $collection->insertMany([ [ 'c' => 'rus', 'n' => 'Russia', 'loc' => [ "type" =>

我试图在
mongodb
中使用
$geocursects
查找点所在的多边形

php
中,我创建了测试数据:

$collection = $db->selectCollection('countries');
$result = $collection->insertMany([
    [
        'c' => 'rus',
        'n' => 'Russia',
        'loc' => [
            "type" => "Polygon",
            "coordinates" => [
                [-109.95117, 39.77477],
                [-100.23926, 46.70974],
                [-94.41608,  37.78902],
                [-104.67541, 32.70375],
                [-109.95117, 39.77477]
            ]
       ]
    ],[
        'c' => 'can',
        'n' => 'Canada',
        'loc' => [
            "type" => "Polygon",
            "coordinates" => [
                [-100.15137, 46.83013],
                [-84.31555,  47.89965],
                [-82.39746,  37.78808],
                [-94.28467,  37.8228 ],
                [-100.15137, 46.83013]
            ]
       ]
    ]
]);
结果是:

然后在
Robomongo
中,我选择:

db.getCollection('countries').find({“loc”:{$geocursects: {$geometry:{“类型”:“点”,“坐标”:[-88.0123388,41.8333926 ]}}}})

并且没有返回任何行!这里可能有什么问题

在shell中相同:

以下是我正在测试的多边形:

以下是要点(41.8333926,-88.0123388):


使用最新版本的mongodb:3.2.9。

答案是坐标结构不正确。我想创建一个索引,但失败了。。这就是如何被发现的

正确的数组:

"coordinates" => [[
                [-109.95117, 39.77477],
                [-100.23926, 46.70974],
                [-94.41608,  37.78902],
                [-104.67541, 32.70375],
                [-109.95117, 39.77477]
            ]]

因此,在我最初的问题中,我把点放在了所谓的多边形中。

答案是坐标的结构是不正确的。我想创建一个索引,但失败了。。这就是如何被发现的

正确的数组:

"coordinates" => [[
                [-109.95117, 39.77477],
                [-100.23926, 46.70974],
                [-94.41608,  37.78902],
                [-104.67541, 32.70375],
                [-109.95117, 39.77477]
            ]]
因此,在我最初的问题中,我把要点放在了所谓的多义词上