Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-20672

Validation of 2dsphere Index does not conform to GeoJSON specification

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.5
    • Component/s: Geo
    • None
    • ALL
    • Hide

      Create database "regions", then:

      db.regions.insert(
      	{
      		"location":
      		{ "type": "MultiPolygon", 
      		    "coordinates":[
      		        [[[1,1],[1.5,1],[2,1],[1.5,2],[1.5,1],[1,2],[1,1]]]
      		    ]
      		}
      	}
      )
      db.regions.createIndex( { location: "2dsphere" } )
      
      Show
      Create database "regions", then: db.regions.insert( { "location": { "type": "MultiPolygon", "coordinates":[ [[[1,1],[1.5,1],[2,1],[1.5,2],[1.5,1],[1,2],[1,1]]] ] } } ) db.regions.createIndex( { location: "2dsphere" } )
    • RPL A (10/09/15), Repl B (10/30/15)

      I am trying to import data on German administrative regions (from www.bkg.bund.de) into a mongoDB. The data contains borders as GeoJSON conforming MultiPolygons (confirmed by geojsonlint.com). Howerver, when trying to create a 2dsphere index on data containing MultiPolygons with duplicate vertices or self intersections (e. g. the state of Bavaria), mongoDB will through an error.

      In the issues SERVER-16238 and SERVER-13735 there are several mentions of duplicate vertices or self intersections within MultiPolygons being invalid according to the GeoJSON spec. Therefore, these bug reports have been resolved as "Works as Designed". However, I do not find these restrictions in the GeoJSON spec. I also don't find mentions of restrictions of the 2dsphere index that go beyond the GeoJSON spec in the mongoDB docs.

      Are these restrictions necessary or could they be removed in future versions? A lot of valid geospatial data out there will not be usable in mongoDB with these restrictions, and many people seem to have noticed. See, also:
      http://gis.stackexchange.com/questions/135871/sqlserver-shapefile-export-wont-load-in-mongodb-due-to-self-intersection
      http://stackoverflow.com/questions/24398292/mongodb-version-2-6-still-fails-on-2dsphere-geoindexing-citing-inability-to-extr?rq=1
      http://stackoverflow.com/questions/23290114/mongodb-malformed-geometry-when-creating-a-geosphere-index?noredirect=1#comment35654181_23290114

            Assignee:
            siyuan.zhou@mongodb.com Siyuan Zhou
            Reporter:
            nimame Nima Mehrafshan
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: