gpt4 book ai didi

Mongodb Sphere 索引拒绝我的对象

转载 作者:可可西里 更新时间:2023-11-01 10:00:53 28 4
gpt4 key购买 nike

您好,我有一个带有 2d 球体索引的集合

wayCollection.createIndex(new BasicDBObject("poly", "2dsphere"));

当我尝试插入某个对象时出现错误:

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

虽然多边形环是闭合的(第一个和最后一个坐标相同)

有什么想法吗?

这是另一个被拒绝的多边形:

{
"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/

也许 mongo db 不喜欢一个点被使用两次

最佳答案

多边形是自相交的: enter image description here

MongoDB 禁止这样的多边形。

关于Mongodb Sphere 索引拒绝我的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24375649/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com