Skip to content

Commit

Permalink
[processing] stop algorithm execution if geometry/feature error occured
Browse files Browse the repository at this point in the history
(fix #11986)
  • Loading branch information
alexbruy committed May 13, 2017
1 parent 3289d61 commit 7734d72
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions python/plugins/processing/algs/qgis/Intersection.py
Expand Up @@ -95,10 +95,14 @@ def processAlgorithm(self, progress):
continue
else:
raise GeoAlgorithmExecutionException(
self.tr('Input layer A contains NULL geometries. Please check "Ignore NULL geometries" if you want to run this algorithm anyway.'))
self.tr('Input layer A contains NULL geometries. '
'Please check "Ignore NULL geometries" '
'if you want to run this algorithm anyway.'))
if not geom.isGeosValid():
raise GeoAlgorithmExecutionException(
self.tr('Input layer A contains invalid geometries (Feature {}). Unable to complete intersection algorithm.'.format(inFeatA.id())))
self.tr('Input layer A contains invalid geometries '
'(feature {}). Unable to complete intersection '
'algorithm.'.format(inFeatA.id())))
atMapA = inFeatA.attributes()
intersects = index.intersects(geom.boundingBox())
for inFeatB in vlayerB.getFeatures(QgsFeatureRequest().setFilterFids(intersects)):
Expand All @@ -108,10 +112,14 @@ def processAlgorithm(self, progress):
continue
else:
raise GeoAlgorithmExecutionException(
self.tr('Input layer B contains NULL geometries. Please check "Ignore NULL geometries" if you want to run this algorithm anyway.'))
self.tr('Input layer B contains NULL geometries. '
'Please check "Ignore NULL geometries" '
'if you want to run this algorithm anyway.'))
if not geom.isGeosValid():
raise GeoAlgorithmExecutionException(
self.tr('Input layer B contains invalid geometries (Feature {}). Unable to complete intersection algorithm.'.format(inFeatB.id())))
self.tr('Input layer B contains invalid geometries '
'(feature {}). Unable to complete intersection '
'algorithm.'.format(inFeatB.id())))

if geom.intersects(tmpGeom):
atMapB = inFeatB.attributes()
Expand All @@ -126,10 +134,10 @@ def processAlgorithm(self, progress):
int_geom = QgsGeometry(diff_geom)

if int_geom.isGeosEmpty() or not int_geom.isGeosValid():
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('GEOS geoprocessing error: One or '
'more input features have invalid '
'geometry.'))
raise GeoAlgorithmExecutionException(
self.tr('GEOS geoprocessing error: One or '
'more input features have invalid '
'geometry.'))
try:
if int_geom.wkbType() in wkbTypeGroups[wkbTypeGroups[int_geom.wkbType()]]:
outFeat.setGeometry(int_geom)
Expand All @@ -139,8 +147,9 @@ def processAlgorithm(self, progress):
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
except:
ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'))
continue
raise GeoAlgorithmExecutionException(
self.tr('Feature geometry error: one or '
'more output features ignored due '
'to invalid geometry.'))

del writer

0 comments on commit 7734d72

Please sign in to comment.