[SERVER-9724] Duplicate coordinate in GeoJSON LineString cause "malformed geometry" (2dsphere index) Created: 17/May/13  Updated: 10/Dec/14  Resolved: 17/May/13

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.4.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mauro Carabotti Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mongo shell on Ubuntu 12.10 64bit


Issue Links:
Duplicate
duplicates SERVER-9401 GeoJSON Parser: Can't extract geo key... Closed
Operating System: ALL
Steps To Reproduce:

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]]}})

Participants:

 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).


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