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

2dsphere index thinks clearly parallel lines intersect

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 5.0.9
    • Component/s: None
    • ALL
    • Hide
      > db.createCollection('xx')
      { "ok" : 1 }
      > db.xx.createIndex({geolocation:'2dsphere'})
      {
          "numIndexesBefore" : 1,
          "numIndexesAfter" : 2,
          "createdCollectionAutomatically" : false,
          "ok" : 1
      }
      > db.xx.insertOne({'_id': 'busted', geolocation: {'type': 'Polygon', 'coordinates': [[[101.5625,-45.25],[76.5625,-45.25],[82.1875,-45.75],[89.6875,-45.75],[101.5625,-45.25]]]}})
      WriteError({
          "index" : 0,
          "code" : 16755,
          "errmsg" : "Can't extract geo keys: { _id: \"busted\", geolocation: { type: \"Polygon\", coordinates: [ [ [ 101.5625, -45.25 ], [ 76.5625, -45.25 ], [ 82.1875, -45.75 ], [ 89.6875, -45.75 ], [ 101.5625, -45.25 ] ] ] } }  Loop is not valid: [ [ 101.5625, -45.25 ], [ 76.5625, -45.25 ], [ 82.1875, -45.75 ], [ 89.6875, -45.75 ], [ 101.5625, -45.25 ] ] Edges 0 and 2 cross. Edge locations in degrees: [-45.2500000, 101.5625000]-[-45.2500000, 76.5625000] and [-45.7500000, 82.1875000]-[-45.7500000, 89.6875000]",
          "op" : {
              "_id" : "busted",
              "geolocation" : {
                  "type" : "Polygon",
                  "coordinates" : [
                      [
                          [
                              101.5625,
                              -45.25
                          ],
                          [
                              76.5625,
                              -45.25
                          ],
                          [
                              82.1875,
                              -45.75
                          ],
                          [
                              89.6875,
                              -45.75
                          ],
                          [
                              101.5625,
                              -45.25
                          ]
                      ]
                  ]
              }
          }
      }) :
      WriteError({
          "index" : 0,
          "code" : 16755,
          "errmsg" : "Can't extract geo keys: { _id: \"busted\", geolocation: { type: \"Polygon\", coordinates: [ [ [ 101.5625, -45.25 ], [ 76.5625, -45.25 ], [ 82.1875, -45.75 ], [ 89.6875, -45.75 ], [ 101.5625, -45.25 ] ] ] } }  Loop is not valid: [ [ 101.5625, -45.25 ], [ 76.5625, -45.25 ], [ 82.1875, -45.75 ], [ 89.6875, -45.75 ], [ 101.5625, -45.25 ] ] Edges 0 and 2 cross. Edge locations in degrees: [-45.2500000, 101.5625000]-[-45.2500000, 76.5625000] and [-45.7500000, 82.1875000]-[-45.7500000, 89.6875000]",
          "op" : {
              "_id" : "busted",
              "geolocation" : {
                  "type" : "Polygon",
                  "coordinates" : [
                      [
                          [
                              101.5625,
                              -45.25
                          ],
                          [
                              76.5625,
                              -45.25
                          ],
                          [
                              82.1875,
                              -45.75
                          ],
                          [
                              89.6875,
                              -45.75
                          ],
                          [
                              101.5625,
                              -45.25
                          ]
                      ]
                  ]
              }
          }
      })
      WriteError@src/mongo/shell/bulk_api.js:465:48
      mergeBatchResults@src/mongo/shell/bulk_api.js:871:49
      executeBatch@src/mongo/shell/bulk_api.js:940:13
      Bulk/this.execute@src/mongo/shell/bulk_api.js:1182:21
      DBCollection.prototype.insertOne@src/mongo/shell/crud_api.js:264:9
      @(shell):1:1 
      Show
      > db.createCollection( 'xx' ) { "ok" : 1 } > db.xx.createIndex({geolocation: '2dsphere' }) {     "numIndexesBefore" : 1,     "numIndexesAfter" : 2,     "createdCollectionAutomatically" : false ,     "ok" : 1 } > db.xx.insertOne({ '_id' : 'busted' , geolocation: { 'type' : 'Polygon' , 'coordinates' : [[[101.5625,-45.25],[76.5625,-45.25],[82.1875,-45.75],[89.6875,-45.75],[101.5625,-45.25]]]}}) WriteError({     "index" : 0,     "code" : 16755,     "errmsg" : "Can't extract geo keys: { _id: \" busted\ ", geolocation: { type: \" Polygon\ ", coordinates: [ [ [ 101.5625, -45.25 ], [ 76.5625, -45.25 ], [ 82.1875, -45.75 ], [ 89.6875, -45.75 ], [ 101.5625, -45.25 ] ] ] } }  Loop is not valid: [ [ 101.5625, -45.25 ], [ 76.5625, -45.25 ], [ 82.1875, -45.75 ], [ 89.6875, -45.75 ], [ 101.5625, -45.25 ] ] Edges 0 and 2 cross. Edge locations in degrees: [-45.2500000, 101.5625000]-[-45.2500000, 76.5625000] and [-45.7500000, 82.1875000]-[-45.7500000, 89.6875000]" ,     "op" : {         "_id" : "busted" ,         "geolocation" : {             "type" : "Polygon" ,             "coordinates" : [                 [                     [                         101.5625,                         -45.25                     ],                     [                         76.5625,                         -45.25                     ],                     [                         82.1875,                         -45.75                     ],                     [                         89.6875,                         -45.75                     ],                     [                         101.5625,                         -45.25                     ]                 ]             ]         }     } }) : WriteError({     "index" : 0,     "code" : 16755,     "errmsg" : "Can't extract geo keys: { _id: \" busted\ ", geolocation: { type: \" Polygon\ ", coordinates: [ [ [ 101.5625, -45.25 ], [ 76.5625, -45.25 ], [ 82.1875, -45.75 ], [ 89.6875, -45.75 ], [ 101.5625, -45.25 ] ] ] } }  Loop is not valid: [ [ 101.5625, -45.25 ], [ 76.5625, -45.25 ], [ 82.1875, -45.75 ], [ 89.6875, -45.75 ], [ 101.5625, -45.25 ] ] Edges 0 and 2 cross. Edge locations in degrees: [-45.2500000, 101.5625000]-[-45.2500000, 76.5625000] and [-45.7500000, 82.1875000]-[-45.7500000, 89.6875000]" ,     "op" : {         "_id" : "busted" ,         "geolocation" : {             "type" : "Polygon" ,             "coordinates" : [                 [                     [                         101.5625,                         -45.25                     ],                     [                         76.5625,                         -45.25                     ],                     [                         82.1875,                         -45.75                     ],                     [                         89.6875,                         -45.75                     ],                     [                         101.5625,                         -45.25                     ]                 ]             ]         }     } }) WriteError@src/mongo/shell/bulk_api.js:465:48 mergeBatchResults@src/mongo/shell/bulk_api.js:871:49 executeBatch@src/mongo/shell/bulk_api.js:940:13 Bulk/ this .execute@src/mongo/shell/bulk_api.js:1182:21 DBCollection.prototype.insertOne@src/mongo/shell/crud_api.js:264:9 @(shell):1:1

      Inserting a geojson polygon in a field indexed with 2dsphere fails, claiming two separate parallel lines of constant latitude intersect. Full repro in 5.0.9 below.

       

        1. Both Edges.png
          Both Edges.png
          62 kB
        2. Intersection.png
          Intersection.png
          16 kB

            Assignee:
            adam.harrison@mongodb.com Adam Harrison
            Reporter:
            mills.wj@gmail.com Bill Mills
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: