Пример #1
0
    def initAlgorithm(self, config):

        # Base contenant la table
        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 contenant la table
        schema_param = QgsProcessingParameterString(self.SCHEMA, tr("Schéma"),
                                                    "veloroutes", False, False)
        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)

        # Table à exporter
        table_param = QgsProcessingParameterEnum(
            self.TABLE,
            tr("Donnée à exporter"),
            options=self.EXPORTABLES,
            defaultValue="",
        )
        table_param.tooltip_3liz = 'Nom de la table à exporter'
        self.addParameter(table_param)

        # Nom du département pour le fichier d'export
        depparam = QgsProcessingParameterString(
            self.DPT, tr("Département au format XXX"), '066', optional=False)
        depparam.tooltip_3liz = 'Pour le département de l\'Ain, mettre 001'
        self.addParameter(depparam)

        # Chemin du dossier de destination
        outparam = QgsProcessingParameterFolderDestination(
            self.PROJECTS_FOLDER, description=tr("Chemin de destination"))
        outparam.tooltip_3liz = 'Chemin de destination pour enregistrer les exports Shapefile'
        self.addParameter(outparam)

        param = QgsProcessingParameterBoolean(
            self.CHARGER,
            tr("Charger le fichier d'export dans le projet"),
            defaultValue=False,
            optional=False,
        )
        param.tooltip_3liz = 'Si le traitement doit charger la couche Shapefile dans le projet'
        self.addParameter(param)

        output = QgsProcessingOutputVectorLayer(self.OUTPUT,
                                                tr("Couches de sortie"))
        output.tooltip_3liz = 'Les couches de l\'export'
        self.addOutput(output)
Пример #2
0
    def initAlgorithm(self, config=None):
        param = QgsProcessingParameterFile(self.FILE, self.tr('OSM file'))
        help_string = tr('The extension can be a OSM or PBF file.')
        if Qgis.QGIS_VERSION_INT >= 31500:
            param.setHelp(help_string)
        else:
            param.tooltip_3liz = help_string
        self.addParameter(param)

        param = QgsProcessingParameterFile(self.OSM_CONF,
                                           self.tr('OSM configuration'),
                                           optional=True)
        help_string = tr(
            'The OGR OSM configuration file. This file is used to customize the import process about OSM '
            'tags. You should read the OGR documentation {url}').format(
                url='https://gdal.org/drivers/vector/osm.html')
        if Qgis.QGIS_VERSION_INT >= 31500:
            param.setHelp(help_string)
        else:
            param.tooltip_3liz = help_string
        self.addParameter(param)

        output = QgsProcessingOutputVectorLayer(self.OUTPUT_POINTS,
                                                self.tr('Output points'),
                                                QgsProcessing.TypeVectorPoint)
        help_string = tr('The point layer from the OGR OSM driver.')
        if Qgis.QGIS_VERSION_INT >= 31500:
            pass
            # output.setHelp(help_string)
        else:
            output.tooltip_3liz = help_string
        self.addOutput(output)

        output = QgsProcessingOutputVectorLayer(self.OUTPUT_LINES,
                                                self.tr('Output lines'),
                                                QgsProcessing.TypeVectorLine)
        help_string = tr('The line layer from the OGR OSM driver.')
        if Qgis.QGIS_VERSION_INT >= 31500:
            pass
            # output.setHelp(help_string)
        else:
            output.tooltip_3liz = help_string
        self.addOutput(output)

        output = QgsProcessingOutputVectorLayer(
            self.OUTPUT_MULTILINESTRINGS, self.tr('Output multilinestrings'),
            QgsProcessing.TypeVectorLine)
        help_string = tr('The multilinestrings layer from the OGR OSM driver.')
        if Qgis.QGIS_VERSION_INT >= 31500:
            pass
            # output.setHelp(help_string)
        else:
            output.tooltip_3liz = help_string
        self.addOutput(output)

        output = QgsProcessingOutputVectorLayer(
            self.OUTPUT_MULTIPOLYGONS, self.tr('Output multipolygons'),
            QgsProcessing.TypeVectorPolygon)
        help_string = tr('The multipolygon layer from the OGR OSM driver.')
        if Qgis.QGIS_VERSION_INT >= 31500:
            pass
            # output.setHelp(help_string)
        else:
            output.tooltip_3liz = help_string
        self.addOutput(output)

        output = QgsProcessingOutputVectorLayer(
            self.OUTPUT_OTHER_RELATIONS, self.tr('Output other relations'),
            QgsProcessing.TypeVector)
        help_string = tr('The relation layer from the OGR OSM driver.')
        if Qgis.QGIS_VERSION_INT >= 31500:
            pass
            # output.setHelp(help_string)
        else:
            output.tooltip_3liz = help_string
        self.addOutput(output)
Пример #3
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)

        # Schema de destination
        label = tr("Schéma")
        tooltip = 'Nom du schéma où importer les données'
        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)

        # Table à exporter
        table_param = QgsProcessingParameterEnum(
            self.TABLE,
            tr("Donnée à exporter"),
            options=self.EXPORTABLES,
            defaultValue="",
        )
        table_param.tooltip_3liz = 'Nom de la table à exporter'
        self.addParameter(table_param)

        # Nom du département pour le fichier d'export
        depparam = QgsProcessingParameterString(
            self.DPT,
            tr("Département au format XXX"),
            '066',
            optional=False
        )
        depparam.tooltip_3liz = 'Pour le département de l\'Ain, mettre 001'
        self.addParameter(depparam)

        # Chemin du dossier de destination
        outparam = QgsProcessingParameterFolderDestination(
            self.PROJECTS_FOLDER,
            description=tr("Chemin de destination")
        )
        outparam.tooltip_3liz = 'Chemin de destination pour enregistrer les exports Shapefile'
        self.addParameter(outparam)

        param = QgsProcessingParameterBoolean(
            self.CHARGER,
            tr("Charger le fichier d'export dans le projet"),
            defaultValue=False,
            optional=False,
        )
        param.tooltip_3liz = 'Si le traitement doit charger la couche Shapefile dans le projet'
        self.addParameter(param)

        output = QgsProcessingOutputVectorLayer(self.OUTPUT, tr("Couches de sortie"))
        output.tooltip_3liz = 'Les couches de l\'export'
        self.addOutput(output)