BUG: fix potential TopologyException in GDAL
This error happened on debian tests: https://cdash.orfeo-toolbox.org/testDetails.php?test=10129083&build=13836
It is caused by an invalid polygon, produced by GDAL_polygonize. This polygon has a common vertice occuring twice in the exterior ring (and no interior ring).
During the polygon merging step, I have added a check to detect invalid geometries. I try to simplify the invalid polygon before adding it to a multipolygon.
In the example shown, the simplification creates a new polygon with an inner ring for the hole.