def initAlgorithm(self, config=None): self.add_top_parameters() param = QgsProcessingParameterString(self.AREA, tr('Around the area'), optional=False) help_string = tr( 'The name of a place, a first query to the Nominatim API will be executed to fetch the OSM ID. ' 'A WKT Point string is accepted as well.') if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param) param = QgsProcessingParameterNumber( self.DISTANCE, tr('Distance (meters)'), defaultValue=1000, minValue=1) help_string = tr( 'The distance to use when doing the buffering around the named area. The distance must be in ' 'meters.') if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param) self.add_bottom_parameters()
def initAlgorithm(self, config): """ Here we define the inputs and output of the algorithm, along with some other properties. """ # INPUTS # Database connection parameters connection_name = QgsExpressionContextUtils.globalScope().variable('veloroutes_connection_name') db_param = QgsProcessingParameterString( self.CONNECTION_NAME, 'Connexion à la base PostgreSQL', defaultValue=connection_name, optional=False ) 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) # OUTPUTS # Add output for status (integer) output = QgsProcessingOutputNumber(self.OUTPUT_STATUS, 'Statut de sortie') output.tooltip_3liz = output.description() self.addOutput(output) # Add output for message output = QgsProcessingOutputString(self.OUTPUT_STRING, 'Message de sortie') output.tooltip_3liz = output.description() self.addOutput(output)
def add_top_parameters(self): param = QgsProcessingParameterString(self.KEY, tr('Key, default to all keys'), optional=True) help_string = tr('The OSM key to use. It can be empty and it will default to all keys.') if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param) param = QgsProcessingParameterString(self.VALUE, tr('Value, default to all values'), optional=True) help_string = tr('The OSM value to use. It can be empty and it will default to all values.') if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param)
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)
def initAlgorithm(self, config=None): self.add_top_parameters() param = QgsProcessingParameterString(self.AREA, tr('Inside the area'), optional=False) help_string = tr( 'The name of the area. This will make a first query to the Nominatim API to fetch the OSM ID.') if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param) self.add_bottom_parameters()
def initAlgorithm(self, config=None): param = QgsProcessingParameterString(self.QUERY, tr('Query'), optional=False, multiLine=True) help_string = tr( 'A XML or OQL query to be send to the Overpass API. It can contains some {{}} tokens.' ) if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param) param = QgsProcessingParameterExtent( self.EXTENT, tr('Extent, if "{{bbox}}" in the query'), optional=True) help_string = tr( 'If the query has a {{bbox}} token, this extent will be used for replacement.' ) if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param) server = get_setting('defaultOAPI', OVERPASS_SERVERS[0]) + 'interpreter' param = QgsProcessingParameterString(self.SERVER, tr('Overpass server'), optional=False, defaultValue=server) param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced) help_string = tr( 'The Overpass API server to use to build the encoded URL.') if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param) param = QgsProcessingParameterString( self.AREA, tr('Area (if you want to override {{geocodeArea}} in the query)'), optional=True) param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced) help_string = tr('{{geocodeArea}} can be overridden on runtime.') if Qgis.QGIS_VERSION_INT >= 31500: param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addParameter(param) output = QgsProcessingOutputString(self.OUTPUT_URL, tr('Query as encoded URL')) help_string = tr( 'The query is generated and encoded with the Overpass API URL. This output should be used in the ' 'File Downloader algorithm.') if Qgis.QGIS_VERSION_INT >= 31500: pass # param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addOutput(output) output = QgsProcessingOutputString(self.OUTPUT_OQL_QUERY, tr('Raw query as OQL')) help_string = tr('The query is generated in the OQL format.') if Qgis.QGIS_VERSION_INT >= 31500: pass # param.setHelp(help_string) else: param.tooltip_3liz = help_string self.addOutput(output)
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)
def initAlgorithm(self, config): # INPUTS # Base de destination 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 de destination 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 où importer les données' self.addParameter(schema_param) # Table de destination table_param = QgsProcessingParameterString(self.TABLE, tr("Table de destination"), 'portion', False) table_param.setMetadata({ "widget_wrapper": { "class": "processing.gui.wrappers_postgis.TableWidgetWrapper", "schema_param": self.SCHEMA } }) # table_param.tooltip_3liz = 'Table de destination' self.addParameter(table_param) # Couche à importer couche = QgsProcessingParameterVectorLayer( self.INPUT, 'Couche à importer', types=[QgsProcessing.TypeVector], ) self.addParameter(couche) # Paramètre pour le mapping de champs table = QgsProcessingParameterMatrix( self.MATRIX, 'matrix', headers=['Champs source', 'Champs destination'], defaultValue=[ "TYPE_PORTION_COVADIS", "type_portion", "MONTANT_SUBVENTION", "mont_subv", "ANNE_SUBVENTION", "annee_subv", "fid", "id_import", "LIEN_ITIN", "lien_itin", "LIEN_CYCLO", "lien_segm" ]) self.addParameter(table) # OUTPUTS self.addOutput( QgsProcessingOutputString(self.OUTPUT_MSG, tr("Message de sortie")))
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)