mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[processing] fixed handling of integer values
This commit is contained in:
parent
4184934b9a
commit
bc0cdc7b0d
@ -30,6 +30,7 @@ __revision__ = '$Format:%H$'
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import math
|
||||||
from inspect import isclass
|
from inspect import isclass
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import numbers
|
import numbers
|
||||||
@ -834,6 +835,8 @@ class ParameterNumber(Parameter):
|
|||||||
try:
|
try:
|
||||||
v = self._evaluate(n)
|
v = self._evaluate(n)
|
||||||
self.value = float(v)
|
self.value = float(v)
|
||||||
|
if self.isInteger:
|
||||||
|
self.value = int(math.floor(self.value))
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
@ -877,7 +880,10 @@ class ParameterNumber(Parameter):
|
|||||||
result = exp.evaluate(_expressionContext())
|
result = exp.evaluate(_expressionContext())
|
||||||
if exp.hasEvalError():
|
if exp.hasEvalError():
|
||||||
raise ValueError("Error evaluating parameter expression: " + exp.evalErrorString())
|
raise ValueError("Error evaluating parameter expression: " + exp.evalErrorString())
|
||||||
return result
|
if self.isInteger:
|
||||||
|
return math.floor(result)
|
||||||
|
else:
|
||||||
|
return result
|
||||||
|
|
||||||
def evaluate(self, alg):
|
def evaluate(self, alg):
|
||||||
if isinstance(self.value, str) and bool(self.value):
|
if isinstance(self.value, str) and bool(self.value):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user