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

Some polygons are refused by the 2dsphere index

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.3
    • Component/s: Geo
    • Labels:
      None
    • Environment:
      Linux
    • Linux
    • Hide

      MongoDB shell version: 2.4.3
      > use prout
      switched to db prout
      > db.mycol.ensureIndex(

      {"loc": "2dsphere"}

      )
      > db.mycol.save({"loc":{"type":"Polygon","coordinates":[[[-116.0,-87.0181],[64.0,-87.0181],[64.0,-71.0181],[-116.0,-71.0181],[-116.0,-88.0181]]]}})
      Can't extract geo keys from object, malformed geometry?:

      { type: "Polygon", coordinates: [ [ [ -116.0, -87.0181 ], [ 64.0, -87.0181 ], [ 64.0, -71.0181 ], [ -116.0, -71.0181 ], [ -116.0, -88.0181 ] ] ] }

      // this one works, observe the subtle difference.

      > db.mycol.save({"loc":{"type":"Polygon","coordinates":[[[-116.0,-87.0181],[64.0,-85.0181],[64.0,-71.0181],[-116.0,-71.0181],[-116.0,-87.0181]]]}})

      Show
      MongoDB shell version: 2.4.3 > use prout switched to db prout > db.mycol.ensureIndex( {"loc": "2dsphere"} ) > db.mycol.save({"loc":{"type":"Polygon","coordinates":[[ [-116.0,-87.0181] , [64.0,-87.0181] , [64.0,-71.0181] , [-116.0,-71.0181] , [-116.0,-88.0181] ]]}}) Can't extract geo keys from object, malformed geometry?: { type: "Polygon", coordinates: [ [ [ -116.0, -87.0181 ], [ 64.0, -87.0181 ], [ 64.0, -71.0181 ], [ -116.0, -71.0181 ], [ -116.0, -88.0181 ] ] ] } // this one works, observe the subtle difference. > db.mycol.save({"loc":{"type":"Polygon","coordinates":[[ [-116.0,-87.0181] , [64.0,-85.0181] , [64.0,-71.0181] , [-116.0,-71.0181] , [-116.0,-87.0181] ]]}})

      There are some GeoJSON polygons that are refused by the 2dsphere index ("Can't extract geo keys from object, malformed geometry")
      There is no obvious pattern on the polygon. A slight perturbation of one of the vertex makes it acceptable again. AFAIK, the polygons are correct.

            Assignee:
            Unassigned Unassigned
            Reporter:
            thoran Frédéric De Jaeger
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: