“MongoError:无法从对象中提取地理密钥”类型:点 [英] "MongoError: Can't extract geo keys from object" with Type : Point

查看:64
本文介绍了“MongoError:无法从对象中提取地理密钥”类型:点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用以下方法准备我的数据库字段以进行地理编码:

I try to prepare my database field for geocoding with this:

MyCollection._ensureIndex({'data.address.located':'2dsphere'});

但是这个错误来了:

MongoError: Can't extract geo keys from object, malformed geometry?:
{ type: "Point", coordinates: [ 32.4586858, -110.8571443 ] }

我看不出这个字段有什么问题?有什么想法?

I can not see whats wrong with this field ? Any idea ?

当我看一看这个它显示了这个:

When I take a look to this it shows up this:

The following example stores a GeoJSON Point:

{ loc: { type: "Point", coordinates: [ 40, 5 ] } }


推荐答案

问题是

[ 32.4586858, -110.8571443 ]

不是有效坐标。顺序应该是经度,然后是纬度,而该坐标看起来是相反的(根据有效纬度范围为-90到90且-110.8571443在此范围之外的事实来判断。)

is not a valid coordinate. The order should be longitude followed by latitude whereas that coordinate appears to be the reverse (judging by the fact that the valid latitude range is -90 to 90 and -110.8571443 is outside of that).

我认为你的意思是:

{ type: "Point", coordinates: [ -110.8571443, 32.4586858 ] }

或者还有其他一些输入错误。

or there was some other entry error.

这篇关于“MongoError:无法从对象中提取地理密钥”类型:点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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