Arrays 查找给定的经度、纬度对是否位于MongoDB中的任何多边形中

Arrays 查找给定的经度、纬度对是否位于MongoDB中的任何多边形中,arrays,database,mongodb,analytics,geospatial,Arrays,Database,Mongodb,Analytics,Geospatial,根据我目前对MongoDB的理解,我们通过传递一个[long,lat]对数组来搜索我们的集合,以检查该文档的[long,lat]对是否存在于坐标[[[],[],[]]内 i、 e db.SomeCollection.find({ "location":{ $geoWithin: { $geometry: { type: "Polygon", coordinates: [

根据我目前对MongoDB的理解,我们通过传递一个[long,lat]对数组来搜索我们的集合,以检查该文档的[long,lat]对是否存在于坐标
[[[],[],[]]

i、 e

db.SomeCollection.find({
    "location":{
        $geoWithin: {
            $geometry: { 
                type: "Polygon", 
                coordinates: [
                    [[1, 2], [1, 3], [1, 4]],
                    [[2, 5], [2, 6], [2, 7]]
                ] }
        }
    }
})
我要寻找的是,我需要将[long,lat]对输入到一个包含固定多边形地理围栏阵列的文档中,并确定[long,lat]对是否存在于这些[Polygonal geofrays]中

这在MongoDB中可能吗?我的问题正确吗

请注意:我是MongoDB以及地理空间数据的新手 如果问题包含错误的术语,请原谅


几天后,我又回到我的问题上来,因为我找到了答案

解决方案已发布在中

因此,将其应用于我的问题将如下所示:

db.Poly_Geofence_collection.find(
{
    "location": {
        $geoIntersects: {
            $geometry: {
                type: "Point",
                coordinates: [1,1]
            }
        }
    }
});
其中,我的
Poly\u geopfence\u集合
集合如下所示:

{
    "_id": ObjectId("SomeRandom12ByteObjectId"),
    "location" : {
        "type" : "Polygon",
        "name" : "Location Name",
        "coordinates" : [
            [
                [0, 0], [1, 2], [1, 1], [2, 1], [0, 0]
            ]
        ]
    }
}

我认为这篇文章包含了您想要的内容: