Open ktaylora opened 3 years ago
You've hit on of the https://gdal.org/api/python_gotchas.html Change gpkg_connection.GetLayerByIndex(0).GetFeature(1).GetGeometryRef().IsValid() to f = gpkg_connection.GetLayerByIndex(0).GetFeature(1) f.GetGeometryRef().IsValid()
Thanks, Even. I shoulda Googled it.
I'll reopen that one as I believe we could fix that without breaking existing code (contrary to reference counting on dataset objects)
Expected behavior and actual behavior.
When repairing broken geometries in Python, we make use of ogr's IsValid() and MakeValid() functions in our application code. When checking for invalid geometries, I am encountering a segfault. When I arbitrarily apply MakeValid() to the same geometries and then check for validity with IsValid(), the geometries are repaired and OGR behaves as expected. This isn't a critical bug, because we can just always call MakeValid() first on geometries we suspect are broken (see below), but it would be nice to LBYL without a segfault.
Steps to reproduce the problem.
using the following geopackage containing broken geometries that need repair.
Operating system
Linux *** 4.14.238-182.422.amzn2.x86_64 #1 SMP *** UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
GDAL version and provenance
GDAL (and dependencies) were compiled from source using gcc version 7.3.1 20180712 (Red Hat 7.3.1-13) (GCC). Relevant dependencies (and versions) :