[SERVER-9957] Some polygons are refused by the 2dsphere index Created: 18/Jun/13  Updated: 29/Jan/15  Resolved: 25/Jun/13

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

Type: Bug Priority: Major - P3
Reporter: Frédéric De Jaeger Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Operating System: Linux
Steps To Reproduce:

MongoDB shell version: 2.4.3
> use prout
switched to db prout
> db.mycol.ensureIndex(

{"loc": "2dsphere"}

)
> db.mycol.save({"loc":{"type":"Polygon","coordinates":[[[-116.0,-87.0181],[64.0,-87.0181],[64.0,-71.0181],[-116.0,-71.0181],[-116.0,-88.0181]]]}})
Can't extract geo keys from object, malformed geometry?:

{ type: "Polygon", coordinates: [ [ [ -116.0, -87.0181 ], [ 64.0, -87.0181 ], [ 64.0, -71.0181 ], [ -116.0, -71.0181 ], [ -116.0, -88.0181 ] ] ] }

// this one works, observe the subtle difference.

> db.mycol.save({"loc":{"type":"Polygon","coordinates":[[[-116.0,-87.0181],[64.0,-85.0181],[64.0,-71.0181],[-116.0,-71.0181],[-116.0,-87.0181]]]}})

Participants:

 Description   

There are some GeoJSON polygons that are refused by the 2dsphere index ("Can't extract geo keys from object, malformed geometry")
There is no obvious pattern on the polygon. A slight perturbation of one of the vertex makes it acceptable again. AFAIK, the polygons are correct.



 Comments   
Comment by Ian Whalen (Inactive) [ 25/Jun/13 ]

Hi thoran - I'm closing this for now, but please feel free to open a separate feature request in re the rectangle primitive if you'd like to discuss the idea with a developer.

Comment by Frédéric De Jaeger [ 19/Jun/13 ]

My fault. Got bitten by the geodesics. It would be nice to have a Rectangle primitive for indexing and querying with the 2dsphere index. I'm sure we are not the only one trying to represent google maps frame with a GeoJSON Polygon and this is incorrect, especially for large area.

Comment by Derick Rethans [ 18/Jun/13 ]

I think this is actually an invalid polygon, as it's a single line crossing the South Pole... (116 + 64 = 180). This is a nice visualisation:
http://www.gcmap.com/mapui?P=116.0W+87.0181S+-+64E+87.0181S%2C+64E+87.0181S+-+64.0E+71.0181S%2C+64.0E+71.0181S+-+116.0W+71.0181S%2C116.0W+71.0181S+-+116.0W+87.0181S&MS=wls&DU=mi

Comment by Frédéric De Jaeger [ 18/Jun/13 ]

sorry I made a copy paste error, here is the command that fails to work for no good reason:

> db.mycol.save({"loc":{"type":"Polygon","coordinates":[[[-116.0,-87.0181],[64.0,-87.0181],[64.0,-71.0181],[-116.0,-71.0181],[-116.0,-87.0181]]]}})

the one provided in the "step to reproduce" is really invalid (first and last vertex mismatch)

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