Error with geo_shape polygon query with points on the dateline

I have a polygon in a test that appears to be processed incorrectly and it ends up triggering an InvalidShapeException. The points are:

-175, 20
180, 15
-177, 10
180, 5
-175, 0
-175, 20

(minor update: This also fails if you use -180 instead of 180, if that makes this easier to visualize. It's a sideways isosceles trapezoid with an indent on the shorter side)

The MultiPolygon that fails has this toString():

MULTIPOLYGON (((-180 5, -180 15, -177 10, -180 5)), ((-180 15, -180 5, -175 0, -175 20, -180 15)))

And the validation error is this:

Self-intersection at or near point (-180.0, 5.0, NaN)

So you can see it decided to split out a concave triangle with the two points that touch the dateline. I tried tracing this but I wasn't really able to understand why. Regardless, this seems to be a "valid" geometry that ends up being invalid due to query processing.

Right now my planned workaround is to nudge points on the dateline slightly, but I don't think that's guaranteed to be correct, so I'm curious about other workarounds/fixes.

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