Polygon - Edges Cross issue

I noticed while trying to perform a $geowithin query within MongoDB compass, mongo does not like it when you cross the polygon lines. See the picture below as an example followed by the error:


When drawing this sort of polygon where the lines cross, the general error presented is:
“An error occurred during schema analysis: Loop is not valid: Edges cross”

I understand the problem. But I would like to inquire if anyone can propose a workaround/solution to this?
I would assume, with my limited understanding, that you would break the polygon up into its constituent parts at the cross and then perform 2x separate queries?

Hi @Stephan_06935,
Try using MultiPolygon.
Good luck,
Rafael,

2 Likes

Thanks Rafael,
Not gonna lie. I should’ve seen this in the docs but completely missed it.

Appreciate your effort!

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.