我试图运行这个mongodb查询
db.building.update( { "_id":ObjectId("53041776a2de55000079b4ba") },
{ $set :
{"geometry":{"type":"Polygon","coordinates":[[[127.357858169667,36.36773567198263],[127.35825816966712,36.36773567198263],[127.35805432178199,36.3675356722397],[127.35825816966712,36.36733567198263],[127.357858169667,36.36733567198263],[127.357858169667,36.36773567198263],[127.357858169667,36.36773567198263]]]}}
}
)
结果是
Exterior shell of polygon is invalid: { type: "Polygon", coordinates: [ [ [ 127.357858169667, 36.36773567198263 ], [ 127.3582581696671, 36.36773567198263 ], [ 127.358054321782, 36.3675356722397 ], [ 127.3582581696671, 36.36733567198263 ], [ 127.357858169667, 36.36733567198263 ], [ 127.357858169667, 36.36773567198263 ], [ 127.357858169667, 36.36773567198263 ] ] ] }
但是GeoJSONLint测试是有效的。
帮帮我吧。谢谢。
答案 0 :(得分:1)
如果多边形格式不正确,则会发生此错误,例如:
1/2重复:
1/2-----3
| |
| |
| |
| |
| |
| |
0------4
交叉点:
1 3
|\ /|
| \ / |
| \/ |
| /\ |
| / \ |
|/ \|
0/4 2
重复项很容易检测,只需检查第一个和最后一个坐标是否相等,然后删除其中一个。
如果你的多边形中有一个交叉点,你可以尝试重新排序点(类似的问题:MongoDB Error: Exterior shell of polygon is invalid?)。
如果这不起作用,请检查GeoJSON is valid(来自此问题:Why is the exterior shell of this GeoJSON invalid?)。