MongoDB地理空间查询 - 距离计算

时间:2017-08-02 12:30:49

标签: mongodb aggregation-framework geospatial

我已经导入了餐馆数据集 https://raw.githubusercontent.com/brianboyko/DigiQuiz/master/primer-dataset.json

Mongo查询如下 -

db.restaurants.aggregate([{
    $geoNear: {
        near:{ type: "Point", coordinates: [ -73.9243061, 40.8276297] }, 
        distanceField: "distance",
        maxDistance: 60,
        num: 5,
        spherical: true
        }},
    {$match: {"borough": "Bronx"}}
]);

输出

{
    "_id" : ObjectId("596613f776bc5df662633887"),
    "address" : {
        "building" : "860",
        "coord" : [ 
            -73.9249324, 
            40.8274822
        ],
        "street" : "Gerard Avenue",
        "zipcode" : "10451"
    },
    "borough" : "Bronx",
    "name" : "Us Fried Chicken",
    "restaurant_id" : "41713384",
    "distance" : 55.2511788230297
}

所以我有一个基本问题: 查询和放大器中指定的maxDistance的单位是多少?什么是输出json中的距离场单位。

当我检查这两点之间的距离[-73.9243061,40.8276297]& [-73.9249324,40.8274822],它说70米。

由于 彩

0 个答案:

没有答案