Skip to content
Permalink
Browse files
Raise GeoAlgorithmExecutionException when encountering invalid
geometries in QgsProcessingUtils::getFeatures
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent e6a33e8 commit f4f4ca3d83e9e1a00f14c642faab62a0d9a403c3
Showing with 8 additions and 0 deletions.
  1. +8 −0 python/plugins/processing/tools/general.py
@@ -38,10 +38,12 @@
from qgis.core import (QgsApplication,
QgsProcessingContext,
QgsProject)
from qgis.PyQt.QtCore import (QCoreApplication)
from processing.core.Processing import Processing
from processing.core.parameters import ParameterSelection
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException


def algorithmOptions(id):
@@ -111,4 +113,10 @@ def createContext():
invalid_features_method = ProcessingConfig.getSetting(ProcessingConfig.FILTER_INVALID_GEOMETRIES)
context.setInvalidGeometryCheck(invalid_features_method)

def raise_error(f):
raise GeoAlgorithmExecutionException(QCoreApplication.translate("FeatureIterator",
'Features with invalid geometries found. Please fix these geometries or specify the "Ignore invalid input features" flag'))

context.setInvalidGeometryCallback(raise_error)

return context

0 comments on commit f4f4ca3

Please sign in to comment.