mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
[processing] warn user about incorrect input data when calculating
mean coordinates using weight field (fix #9084)
This commit is contained in:
parent
9bd0d7a7bb
commit
4963548f4d
@ -34,6 +34,7 @@ from qgis.PyQt.QtCore import QVariant
|
|||||||
from qgis.core import Qgis, QgsField, QgsFeature, QgsGeometry, QgsPoint, QgsWkbTypes
|
from qgis.core import Qgis, QgsField, QgsFeature, QgsGeometry, QgsPoint, QgsWkbTypes
|
||||||
|
|
||||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
from processing.core.GeoAlgorithm import GeoAlgorithm
|
||||||
|
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
||||||
from processing.core.parameters import ParameterTableField
|
from processing.core.parameters import ParameterTableField
|
||||||
from processing.core.parameters import ParameterVector
|
from processing.core.parameters import ParameterVector
|
||||||
from processing.core.outputs import OutputVector
|
from processing.core.outputs import OutputVector
|
||||||
@ -110,6 +111,10 @@ class MeanCoords(GeoAlgorithm):
|
|||||||
weight = float(feat.attributes()[weightIndex])
|
weight = float(feat.attributes()[weightIndex])
|
||||||
except:
|
except:
|
||||||
weight = 1.00
|
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:
|
if clazz not in means:
|
||||||
means[clazz] = (0, 0, 0)
|
means[clazz] = (0, 0, 0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user