Skip to content

Commit

Permalink
[processing] Fix some potential errors in clip algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 14, 2016
1 parent a064c0a commit f9e1088
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/plugins/processing/algs/qgis/Clip.py
Expand Up @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit f9e1088

Please sign in to comment.