def initAlgorithm(self, config):
        # INPUTS
        db_param = QgsProcessingParameterString(
            self.DATABASE, tr("Connexion à la base de données"))
        db_param.setMetadata({
            "widget_wrapper": {
                "class":
                "processing.gui.wrappers_postgis.ConnectionWidgetWrapper"
            }
        })
        db_param.tooltip_3liz = 'Nom de la connexion dans QGIS pour se connecter à la base de données'
        self.addParameter(db_param)

        schema_param = QgsProcessingParameterString(self.SCHEMA, tr("Schéma"),
                                                    "veloroutes", False, True)
        schema_param.setMetadata({
            "widget_wrapper": {
                "class": "processing.gui.wrappers_postgis.SchemaWidgetWrapper",
                "connection_param": self.DATABASE,
            }
        })
        schema_param.tooltip_3liz = 'Nom du schéma pour chercher les couches dans la base de données'
        self.addParameter(schema_param)

        self.addParameter(
            QgsProcessingParameterBoolean(
                self.RASTER,
                tr("Ajouter un fond raster OpenStreetMap?"),
                defaultValue=False,
                optional=False,
            ))

        # OUTPUTS
        output = QgsProcessingOutputMultipleLayers(self.OUTPUT,
                                                   tr("Couches de sortie"))
        output.tooltip_3liz = 'Les différentes couches de l\'extention véloroutes et voies vertes'
        self.addOutput(output)

        output = QgsProcessingOutputString(self.OUTPUT_MSG,
                                           tr("Message de sortie"))
        output.tooltip_3liz = output.description()
        self.addOutput(output)
Exemplo n.º 2
0
    def initAlgorithm(self, config):
        label = tr("Connexion à la base de données")
        tooltip = 'Nom de la connexion dans QGIS pour se connecter à la base de données'
        if Qgis.QGIS_VERSION_INT >= 31400:
            param = QgsProcessingParameterProviderConnection(
                self.DATABASE,
                label,
                "postgres",
                optional=False,
            )
        else:
            param = QgsProcessingParameterString(self.DATABASE, label)
            param.setMetadata({
                "widget_wrapper": {
                    "class":
                    "processing.gui.wrappers_postgis.ConnectionWidgetWrapper"
                }
            })
        if Qgis.QGIS_VERSION_INT >= 31600:
            param.setHelp(tooltip)
        else:
            param.tooltip_3liz = tooltip
        self.addParameter(param)

        label = tr("Schéma")
        tooltip = 'Nom du schéma pour importer les couches'
        default = 'veloroutes'
        if Qgis.QGIS_VERSION_INT >= 31400:
            param = QgsProcessingParameterDatabaseSchema(
                self.SCHEMA,
                label,
                self.DATABASE,
                defaultValue=default,
                optional=False,
            )
        else:
            param = QgsProcessingParameterString(self.SCHEMA, label, default,
                                                 False, True)
            param.setMetadata({
                "widget_wrapper": {
                    "class":
                    "processing.gui.wrappers_postgis.SchemaWidgetWrapper",
                    "connection_param": self.DATABASE,
                }
            })
        if Qgis.QGIS_VERSION_INT >= 31600:
            param.setHelp(tooltip)
        else:
            param.tooltip_3liz = tooltip
        self.addParameter(param)

        self.addParameter(
            QgsProcessingParameterBoolean(
                self.RASTER,
                tr("Ajouter un fond raster OpenStreetMap ?"),
                defaultValue=False,
                optional=False,
            ))

        # OUTPUTS
        output = QgsProcessingOutputMultipleLayers(self.OUTPUT,
                                                   tr("Couches de sortie"))
        output.tooltip_3liz = 'Les différentes couches de l\'extension véloroutes et voies vertes'
        self.addOutput(output)

        output = QgsProcessingOutputString(self.OUTPUT_MSG,
                                           tr("Message de sortie"))
        output.tooltip_3liz = output.description()
        self.addOutput(output)