db.getCollection('places').find({
"features.geometry":{
$near: {
$geometry: {
type: "Point" ,
coordinates:[
-834502.889188578,3970333.88258796
]}
,
$maxDistance: a given number
}
}
});
这就是代码,我想要的是返回几何图形接近的文档
[-834502.889188578,3970333.88258796
]
和tha(错误
Error: error: {
"waitedMS" : NumberLong(0),
"ok" : 0,
"errmsg" : "invalid point in geo near query $geometry argument: { type: \"Point\", coordinates: [ -834502.889188578, 3970333.88258796 ] } longitude/latitude is out of bounds, lng: -834503 lat: 3.97033e+006",
"code" : 2
}
答案 0 :(得分:0)
这些不是有效的lat和long值。纬度范围为+/- 90,经度范围为+/- 180。
这些不是有效的lat和long值。纬度范围为+/- 90,经度范围为+/- 180.在mongo $ geoNear坐标中,第一个值是经度,第二个值是纬度。传递给:
db.getCollection('places').find({
"features.geometry":{
$near: {
$geometry: {
type: "Point" ,
coordinates:[
longitude, latitude
]}
,
$maxDistance: a given number
}
}
});