|
Thanks for the detailed description. The links you cited have different issues, so I'll just focus on your case.
GeoJSON specifies the syntax, not all the semantics. For example, it doesn't define the winding order of a polygon, i.e. which side of a polygon on the Earth is the inner. MongoDB assumes the smaller part is the inner, unless you use big polygon explicitly. MongoDB and its geospatial library do have some restrictions, e.g. duplicate vertices or self intersections are not allowed, but for good reasons. Internally, MongoDB follows left-hand rule in terms of winding order and converts the smaller polygon defined by the coordinates to this form. Imagine you are walking along the edges in the given order, the inner is always on you left. Now It's obvious to see why self-intersection is ambiguous. What's on your left when walking along the edges of an "8" shape with one stroke? Duplicated vertices have the same problem.
On the other hand, these restrictions don't affect expressiveness. By separating the self-intersected polygon into two polygons using MultiPolygon, one can define the same shape without ambiguity. In your case, the MultiPolygon could be as follow.
{
|
"type": "MultiPolygon",
|
"coordinates": [
|
[[[1, 1], [1.5, 1], [1, 2], [1, 1]]],
|
[[[1.5, 1], [2, 1], [1.5, 2], [1.5, 1]]]
|
]
|
}
|
|