Mongodb error: cannot extract geo-keys from an object with distorted geometry?

I get the following error: mongodb 2.4.3

Can't extract geo keys from object, malformed geometry?

 {type: "Polygon", coordinates: [ [ [ 103.8324334524412, 1.284232321447769 ], [ 103.8342325475588, 1.284232321447769 ], [ 103.8342325469261, 1.282433678236006 ], [ 103.8324334530738, 1.282433678236006 ] ] ]} 

Can someone help me understand the problem? it looks like a valid geoJSON object. My index is of 2dsphere type.

I follow these two steps:

 collection.ensureIndex {'geometry' : "2dsphere"}, (error) => # some error checking # and then collection.insert features, (error) => # features is an array of geoJSON feature objects # {"type" : "Feature" # "geometry" : <the Polygon object above> } 

The insert request gives this error. The whole document I'm trying to insert:

 { "type":"Feature", "geometry": { "type":"Polygon", "coordinates":[ [ [103.83243345244122,1.2842323214477689], [103.83423254755876,1.2842323214477689], [103.83423254692615,1.2824336782360055], [103.83243345307383,1.2824336782360055] ] ] }, "properties":{"name" : "My location"} } 
+6
source share
3 answers

The polygon object in geoJSON requires the first dot ([lon, lat]) to be the same as the last dot. Having made this change:

 {type: "Polygon", coordinates: [ [ [ 103.8324334524412, 1.284232321447769 ], [ 103.8342325475588, 1.284232321447769 ], [ 103.8342325469261, 1.282433678236006 ], [ 103.8324334530738, 1.282433678236006 ], [ 103.8324334524412, 1.284232321447769 ] ] ]} 

The insert request works fine.

+9
source

In my case, the problem was the same as above, but the solution to what worked for me is

 point ([longitude, latitude]) 

I just did the opposite how

 point ([latitude, longitude]) 

It was pretty stupid from me, but it’s very difficult to understand the error. Can't extract geo-keys from an object with distorted geometry?

But just substitute someone like me, find it, please check it.

+3
source

I had the same problem and my longitude, latitude order was correct. My mistake was that I wrote coordiantes instead of coordinates mongo gave me this:

 pymongo.errors.WriteError: Can't extract geo keys: {data} Point must be an array or object 

so maybe you have the right order, but you have problems with the names of your keys, make sure that you obey the rules of the mango!

0
source

Source: https://habr.com/ru/post/947809/


All Articles