Skip to content
Browse files
[processing] Remove special handling for invalid geometries
Instead rely on QgsFeatureRequest method. There's a temporary
loss of the feedback on encountering an invalid geometry
when abort on invalid is set, but that will be resurrected
when all of vector.features is moved to c++
  • Loading branch information
nyalldawson committed Apr 25, 2017
1 parent 5d377be commit ee777447a986c847824a31c341094e01ece7ed7c
Showing with 7 additions and 21 deletions.
  1. +7 −21 python/plugins/processing/tools/
@@ -99,34 +99,20 @@ class Features(object):
def __init__(self, layer, request):
self.layer = layer
self.selection = False

invalidFeaturesMethod = ProcessingConfig.getSetting(ProcessingConfig.FILTER_INVALID_GEOMETRIES)
if invalidFeaturesMethod == self.IGNORE:
elif invalidFeaturesMethod == self.RAISE_EXCEPTION:

if ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED)\
and layer.selectedFeatureCount() > 0:
self.iter = layer.selectedFeaturesIterator(request)
self.selection = True
self.iter = layer.getFeatures(request)

invalidFeaturesMethod = ProcessingConfig.getSetting(ProcessingConfig.FILTER_INVALID_GEOMETRIES)

def filterFeature(f, ignoreInvalid):
geom = f.geometry()
if geom is None:
ProcessingLog.addToLog(ProcessingLog.LOG_INFO,'Feature with NULL geometry found.'))
elif not geom.isGeosValid():
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,'GEOS geoprocessing error: One or more input features have invalid geometry.'))
if ignoreInvalid:
return False
raise GeoAlgorithmExecutionException('Features with invalid geometries found. Please fix these geometries or specify the "Ignore invalid input features" flag'))
return True

if invalidFeaturesMethod == self.IGNORE:
self.iter = filter(lambda x: filterFeature(x, True), self.iter)
elif invalidFeaturesMethod == self.RAISE_EXCEPTION:
self.iter = filter(lambda x: filterFeature(x, False), self.iter)

def __iter__(self):
return self.iter

0 comments on commit ee77744

Please sign in to comment.