$ near需要geojson点,给定geojson点 [英] $near requires geojson point, given geojson point
本文介绍了$ near需要geojson点,给定geojson点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些文档,其中包含如下所示的地理位置字段.
I have documents which contain a geo field like the below.
"geo" : {
"type" : "Point",
"coordinates" : [
37.44609999,
-121.88355687
]
},
我创建了一个空间索引,如下所示.
I have created a spatial index, proof below.
db.collection.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "db.collection",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"geo.coordinates" : "2dsphere"
},
"ns" : "db.collection",
"name" : "geo.coordinates_2dsphere"
}
]
但是,当我执行以下查询时(MongoDB手册中的详细内容).
However when I execute the following query (verbatim from the MongoDB manual ).
db.collection.find( { 'geo.coordinates': { $near:
{ $geometry :
{ type : "Point",
coordinates: [ 37.44609999, -121.88355687 ] } },
$maxDistance: 1000
} } )
我收到以下错误消息.
error: {
"$err" : "$near requires geojson point, given { type: \"Point\", coordinates: [ 37.44609999, -121.88355687 ] }",
"code" : 16681
}
有人能启发我为什么吗?
Can someone enlighten me as to why?
推荐答案
这样翻转点:
"geo":{ "type":"Point", 坐标":[ -121.88355687, 37.44609999 ] }
"geo" : { "type" : "Point", "coordinates" : [ -121.88355687, 37.44609999 ] },
否则,请检查您的坐标以查看它们是否为实: http://geojsonlint.com/
Otherwise, check your coordinates to see if they are real: http://geojsonlint.com/
这篇关于$ near需要geojson点,给定geojson点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文