Mongodb Sphere索引拒绝我的对象 [英] Mongodb Sphere index rejects my object
问题描述
我有一个2d球面索引的集合
Hi i have an COllection with an 2d sphere index
wayCollection.createIndex(new BasicDBObject("poly", "2dsphere"));
我尝试插入某个对象时出现错误:
i when i try to insert a certain object i get an error:
Exception in thread "main" com.mongodb.WriteConcernException: { "serverUsed" : "localhost:27017" , "ok" : 1 , "n" : 0 , "err" : "insertDocument :: caused by :: 16755 Can't extract geo keys from object, malformed geometry?: { _id: ObjectId('53a89dc6a0042baf54050037'), id: 24837452, version: \"64\", changeset: \"13731788\", uid: \"362915\", user: \"micha555\", timestamp: \"2012-11-03T09:11:23Z\", poly: { type: \"Polygon\", coordinates: [ [ [ 9.1244131, 50.0109503 ], [ 9.120464800000001, 50.0099731 ], [ 9.116641, 50.0077
尽管多边形环是闭合的(第一个和最后一个坐标相同)
although the multipolygon ring is closed (first and last coordinate is the same)
有什么想法吗?
这是另一个被拒绝的多边形:
Here is another polygon which is rejected:
{
"type":"Polygon",
"coordinates":[
[
[
9.0496053,
51.3255584
],
[
9.0492235,
51.32532
],
[
9.0495831,
51.3251321
],
[
9.049917199999999,
51.3253429
],
[
9.0496053,
51.3255584
],
[
9.049984500000001,
51.3258463
],
[
9.0505795,
51.3262127
],
[
9.050045600000001,
51.326574
],
[
9.0496432,
51.3263928
],
[
9.049625300000001,
51.3262806
],
[
9.0495628,
51.3261244
],
[
9.0495316,
51.3259341
],
[
9.0495471,
51.3257127
],
[
9.0496053,
51.3255584
]
]
]
}
当我将其粘贴到此处时,似乎没问题: http://geojsonlint.com/
when i paste it here it seems to be ok: http://geojsonlint.com/
也许mongo db不喜欢两次使用一个点
maybe mongo db does not like when a point is used twice
推荐答案
我要做的第一件事是在 http://geojsonlint.com/.如果未通过,则说明您的数据点存在问题(以前曾对许多人造成此错误).
First thing I would do is check your polygon at http://geojsonlint.com/ . If it does not pass then you know you have an issue with your data points (which has caused this error for many people previously).
如果确实通过,那么我将检查最近报告并提交给MongoDB的此错误: https ://jira.mongodb.org/browse/SERVER-13735 .基本上,有效的MultiPolygon会导致MongoDB 2.6.X上的2dsphere索引错误.其他人也报告了类似的问题,所以我敢打赌这是一个错误或一些未记录的限制.
If it does pass then I would check this bug that was recently reported and submitted to MongoDB: https://jira.mongodb.org/browse/SERVER-13735 . Basically a valid MultiPolygon is causing an error with the 2dsphere index on MongoDB 2.6.X. Others have reported similar issues so my bet is that it's a bug, or some undocumented limitation.
我会对JIRA上的问题投赞成票,并在评论中添加您的声音-越来越多的人让MongoDB知道此错误的存在,并且对他们的影响会更快地得到解决.
I'd vote up the issue on JIRA and add your voice to the comments - the more people let MongoDB know that this bug exists and is impacting them the faster it will get fixed.
这篇关于Mongodb Sphere索引拒绝我的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!