哪个位置包含我的GPS协调?

时间:2018-10-11 08:08:59

标签: mongodb

我有包含圆形坐标(纬度,对数,半径)的文档。

{
    "_id" : ObjectId("5bbee50cc0fc467b97a205e8"),
    "radius" : 500,
    "location" : {
        "type" : "Point",
        "coordinates" : [
            59.566004414819304,
            36.30634702972963
        ]
    },
}
{
    "_id" : ObjectId("5bbee52dc0fc467b97a205f6"),
    "radius" : 300,
    "location" : {
        "type" : "Point",
        "coordinates" : [
            59.586947102807585,
            36.29133618357846
        ]
    },
}
{
    "_id" : ObjectId("5bbee51dc0fc467b97a205ef"),
    "radius" : 750,
    "location" : {
        "type" : "Point",
        "coordinates" : [
            59.54042686965329,
            36.31526915899667
        ]
    },
}

我可以按照最近的中心协调对它们进行排序:

{'$near': {'$geometry': {'type': 'Point', 'coordinates': [36.30551244297848, 59.56594241783023]}, '$maxDistance': 100000}}

但是问题在于,由于半径的原因,最近的中心坐标可能不会包含我的坐标。
有没有办法找到哪个圆圈包含我的坐标?

0 个答案:

没有答案