示例#1
0
    def processAlgorithm(self, parameters, context, feedback):
        """
        Here is where the processing itself takes place.
        """
        layerHandler = LayerHandler()
        inputLyr = self.parameterAsVectorLayer(parameters, self.INPUT, context)
        if inputLyr is None:
            raise QgsProcessingException(
                self.invalidSourceError(parameters, self.INPUT))
        onlySelected = self.parameterAsBool(parameters, self.SELECTED, context)
        attributeBlackList = self.parameterAsFields(parameters,
                                                    self.ATTRIBUTE_BLACK_LIST,
                                                    context)
        ignoreVirtual = self.parameterAsBool(parameters,
                                             self.IGNORE_VIRTUAL_FIELDS,
                                             context)
        ignorePK = self.parameterAsBool(parameters, self.IGNORE_PK_FIELDS,
                                        context)
        # Compute the number of steps to display within the progress bar and
        # get features from source
        multiStepFeedback = QgsProcessingMultiStepFeedback(2, feedback)
        multiStepFeedback.setCurrentStep(0)
        duplicatedGeomDict = layerHandler.getDuplicatedFeaturesDict(
            inputLyr,
            onlySelected=onlySelected,
            attributeBlackList=attributeBlackList,
            excludePrimaryKeys=ignorePK,
            ignoreVirtualFields=ignoreVirtual,
            feedback=multiStepFeedback)
        multiStepFeedback.setCurrentStep(1)
        self.deleteDuplicatedFeaturesFlags(inputLyr, duplicatedGeomDict,
                                           multiStepFeedback)

        return {self.OUTPUT: inputLyr}
示例#2
0
 def processAlgorithm(self, parameters, context, feedback):
     """
     Here is where the processing itself takes place.
     """
     inputLyr = self.parameterAsVectorLayer(parameters, self.INPUT, context)
     if inputLyr is None:
         raise QgsProcessingException(
             self.invalidSourceError(parameters, self.INPUT))
     onlySelected = self.parameterAsBool(parameters, self.SELECTED, context)
     self.prepareFlagSink(parameters, inputLyr, inputLyr.wkbType(), context)
     # Compute the number of steps to display within the progress bar and
     # get features from source
     layerHandler = LayerHandler()
     multiStepFeedback = QgsProcessingMultiStepFeedback(2, feedback)
     multiStepFeedback.setCurrentStep(0)
     geomDict = layerHandler.getDuplicatedFeaturesDict(
         inputLyr, onlySelected=onlySelected, feedback=multiStepFeedback)
     multiStepFeedback.setCurrentStep(1)
     self.raiseDuplicatedFeaturesFlags(
         inputLyr, geomDict, multiStepFeedback)
     return {self.FLAGS: self.flag_id}