Bug in validating a polygon

335 views
Skip to first unread message

lsaf...@uncc.edu

unread,
Mar 15, 2017, 1:39:31 AM3/15/17
to mongodb-dev
Hi all,

It seems I have found a bug in MongoDB 3.2. I am not sure whether this bug is reported or not. MongoDB cannot validate the following polygon

[ [ 22.5, 33.75 ], [ 135.0, 33.75 ], [ 135.0, 39.375 ], [ 67.5, 39.375 ], [ 22.5, 39.375 ], [ 22.5, 33.75 ] ]

It gives a wrong message
Error: error: {
        "waitedMS" : NumberLong(0),
        "ok" : 0,
        "errmsg" : "Loop is not valid: [ [ 22.5, 33.75 ], [ 135.0, 33.75 ], [ 13
5.0, 39.375 ], [ 67.5, 39.375 ], [ 22.5, 39.375 ], [ 22.5, 33.75 ] ] Edges 0 and
 2 cross. Edge locations in degrees: [22.5000000, 33.7500000]-[135.0000000, 33.7
500000] and [135.0000000, 39.3750000]-[67.5000000, 39.3750000]
",
        "code" : 2
}

These edges are not crossing. they are parallel to each other.

It seems that two edges cannot be on a horizontal line.

if you merge the two edges on a horizontal line then it works
[ [ 22.5, 33.75 ], [ 135.0, 33.75 ], [ 135.0, 39.375 ], [ 22.5, 39.375 ], [ 22.5, 33.75 ] ]

My guess is that somewhere in code divide by zero or overflow exception is occurring because the degree between two sides is 2*pi, can someone check? or explain what is going on.

Note: I have posted about the problem in mongodb-user, then I thought it is a bug so I  think this forum is more approporiate.

Regards,
Lida

Andy Schwerin

unread,
Mar 15, 2017, 7:46:06 AM3/15/17
to mongodb-dev

The shortest distance between the first two points you describe on the surface of a sphere is an arc whose maximum latitude is greater than the latitude of the arc described by the second two points at some longitude.

If you want to draw a polygon on the sphere whose Mercator projection approximates a large rectangle, you'll need to specify a large number of intermediate points.


--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev...@googlegroups.com.
To post to this group, send email to mongo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/c540997d-5106-4b7b-9c19-82b3a1b88f16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages