[SERVER-11395] Cannot create 2dsphere index on GeoJSON data Created: 25/Oct/13  Updated: 07/May/14  Resolved: 01/Nov/13

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.5.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Robert Gordon Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: geo, geojson, geometry
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOs, OSX Mountain LIon


Attachments: PNG File Screen Shot 2013-10-30 at 7.36.12 PM.png     Text File mongo-error.txt    
Issue Links:
Related
related to SERVER-13857 WriteConcern detected an error 'inser... Closed
Operating System: Linux
Steps To Reproduce:

Insert GeoJSON record specified in attachment into a new collection. Attempt to create a 2dsphere index on that collection using the following command:
db.btest.ensureIndex(

{geometry:"2dsphere"}

)

Participants:

 Description   

I have shape data file data which I converted to GeoJSON using QGIS 1.7.3 for Mac. I parsed out each GeoJSON object from the generated file and then wrote out each object (one object per line) to an output file. Finally, I loaded that output file into mongo using the 'mongoimport' utility, creating a new collection for the data.

I then log in to the database using the 'mongo' tool and attempt to create a '2dsphere' index on the newly created collection. About 18% of the way through the data I receive the error

"Can't extract geo keys from object, malformed geometry?"
This sounds similar to ticket SERVER-9401

I've checked http://geojsonlint.com and the GeoJSON mentioned in the error passes and successfully renders.

I've attached the exact error and its output to the ticket

{ type: "Polygon", coordinates: [ [ [ -73.99625346569333, 40.76190478805697 ], [ -73.99609819005899, 40.76212541008178 ], [ -73.99589543781777, 40.76203152905607 ], [ -73.99612203263234, 40.76172143380322 ], [ -73.99614119142737, 40.76169823745224 ], [ -73.99713046436048, 40.76211428136805 ], [ -73.99678540634655, 40.76258863993873 ], [ -73.9959938151665, 40.76225573199486 ], [ -73.99609819005899, 40.76212541008178 ], [ -73.99647687902545, 40.76227949768229 ], [ -73.99650084085626, 40.76224545124312 ], [ -73.99670747493275, 40.76232952932145 ], [ -73.99682613447295, 40.76216093031877 ], [ -73.99629031476267, 40.76194290760107 ], [ -73.99630296782105, 40.7619249303378 ], [ -73.99625346569333, 40.76190478805697 ] ] ] }

 Comments   
Comment by A. Jesse Jiryu Davis [ 01/Nov/13 ]

This behavior is expected; the polygon self-intersects at a corner. It is not defined whether a polygon's vertex is inside or outside the polygon, so accepting or rejecting this polygon would both be acceptable behavior.

As a workaround, you might add a minuscule amount of space between the two corners to ensure the polygon does not intersect itself.

Comment by A. Jesse Jiryu Davis [ 30/Oct/13 ]

Visualization of this polygon; it self-intersects at [-73.99609819005899, 40.76212541008178].

Comment by Robert Gordon [ 25/Oct/13 ]

Another message being displayed in the error is the following:

Exterior shell of polygon is invalid

Generated at Thu Feb 08 03:25:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.