コード例 #1
0
    def initAlgorithm(self, config=None):
        self.addParameter(
            QgsProcessingParameterString(self.TITLE,
                                         self.tr('Flight plan description'),
                                         'QGIS flight plan'))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT, self.tr('Flight waypoints layer'),
                [QgsProcessing.TypeVectorPoint]))
        self.addParameter(
            QgsProcessingParameterField(
                self.NAME_FIELD,
                self.tr('Waypoints name field'),
                parentLayerParameterName=self.INPUT,
                type=QgsProcessingParameterField.String,
                optional=True))

        elevation_param = QgsProcessingParameterField(
            self.ELEVATION_FIELD,
            self.tr('Waypoints elevation field'),
            parentLayerParameterName=self.INPUT,
            type=QgsProcessingParameterField.Numeric,
            optional=True)
        elevation_param.setFlags(
            elevation_param.flags()
            | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(elevation_param)
        orderby_param = QgsProcessingParameterExpression(
            self.ORDERBY_EXPRESSION,
            self.tr('Waypoints ordering by expression'),
            parentLayerParameterName=self.INPUT,
            optional=True)
        orderby_param.setFlags(orderby_param.flags()
                               | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(orderby_param)

        departure_airport_param = QgsProcessingParameterString(
            self.DEPARTURE_AIRPORT,
            self.tr('Custom departure airport ICAO ID'),
            '',
            optional=True)
        departure_airport_param.setFlags(
            departure_airport_param.flags()
            | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(departure_airport_param)
        destination_airport_param = QgsProcessingParameterString(
            self.DESTINATION_AIRPORT,
            self.tr('Custom destination airport ICAO ID'),
            '',
            optional=True)
        destination_airport_param.setFlags(
            destination_airport_param.flags()
            | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(destination_airport_param)

        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.OUTPUT,
                self.tr('Output flight plan file (.PLN)'),
                fileFilter='Flight plan files (*.PLN *.pln)'))
コード例 #2
0
    def initAlgorithm(self, config=None):

        # layer
        self.addParameter(
            QgsProcessingParameterFeatureSource(self.INPUT,
                                                self.tr('Input layer')))

        # x fields (or expression)
        self.addParameter(
            QgsProcessingParameterExpression(
                self.XEXPRESSION,
                self.tr('X Field'),
                parentLayerParameterName=self.INPUT))

        # y field (or expression)
        self.addParameter(
            QgsProcessingParameterExpression(
                self.YEXPRESSION,
                self.tr('Y Field'),
                parentLayerParameterName=self.INPUT))

        # size
        size_param = QgsProcessingParameterNumber(self.SIZE,
                                                  self.tr('Marker size'),
                                                  defaultValue=10)
        size_param.setIsDynamic(True)
        size_param.setDynamicLayerParameterName(self.INPUT)
        size_param.setDynamicPropertyDefinition(
            QgsPropertyDefinition(
                "SIZE",
                self.tr("Size"),
                QgsPropertyDefinition.Double,
            ))
        self.addParameter(size_param)

        # color
        color_param = QgsProcessingParameterColor(self.COLOR,
                                                  self.tr('Color'),
                                                  optional=True,
                                                  defaultValue='#8ebad9')
        color_param.setIsDynamic(True)
        color_param.setDynamicLayerParameterName(self.INPUT)
        color_param.setDynamicPropertyDefinition(
            QgsPropertyDefinition(
                "COLOR",
                self.tr("Color"),
                QgsPropertyDefinition.Double,
            ))
        self.addParameter(color_param)

        facet_row = QgsProcessingParameterExpression(
            self.FACET_ROW,
            self.tr('Facet row'),
            parentLayerParameterName=self.INPUT)
        facet_row.setFlags(QgsProcessingParameterDefinition.FlagAdvanced
                           | QgsProcessingParameterDefinition.FlagOptional)
        self.addParameter(facet_row)

        facet_col = QgsProcessingParameterExpression(
            self.FACET_COL,
            self.tr('Facet col'),
            optional=True,
            parentLayerParameterName=self.INPUT)
        facet_col.setFlags(QgsProcessingParameterDefinition.FlagAdvanced
                           | QgsProcessingParameterDefinition.FlagOptional)
        self.addParameter(facet_col)

        # offline parameter
        offline_param = QgsProcessingParameterBoolean(
            self.OFFLINE,
            self.tr('Complete offline usage'),
            defaultValue=False)
        offline_param.setFlags(QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(offline_param)

        # html file output
        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.OUTPUT_HTML_FILE, self.tr('Scatter Plot'),
                self.tr('HTML files (*.html)')))

        # json file output
        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.OUTPUT_JSON_FILE,
                self.tr('JSON file'),
                self.tr('JSON Files (*.json)'),
                createByDefault=False,
                optional=True))
コード例 #3
0
    def accept(self):
        description = self.nameTextBox.text()
        if description.strip() == '':
            QMessageBox.warning(self, self.tr('Unable to define parameter'),
                                self.tr('Invalid parameter name'))
            return
        if self.param is None:
            validChars = \
                'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
            safeName = ''.join(c for c in description if c in validChars)
            name = safeName.lower()
            i = 2
            while self.alg.parameterDefinition(name):
                name = safeName.lower() + str(i)
                i += 1
        else:
            name = self.param.name()

        # Destination parameter
        if (isinstance(self.param, QgsProcessingParameterFeatureSink)):
            self.param = QgsProcessingParameterFeatureSink(
                name=name,
                description=self.param.description(),
                type=self.param.dataType(),
                defaultValue=self.defaultWidget.value())
        elif (isinstance(self.param, QgsProcessingParameterFileDestination)):
            self.param = QgsProcessingParameterFileDestination(
                name=name,
                description=self.param.description(),
                fileFilter=self.param.fileFilter(),
                defaultValue=self.defaultWidget.value())
        elif (isinstance(self.param, QgsProcessingParameterFolderDestination)):
            self.param = QgsProcessingParameterFolderDestination(
                name=name,
                description=self.param.description(),
                defaultValue=self.defaultWidget.value())
        elif (isinstance(self.param, QgsProcessingParameterRasterDestination)):
            self.param = QgsProcessingParameterRasterDestination(
                name=name,
                description=self.param.description(),
                defaultValue=self.defaultWidget.value())
        elif (isinstance(self.param, QgsProcessingParameterVectorDestination)):
            self.param = QgsProcessingParameterVectorDestination(
                name=name,
                description=self.param.description(),
                type=self.param.dataType(),
                defaultValue=self.defaultWidget.value())

        else:
            if self.paramType:
                typeId = self.paramType
            else:
                typeId = self.param.type()

            paramTypeDef = QgsApplication.instance().processingRegistry(
            ).parameterType(typeId)
            if not paramTypeDef:
                msg = self.tr(
                    'The parameter `{}` is not registered, are you missing a required plugin?'
                    .format(typeId))
                raise UndefinedParameterException(msg)
            self.param = paramTypeDef.create(name)
            self.param.setDescription(description)
            self.param.setMetadata(paramTypeDef.metadata())

        if not self.requiredCheck.isChecked():
            self.param.setFlags(
                self.param.flags()
                | QgsProcessingParameterDefinition.FlagOptional)
        else:
            self.param.setFlags(
                self.param.flags()
                & ~QgsProcessingParameterDefinition.FlagOptional)

        if self.advancedCheck.isChecked():
            self.param.setFlags(
                self.param.flags()
                | QgsProcessingParameterDefinition.FlagAdvanced)
        else:
            self.param.setFlags(
                self.param.flags()
                & ~QgsProcessingParameterDefinition.FlagAdvanced)

        settings = QgsSettings()
        settings.setValue(
            "/Processing/modelParametersDefinitionDialogGeometry",
            self.saveGeometry())

        QDialog.accept(self)
コード例 #4
0
 def initAlgorithm(self, config):
     for par in self.param:
         pl = par.split('|')
         if pl[0] == 'ParameterRaster':
             self.addParameter(
                 QgsProcessingParameterRasterLayer(pl[1],
                                                   self.tr(pl[2]), '',
                                                   bool(strtobool(pl[3]))))
         if pl[0] == 'ParameterVector':
             self.addParameter(
                 QgsProcessingParameterVectorLayer(pl[1], self.tr(
                     pl[2]), [QgsProcessing.TypeVector], '',
                                                   bool(strtobool(pl[4]))))
         if pl[0] == 'ParameterNumber':
             try:
                 int(pl[5])
                 if pl[4] != 'None':
                     self.addParameter(
                         QgsProcessingParameterNumber(
                             pl[1], self.tr(pl[2]), 0, int(pl[5]), False,
                             int(pl[3]), int(pl[4])))
                 else:
                     self.addParameter(
                         QgsProcessingParameterNumber(
                             pl[1], self.tr(pl[2]), 0, int(pl[5]), False,
                             int(pl[3])))
             except ValueError:
                 if pl[4] != 'None':
                     self.addParameter(
                         QgsProcessingParameterNumber(
                             pl[1], self.tr(pl[2]), 1, float(pl[5]), False,
                             float(pl[3]), float(pl[4])))
                 else:
                     self.addParameter(
                         QgsProcessingParameterNumber(
                             pl[1], self.tr(pl[2]), 1, float(pl[5]), False,
                             float(pl[3])))
         if pl[0] == 'ParameterBoolean':
             self.addParameter(
                 QgsProcessingParameterBoolean(pl[1], self.tr(pl[2]),
                                               bool(strtobool(pl[3])),
                                               False))
         if pl[0] == 'ParameterEnum':
             self.addParameter(
                 QgsProcessingParameterEnum(pl[1], self.tr(pl[2]),
                                            literal_eval(pl[3]), False,
                                            pl[4], False))
     for out in self.outputline:
         ol = out.split('|')
         if ol[0] == 'OutputRaster':
             self.addParameter(
                 QgsProcessingParameterRasterDestination(
                     ol[1][1:], self.tr(ol[2])))
         if ol[0] == 'OutputVector':
             self.addParameter(
                 QgsProcessingParameterVectorDestination(
                     ol[1][1:], self.tr(ol[2])))
         if ol[0] == 'OutputFile':
             self.addParameter(
                 QgsProcessingParameterFileDestination(
                     ol[1][1:], self.tr(ol[2])))
