Mongodb错误:无法从对象,格式错误的几何图形中提取地理键? [英] Mongodb error : Can't extract geo keys from object, malformed geometry?

查看:80
本文介绍了Mongodb错误:无法从对象,格式错误的几何图形中提取地理键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mongodb 2.4.3中遇到以下错误

I get the following error with mongodb 2.4.3

Can't extract geo keys from object, malformed geometry?

{type: "Polygon",
coordinates: [
    [
        [
            103.8324334524412,
            1.284232321447769
        ],
        [
            103.8342325475588,
            1.284232321447769
        ],
        [
            103.8342325469261,
            1.282433678236006
        ],
        [
            103.8324334530738,
            1.282433678236006
        ]
    ]
]}

有人可以帮助我理解问题吗?它看起来像一个有效的geoJSON对象.我的索引是2dsphere类型.

Can someone help me understand the problem? it looks like a valid geoJSON object. My index is of type 2dsphere.

我正在运行的两个步骤是:

The two steps i am running are :

collection.ensureIndex {'geometry' : "2dsphere"}, (error) =>
  # some error checking
  # and then
  collection.insert features, (error) =>
    # features is an array of geoJSON feature objects
    # {"type" : "Feature"
    #  "geometry" : <the Polygon object above>
      }

insert查询给出此错误. 我要插入的完整文档是:

The insert query gives this error. The complete document i am trying to insert is:

{
    "type":"Feature",
    "geometry": {
        "type":"Polygon",
        "coordinates":[
           [
             [103.83243345244122,1.2842323214477689],
             [103.83423254755876,1.2842323214477689],
             [103.83423254692615,1.2824336782360055],
             [103.83243345307383,1.2824336782360055]
           ]
        ]
      },
    "properties":{"name" : "My location"}
  }

推荐答案

geoJSON中的多边形对象要求第一个点([lon,lat])与最后一个点相同. 通过进行此更改:

The polygon object in geoJSON requires first point ([lon, lat]) to be same as last point. By making this change:

{type: "Polygon",
coordinates: [
    [
        [
            103.8324334524412,
            1.284232321447769
        ],
        [
            103.8342325475588,
            1.284232321447769
        ],
        [
            103.8342325469261,
            1.282433678236006
        ],
        [
            103.8324334530738,
            1.282433678236006
        ],
        [
            103.8324334524412,
            1.284232321447769
        ]
    ]
]}

插入查询工作正常.

这篇关于Mongodb错误:无法从对象,格式错误的几何图形中提取地理键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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