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

Duplicate coordinate in GeoJSON LineString cause "malformed geometry" (2dsphere index)

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.1
    • Geo
    • None
    • mongo shell on Ubuntu 12.10 64bit
    • ALL
    • Hide

      Create a 'trails' collection with a 2dsphere index on "path" mine is like that (stats output):

      {
      "ns" : "sentido-development.trails",
      "count" : 34,
      "size" : 216960,
      "avgObjSize" : 6381.176470588235,
      "storageSize" : 2338816,
      "numExtents" : 2,
      "nindexes" : 2,
      "lastExtentSize" : 2330624,
      "paddingFactor" : 1,
      "systemFlags" : 1,
      "userFlags" : 0,
      "totalIndexSize" : 16352,
      "indexSizes" :

      { "_id_" : 8176, "path_2dsphere" : 8176 }

      ,
      "ok" : 1
      }

      Try to save an item with the following in mongodb shell (duplicate coordinates in bold):

      db.trails.insert({"name": "ch1086.121", "path": {"type": "LineString", "coordinates": [[7.416898, 47.339062], [7.416977, 47.339134],[7.416977, 47.339134]]}})

      You get:

      Can't extract geo keys from object, malformed geometry?:

      { type: "LineString", coordinates: [ [ 7.416898, 47.339062 ], [ 7.416977, 47.339134 ], [ 7.416977, 47.339134 ] ] }

      Wenn removing duplicates it works:

      db.trails.insert({"name": "ch1086.121", "path": {"type": "LineString", "coordinates": [[7.416898, 47.339062], [7.416977, 47.339134]]}})

      Show
      Create a 'trails' collection with a 2dsphere index on "path" mine is like that (stats output): { "ns" : "sentido-development.trails", "count" : 34, "size" : 216960, "avgObjSize" : 6381.176470588235, "storageSize" : 2338816, "numExtents" : 2, "nindexes" : 2, "lastExtentSize" : 2330624, "paddingFactor" : 1, "systemFlags" : 1, "userFlags" : 0, "totalIndexSize" : 16352, "indexSizes" : { "_id_" : 8176, "path_2dsphere" : 8176 } , "ok" : 1 } Try to save an item with the following in mongodb shell (duplicate coordinates in bold): db.trails.insert({"name": "ch1086.121", "path": {"type": "LineString", "coordinates": [ [7.416898, 47.339062] , [7.416977, 47.339134] , [7.416977, 47.339134] ]}}) You get: Can't extract geo keys from object, malformed geometry?: { type: "LineString", coordinates: [ [ 7.416898, 47.339062 ], [ 7.416977, 47.339134 ], [ 7.416977, 47.339134 ] ] } Wenn removing duplicates it works: db.trails.insert({"name": "ch1086.121", "path": {"type": "LineString", "coordinates": [ [7.416898, 47.339062] , [7.416977, 47.339134] ]}})

    Description

      When trying to insert a LineString GeoJSON containing duplicate coordinates pair you get.

      Can't extract geo keys from object, malformed geometry

      I would expect this to work. Duplicates coordinates can occur quite often for example when you are parsing gpx files and saving them (I noticed it that way).

      Attachments

        Activity

          People

            Unassigned Unassigned
            zeekox Mauro Carabotti
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: