與MongoDB的工作2dsphere存儲以GeoJSON和緯度/經度的某些商店我不斷收到以下錯誤:不能提取地理鑰匙,經度/緯度超出範圍
{
"code": 16755,
"index": 0,
"errmsg": "Can't extract geo keys: { _id: ObjectId('586ff135b79aa00b84181bfb'), name: \"Austin\", slug: \"Austin\", description: \"\", twitter: \"\", facebook: \"\", instagram: \"\", author: ObjectId('57b60fed8620b56af460d5c5'), tags: [], created: new Date(1483731253640), location: { address: \"Austin, TX, United States\", coordinates: [ 30.267153, -97.74306079999997 ], type: \"Point\" }, __v: 0 } longitude/latitude is out of bounds, lng: 30.2672 lat: -97.7431",
"op": {
"name": "Austin",
"slug": "Austin",
"description": "",
"twitter": "",
"facebook": "",
"instagram": "",
"author": "57b60fed8620b56af460d5c5",
"_id": "586ff135b79aa00b84181bfb",
"tags": [
],
"created": "2017-01-06T19:34:13.640Z",
"location": {
"address": "Austin, TX, United States",
"coordinates": [
30.267153,
-97.74306079999997
],
"type": "Point"
},
"__v": 0
}
}
我不能似乎弄清楚爲什麼它不喜歡一些緯度/經度座標。
這裏是我的位置字段模式:
location: {
type: { type: String, default: 'Point' },
coordinates: [Number],
address: String
},
,它的索引爲2dsphere
:
storeSchema.index({ location: '2dsphere' });
唯一奇怪的事情,我可以看到的是,該錯誤消息:
longitude/latitude is out of bounds, lng: 30.2672 lat: -97.7431",
lat/lng縮短了我輸入的內容 - 不確定這與它有什麼關係。
當我從節點4.2.2升級到7.6.0時,我剛開始出現這個問題。我還沒有解決它。建議將lng,lat交換,如果屬實,則a **中的痛苦將被修復。我希望有一種方法可以在索引中進行設置。 – ra9r
我想出了一個解決這個問題的方法。看到我的迴應。 – ra9r