Using Spring Data,Mongodb, how can I avoid Duplicate vertices error Using Spring Data,Mongodb, how can I avoid Duplicate vertices error mongodb mongodb

Using Spring Data,Mongodb, how can I avoid Duplicate vertices error


In this case you have duplicate vertex at index 0 and index 1341 for 2nd polygon.

[ -62.95859676499998, 46.20653318300003 ]

The insertion fails when Mongo db is trying to build the 2d sphere index for the document. Remove the coordinate at index 1341 and you should be able to persist successfully.

You just have to cleanse the data when you find the error.You can write a small program to read the error from mongo db and provide the update back to the client. Client can act on those messages and try again the request.

More information on geo errors can be found here.You can look at the code here for GeoParser to find how/what errors are generated. For the specific error you got you can take a look here GeoParser. This error is generated by S2 library that Mongodb uses for validation.