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

Cannot insert GeoJSON polygon with colinear edges

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 4.2.10, 3.2.22
    • Fix Version/s: Backlog
    • Component/s: Geo
    • Labels:
      None
    • Environment:
      standalone server 3.2, Atlas 4.2.10
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      db.data.createIndex(

      { "geom": "2dsphere" }

      ,

      { "2dsphereIndexVersion": 3 }

      );

      db.data.insertOne({
      geom:

      { "type": "Polygon", "coordinates": [ [ [ -157.515, 4.937 ], [ -142.529, -89.999 ], [ -142.529, -43.676 ], [ -12.529, -42.767 ], [ -142.529, -6.001 ], [ -142.529, 50.047 ], [ -157.515, 4.937 ] ] ] }

      });

      Show
      db.data.createIndex( { "geom": "2dsphere" } , { "2dsphereIndexVersion": 3 } ); db.data.insertOne({ geom: { "type": "Polygon", "coordinates": [ [ [ -157.515, 4.937 ], [ -142.529, -89.999 ], [ -142.529, -43.676 ], [ -12.529, -42.767 ], [ -142.529, -6.001 ], [ -142.529, 50.047 ], [ -157.515, 4.937 ] ] ] } });
    • Sprint:
      Query 2021-01-11

      Description

      Inserting what seems like a perfectly valid CCW polygon (checked in QGIS, geojsonlint.com, geojson.io) results in this error:

      MongoError: Can't extract geo keys: \{ _id: ObjectId('5fb4fbe26a989905900a0f90'), geom: { type: "Polygon", coordinates: [ [ [ -157.515, 4.937 ], [ -142.529, -89.999 ], [ -142.529, -43.676 ], [ -12.529, -42.767 ], [ -142.529, -6.001 ], [ -142.529, 50.047 ], [ -157.515, 4.937 ] ] ] } } Loop is not valid: [ [ 157.515, 4.937 ], [ -142.529, -89.999 ], [ -142.529, -43.676 ], [ -12-.-529, -42.767 ], [ -142.529, -6.001 ], [ -142.529, 50.047 ], [ -157.515, 4.937 ] ] *Edges 1 and 4 cross. Edge locations in degrees: [-142.5290000, -89.9990000]**[-142.5290000, -43.6760000] and [-142.5290000, -6.0010000]-[-142.5290000, 50.0470000]*
      

      But those two offending collinear edges are not even touching.

       

      I guess it boils down to this line in the S2 library:

      https://github.com/mongodb/mongo/blob/master/src/third_party/s2/s2loop.cc#L148
       

        Attachments

          Activity

            People

            Assignee:
            backlog-query-execution Backlog - Query Execution
            Reporter:
            ales.pecha@email.cz Ales Pecha
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated: