Skip to content
Permalink
Browse files

Transform errors encountered while iterating features in

processing are non-fatal. We report them to users, and treat the
feature as having no geometry, but don't stop execution.
  • Loading branch information
nyalldawson committed Jun 23, 2017
1 parent 57f2c62 commit 4ea85362f41c9ab2721a67cefb7253dbdfed13e4
@@ -113,7 +113,7 @@ def execute(self, parameters, context=None, feedback=None, model=None):
if feedback is None:
feedback = QgsProcessingFeedback()
if context is None:
context = dataobjects.createContext()
context = dataobjects.createContext(feedback)

self.model = model
try:
@@ -327,7 +327,7 @@ def executeAlgorithm(alg, parameters, context=None, feedback=None, model=None):
if feedback is None:
feedback = QgsProcessingFeedback()
if context is None:
context = dataobjects.createContext()
context = dataobjects.createContext(feedback)

#self.model = model

@@ -193,11 +193,17 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
return
i = i + 1

feedback = None
if kwargs is not None and "feedback" in list(kwargs.keys()):
feedback = kwargs["feedback"]
elif iface is not None:
feedback = MessageBarProgress(alg.displayName())

context = None
if kwargs is not None and 'context' in list(kwargs.keys()):
context = kwargs["context"]
else:
context = dataobjects.createContext()
context = dataobjects.createContext(feedback)

ok, msg = alg.checkParameterValues(parameters, context)
if not ok:
@@ -226,12 +232,6 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
overrideCursor = True

feedback = None
if kwargs is not None and "feedback" in list(kwargs.keys()):
feedback = kwargs["feedback"]
elif iface is not None:
feedback = MessageBarProgress(alg.displayName())

ret, results = execute(alg, parameters, context, feedback)
if ret:
if onFinish is not None:
@@ -164,12 +164,11 @@ def checkExtentCRS(self):
def accept(self):
super(AlgorithmDialog, self)._saveGeometry()

context = dataobjects.createContext()
feedback = self.createFeedback()
context = dataobjects.createContext(feedback)

checkCRS = ProcessingConfig.getSetting(ProcessingConfig.WARN_UNMATCHING_CRS)
try:
feedback = self.createFeedback()

parameters = self.getParamValues()

if checkCRS and not self.alg.validateInputCrs(parameters, context):
@@ -56,7 +56,7 @@ def execute(alg, parameters, context=None, feedback=None):
if feedback is None:
feedback = QgsProcessingFeedback()
if context is None:
context = dataobjects.createContext()
context = dataobjects.createContext(feedback)

try:
results, ok = alg.run(parameters, context, feedback)
@@ -78,8 +78,8 @@ def accept(self):
alg_parameters = []
load = []

context = dataobjects.createContext()
feedback = self.createFeedback()
context = dataobjects.createContext(feedback)

for row in range(self.mainWidget.tblParameters.rowCount()):
col = 0
@@ -253,7 +253,6 @@ def executeAlgorithmAsBatchProcess(self):
def executeAlgorithm(self):
item = self.algorithmTree.currentItem()
if isinstance(item, TreeAlgorithmItem):
context = dataobjects.createContext()
alg = QgsApplication.processingRegistry().algorithmById(item.alg.id())
ok, message = alg.canExecute()
if not ok:
@@ -287,6 +286,7 @@ def executeAlgorithm(self):
self.addRecentAlgorithms(True)
else:
feedback = MessageBarProgress()
context = dataobjects.createContext(feedback)
parameters = {}
ret, results = execute(alg, parameters, context, feedback)
handleAlgorithmResults(alg, parameters, context, feedback)
@@ -203,7 +203,6 @@ def _executeAlgorithm(alg):
dlg.exec_()
return

context = dataobjects.createContext()
if (alg.countVisibleParameters()) > 0:
dlg = alg.createCustomParametersWidget(None)
if not dlg:
@@ -220,6 +219,7 @@ def _executeAlgorithm(alg):
canvas.setMapTool(prevMapTool)
else:
feedback = MessageBarProgress()
context = dataobjects.createContext(feedback)
parameters = {}
ret, results = execute(alg, parameters, context, feedback)
handleAlgorithmResults(alg, context, feedback)
@@ -65,7 +65,7 @@
TYPE_TABLE = 5


def createContext():
def createContext(feedback):
"""
Creates a default processing context
"""
@@ -77,9 +77,11 @@ def createContext():
invalid_features_method = QgsFeatureRequest.GeometryAbortOnInvalid
context.setInvalidGeometryCheck(invalid_features_method)

def raise_transform_error(f):
raise GeoAlgorithmExecutionException(QCoreApplication.translate("FeatureIterator",
'Encountered a transform error when reprojecting feature with id {}.'.format(f.id())))
def raise_transform_error(f, feedback=feedback):
if feedback:
feedback.pushInfo(QCoreApplication.translate("FeatureIterator",
'Encountered a transform error when reprojecting feature with id {}.'.format(f.id())))

context.setTransformErrorCallback(raise_transform_error)

settings = QgsSettings()

0 comments on commit 4ea8536

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