【问题标题】:MongoDB Error: Exterior shell of polygon is invalid?MongoDB 错误:多边形的外壳无效?
【发布时间】:2013-07-29 11:06:49
【问题描述】:
db.restaurant.ensureIndex({'deliver_area': '2dsphere'})
db.restaurant.insert({'deliver_area':{type: 'Polygon', coordinates:[[[0,0], [0,1], [1,0], [1,1], [0, 0]]]}})

提高exc:

多边形的外壳无效:{类型:“多边形”,坐标:[ [ [ 0.0, 0.0 ], [ 0.0, 1.0 ], [ 1.0, 0.0 ], [ 1.0, 1.0 ], [ 0.0, 0.0 ] ] ] }

为什么多边形无效?

【问题讨论】:

    标签: mongodb gis polygon


    【解决方案1】:

    这是一个自相交的多边形:

      2      4
      |\    /|
      | \  / |
      |  \/  |
      |  /\  |
      | /  \ |
      |/    \|
     1/5     3
    

    你想要:

    {
        type: "Polygon", 
        coordinates: [ [ 
            [ 0.0, 0.0 ], 
            [ 0.0, 1.0 ], 
            [ 1.0, 1.0 ], 
            [ 1.0, 0.0 ], 
            [ 0.0, 0.0 ] 
        ] ] 
    }
    

    这是:

      2------3
      |      |
      |      |
      |      |
      |      |
      |      |
      |      |
     1/5-----4
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    • 2018-09-19
    • 1970-01-01
    • 2022-01-18
    相关资源
    最近更新 更多