def processAlgorithm(self, progress):
        layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
        fieldName = self.getParameterValue(self.FIELD_NAME)

        outputFile = self.getOutputValue(self.OUTPUT_HTML_FILE)

        index = layer.fieldNameIndex(fieldName)
        layer.select([index], QgsRectangle(), False)

        cvValue = 0
        minValue = 0
        maxValue = 0
        sumValue = 0
        meanValue = 0
        medianValue = 0
        stdDevValue = 0

        isFirst = True
        values = []

        features = QGisLayers.features(layer)
        count = len(features)
        total = 100.0 / float(count)
        current = 0
        for ft in features:
            value = float(ft.attributeMap()[index].toDouble()[0])

            if isFirst:
                minValue = value
                maxValue = value
                isFirst = False
            else:
                if value < minValue:
                    minValue = value
                if value > maxValue:
                    maxValue = value

            values.append( value )
            sumValue += value

            current += 1
            progress.setPercentage(int(current * total))

        # calculate additional values
        rValue = maxValue - minValue
        uniqueValue = utils.getUniqueValuesCount(layer, index)

        if count > 0:
          meanValue = sumValue / count
          if meanValue != 0.00:
            for v in values:
              stdDevValue += ((v - meanValue) * (v - meanValue))
            stdDevValue = math.sqrt(stdDevValue / count)
            cvValue = stdDevValue / meanValue

        if count > 1:
          tmp = values
          tmp.sort()
          # calculate median
          if (count % 2) == 0:
            medianValue = 0.5 * (tmp[(count - 1) / 2] + tmp[count / 2])
          else:
            medianValue = tmp[(count + 1) / 2 - 1]

        data = []
        data.append("Count: " + unicode(count))
        data.append("Unique values: " + unicode(uniqueValue))
        data.append("Minimum value: " + unicode(minValue))
        data.append("Maximum value: " + unicode(maxValue))
        data.append("Range: " + unicode(rValue))
        data.append("Sum: " + unicode(sumValue))
        data.append("Mean value: " + unicode(meanValue))
        data.append("Median value: " + unicode(medianValue))
        data.append("Standard deviation: " + unicode(stdDevValue))
        data.append("Coefficient of Variation: " + unicode(cvValue))

        self.createHTML(outputFile, data)

        self.setOutputValue(self.COUNT, count)
        self.setOutputValue(self.UNIQUE, uniqueValue)
        self.setOutputValue(self.MIN, minValue)
        self.setOutputValue(self.MAX, maxValue)
        self.setOutputValue(self.RANGE, rValue)
        self.setOutputValue(self.SUM, sumValue)
        self.setOutputValue(self.MEAN, meanValue)
        self.setOutputValue(self.MEDIAN, medianValue)
        self.setOutputValue(self.STD_DEV, stdDevValue)
        self.setOutputValue(self.CV, cvValue)
    def processAlgorithm(self, progress):
        layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
        fieldName = self.getParameterValue(self.FIELD_NAME)

        outputFile = self.getOutputValue(self.OUTPUT_HTML_FILE)

        index = layer.fieldNameIndex(fieldName)
        layer.select([index], QgsRectangle(), False)

        sumValue = 0
        minValue = 0
        maxValue = 0
        meanValue = 0
        countEmpty = 0
        countFilled = 0

        isFirst = True
        values = []

        features = QGisLayers.features(layer)
        count = len(features)
        total = 100.0 / float(count)
        current = 0
        for ft in features:
            length = float(len(ft.attributeMap()[index].toString()))

            if isFirst:
                minValue = length
                maxValue = length
                isFirst = False
            else:
                if length < minValue:
                    minValue = length
                if length > maxValue:
                    maxValue = length

            if length != 0.00:
                countFilled += 1
            else:
                countEmpty += 1

            values.append(length)
            sumValue += length

            current += 1
            progress.setPercentage(int(current * total))

        n = float(len(values))
        if n > 0:
            meanValue = sumValue / n

        uniqueValues = utils.getUniqueValuesCount(layer, index)

        data = []
        data.append("Minimum length: " + unicode(minValue))
        data.append("Maximum length: " + unicode(maxValue))
        data.append("Mean length: " + unicode(meanValue))
        data.append("Filled: " + unicode(countFilled))
        data.append("Empty: " + unicode(countEmpty))
        data.append("Count: " + unicode(count))
        data.append("Unique: " + unicode(uniqueValues))

        self.createHTML(outputFile, data)

        self.setOutputValue(self.MIN_LEN, minValue)
        self.setOutputValue(self.MAX_LEN, maxValue)
        self.setOutputValue(self.MEAN_LEN, meanValue)
        self.setOutputValue(self.FILLED, countFilled)
        self.setOutputValue(self.EMPTY, countEmpty)
        self.setOutputValue(self.COUNT, count)
        self.setOutputValue(self.UNIQUE, uniqueValues)
    def processAlgorithm(self, progress):
        layer = QGisLayers.getObjectFromUri(
            self.getParameterValue(self.INPUT_LAYER))
        fieldName = self.getParameterValue(self.FIELD_NAME)

        outputFile = self.getOutputValue(self.OUTPUT_HTML_FILE)

        index = layer.fieldNameIndex(fieldName)
        layer.select([index], QgsRectangle(), False)

        sumValue = 0
        minValue = 0
        maxValue = 0
        meanValue = 0
        countEmpty = 0
        countFilled = 0

        isFirst = True
        values = []

        features = QGisLayers.features(layer)
        count = len(features)
        total = 100.0 / float(count)
        current = 0
        for ft in features:
            length = float(len(ft.attributeMap()[index].toString()))

            if isFirst:
                minValue = length
                maxValue = length
                isFirst = False
            else:
                if length < minValue:
                    minValue = length
                if length > maxValue:
                    maxValue = length

            if length != 0.00:
                countFilled += 1
            else:
                countEmpty += 1

            values.append(length)
            sumValue += length

            current += 1
            progress.setPercentage(int(current * total))

        n = float(len(values))
        if n > 0:
            meanValue = sumValue / n

        uniqueValues = utils.getUniqueValuesCount(layer, index)

        data = []
        data.append("Minimum length: " + unicode(minValue))
        data.append("Maximum length: " + unicode(maxValue))
        data.append("Mean length: " + unicode(meanValue))
        data.append("Filled: " + unicode(countFilled))
        data.append("Empty: " + unicode(countEmpty))
        data.append("Count: " + unicode(count))
        data.append("Unique: " + unicode(uniqueValues))

        self.createHTML(outputFile, data)

        self.setOutputValue(self.MIN_LEN, minValue)
        self.setOutputValue(self.MAX_LEN, maxValue)
        self.setOutputValue(self.MEAN_LEN, meanValue)
        self.setOutputValue(self.FILLED, countFilled)
        self.setOutputValue(self.EMPTY, countEmpty)
        self.setOutputValue(self.COUNT, count)
        self.setOutputValue(self.UNIQUE, uniqueValues)
    def processAlgorithm(self, progress):
        layer = QGisLayers.getObjectFromUri(
            self.getParameterValue(self.INPUT_LAYER))
        fieldName = self.getParameterValue(self.FIELD_NAME)

        outputFile = self.getOutputValue(self.OUTPUT_HTML_FILE)

        index = layer.fieldNameIndex(fieldName)
        layer.select([index], QgsRectangle(), False)

        cvValue = 0
        minValue = 0
        maxValue = 0
        sumValue = 0
        meanValue = 0
        medianValue = 0
        stdDevValue = 0

        isFirst = True
        values = []

        features = QGisLayers.features(layer)
        count = len(features)
        total = 100.0 / float(count)
        current = 0
        for ft in features:
            value = float(ft.attributeMap()[index].toDouble()[0])

            if isFirst:
                minValue = value
                maxValue = value
                isFirst = False
            else:
                if value < minValue:
                    minValue = value
                if value > maxValue:
                    maxValue = value

            values.append(value)
            sumValue += value

            current += 1
            progress.setPercentage(int(current * total))

        # calculate additional values
        rValue = maxValue - minValue
        uniqueValue = utils.getUniqueValuesCount(layer, index)

        if count > 0:
            meanValue = sumValue / count
            if meanValue != 0.00:
                for v in values:
                    stdDevValue += ((v - meanValue) * (v - meanValue))
                stdDevValue = math.sqrt(stdDevValue / count)
                cvValue = stdDevValue / meanValue

        if count > 1:
            tmp = values
            tmp.sort()
            # calculate median
            if (count % 2) == 0:
                medianValue = 0.5 * (tmp[(count - 1) / 2] + tmp[count / 2])
            else:
                medianValue = tmp[(count + 1) / 2 - 1]

        data = []
        data.append("Count: " + unicode(count))
        data.append("Unique values: " + unicode(uniqueValue))
        data.append("Minimum value: " + unicode(minValue))
        data.append("Maximum value: " + unicode(maxValue))
        data.append("Range: " + unicode(rValue))
        data.append("Sum: " + unicode(sumValue))
        data.append("Mean value: " + unicode(meanValue))
        data.append("Median value: " + unicode(medianValue))
        data.append("Standard deviation: " + unicode(stdDevValue))
        data.append("Coefficient of Variation: " + unicode(cvValue))

        self.createHTML(outputFile, data)

        self.setOutputValue(self.COUNT, count)
        self.setOutputValue(self.UNIQUE, uniqueValue)
        self.setOutputValue(self.MIN, minValue)
        self.setOutputValue(self.MAX, maxValue)
        self.setOutputValue(self.RANGE, rValue)
        self.setOutputValue(self.SUM, sumValue)
        self.setOutputValue(self.MEAN, meanValue)
        self.setOutputValue(self.MEDIAN, medianValue)
        self.setOutputValue(self.STD_DEV, stdDevValue)
        self.setOutputValue(self.CV, cvValue)