machine
machine copied to clipboard
GDAL error handling for linear rings
I'm trying to figure out how to get the sources that the machine throws these pesky errors going again:
GDAL gave Failure 1: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4
Here's the responsible code for this:
try:
centroid = geom.Centroid()
except RuntimeError as e:
if 'Invalid number of points in LinearRing found' not in str(e):
raise
The conditional is supposed to be checking for a certain type of error and short-circuit handling, but I don't think it's doing what it's supposed to. If I change the above to:
try:
centroid = geom.Centroid()
except RuntimeError as e:
_L.info("actual error raised: '{0}'".format(e))
_L.info("actual error raised: '{0}'".format(str(e)))
if 'Invalid number of points in LinearRing found' not in str(e):
raise
to log the actual error, I see the following in the output (I output both raw and cast as a string):
309 32449.1 ERROR: GDAL gave Failure 1: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4
309 32449.3 INFO: actual error raised: ''
309 32449.5 INFO: actual error raised: ''
This tells me 2 things:
-
gdal_error_handler
defined and registered on lines 30 and 41 are getting the error before theexcept Runtime
block - the error
e
is "disappearing" before the error message test condition is firing
At least I think this is what's going on. I know very little about Python or the intent of the authors of what should be done in these cases but the special conditional for invalid linear rings isn't operating as expected.
In fact, if I comment out the special condition to not raise an error for invalid linear rings, I still get the error messages and the source succeeds. The source I'm testing with is openaddresses/openaddresses#2565.