Skip to content

Commit bc4e70a

Browse files
committedMay 13, 2017
[processing] check difference result befor using it in further
operations (ref #15962)
1 parent 02c8ac8 commit bc4e70a

File tree

1 file changed

+10
-1
lines changed
  • python/plugins/processing/algs/qgis

1 file changed

+10
-1
lines changed
 

‎python/plugins/processing/algs/qgis/Union.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def processAlgorithm(self, progress):
7575
geomType = vlayerA.wkbType()
7676
fields = vector.combineVectorFields(vlayerA, vlayerB)
7777
writer = self.getOutputFromName(Union.OUTPUT).getVectorWriter(fields,
78-
geomType, vlayerA.crs())
78+
geomType,
79+
vlayerA.crs())
7980
inFeatA = QgsFeature()
8081
inFeatB = QgsFeature()
8182
outFeat = QgsFeature()
@@ -161,6 +162,10 @@ def processAlgorithm(self, progress):
161162
if len(lstIntersectingB) != 0:
162163
intB = QgsGeometry.unaryUnion(lstIntersectingB)
163164
diff_geom = diff_geom.difference(intB)
165+
if diff_geom is None:
166+
ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
167+
self.tr('GEOS geoprocessing error: One or more input features have invalid geometry.'))
168+
diff_geom = QgsGeometry()
164169
if diff_geom.isGeosEmpty() or not diff_geom.isGeosValid():
165170
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
166171
self.tr('GEOS geoprocessing error: One or more input features have invalid geometry.'))
@@ -207,6 +212,10 @@ def processAlgorithm(self, progress):
207212
else:
208213
intA = QgsGeometry.unaryUnion(lstIntersectingA)
209214
res_geom = geom.difference(intA)
215+
if res_geom is None:
216+
ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
217+
self.tr('GEOS geoprocessing error: One or more input features have invalid geometry.'))
218+
res_geom = QgsGeometry()
210219
if res_geom.isGeosEmpty() or not res_geom.isGeosValid():
211220
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
212221
self.tr('GEOS geoprocessing error: One or more input features have invalid geometry.'))

0 commit comments

Comments
 (0)
Please sign in to comment.