无法提取地理位置键,经度/纬度超出范围 [英] Can't extract geo keys, longitude/latitude is out of bounds

查看:458
本文介绍了无法提取地理位置键,经度/纬度超出范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与MongoDB 2dsphere一起存储GEOJSON并在lat/lng的某些存储上,我不断遇到以下错误:

Working with MongoDB 2dsphere to store GEOJSON and on certain stores of lat/lng I keep getting the following error:

{
  "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
  }
}

我似乎无法弄清为什么它不喜欢某些经/纬度坐标.

I can't seem to figure out why it doesn't like some lat/lng coordinates.

这是我的位置字段架构:

Here is my schema for the location field:

  location: {
    type: { type: String, default: 'Point' },
    coordinates: [Number],
    address: String
  },

,它的索引为2dsphere:

storeSchema.index({ location: '2dsphere' });

我唯一看到的奇怪的是错误消息:

The only weird thing I can see is that the error message:

longitude/latitude is out of bounds, lng: 30.2672 lat: -97.7431",

纬度/经度比我输入的要短-不确定是否与此有关.

the lat/lng are shortened from what I inputted - not sure if that has anything to do with it.

推荐答案

哦-我不确定是谁决定的,但Mongodb希望您将其存储为[lng, lat],而不是[lat,lng].

Oh wow - I'm not sure who decided this but Mongodb expects you to store as [lng, lat], not [lat,lng] like everything else in this world.

:|

这篇关于无法提取地理位置键,经度/纬度超出范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