Skip to content
Permalink
Browse files

[processing] Fix some potential errors in clip algorithm

(cherry-picked from f9e1088)
  • Loading branch information
nyalldawson committed Aug 17, 2016
1 parent 64b7def commit 686cdfca510b56ab236115be096e6f7f97e9b513
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() == QGis.WKBUnknown or QgsWKBTypes.flatType(new_geom.geometry().wkbType()) == QgsWKBTypes.GeometryCollection:
int_com = in_feat.constGeometry().combine(new_geom)
int_sym = in_feat.constGeometry().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 = QgsGeometry(in_feat.constGeometry())

0 comments on commit 686cdfc

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