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 75e9502 commit c620c7c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions python/plugins/processing/algs/qgis/Intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
QgsMessageLog,
QgsProcessingUtils)

from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.parameters import ParameterVector
from processing.core.outputs import OutputVector
Expand Down Expand Up @@ -114,9 +115,10 @@ def processAlgorithm(self, context, feedback):
int_sym = geom.symDifference(tmpGeom)
int_geom = QgsGeometry(int_com.difference(int_sym))
if int_geom.isEmpty() or not int_geom.isGeosValid():
QgsMessageLog.logMessage(self.tr('GEOS geoprocessing error: One or '
'more input features have invalid '
'geometry.'), self.tr('Processing'), QgsMessageLog.CRITICAL)
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 @@ -126,7 +128,9 @@ def processAlgorithm(self, context, feedback):
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
except:
QgsMessageLog.logMessage(self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'), self.tr('Processing'), QgsMessageLog.INFO)
continue
raise GeoAlgorithmExecutionException(
self.tr('Feature geometry error: One or more '
'output features ignored due to invalid '
'geometry.'))

del writer

0 comments on commit c620c7c

Please sign in to comment.