[SERVER-9401] GeoJSON Parser: Can't extract geo keys from object, malformed geometry? Created: 19/Apr/13  Updated: 11/Jul/16  Resolved: 29/Apr/13

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.4.2
Fix Version/s: 2.4.4, 2.5.0

Type: Bug Priority: Major - P3
Reporter: Jeffrey Mealo Assignee: hari.khalsa@10gen.com
Resolution: Done Votes: 0
Labels: geo, geometry, geospatial, json
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 12.04 LTS
OSX 10.8


Attachments: Text File error.txt     File input.json    
Issue Links:
Duplicate
is duplicated by SERVER-9724 Duplicate coordinate in GeoJSON LineS... Closed
Related
related to SERVER-14508 Better error messages from GeoJSON pa... Closed
is related to SERVER-9240 Exterior shell of polygon is invalid:... Closed
Operating System: ALL
Steps To Reproduce:

1. Insert geometry from input.json into a 2dsphere index

Participants:

 Description   

There seems to be a problem with the GeoJSON Parser.

I've attached a JSON file containing valid GeoJSON (passes http://geojsonlint.com/).

When I try to insert a document with input.json as the value for a 2dsphere index, I get the attached error (error.txt).



 Comments   
Comment by Neville Dipale [ 08/Oct/13 ]

Just saw this now. I had written a function in my project that parses LineStrings to remove adjacent points. Glad that I'll be able to remove that from 2.6

Comment by auto [ 13/May/13 ]

Author:

{u'date': u'2013-04-25T17:10:00Z', u'name': u'Hari Khalsa', u'email': u'hkhalsa@10gen.com'}

Message: SERVER-9401 remove duplicate points in lines because S2 doesn't like them
Branch: v2.4
https://github.com/mongodb/mongo/commit/b5c4e7ac53d57767ce5e88c18d1b76d89fb67808

Comment by auto [ 29/Apr/13 ]

Author:

{u'date': u'2013-04-25T17:10:00Z', u'name': u'Hari Khalsa', u'email': u'hkhalsa@10gen.com'}

Message: SERVER-9401 remove duplicate points in lines because S2 doesn't like them
Branch: master
https://github.com/mongodb/mongo/commit/7f0c71f871e5faa548cb47aee932495694f68244

Comment by hari.khalsa@10gen.com [ 25/Apr/13 ]

Hi!

Our internal geometry library expects that there are no adjacent identical vertices in lines. The LineString you provided had two adjacent identical points. We can detect and ignore these vertices. I will submit a fix shortly.

Comment by Jeffrey Mealo [ 20/Apr/13 ]

This LineString is a way from OpenStreetMap. I can change the geometry when I go to insert it.

I can see this being an issue with roundabouts and cul-de-sacs when storing road networks in MongoDB.

If a line string forms a closed geometry, it should be represented as a polygon I suppose. I'm not sure if this is a bug, here's a relevant statement from the GeoJSON spec:

"A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition." http://www.geojson.org/geojson-spec.html#id16

It doesn't explicitly say one way or another; if anything, it states that the specification is incomplete.

Any thoughts?

Comment by Daniel Pasette (Inactive) [ 19/Apr/13 ]

Parser is having trouble parsing repeated positions in a sequence. I don't think the spec says this is illegal. Repeated positions but not in sequence parses fine.

> var doc = {
    "loc" : {
        "type" : "LineString",
        "coordinates" : [
            [
                0,
                0
            ],
            [
                0,
                0
            ]
        ]
    }
}
> db.geo.insert(doc2)
Can't extract geo keys from object, malformed geometry?:{ type: "LineString", coordinates: [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] }

Generated at Thu Feb 08 03:20:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.