コード例 #5
0
    def initAlgorithm(self, config=None):

        # The name that the user will see in the toolbox

        self.addParameter(
            QgsProcessingParameterRasterLayer(self.INPUT_RASTER,
                                              self.tr('Input raster')))

        # Train algorithm

        self.addParameter(
            QgsProcessingParameterEnum(self.TRAIN, "Select algorithm to train",
                                       self.TRAIN_ALGORITHMS, 0))

        # ROI
        # VECTOR
        self.addParameter(
            QgsProcessingParameterVectorLayer(
                self.INPUT_LAYER,
                'Input layer',
            ))
        # TABLE / COLUMN
        self.addParameter(
            QgsProcessingParameterField(
                self.INPUT_COLUMN,
                'Field (column must have classification number (e.g. \'1\' forest, \'2\' water...))',
                parentLayerParameterName=self.INPUT_LAYER,
                optional=False))  # save model

        # DISTANCE
        self.addParameter(
            QgsProcessingParameterNumber(
                self.DISTANCE,
                self.tr('Distance in pixels'),
                type=QgsProcessingParameterNumber.Integer,
                minValue=0,
                maxValue=99999,
                defaultValue=100))

        # MAX ITER
        self.addParameter(
            QgsProcessingParameterNumber(
                self.MAXITER,
                self.
                tr('Maximum iteration (default : 0 e.g. class with min effective)'
                   ),
                type=QgsProcessingParameterNumber.Integer,
                minValue=0,
                maxValue=99999,
                defaultValue=0))
        #
        self.addParameter(
            QgsProcessingParameterString(
                self.PARAMGRID,
                self.tr('Parameters for the hyperparameters of the algorithm'),
                optional=True))
        # SAVE AS
        # SAVE MODEL
        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.OUTPUT_MODEL,
                self.tr("Output model (to use for classifying)")))
        """
        # SAVE CONFUSION MATRIX
        self.addParameter(
        QgsProcessingParameterFileDestination(
            self.OUTPUT_MATRIX,
            self.tr("Output confusion matrix"),
            fileFilter='csv'))#,
            #ext='csv'))
        """
        # SAVE DIR
        self.addParameter(
            QgsProcessingParameterFolderDestination(
                self.SAVEDIR,
                self.tr("Directory to save every confusion matrix")))
