A small number of my polygons were causing my whole pipeline to hang, often indefinitely. For the most part these were weird and wonderful shapes, often with artefacts in them that could be smoothed out. Unfortunately this then started happening on "normal" polygons so I went digging.
Turns out that for certain shapes what it was trying to do is spin over pretty much all the shapes in existence to determine the covering. The below code demonstrates this, working at level 0 we get all 6 faces and the runtime just increases exponentially from then on.
I'm not sure I get enough of S2's internals to fix/understand this without an amount of study I don't really have time for but I've got no problem putting a fix in for it if someone can help me pin it down.
Reproducible example below, the polygon is valid (according to geotools anyway!).
A small number of my polygons were causing my whole pipeline to hang, often indefinitely. For the most part these were weird and wonderful shapes, often with artefacts in them that could be smoothed out. Unfortunately this then started happening on "normal" polygons so I went digging.
Turns out that for certain shapes what it was trying to do is spin over pretty much all the shapes in existence to determine the covering. The below code demonstrates this, working at level 0 we get all 6 faces and the runtime just increases exponentially from then on.
I'm not sure I get enough of S2's internals to fix/understand this without an amount of study I don't really have time for but I've got no problem putting a fix in for it if someone can help me pin it down.
Reproducible example below, the polygon is valid (according to geotools anyway!).