Skip to content
Permalink
Browse files

[processing] Fix some potential errors in clip algorithm

  • Loading branch information
nyalldawson committed Aug 14, 2016
1 parent a064c0a commit f9e10888cbf567b09d334b286c92c918f59c9bfe
Showing with 10 additions and 2 deletions.
  1. +10 −2 python/plugins/processing/algs/qgis/Clip.py
@@ -92,6 +92,9 @@ def processAlgorithm(self, progress):
for i, clip_geom in enumerate(clip_geoms):
input_features = [f for f in vector.features(source_layer, QgsFeatureRequest().setFilterRect(clip_geom.boundingBox()))]

if not input_features:
continue

if single_clip_feature:
total = 100.0 / len(input_features)
else:
@@ -116,11 +119,16 @@ def processAlgorithm(self, progress):
if new_geom.wkbType() == QgsWkbTypes.Unknown or QgsWkbTypes.flatType(new_geom.geometry().wkbType()) == QgsWkbTypes.GeometryCollection:
int_com = in_feat.geometry().combine(new_geom)
int_sym = in_feat.geometry().symDifference(new_geom)
new_geom = int_com.difference(int_sym)
if new_geom.isGeosEmpty() or not new_geom.isGeosValid():
if not int_com or not int_sym:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('GEOS geoprocessing error: One or more '
'input features have invalid geometry.'))
else:
new_geom = int_com.difference(int_sym)
if new_geom.isGeosEmpty() or not new_geom.isGeosValid():
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('GEOS geoprocessing error: One or more '
'input features have invalid geometry.'))
else:
# clip geometry totally contains feature geometry, so no need to perform intersection
new_geom = in_feat.geometry()

0 comments on commit f9e1088

Please sign in to comment.
You can’t perform that action at this time.