コード例 #6
0
    def initAlgorithm(self, config=None):
        self.units = ((self.tr('Meters'), 'm'),
                      (self.tr('Feet'), 'f'))

        self.csystems = ((self.tr('Unknown'), '0'),
                         (self.tr('UTM'), '1'),
                         (self.tr('State plane'), '2'))

        self.hdatums = ((self.tr('Unknown'), '0'),
                        (self.tr('NAD27'), '1'),
                        (self.tr('NAD83'), '2'))

        self.vdatums = ((self.tr('Unknown'), '0'),
                        (self.tr('NGVD29'), '1'),
                        (self.tr('NAVD88'), '2'),
                        (self.tr('GRS80'), '3'))

        self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT,
                                                            self.tr('Surface raster')))
        self.addParameter(QgsProcessingParameterEnum(self.XYUNITS,
                                                     self.tr('Units for LIDAR data XY'),
                                                     options=[i[0] for i in self.units],
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterEnum(self.ZUNITS,
                                                     self.tr('Units for LIDAR data elevations'),
                                                     options=[i[0] for i in self.units],
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterEnum(self.COORDSYS,
                                                     self.tr('Coordinate system'),
                                                     options=[i[0] for i in self.csystems],
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterNumber(self.ZONE,
                                                       self.tr('Coordinate system zone (0 for unknown)'),
                                                       QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       maxValue=60,
                                                       defaultValue=0))
        self.addParameter(QgsProcessingParameterEnum(self.HDATUM,
                                                     self.tr('Horizontal datum'),
                                                     options=[i[0] for i in self.hdatums],
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterEnum(self.VDATUM,
                                                     self.tr('Vertical datum'),
                                                     options=[i[0] for i in self.vdatums],
                                                     defaultValue=0))
        params = []
        params.append(QgsProcessingParameterNumber(self.MULTIPLIER,
                                                   self.tr('Multiply all data values by the constant'),
                                                   QgsProcessingParameterNumber.Double,
                                                   defaultValue=None,
                                                   optional=True))
        params.append(QgsProcessingParameterNumber(self.OFFSET,
                                                   self.tr('Add the constant to all data values'),
                                                   QgsProcessingParameterNumber.Double,
                                                   defaultValue=None,
                                                   optional=True))
        params.append(QgsProcessingParameterBoolean(self.NAN,
                                                    self.tr('Use more robust (but slower) logic for parsing NAN values'),
                                                    defaultValue=None,
                                                    optional=True))

        for p in params:
            p.setFlags(p.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
            self.addParameter(p)

        self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT,
                                                                self.tr('Output'),
                                                                self.tr('DTM files (*.dtm *.DTM)')))
コード例 #7
0
    def initAlgorithm(self, config=None):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """

        self.db_variables = QgsSettings()
        self.taxonomic_ranks_variables = [
            "Groupes taxonomiques", "Règnes", "Phylum", "Classes", "Ordres",
            "Familles",
            "Groupes 1 INPN (regroupement vernaculaire du référentiel national - niveau 1)",
            "Groupes 2 INPN (regroupement vernaculaire du référentiel national - niveau 2)"
        ]
        self.period_variables = [
            "Pas de filtre temporel", "5 dernières années",
            "10 dernières années",
            "Date de début - Date de fin (à définir ci-dessous)"
        ]
        histogram_variables = [
            "Pas d'histogramme", "Histogramme du nombre de données par taxon",
            "Histogramme du nombre d'espèces par taxon",
            "Histogramme du nombre d'observateurs par taxon",
            "Histogramme du nombre de dates par taxon",
            "Histogramme du nombre de données de mortalité par taxon"
        ]

        # Data base connection
        db_param = QgsProcessingParameterString(
            self.DATABASE,
            self.
            tr("""<b style="color:#0a84db">CONNEXION À LA BASE DE DONNÉES</b><br/>
                <b>*1/</b> Sélectionnez votre <u>connexion</u> à la base de données LPO AuRA (<i>gnlpoaura</i>)"""
               ),
            defaultValue='gnlpoaura')
        db_param.setMetadata({
            'widget_wrapper': {
                'class':
                'processing.gui.wrappers_postgis.ConnectionWidgetWrapper'
            }
        })
        self.addParameter(db_param)

        # Input vector layer = study area
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.STUDY_AREA,
                self.tr("""<b style="color:#0a84db">ZONE D'ÉTUDE</b><br/>
                    <b>*2/</b> Sélectionnez votre <u>zone d'étude</u>, à partir de laquelle seront extraits les résultats"""
                        ), [QgsProcessing.TypeVectorPolygon]))

        # Taxonomic rank
        taxonomic_rank = QgsProcessingParameterEnum(
            self.TAXONOMIC_RANK,
            self.tr("""<b style="color:#0a84db">RANG TAXONOMIQUE</b><br/>
                <b>*3/</b> Sélectionnez le <u>rang taxonomique</u> qui vous intéresse"""
                    ),
            self.taxonomic_ranks_variables,
            allowMultiple=False)
        taxonomic_rank.setMetadata({
            'widget_wrapper': {
                'useCheckBoxes': True,
                'columns': len(self.taxonomic_ranks_variables) / 2
            }
        })
        self.addParameter(taxonomic_rank)

        ### Taxons filters ###
        self.addParameter(
            QgsProcessingParameterEnum(
                self.GROUPE_TAXO,
                self.tr(
                    """<b style="color:#0a84db">FILTRES DE REQUÊTAGE</b><br/>
                    <b>4/</b> Si cela vous intéresse, vous pouvez sélectionner un/plusieurs <u>taxon(s)</u> dans la liste déroulante suivante (à choix multiples)<br/> pour filtrer vos données d'observations. <u>Sinon</u>, vous pouvez ignorer cette étape.<br/>
                    <i style="color:#952132"><b>N.B.</b> : D'autres filtres taxonomiques sont disponibles dans les paramètres avancés (plus bas, juste avant l'enregistrement des résultats).</i><br/>
                    - Groupes taxonomiques :"""),
                self.db_variables.value("groupe_taxo"),
                allowMultiple=True,
                optional=True))

        regne = QgsProcessingParameterEnum(self.REGNE,
                                           self.tr("- Règnes :"),
                                           self.db_variables.value("regne"),
                                           allowMultiple=True,
                                           optional=True)
        regne.setFlags(regne.flags()
                       | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(regne)

        phylum = QgsProcessingParameterEnum(self.PHYLUM,
                                            self.tr("- Phylum :"),
                                            self.db_variables.value("phylum"),
                                            allowMultiple=True,
                                            optional=True)
        phylum.setFlags(phylum.flags()
                        | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(phylum)

        classe = QgsProcessingParameterEnum(self.CLASSE,
                                            self.tr("- Classe :"),
                                            self.db_variables.value("classe"),
                                            allowMultiple=True,
                                            optional=True)
        classe.setFlags(classe.flags()
                        | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(classe)

        ordre = QgsProcessingParameterEnum(self.ORDRE,
                                           self.tr("- Ordre :"),
                                           self.db_variables.value("ordre"),
                                           allowMultiple=True,
                                           optional=True)
        ordre.setFlags(ordre.flags()
                       | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(ordre)

        famille = QgsProcessingParameterEnum(
            self.FAMILLE,
            self.tr("- Famille :"),
            self.db_variables.value("famille"),
            allowMultiple=True,
            optional=True)
        famille.setFlags(famille.flags()
                         | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(famille)

        group1_inpn = QgsProcessingParameterEnum(
            self.GROUP1_INPN,
            self.
            tr("- Groupe 1 INPN (regroupement vernaculaire du référentiel national - niveau 1) :"
               ),
            self.db_variables.value("group1_inpn"),
            allowMultiple=True,
            optional=True)
        group1_inpn.setFlags(group1_inpn.flags()
                             | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(group1_inpn)

        group2_inpn = QgsProcessingParameterEnum(
            self.GROUP2_INPN,
            self.
            tr("- Groupe 2 INPN (regroupement vernaculaire du référentiel national - niveau 2) :"
               ),
            self.db_variables.value("group2_inpn"),
            allowMultiple=True,
            optional=True)
        group2_inpn.setFlags(group2_inpn.flags()
                             | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(group2_inpn)

        ### Datetime filter ###
        period = QgsProcessingParameterEnum(
            self.PERIOD,
            self.
            tr("<b>*5/</b> Sélectionnez une <u>période</u> pour filtrer vos données d'observations"
               ),
            self.period_variables,
            allowMultiple=False,
            optional=False)
        period.setMetadata({
            'widget_wrapper': {
                'useCheckBoxes': True,
                'columns': len(self.period_variables) / 2
            }
        })
        self.addParameter(period)

        start_date = QgsProcessingParameterString(
            self.START_DATE,
            """- Date de début <i style="color:#952132">(nécessaire seulement si vous avez sélectionné l'option <b>Date de début - Date de fin</b>)</i> :""",
            defaultValue="",
            optional=True)
        start_date.setMetadata({'widget_wrapper': {'class': DateTimeWidget}})
        self.addParameter(start_date)

        end_date = QgsProcessingParameterString(
            self.END_DATE,
            """- Date de fin <i style="color:#952132">(nécessaire seulement si vous avez sélectionné l'option <b>Date de début - Date de fin</b>)</i> :""",
            optional=True)
        end_date.setMetadata({'widget_wrapper': {'class': DateTimeWidget}})
        self.addParameter(end_date)

        # Extra "where" conditions
        extra_where = QgsProcessingParameterString(
            self.EXTRA_WHERE,
            self.
            tr("""Vous pouvez ajouter des <u>conditions "where"</u> supplémentaires dans l'encadré suivant, en langage SQL <b style="color:#952132">(commencez par <i>and</i>)</b>"""
               ),
            multiLine=True,
            optional=True)
        extra_where.setFlags(extra_where.flags()
                             | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(extra_where)

        # Output PostGIS layer = summary table
        self.addOutput(
            QgsProcessingOutputVectorLayer(
                self.OUTPUT, self.tr('Couche en sortie'),
                QgsProcessing.TypeVectorAnyGeometry))

        # Output PostGIS layer name
        self.addParameter(
            QgsProcessingParameterString(
                self.OUTPUT_NAME,
                self.
                tr("""<b style="color:#0a84db">PARAMÉTRAGE DES RESULTATS EN SORTIE</b><br/>
                    <b>*6/</b> Définissez un <u>nom</u> pour votre nouvelle couche PostGIS"""
                   ), self.tr("État des connaissances")))

        # Boolean : True = add the summary table in the DB ; False = don't
        self.addParameter(
            QgsProcessingParameterBoolean(
                self.ADD_TABLE,
                self.
                tr("Enregistrer les résultats en sortie dans une nouvelle table PostgreSQL"
                   ),
                defaultValue=False))

        ### Histogram ###
        histogram_options = QgsProcessingParameterEnum(
            self.HISTOGRAM_OPTIONS,
            self.
            tr("<b>7/</b> Si cela vous intéresse, vous pouvez <u>exporter</u> les résultats sous forme d'<u>histogramme</u>. Dans ce cas, sélectionnez le type<br/> d'histogramme qui vous convient. <u>Sinon</u>, vous pouvez ignorer cette étape."
               ),
            histogram_variables,
            defaultValue="Pas d'histogramme")
        histogram_options.setMetadata({
            'widget_wrapper': {
                'useCheckBoxes': True,
                'columns': len(histogram_variables) / 3
            }
        })
        self.addParameter(histogram_options)

        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.OUTPUT_HISTOGRAM,
                self.
                tr("""<b style="color:#0a84db">ENREGISTREMENT DES RESULTATS</b><br/>
                <b>8/</b> <u style="color:#952132">Si (et seulement si !)</u> vous avez sélectionné un type d'<u>histogramme</u>, veuillez renseigner un emplacement pour l'enregistrer<br/> sur votre ordinateur (au format image). <u>Dans le cas contraire</u>, vous pouvez ignorer cette étape.<br/>
                <font style='color:#06497a'><u>Aide</u> : Cliquez sur le bouton [...] puis sur 'Enregistrer vers un fichier...'</font>"""
                   ),
                self.tr('image PNG (*.png)'),
                optional=True,
                createByDefault=False))
コード例 #8
0
    def accept(self):
        description = self.nameTextBox.text()
        if description.strip() == '':
            QMessageBox.warning(self, self.tr('Unable to define parameter'),
                                self.tr('Invalid parameter name'))
            return
        if self.param is None:
            validChars = \
                'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
            safeName = ''.join(c for c in description if c in validChars)
            name = safeName.lower()
            i = 2
            while self.alg.parameterDefinition(name):
                name = safeName.lower() + str(i)
                i += 1
        else:
            name = self.param.name()
        if (self.paramType == parameters.PARAMETER_BOOLEAN
                or isinstance(self.param, QgsProcessingParameterBoolean)):
            self.param = QgsProcessingParameterBoolean(name, description,
                                                       self.state.isChecked())
        elif (self.paramType == parameters.PARAMETER_TABLE_FIELD
              or isinstance(self.param, QgsProcessingParameterField)):
            if self.parentCombo.currentIndex() < 0:
                QMessageBox.warning(
                    self, self.tr('Unable to define parameter'),
                    self.tr('Wrong or missing parameter values'))
                return
            parent = self.parentCombo.currentData()
            datatype = self.datatypeCombo.currentData()
            default = self.defaultTextBox.text()
            if not default:
                default = None
            self.param = QgsProcessingParameterField(
                name,
                description,
                defaultValue=default,
                parentLayerParameterName=parent,
                type=datatype,
                allowMultiple=self.multipleCheck.isChecked())
        elif (self.paramType == parameters.PARAMETER_BAND
              or isinstance(self.param, QgsProcessingParameterBand)):
            if self.parentCombo.currentIndex() < 0:
                QMessageBox.warning(
                    self, self.tr('Unable to define parameter'),
                    self.tr('Wrong or missing parameter values'))
                return
            parent = self.parentCombo.currentData()
            self.param = QgsProcessingParameterBand(name, description, None,
                                                    parent)
        elif (self.paramType == parameters.PARAMETER_LAYOUTITEM
              or isinstance(self.param, QgsProcessingParameterLayoutItem)):
            if self.parentCombo.currentIndex() < 0:
                QMessageBox.warning(
                    self, self.tr('Unable to define parameter'),
                    self.tr('Wrong or missing parameter values'))
                return
            parent = self.parentCombo.currentData()
            self.param = QgsProcessingParameterLayoutItem(
                name, description, None, parent)
        elif (self.paramType == parameters.PARAMETER_MAP_LAYER
              or isinstance(self.param, QgsProcessingParameterMapLayer)):
            self.param = QgsProcessingParameterMapLayer(name, description)
        elif (self.paramType == parameters.PARAMETER_RASTER
              or isinstance(self.param, QgsProcessingParameterRasterLayer)):
            self.param = QgsProcessingParameterRasterLayer(name, description)
        elif (self.paramType == parameters.PARAMETER_TABLE
              or isinstance(self.param, QgsProcessingParameterVectorLayer)):
            self.param = QgsProcessingParameterVectorLayer(
                name, description, [self.shapetypeCombo.currentData()])
        elif (self.paramType == parameters.PARAMETER_VECTOR
              or isinstance(self.param, QgsProcessingParameterFeatureSource)):
            self.param = QgsProcessingParameterFeatureSource(
                name, description, [self.shapetypeCombo.currentData()])
        elif (self.paramType == parameters.PARAMETER_MULTIPLE
              or isinstance(self.param, QgsProcessingParameterMultipleLayers)):
            self.param = QgsProcessingParameterMultipleLayers(
                name, description, self.datatypeCombo.currentData())
        elif (self.paramType == parameters.PARAMETER_DISTANCE
              or isinstance(self.param, QgsProcessingParameterDistance)):
            self.param = QgsProcessingParameterDistance(
                name, description, self.defaultTextBox.text())
            try:
                vmin = self.minTextBox.text().strip()
                if not vmin == '':
                    self.param.setMinimum(float(vmin))
                vmax = self.maxTextBox.text().strip()
                if not vmax == '':
                    self.param.setMaximum(float(vmax))
            except:
                QMessageBox.warning(
                    self, self.tr('Unable to define parameter'),
                    self.tr('Wrong or missing parameter values'))
                return

            if self.parentCombo.currentIndex() < 0:
                QMessageBox.warning(
                    self, self.tr('Unable to define parameter'),
                    self.tr('Wrong or missing parameter values'))
                return
            parent = self.parentCombo.currentData()
            if parent:
                self.param.setParentParameterName(parent)
        elif (self.paramType == parameters.PARAMETER_NUMBER
              or isinstance(self.param, QgsProcessingParameterNumber)):

            type = self.type_combo.currentData()
            self.param = QgsProcessingParameterNumber(
                name, description, type, self.defaultTextBox.text())
            try:
                vmin = self.minTextBox.text().strip()
                if not vmin == '':
                    self.param.setMinimum(float(vmin))
                vmax = self.maxTextBox.text().strip()
                if not vmax == '':
                    self.param.setMaximum(float(vmax))
            except:
                QMessageBox.warning(
                    self, self.tr('Unable to define parameter'),
                    self.tr('Wrong or missing parameter values'))
                return
        elif (self.paramType == parameters.PARAMETER_EXPRESSION
              or isinstance(self.param, QgsProcessingParameterExpression)):
            parent = self.parentCombo.currentData()
            self.param = QgsProcessingParameterExpression(
                name, description, str(self.defaultEdit.expression()), parent)
        elif (self.paramType == parameters.PARAMETER_STRING
              or isinstance(self.param, QgsProcessingParameterString)):
            self.param = QgsProcessingParameterString(
                name, description, str(self.defaultTextBox.text()))
        elif (self.paramType == parameters.PARAMETER_EXTENT
              or isinstance(self.param, QgsProcessingParameterExtent)):
            self.param = QgsProcessingParameterExtent(name, description)
        elif (self.paramType == parameters.PARAMETER_FILE
              or isinstance(self.param, QgsProcessingParameterFile)):
            isFolder = self.fileFolderCombo.currentIndex() == 1
            self.param = QgsProcessingParameterFile(
                name, description, QgsProcessingParameterFile.Folder
                if isFolder else QgsProcessingParameterFile.File)
        elif (self.paramType == parameters.PARAMETER_POINT
              or isinstance(self.param, QgsProcessingParameterPoint)):
            self.param = QgsProcessingParameterPoint(
                name, description, str(self.defaultTextBox.text()))
        elif (self.paramType == parameters.PARAMETER_CRS
              or isinstance(self.param, QgsProcessingParameterCrs)):
            self.param = QgsProcessingParameterCrs(
                name, description,
                self.selector.crs().authid())
        elif (self.paramType == parameters.PARAMETER_ENUM
              or isinstance(self.param, QgsProcessingParameterEnum)):
            self.param = QgsProcessingParameterEnum(
                name, description, self.widget.options(),
                self.widget.allowMultiple(), self.widget.defaultOptions())
        elif (self.paramType == parameters.PARAMETER_MATRIX
              or isinstance(self.param, QgsProcessingParameterMatrix)):
            self.param = QgsProcessingParameterMatrix(
                name,
                description,
                hasFixedNumberRows=self.widget.fixedRows(),
                headers=self.widget.headers(),
                defaultValue=self.widget.value())

        # Destination parameter
        elif (isinstance(self.param, QgsProcessingParameterFeatureSink)):
            self.param = QgsProcessingParameterFeatureSink(
                name=name,
                description=self.param.description(),
                type=self.param.dataType(),
                defaultValue=self.defaultWidget.getValue())
        elif (isinstance(self.param, QgsProcessingParameterFileDestination)):
            self.param = QgsProcessingParameterFileDestination(
                name=name,
                description=self.param.description(),
                fileFilter=self.param.fileFilter(),
                defaultValue=self.defaultWidget.getValue())
        elif (isinstance(self.param, QgsProcessingParameterFolderDestination)):
            self.param = QgsProcessingParameterFolderDestination(
                name=name,
                description=self.param.description(),
                defaultValue=self.defaultWidget.getValue())
        elif (isinstance(self.param, QgsProcessingParameterRasterDestination)):
            self.param = QgsProcessingParameterRasterDestination(
                name=name,
                description=self.param.description(),
                defaultValue=self.defaultWidget.getValue())
        elif (isinstance(self.param, QgsProcessingParameterVectorDestination)):
            self.param = QgsProcessingParameterVectorDestination(
                name=name,
                description=self.param.description(),
                type=self.param.dataType(),
                defaultValue=self.defaultWidget.getValue())

        else:
            if self.paramType:
                typeId = self.paramType
            else:
                typeId = self.param.type()

            paramTypeDef = QgsApplication.instance().processingRegistry(
            ).parameterType(typeId)
            if not paramTypeDef:
                msg = self.tr(
                    'The parameter `{}` is not registered, are you missing a required plugin?'
                    .format(typeId))
                raise UndefinedParameterException(msg)
            self.param = paramTypeDef.create(name)
            self.param.setDescription(description)
            self.param.setMetadata(paramTypeDef.metadata())

        if not self.requiredCheck.isChecked():
            self.param.setFlags(
                self.param.flags()
                | QgsProcessingParameterDefinition.FlagOptional)
        else:
            self.param.setFlags(
                self.param.flags()
                & ~QgsProcessingParameterDefinition.FlagOptional)

        settings = QgsSettings()
        settings.setValue(
            "/Processing/modelParametersDefinitionDialogGeometry",
            self.saveGeometry())

        QDialog.accept(self)
コード例 #9
0
    def initAlgorithm(self, config=None):
        # === INPUT PARAMETERS ===
        # === INPUT PARAMETERS ===
        inputAscParam = QgsProcessingParameterRasterLayer(
            name=self.INPUT_LAYER_ASC, description=self.tr('Input layer asc'))

        inputAscParam.setMetadata({
            'widget_wrapper': {
                'class':
                'Chloe.chloe_algorithm_dialog.ChloeAscRasterWidgetWrapper'
            }
        })
        self.addParameter(inputAscParam)

        gridSizeParam = QgsProcessingParameterString(
            name=self.GRID_SIZES, description=self.tr(
                'Grid sizes (pixels)'))  # [constraint V2.0: "select only one"]

        gridSizeParam.setMetadata({
            'widget_wrapper': {
                'class':
                'Chloe.chloe_algorithm_dialog.ChloeIntListWidgetWrapper',
                'initialValue': 2,
                'maxValue': 100001,
                'minValue': 1,
                'oddNum': None
            }
        })
        self.addParameter(gridSizeParam)

        metricsParam = QgsProcessingParameterString(
            name=self.METRICS, description=self.tr('Select metrics'))

        metricsParam.setMetadata({
            'widget_wrapper': {
                'class':
                'Chloe.chloe_algorithm_dialog.ChloeMultipleMetricsSelectorWidgetWrapper',
                'dictValues': self.types_of_metrics,
                'initialValue': 'value metrics',
                'rasterLayerParamName': self.INPUT_LAYER_ASC,
                'parentWidgetConfig': {
                    'paramName': self.INPUT_LAYER_ASC,
                    'refreshMethod': 'refreshMetrics'
                }
            }
        })

        self.addParameter(metricsParam)

        self.addParameter(
            QgsProcessingParameterNumber(
                name=self.MAXIMUM_RATE_MISSING_VALUES,
                description=self.tr('Maximum rate of mising values'),
                minValue=0,
                maxValue=100,
                defaultValue=100))

        # === OUTPUT PARAMETERS ===
        self.addParameter(
            ChloeParameterFolderDestination(
                name=self.OUTPUT_DIR, description=self.tr('Output directory')))

        self.addParameter(
            QgsProcessingParameterFileDestination(
                name=self.SAVE_PROPERTIES,
                description=self.tr('Properties file'),
                fileFilter='Properties (*.properties)'))
コード例 #10
0
    def initAlgorithm(self, config=None):
        # === INPUT PARAMETERS ===
        inputAscParam = QgsProcessingParameterRasterLayer(
            name=self.INPUT_LAYER_ASC, description=self.tr('Input layer asc'))

        inputAscParam.setMetadata({
            'widget_wrapper': {
                'class':
                'Chloe.chloe_algorithm_dialog.ChloeAscRasterWidgetWrapper'
            }
        })
        self.addParameter(inputAscParam)

        self.addParameter(
            QgsProcessingParameterNumber(
                name=self.GRID_SIZES,
                description=self.tr('Grid size (pixels)'),
                defaultValue=2,
                minValue=1))

        metricsParam = QgsProcessingParameterString(
            name=self.METRICS, description=self.tr('Select metrics'))

        metricsParam.setMetadata({
            'widget_wrapper': {
                'class':
                'Chloe.chloe_algorithm_dialog.ChloeDoubleComboboxWidgetWrapper',
                'dictValues': self.types_of_metrics,
                'initialValue': 'value metrics',
                'rasterLayerParamName': self.INPUT_LAYER_ASC,
                'parentWidgetConfig': {
                    'paramName': self.INPUT_LAYER_ASC,
                    'refreshMethod': 'refreshMappingCombobox'
                }
            }
        })

        self.addParameter(metricsParam)

        self.addParameter(
            QgsProcessingParameterNumber(
                name=self.MAXIMUM_RATE_MISSING_VALUES,
                description=self.tr('Maximum rate of mising values'),
                minValue=0,
                maxValue=100,
                defaultValue=100))

        # self.addParameter(QgsProcessingParameterString(
        #     name=self.COMMENT,
        #     description=self.tr('Comment'))
        # )

        # === OUTPUT PARAMETERS ===

        self.addParameter(
            ChloeCSVParameterFileDestination(name=self.OUTPUT_CSV,
                                             description=self.tr('Output csv'),
                                             addToMapDefaultState=False))

        fieldsParam = ChloeASCParameterFileDestination(
            name=self.OUTPUT_ASC, description=self.tr('Output Raster ascii'))
        self.addParameter(fieldsParam, createOutput=True)

        self.addParameter(
            QgsProcessingParameterFileDestination(
                name=self.SAVE_PROPERTIES,
                description=self.tr('Properties file'),
                fileFilter='Properties (*.properties)'))
コード例 #11
0
    def initAlgorithm(self, config=None):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """

        self.ts = datetime.now()
        self.db_variables = QgsSettings()
        self.interval_variables = ["Par année", "Par mois"]
        self.months_names_variables = [
            "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet",
            "Août", "Septembre", "Octobre", "Novembre", "Décembre"
        ]
        self.taxonomic_ranks_variables = ["Espèces", "Groupes taxonomiques"]
        self.agg_variables = ["Nombre de données", "Nombre d'espèces"]

        # Data base connection
        db_param = QgsProcessingParameterString(
            self.DATABASE,
            self.
            tr("""<b style="color:#0a84db">CONNEXION À LA BASE DE DONNÉES</b><br/>
                <b>*1/</b> Sélectionnez votre <u>connexion</u> à la base de données LPO AuRA (<i>gnlpoaura</i>)"""
               ),
            defaultValue='gnlpoaura')
        db_param.setMetadata({
            'widget_wrapper': {
                'class':
                'processing.gui.wrappers_postgis.ConnectionWidgetWrapper'
            }
        })
        self.addParameter(db_param)

        # Input vector layer = study area
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.STUDY_AREA,
                self.tr("""<b style="color:#0a84db">ZONE D'ÉTUDE</b><br/>
                    <b>*2/</b> Sélectionnez votre <u>zone d'étude</u>, à partir de laquelle seront extraits les résultats"""
                        ), [QgsProcessing.TypeVectorPolygon]))

        ### Time interval and period ###
        time_interval = QgsProcessingParameterEnum(
            self.TIME_INTERVAL,
            self.
            tr("""<b style="color:#0a84db">AGRÉGATION TEMPORELLE ET PÉRIODE</b><br/>
                <b>*3/</b> Sélectionnez l'<u>agrégation temporelle</u> qui vous intéresse"""
               ),
            self.interval_variables,
            allowMultiple=False)
        time_interval.setMetadata({
            'widget_wrapper': {
                'useCheckBoxes': True,
                'columns': len(self.interval_variables)
            }
        })
        self.addParameter(time_interval)

        add_five_years = QgsProcessingParameterEnum(
            self.ADD_FIVE_YEARS,
            self.
            tr("""<b>4/</b> <u style="color:#952132">Si (et seulement si !)</u> vous avez sélectionné l'<u>agrégation <b>Par année</b></u> :<br/> cochez la case ci-dessous si vous souhaitez ajouter des colonnes dîtes "bilan" par intervalle de 5 ans.<br/>
            <i style="color:#952132"><b>N.B.</b> : En cochant cette case, vous devez vous assurer de renseigner une période en années (cf. <b>*5/</b>) qui soit <b>divisible par 5</b>.<br/> Exemple : 2011 - 2020.</i>"""
               ),
            [
                'Oui, je souhaite ajouter des colonnes dîtes "bilan" par intervalle de 5 ans'
            ],
            allowMultiple=True,
            optional=True)
        add_five_years.setMetadata(
            {'widget_wrapper': {
                'useCheckBoxes': True,
                'columns': 1
            }})
        self.addParameter(add_five_years)

        self.addParameter(
            QgsProcessingParameterEnum(
                self.START_MONTH,
                self.
                tr("""<b>*5/</b> Sélectionnez la <u>période</u> qui vous intéresse<br/>
                    - Mois de début <i style="color:#952132">(nécessaire seulement si vous avez sélectionné l'agrégation <b>Par mois</b>)</i> :"""
                   ),
                self.months_names_variables,
                allowMultiple=False,
                optional=True))

        self.addParameter(
            QgsProcessingParameterNumber(self.START_YEAR,
                                         self.tr("- *Année de début :"),
                                         QgsProcessingParameterNumber.Integer,
                                         defaultValue=2010,
                                         minValue=1800,
                                         maxValue=int(self.ts.strftime('%Y'))))

        self.addParameter(
            QgsProcessingParameterEnum(
                self.END_MONTH,
                self.
                tr("""- Mois de fin <i style="color:#952132">(nécessaire seulement si vous avez sélectionné l'agrégation <b>Par mois</b>)</i> :"""
                   ),
                self.months_names_variables,
                allowMultiple=False,
                optional=True))

        self.addParameter(
            QgsProcessingParameterNumber(self.END_YEAR,
                                         self.tr("- *Année de fin :"),
                                         QgsProcessingParameterNumber.Integer,
                                         defaultValue=self.ts.strftime('%Y'),
                                         minValue=1800,
                                         maxValue=int(self.ts.strftime('%Y'))))

        # Taxonomic rank
        taxonomic_rank = QgsProcessingParameterEnum(
            self.TAXONOMIC_RANK,
            self.tr("""<b style="color:#0a84db">RANG TAXONOMIQUE</b><br/>
                <b>*6/</b> Sélectionnez le <u>rang taxonomique</u> qui vous intéresse"""
                    ),
            self.taxonomic_ranks_variables,
            allowMultiple=False)
        taxonomic_rank.setMetadata({
            'widget_wrapper': {
                'useCheckBoxes': True,
                'columns': len(self.taxonomic_ranks_variables)
            }
        })
        self.addParameter(taxonomic_rank)

        # Aggregation type
        aggregation_type = QgsProcessingParameterEnum(
            self.AGG,
            self.tr(
                """<b style="color:#0a84db">AGRÉGATION DES RÉSULTATS</b><br/>
                <b>*7/</b> Sélectionnez le <u>type d'agrégation</u> qui vous intéresse pour les résultats<br/>
                <i style="color:#952132"><b>N.B.</b> : Si vous avez choisi <b>Espèces</b> pour le rang taxonomique, <b>Nombre de données</b> sera utilisé <b>par défaut</b></i>"""
            ),
            self.agg_variables,
            allowMultiple=False,
            defaultValue="Nombre de données")
        aggregation_type.setMetadata({
            'widget_wrapper': {
                'useCheckBoxes': True,
                'columns': len(self.agg_variables)
            }
        })
        self.addParameter(aggregation_type)

        ### Taxons filters ###
        self.addParameter(
            QgsProcessingParameterEnum(
                self.GROUPE_TAXO,
                self.tr(
                    """<b style="color:#0a84db">FILTRES DE REQUÊTAGE</b><br/>
                    <b>8/</b> Si cela vous intéresse, vous pouvez sélectionner un/plusieurs <u>taxon(s)</u> dans la liste déroulante suivante (à choix multiples)<br/> pour filtrer vos données d'observations. <u>Sinon</u>, vous pouvez ignorer cette étape.<br/>
                    <i style="color:#952132"><b>N.B.</b> : D'autres filtres taxonomiques sont disponibles dans les paramètres avancés (plus bas, juste avant l'enregistrement des résultats).</i><br/>
                    - Groupes taxonomiques :"""),
                self.db_variables.value("groupe_taxo"),
                allowMultiple=True,
                optional=True))

        regne = QgsProcessingParameterEnum(self.REGNE,
                                           self.tr("- Règnes :"),
                                           self.db_variables.value("regne"),
                                           allowMultiple=True,
                                           optional=True)
        regne.setFlags(regne.flags()
                       | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(regne)

        phylum = QgsProcessingParameterEnum(self.PHYLUM,
                                            self.tr("- Phylum :"),
                                            self.db_variables.value("phylum"),
                                            allowMultiple=True,
                                            optional=True)
        phylum.setFlags(phylum.flags()
                        | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(phylum)

        classe = QgsProcessingParameterEnum(self.CLASSE,
                                            self.tr("- Classe :"),
                                            self.db_variables.value("classe"),
                                            allowMultiple=True,
                                            optional=True)
        classe.setFlags(classe.flags()
                        | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(classe)

        ordre = QgsProcessingParameterEnum(self.ORDRE,
                                           self.tr("- Ordre :"),
                                           self.db_variables.value("ordre"),
                                           allowMultiple=True,
                                           optional=True)
        ordre.setFlags(ordre.flags()
                       | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(ordre)

        famille = QgsProcessingParameterEnum(
            self.FAMILLE,
            self.tr("- Famille :"),
            self.db_variables.value("famille"),
            allowMultiple=True,
            optional=True)
        famille.setFlags(famille.flags()
                         | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(famille)

        group1_inpn = QgsProcessingParameterEnum(
            self.GROUP1_INPN,
            self.
            tr("- Groupe 1 INPN (regroupement vernaculaire du référentiel national - niveau 1) :"
               ),
            self.db_variables.value("group1_inpn"),
            allowMultiple=True,
            optional=True)
        group1_inpn.setFlags(group1_inpn.flags()
                             | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(group1_inpn)

        group2_inpn = QgsProcessingParameterEnum(
            self.GROUP2_INPN,
            self.
            tr("- Groupe 2 INPN (regroupement vernaculaire du référentiel national - niveau 2) :"
               ),
            self.db_variables.value("group2_inpn"),
            allowMultiple=True,
            optional=True)
        group2_inpn.setFlags(group2_inpn.flags()
                             | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(group2_inpn)

        # Extra "where" conditions
        extra_where = QgsProcessingParameterString(
            self.EXTRA_WHERE,
            self.
            tr("""Vous pouvez ajouter des <u>conditions "where"</u> supplémentaires dans l'encadré suivant, en langage SQL <b style="color:#952132">(commencez par <i>and</i>)</b>"""
               ),
            multiLine=True,
            optional=True)
        extra_where.setFlags(extra_where.flags()
                             | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(extra_where)

        # Output PostGIS layer = summary table
        self.addOutput(
            QgsProcessingOutputVectorLayer(
                self.OUTPUT, self.tr('Couche en sortie'),
                QgsProcessing.TypeVectorAnyGeometry))

        # Output PostGIS layer name
        self.addParameter(
            QgsProcessingParameterString(
                self.OUTPUT_NAME,
                self.
                tr("""<b style="color:#0a84db">PARAMÉTRAGE DES RESULTATS EN SORTIE</b><br/>
                    <b>*9/</b> Définissez un <u>nom</u> pour votre couche PostGIS"""
                   ), self.tr("Tableau synthèse temps")))

        # Boolean : True = add the summary table in the DB ; False = don't
        self.addParameter(
            QgsProcessingParameterBoolean(
                self.ADD_TABLE,
                self.
                tr("Enregistrer les résultats en sortie dans une nouvelle table PostgreSQL"
                   ), False))

        ### Histogram ###
        add_histogram = QgsProcessingParameterEnum(
            self.ADD_HISTOGRAM,
            self.
            tr("""<b>10/</b> Cochez la case ci-dessous si vous souhaitez <u>exporter</u> les résultats sous la forme d'un <u>histogramme</u> du total par<br/> pas de temps choisi."""
               ),
            [
                "Oui, je souhaite exporter les résultats sous la forme d'un histogramme du total par pas de temps choisi"
            ],
            allowMultiple=True,
            optional=True)
        add_histogram.setMetadata(
            {'widget_wrapper': {
                'useCheckBoxes': True,
                'columns': 1
            }})
        self.addParameter(add_histogram)

        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.OUTPUT_HISTOGRAM,
                self.
                tr("""<b style="color:#0a84db">ENREGISTREMENT DES RESULTATS</b><br/>
                <b>11/</b> <u style="color:#952132">Si (et seulement si !)</u> vous avez sélectionné l'export sous forme d'<u>histogramme</u>, veuillez renseigner un emplacement<br/> pour l'enregistrer sur votre ordinateur (au format image). <u>Dans le cas contraire</u>, vous pouvez ignorer cette étape.<br/>
                <font style='color:#06497a'><u>Aide</u> : Cliquez sur le bouton [...] puis sur 'Enregistrer vers un fichier...'</font>"""
                   ),
                self.tr('image PNG (*.png)'),
                optional=True,
                createByDefault=False))
コード例 #12
0
 def initAlgorithm(self, config):
     """Initialize algorithm with inputs and output parameters."""
     if HAS_DB_PROCESSING_PARAMETER:
         db_param = QgsProcessingParameterProviderConnection(
             self.DATABASE,
             self.tr('Database (connection name)'),
             'postgres',
         )
     else:
         db_param = QgsProcessingParameterString(
             self.DATABASE,
             self.tr('Database (connection name)'),
         )
         db_param.setMetadata({
             'widget_wrapper': {
                 'class': ('processing.gui.wrappers_postgis'
                           '.ConnectionWidgetWrapper')
             }
         })
     self.addParameter(db_param)
     self.addParameter(
         QgsProcessingParameterString(
             self.SELECT_SQL,
             self.tr('SELECT SQL query'),
             multiLine=True,
         ))
     self.addParameter(
         QgsProcessingParameterEnum(
             self.SEPARATOR,
             self.tr('Separator'),
             options=[
                 '{name} ("{char}")'.format(name=name, char=char)
                 for name, char in _SEPARATORS
             ],
             defaultValue=0,
         ))
     self.addParameter(
         QgsProcessingParameterEnum(
             self.QUOTING,
             self.tr('Quoting'),
             options=[
                 '{name}'.format(name=name)
                 for name, _ in _QUOTING_STRATEGIES
             ],
             defaultValue=0,
         ))
     self.addParameter(
         QgsProcessingParameterEnum(
             self.LINE_TERMINATOR,
             self.tr('End-line character'),
             options=[
                 '{name} ("{char}")'.format(name=name, char=char)
                 for name, char in _LINE_TERMINATORS
             ],
             defaultValue=0,
         ))
     self.addParameter(
         QgsProcessingParameterFileDestination(
             self.OUTPUT,
             self.tr('CSV file'),
             'CSV files (*.csv)',
         ))
コード例 #13
0
 def initAlgorithm(self, config=None):
     self.addParameter(QgsProcessingParameterFile(
         self.ILI,
         self.tr('Interlis model file'), optional=False))
     self.addParameter(QgsProcessingParameterFileDestination(
         self.IMD, description="IlisMeta XML model output file"))
コード例 #14
0
    def initAlgorithm(self, config=None):
        self.DIRECTIONS = OrderedDict([
            (self.tr('Forward direction'), QgsVectorLayerDirector.DirectionForward),
            (self.tr('Backward direction'), QgsVectorLayerDirector.DirectionBackward),
            (self.tr('Both directions'), QgsVectorLayerDirector.DirectionBoth)])

        self.STRATEGIES = [self.tr('Shortest Path (distance optimization)'),
                           self.tr('Fastest Path (time optimization)')
                           ]

        self.ENTRY_COST_CALCULATION_METHODS = [self.tr('Ellipsoidal'),
                                       self.tr('Planar (only use with projected CRS)')]
            

        self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
                                                              self.tr('Network Layer'),
                                                              [QgsProcessing.TypeVectorLine]))
        self.addParameter(QgsProcessingParameterFeatureSource(self.POINTS,
                                                              self.tr('Point Layer'),
                                                              [QgsProcessing.TypeVectorPoint]))
        self.addParameter(QgsProcessingParameterField(self.ID_FIELD,
                                                       self.tr('Unique Point ID Field'),
                                                       None,
                                                       self.POINTS,
                                                       optional=False))
        self.addParameter(QgsProcessingParameterEnum(self.STRATEGY,
                                                     self.tr('Optimization Criterion'),
                                                     self.STRATEGIES,
                                                     defaultValue=0))

        params = []
        params.append(QgsProcessingParameterEnum(self.ENTRY_COST_CALCULATION_METHOD,
                                                 self.tr('Entry Cost calculation method'),
                                                 self.ENTRY_COST_CALCULATION_METHODS,
                                                 defaultValue=0))
        params.append(QgsProcessingParameterField(self.DIRECTION_FIELD,
                                                  self.tr('Direction field'),
                                                  None,
                                                  self.INPUT,
                                                  optional=True))
        params.append(QgsProcessingParameterString(self.VALUE_FORWARD,
                                                   self.tr('Value for forward direction'),
                                                   optional=True))
        params.append(QgsProcessingParameterString(self.VALUE_BACKWARD,
                                                   self.tr('Value for backward direction'),
                                                   optional=True))
        params.append(QgsProcessingParameterString(self.VALUE_BOTH,
                                                   self.tr('Value for both directions'),
                                                   optional=True))
        params.append(QgsProcessingParameterEnum(self.DEFAULT_DIRECTION,
                                                 self.tr('Default direction'),
                                                 list(self.DIRECTIONS.keys()),
                                                 defaultValue=2))
        params.append(QgsProcessingParameterField(self.SPEED_FIELD,
                                                  self.tr('Speed field'),
                                                  None,
                                                  self.INPUT,
                                                  optional=True))
        params.append(QgsProcessingParameterNumber(self.DEFAULT_SPEED,
                                                   self.tr('Default speed (km/h)'),
                                                   QgsProcessingParameterNumber.Double,
                                                   5.0, False, 0, 99999999.99))
        params.append(QgsProcessingParameterNumber(self.TOLERANCE,
                                                   self.tr('Topology tolerance'),
                                                   QgsProcessingParameterNumber.Double,
                                                   0.0, False, 0, 99999999.99))

        for p in params:
            p.setFlags(p.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
            self.addParameter(p)

        self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Output OD Matrix'), self.tr('CSV files (*.csv)')),True)
コード例 #15
0
    def initAlgorithm(self, config):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """
        self.addParameter(
            QgsProcessingParameterFile(self.QLSC,
                                       self.tr('Codification file'),
                                       extension='qlsc'))

        self.addParameter(
            QgsProcessingParameterFileDestination(self.OUTPUT,
                                                  self.tr('Output CSV'),
                                                  fileFilter='*.csv'))
        self.addParameter(
            QgsProcessingParameterBoolean('source',
                                          'source',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('pathname',
                                          'pathname',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('dirname',
                                          'dirname',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('basename',
                                          'basename',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('layername',
                                          'layername',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('internaltype',
                                          'internaltype',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('displaytype',
                                          'displaytype',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('geometrytype',
                                          'geometrytype',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('description',
                                          'description',
                                          defaultValue=True,
                                          optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean('attributes',
                                          'attributes',
                                          defaultValue=True,
                                          optional=True))
コード例 #16
0
    def initAlgorithm(self, config=None):
        self.methods = ((self.tr('Nearest neighbour'), 'near'),
                        (self.tr('Bilinear'), 'bilinear'),
                        (self.tr('Cubic'), 'cubic'),
                        (self.tr('Cubic spline'), 'cubicspline'),
                        (self.tr('Lanczos windowed sinc'), 'lanczos'),)

        self.addParameter(QgsProcessingParameterMultipleLayers(self.INPUT,
                                                               self.tr('Input files'),
                                                               QgsProcessing.TypeRaster))
        self.addParameter(QgsProcessingParameterNumber(self.TILE_SIZE_X,
                                                       self.tr('Tile width'),
                                                       type=QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       defaultValue=256))
        self.addParameter(QgsProcessingParameterNumber(self.TILE_SIZE_Y,
                                                       self.tr('Tile height'),
                                                       type=QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       defaultValue=256))
        self.addParameter(QgsProcessingParameterNumber(self.OVERLAP,
                                                       self.tr('Overlap in pixels between consecutive tiles'),
                                                       type=QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       defaultValue=0))
        self.addParameter(QgsProcessingParameterNumber(self.LEVELS,
                                                       self.tr('Number of pyramids levels to build'),
                                                       type=QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       defaultValue=1))

        params = []
        params.append(QgsProcessingParameterCrs(self.SOURCE_CRS,
                                                self.tr('Source coordinate reference system'),
                                                optional=True))
        params.append(QgsProcessingParameterEnum(self.RESAMPLING,
                                                 self.tr('Resampling method'),
                                                 options=[i[0] for i in self.methods],
                                                 allowMultiple=False,
                                                 defaultValue=0))
        params.append(QgsProcessingParameterString(self.DELIMITER,
                                                   self.tr('Column delimiter used in the CSV file'),
                                                   defaultValue=';',
                                                   optional=True))

        options_param = QgsProcessingParameterString(self.OPTIONS,
                                                     self.tr('Additional creation options'),
                                                     defaultValue='',
                                                     optional=True)
        options_param.setMetadata({
            'widget_wrapper': {
                'class': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'}})
        params.append(options_param)

        params.append(QgsProcessingParameterEnum(self.DATA_TYPE,
                                                 self.tr('Output data type'),
                                                 self.TYPES,
                                                 allowMultiple=False,
                                                 defaultValue=5))

        params.append(QgsProcessingParameterBoolean(self.ONLY_PYRAMIDS,
                                                    self.tr('Build only the pyramids'),
                                                    defaultValue=False))
        params.append(QgsProcessingParameterBoolean(self.DIR_FOR_ROW,
                                                    self.tr('Use separate directory for each tiles row'),
                                                    defaultValue=False))

        for param in params:
            param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
            self.addParameter(param)

        self.addParameter(QgsProcessingParameterFolderDestination(self.OUTPUT,
                                                                  self.tr('Output directory')))

        output_csv_param = QgsProcessingParameterFileDestination(self.OUTPUT_CSV,
                                                                 self.tr('CSV file containing the tile(s) georeferencing information'),
                                                                 'CSV files (*.csv)',
                                                                 optional=True)
        output_csv_param.setCreateByDefault(False)
        self.addParameter(output_csv_param)
コード例 #17
0
ファイル: TilesXYZ.py プロジェクト: zhutf509/QGIS
 def initAlgorithm(self, config=None):
     super(TilesXYZAlgorithmMBTiles, self).initAlgorithm()
     self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT_FILE,
                                                             self.tr('Output file (for MBTiles)'),
                                                             self.tr('MBTiles files (*.mbtiles)'),
                                                             optional=True))
コード例 #18
0
    def initAlgorithm(self, config=None):
        self.addParameter(
            QgsProcessingParameterFeatureSource(self.INPUT_LAYER,
                                                self.tr('Input layer')))

        self.addParameter(
            QgsProcessingParameterField(
                self.FIELD_NAME, self.tr('Field to calculate statistics on'),
                None, self.INPUT_LAYER, QgsProcessingParameterField.Any))

        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.OUTPUT_HTML_FILE, self.tr('Statistics'),
                self.tr('HTML files (*.html)'), None, True))

        self.addOutput(QgsProcessingOutputNumber(self.COUNT, self.tr('Count')))
        self.addOutput(
            QgsProcessingOutputNumber(self.UNIQUE,
                                      self.tr('Number of unique values')))
        self.addOutput(
            QgsProcessingOutputNumber(
                self.EMPTY, self.tr('Number of empty (null) values')))
        self.addOutput(
            QgsProcessingOutputNumber(self.FILLED,
                                      self.tr('Number of non-empty values')))
        self.addOutput(
            QgsProcessingOutputNumber(self.MIN, self.tr('Minimum value')))
        self.addOutput(
            QgsProcessingOutputNumber(self.MAX, self.tr('Maximum value')))
        self.addOutput(
            QgsProcessingOutputNumber(self.MIN_LENGTH,
                                      self.tr('Minimum length')))
        self.addOutput(
            QgsProcessingOutputNumber(self.MAX_LENGTH,
                                      self.tr('Maximum length')))
        self.addOutput(
            QgsProcessingOutputNumber(self.MEAN_LENGTH,
                                      self.tr('Mean length')))
        self.addOutput(
            QgsProcessingOutputNumber(self.CV,
                                      self.tr('Coefficient of Variation')))
        self.addOutput(QgsProcessingOutputNumber(self.SUM, self.tr('Sum')))
        self.addOutput(
            QgsProcessingOutputNumber(self.MEAN, self.tr('Mean value')))
        self.addOutput(
            QgsProcessingOutputNumber(self.STD_DEV,
                                      self.tr('Standard deviation')))
        self.addOutput(QgsProcessingOutputNumber(self.RANGE, self.tr('Range')))
        self.addOutput(
            QgsProcessingOutputNumber(self.MEDIAN, self.tr('Median')))
        self.addOutput(
            QgsProcessingOutputNumber(
                self.MINORITY, self.tr('Minority (rarest occurring value)')))
        self.addOutput(
            QgsProcessingOutputNumber(
                self.MAJORITY,
                self.tr('Majority (most frequently occurring value)')))
        self.addOutput(
            QgsProcessingOutputNumber(self.FIRSTQUARTILE,
                                      self.tr('First quartile')))
        self.addOutput(
            QgsProcessingOutputNumber(self.THIRDQUARTILE,
                                      self.tr('Third quartile')))
        self.addOutput(
            QgsProcessingOutputNumber(self.IQR,
                                      self.tr('Interquartile Range (IQR)')))
コード例 #19
0
    def initAlgorithm(self, config=None):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """

        self.isoconfig = {
            "squaresizes": ['1000', '500', '100'],
            "mapDatabases": {
                "Syss belägenhet": {
                    "NamnRad7_0": "Rutid ",
                    "NamnRad7_1": " m SWEREF99",
                    "FACTTABLE": "Personer",
                    "VALUESET_0": "kSaRutid",
                    "VALUESET_1": "_SWEREF99"
                },
                "Bef belägenhet": {
                    "NamnRad7_0": "Rutid ",
                    "NamnRad7_1": " m SWEREF99",
                    "FACTTABLE": "fBBefolkning",
                    "VALUESET_0": "kBRutid",
                    "VALUESET_1": "_SWEREF99"
                },
                "Flytt belägenhet": {
                    "NamnRad7_0": "Rutid ",
                    "NamnRad7_1": " m SWEREF99",
                    "FACTTABLE": "fFlyttning",
                    "VALUESET_0": "kFRutid",
                    "VALUESET_1": "_SWEREF99"
                },
                "Syss relationsbelägenhet": {
                    "NamnRad7_0": "RelationsRutid ",
                    "NamnRad7_1": " m SWEREF99",
                    "FACTTABLE": "Personer",
                    "VALUESET_0": "kSaRutid",
                    "VALUESET_1": "_SWEREF99"
                },
                "Flytt relationsbelägenhet": {
                    "NamnRad7_0": "Rutid ",
                    "NamnRad7_1": " m SWEREF99 flyttningsrelation",
                    "FACTTABLE": "fFlyttning",
                    "VALUESET_0": "kFRutid",
                    "VALUESET_1": "_SWEREF99"
                }
            }
        }

        # Input file
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT, self.tr('Rutlager att skapa recodes från'),
                [QgsProcessing.TypeVectorPolygon]))

        # Rutid field
        self.addParameter(
            QgsProcessingParameterField(self.RUTID, self.tr('RutID-kolumn'),
                                        'Rutid_txt', self.INPUT))

        # Cost_level field
        self.addParameter(
            QgsProcessingParameterField(
                self.COSTLEVEL,
                self.tr('Kolumn som innehåller kategorier för recode'),
                'cost_level', self.INPUT))

        # Rutstorlek options
        #name,description,options,allowMultiple,defaultValue
        self.addParameter(
            QgsProcessingParameterEnum(self.RUTSTORLEK, self.tr('Rutstorlek'),
                                       self.isoconfig["squaresizes"], False,
                                       0))

        # Database options
        self.addParameter(
            QgsProcessingParameterEnum(
                self.DATABAS, self.tr('Typ av databas i Supercross'),
                [k for k in self.isoconfig["mapDatabases"]], False, 0))

        # Add rad 1-6 input
        self.addParameter(
            QgsProcessingParameterString(
                self.RADER,
                self.
                tr('Första raderna i recode-filen (ska normalt inte behöva ändras)'
                   ),
                'HEADER\n	VERSION 2\n	UNICODE\n	ESCAPE_CHAR & ITEM_BY_CODE\nEND HEADER\n',
                True))

        # Optional prefix for rutid.
        self.addParameter(
            QgsProcessingParameterString(
                self.PREFIXRUTID,
                self.
                tr('Prefix för RutID som används i recodefilen (vanligtvis är det länskoden)'
                   ), 20, False, False))

        # Output file destination
        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.OUTPUT, self.tr('Utdatafil'), 'Text file(*.txt)',
                'C:\\Lokalt\\GIS\\Outputfil.txt'))
コード例 #20
0
ファイル: retile.py プロジェクト: yoichigmf/QGIS
    def initAlgorithm(self, config=None):
        self.methods = ((self.tr('Nearest neighbour'), 'near'),
                        (self.tr('Bilinear'), 'bilinear'),
                        (self.tr('Cubic'), 'cubic'),
                        (self.tr('Cubic spline'), 'cubicspline'),
                        (self.tr('Lanczos windowed sinc'), 'lanczos'),)

        self.addParameter(QgsProcessingParameterMultipleLayers(self.INPUT,
                                                               self.tr('Input files'),
                                                               QgsProcessing.TypeRaster))
        self.addParameter(QgsProcessingParameterNumber(self.TILE_SIZE_X,
                                                       self.tr('Tile width'),
                                                       type=QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       defaultValue=256))
        self.addParameter(QgsProcessingParameterNumber(self.TILE_SIZE_Y,
                                                       self.tr('Tile height'),
                                                       type=QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       defaultValue=256))
        self.addParameter(QgsProcessingParameterNumber(self.OVERLAP,
                                                       self.tr('Overlap in pixels between consecutive tiles'),
                                                       type=QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       defaultValue=0))
        self.addParameter(QgsProcessingParameterNumber(self.LEVELS,
                                                       self.tr('Number of pyramids levels to build'),
                                                       type=QgsProcessingParameterNumber.Integer,
                                                       minValue=0,
                                                       defaultValue=1))

        params = []
        params.append(QgsProcessingParameterCrs(self.SOURCE_CRS,
                                                self.tr('Source coordinate reference system'),
                                                optional=True))
        params.append(QgsProcessingParameterEnum(self.RESAMPLING,
                                                 self.tr('Resampling method'),
                                                 options=[i[0] for i in self.methods],
                                                 allowMultiple=False,
                                                 defaultValue=0))
        params.append(QgsProcessingParameterString(self.DELIMITER,
                                                   self.tr('Column delimiter used in the CSV file'),
                                                   defaultValue=';',
                                                   optional=True))

        options_param = QgsProcessingParameterString(self.OPTIONS,
                                                     self.tr('Additional creation options'),
                                                     defaultValue='',
                                                     optional=True)
        options_param.setMetadata({
            'widget_wrapper': {
                'class': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'}})
        params.append(options_param)

        params.append(QgsProcessingParameterEnum(self.DATA_TYPE,
                                                 self.tr('Output data type'),
                                                 self.TYPES,
                                                 allowMultiple=False,
                                                 defaultValue=5))

        params.append(QgsProcessingParameterBoolean(self.ONLY_PYRAMIDS,
                                                    self.tr('Build only the pyramids'),
                                                    defaultValue=False))
        params.append(QgsProcessingParameterBoolean(self.DIR_FOR_ROW,
                                                    self.tr('Use separate directory for each tiles row'),
                                                    defaultValue=False))

        for param in params:
            param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
            self.addParameter(param)

        self.addParameter(QgsProcessingParameterFolderDestination(self.OUTPUT,
                                                                  self.tr('Output directory')))

        output_csv_param = QgsProcessingParameterFileDestination(self.OUTPUT_CSV,
                                                                 self.tr('CSV file containing the tile(s) georeferencing information'),
                                                                 'CSV files (*.csv)',
                                                                 optional=True)
        output_csv_param.setCreateByDefault(False)
        self.addParameter(output_csv_param)
コード例 #21
0
    def initAlgorithm(self, config):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.POLES_O,
                self.tr('Origins'),
                [QgsProcessing.TypeVectorPoint]
            )
        )
        
        self.addParameter(
            QgsProcessingParameterField(
                self.ID_O,
                self.tr('Origins node ID'),
                parentLayerParameterName=self.POLES_O,
            )
        )
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.POLES_D,
                self.tr('Destinations'),
                [QgsProcessing.TypeVectorPoint]
            )
        )
        
        self.addParameter(
            QgsProcessingParameterField(
                self.ID_D,
                self.tr('Destinations node ID'),
                parentLayerParameterName=self.POLES_D,
            )
        )
        self.addParameter(
            QgsProcessingParameterNumber(
                self.NB_PASSAGERS,
                self.tr('Demand'),
                QgsProcessingParameterNumber.Double,
                defaultValue=1.0,
            )
        )
        self.addParameter(
            QgsProcessingParameterNumber(
                self.JOUR,
                self.tr('Day'),
                QgsProcessingParameterNumber.Integer,
                defaultValue=1,
            )
        )       
        
        self.addParameter(
            QgsProcessingParameterString(
                self.DEBUT_PERIODE,
                self.tr('Start time'),
                defaultValue=str.format("{0}:00:00",datetime.datetime.now().hour)
                
            )
        )
        self.addParameter(
            QgsProcessingParameterString(
                self.FIN_PERIODE,
                self.tr('End time'),
                defaultValue=str.format("{0}:00:00",datetime.datetime.now().hour+1)
                
            )
        )
        self.addParameter(
            QgsProcessingParameterNumber(
                self.INTERVALLE,
                self.tr('Step'),
                QgsProcessingParameterNumber.Double,
                defaultValue=15,
            )
        )
        self.addParameter(
            QgsProcessingParameterEnum(
                self.DEPART,
                self.tr("Departure/Arrival"),
                [self.tr('Departure'),self.tr('Arrival')],
                defaultValue=0
            )
        )    
        self.addParameter(
            QgsProcessingParameterBoolean(
                self.LABEL,
                self.tr("OD label?"),
                False
            )
        )          

        # We add a feature sink in which to store our processed features (this
        # usually takes the form of a newly created vector layer when the
        # algorithm is run in QGIS).
        self.addParameter(
            QgsProcessingParameterFileDestination(
                self.SORTIE,
                self.tr('Musliw matrix'),
                '*.txt'
            )
        )