[processing] warn user about incorrect input data when calculating

mean coordinates using weight field (fix #9084)
This commit is contained in:
Alexander Bruy 2017-02-07 16:29:27 +02:00
parent 9bd0d7a7bb
commit 4963548f4d

View File

@ -34,6 +34,7 @@ from qgis.PyQt.QtCore import QVariant
from qgis.core import Qgis, QgsField, QgsFeature, QgsGeometry, QgsPoint, QgsWkbTypes
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterTableField
from processing.core.parameters import ParameterVector
from processing.core.outputs import OutputVector
@ -110,6 +111,10 @@ class MeanCoords(GeoAlgorithm):
weight = float(feat.attributes()[weightIndex])
except:
weight = 1.00
if weight < 0:
raise GeoAlgorithmExecutionException(self.tr('Negative weight value found. Please fix you data and try again.'))
if clazz not in means:
means[clazz] = (0, 0, 0)