Skip to content

Commit f9e1088

Browse files
committed
[processing] Fix some potential errors in clip algorithm
1 parent a064c0a commit f9e1088

File tree

1 file changed

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

1 file changed

+10
-2
lines changed

python/plugins/processing/algs/qgis/Clip.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def processAlgorithm(self, progress):
9292
for i, clip_geom in enumerate(clip_geoms):
9393
input_features = [f for f in vector.features(source_layer, QgsFeatureRequest().setFilterRect(clip_geom.boundingBox()))]
9494

95+
if not input_features:
96+
continue
97+
9598
if single_clip_feature:
9699
total = 100.0 / len(input_features)
97100
else:
@@ -116,11 +119,16 @@ def processAlgorithm(self, progress):
116119
if new_geom.wkbType() == QgsWkbTypes.Unknown or QgsWkbTypes.flatType(new_geom.geometry().wkbType()) == QgsWkbTypes.GeometryCollection:
117120
int_com = in_feat.geometry().combine(new_geom)
118121
int_sym = in_feat.geometry().symDifference(new_geom)
119-
new_geom = int_com.difference(int_sym)
120-
if new_geom.isGeosEmpty() or not new_geom.isGeosValid():
122+
if not int_com or not int_sym:
121123
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
122124
self.tr('GEOS geoprocessing error: One or more '
123125
'input features have invalid geometry.'))
126+
else:
127+
new_geom = int_com.difference(int_sym)
128+
if new_geom.isGeosEmpty() or not new_geom.isGeosValid():
129+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
130+
self.tr('GEOS geoprocessing error: One or more '
131+
'input features have invalid geometry.'))
124132
else:
125133
# clip geometry totally contains feature geometry, so no need to perform intersection
126134
new_geom = in_feat.geometry()

0 commit comments

Comments
 (0)