I used the very nice "Fix Geometries" tool in the Processing Toolbox of QGIS 3.6 to repair a vector layer that was giving me trouble. The tool in QGIS worked just fine, but I was hoping to find out the actual algorithm or Python/C++ code used to implement this feature. I was wondering if anyone knew what code was used to actually implement this tool and fix geometries. Or if there is a different an better way to fix the geometries, any such recommendation would work too.
So let me explain a little bit. I did look up the QGIS documentation for the "Fix Geometries" tool in the Processing Toolbox. Unfortunately, that documentation does not explain how it fixes the geometry--meaning the algorithm. Here is a little excerpt from the documentation:
Attempts to create a valid representation of a given invalid geometry without losing any of the input vertices. Already valid geometries are returned without further intervention. Always outputs multi-geometry layer.
I also looked in the Log window of the Fix Geometries tool, but it did not seem to show the GDAL code or such, as in other tools.
In the past I have resolved this issue by wrapping a narrow buffer around the geometry of interest, to overcome invalid geometry errors. Of course this does create some errors in the resulting layers. However, I saw that the Fix Geometry tool did not seem to add a buffer, and hence seemed to solve the invalid geometry problem without introducing some error. Hence I was wondering if anyone knew the code behind that tool.