Can't create index 2dsphere in mongoDB

When I try to create a 2dsphere index in mongoDB I get this msg error:

> db.mahalle.createIndex({geometry:"2dsphere"})
{
        "createdCollectionAutomatically" : false,
        "numIndexesBefore" : 1,
        "errmsg" : "exception: Can't extract geo keys: { _id: ObjectId('55b4e025a6ef7e9c50ae79cd'), type: \"Feature\", p
roperties: { ADI: \"Çelemli\", ILADI: \"Adana\", ILCEADI: \"Yüre?ir\", BUCAKADI: \"Merkez\", KOYADI: \"Çelemli\", ILKOD:
 1 }, geometry: { type: \"Polygon\", coordinates: [ [ [ 35.624498, 36.849395 ], [ 35.649357, 36.876937 ], [ 35.657724, 3
6.879572 ], [ 35.663334, 36.873718 ], [ 35.668063, 36.875857 ], [ 35.671228, 36.87511 ], [ 35.676613, 36.872193 ], [ 35.
676789, 36.86627 ], [ 35.681188, 36.865075 ], [ 35.683002, 36.864582 ], [ 35.685911, 36.858289 ], [ 35.690937, 36.856315
 ], [ 35.698809, 36.857084 ], [ 35.70811, 36.84059 ], [ 35.703934, 36.838901 ], [ 35.669599, 36.82501 ], [ 35.65748, 36.
820107 ], [ 35.63049, 36.809188 ], [ 35.639549, 36.812853 ], [ 35.625102, 36.834434 ], [ 35.624498, 36.849395 ] ] ] } }
 Loop is not valid: [ [ 35.624498, 36.849395 ], [ 35.649357, 36.876937 ], [ 35.657724, 36.879572 ], [ 35.663334, 36.8737
18 ], [ 35.668063, 36.875857 ], [ 35.671228, 36.87511 ], [ 35.676613, 36.872193 ], [ 35.676789, 36.86627 ], [ 35.681188,
 36.865075 ], [ 35.683002, 36.864582 ], [ 35.685911, 36.858289 ], [ 35.690937, 36.856315 ], [ 35.698809, 36.857084 ], [
35.70811, 36.84059 ], [ 35.703934, 36.838901 ], [ 35.669599, 36.82501 ], [ 35.65748, 36.820107 ], [ 35.63049, 36.809188
], [ 35.639549, 36.812853 ], [ 35.625102, 36.834434 ], [ 35.624498, 36.849395 ] ] Edges 16 and 18 cross. Edge locations
in degrees: [35.6574800, 36.8201070]-[35.6304900, 36.8091880] and [35.6395490, 36.8128530]-[35.6251020, 36.8344340]",
        "code" : 16755,
        "ok" : 0
}
>

      

the collection data looks like this:

> db.mahalle.findOne()
{
        "_id" : ObjectId("55b4e025a6ef7e9c50ae792f"),
        "type" : "Feature",
        "properties" : {
                "KOYADI" : "Ömerli",
                "ILKOD" : 1,
                "ADI" : "Ömerli",
                "ILADI" : "Adana",
                "ILCEADI" : "Pozanty",
                "BUCAKADI" : "Merkez"
        },
        "geometry" : {
                "type" : "Polygon",
                "coordinates" : [
                        [
                                [
                                        34.840791,
                                        37.516416
                                ],
                                [
                                        34.843066,
                                        37.525614
                                ],
                                [
                                        34.847284,
                                        37.545556
                                ],
                                [
                                        34.849961,
                                        37.602446
                                ],
                                [
                                        34.892618,
                                        37.570159
                                ],
                                [
                                        34.8991,
                                        37.559108
                                ],
                                [
                                        34.902859,
                                        37.545415
                                ],
                                [
                                        34.887897,
                                        37.508253
                                ],
                                [
                                        34.843046,
                                        37.489936
                                ],
                                [
                                        34.842049,
                                        37.501638
                                ],
                                [
                                        34.840791,
                                        37.516416
                                ]
                        ]
                ]
        }
}

      

I need to create a 2dsphere index to find coordinates in polygonal areas. How can I fix this? Thanks to

+3


source to share





All Articles