@@ -54,7 +54,7 @@ class FieldsCalculator(GeoAlgorithm):
5454 def defineCharacteristics (self ):
5555 self .name = "Field calculator"
5656 self .group = "Vector table tools"
57- self .addParameter (ParameterVector (self .INPUT_LAYER , "Input layer" , ParameterVector .VECTOR_TYPE_ANY , False ))
57+ self .addParameter (ParameterVector (self .INPUT_LAYER , "Input layer" , [ ParameterVector .VECTOR_TYPE_ANY ] , False ))
5858 self .addParameter (ParameterString (self .FIELD_NAME , "Result field name" ))
5959 self .addParameter (ParameterSelection (self .FIELD_TYPE , "Field type" , self .TYPE_NAMES ))
6060 self .addParameter (ParameterNumber (self .FIELD_LENGTH , "Field length" , 1 , 255 , 10 ))
@@ -81,20 +81,20 @@ def processAlgorithm(self, progress):
8181 nFeat = provider .featureCount ()
8282 nElement = 0
8383 features = QGisLayers .features (layer )
84-
85- fieldnames = [field .name () for field in provider .fields ()]
84+
85+ fieldnames = [field .name () for field in provider .fields ()]
8686 fieldnames .sort (key = len , reverse = False )
8787 fieldidx = [fieldnames .index (field .name ()) for field in provider .fields ()]
8888 print fieldidx
8989 for inFeat in features :
9090 progress .setPercentage (int ((100 * nElement ) / nFeat ))
9191 attrs = inFeat .attributes ()
92- expression = formula
93- for idx in fieldidx :
94- expression = expression .replace (unicode (fields [idx ].name ()), unicode (attrs [idx ]))
95- try :
92+ expression = formula
93+ for idx in fieldidx :
94+ expression = expression .replace (unicode (fields [idx ].name ()), unicode (attrs [idx ]))
95+ try :
9696 result = eval (expression )
97- except Exception :
97+ except Exception :
9898 result = None
9999 nElement += 1
100100 inGeom = inFeat .geometry ()
0 commit comments