MongoDB错误:多边形的外壳无效?

时间:2013-07-29 11:06:50

标签: mongodb gis polygon

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:

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

为什么多边形无效?

1 个答案:

答案 0 :(得分:3)

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

  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
相关问题