Ejemplo n.º 1
0
    def initAlgorithm(self, config=None):
        self.METHODS = [self.tr('Linear'),
                        self.tr('Clough-Toucher (cubic)')
                        ]

        self.addParameter(ParameterInterpolationData(self.INTERPOLATION_DATA,
                                                     self.tr('Input layer(s)')))
        self.addParameter(QgsProcessingParameterEnum(self.METHOD,
                                                     self.tr('Interpolation method'),
                                                     options=self.METHODS,
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterNumber(self.COLUMNS,
                                                       self.tr('Number of columns'),
                                                       minValue=0, maxValue=10000000, defaultValue=300))
        self.addParameter(QgsProcessingParameterNumber(self.ROWS,
                                                       self.tr('Number of rows'),
                                                       minValue=0, maxValue=10000000, defaultValue=300))
        self.addParameter(QgsProcessingParameterExtent(self.EXTENT,
                                                       self.tr('Extent'),
                                                       optional=False))
        self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
                                                                  self.tr('Interpolated')))

        triangulation_file_param = QgsProcessingParameterFeatureSink(self.TRIANGULATION,
                                                                     self.tr('Triangulation'),
                                                                     type=QgsProcessing.TypeVectorLine,
                                                                     optional=True)
        triangulation_file_param.setCreateByDefault(False)
        self.addParameter(triangulation_file_param)
Ejemplo n.º 2
0
    def initAlgorithm(self, config=None):
        self.METHODS = [self.tr('Linear'),
                        self.tr('Clough-Toucher (cubic)')
                        ]

        self.addParameter(ParameterInterpolationData(self.INTERPOLATION_DATA,
                                                     self.tr('Input layer(s)')))
        self.addParameter(QgsProcessingParameterEnum(self.METHOD,
                                                     self.tr('Interpolation method'),
                                                     options=self.METHODS,
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterExtent(self.EXTENT,
                                                       self.tr('Extent'),
                                                       optional=False))
        pixel_size_param = ParameterPixelSize(self.PIXEL_SIZE,
                                              self.tr('Output raster size'),
                                              layersData=self.INTERPOLATION_DATA,
                                              extent=self.EXTENT,
                                              minValue=0.0,
                                              default=0.1)
        self.addParameter(pixel_size_param)

        cols_param = QgsProcessingParameterNumber(self.COLUMNS,
                                                  self.tr('Number of columns'),
                                                  optional=True,
                                                  minValue=0, maxValue=10000000)
        cols_param.setFlags(cols_param.flags() | QgsProcessingParameterDefinition.FlagHidden)
        self.addParameter(cols_param)

        rows_param = QgsProcessingParameterNumber(self.ROWS,
                                                  self.tr('Number of rows'),
                                                  optional=True,
                                                  minValue=0, maxValue=10000000)
        rows_param.setFlags(rows_param.flags() | QgsProcessingParameterDefinition.FlagHidden)
        self.addParameter(rows_param)

        self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
                                                                  self.tr('Interpolated')))

        triangulation_file_param = QgsProcessingParameterFeatureSink(self.TRIANGULATION,
                                                                     self.tr('Triangulation'),
                                                                     type=QgsProcessing.TypeVectorLine,
                                                                     optional=True)
        triangulation_file_param.setCreateByDefault(False)
        self.addParameter(triangulation_file_param)
Ejemplo n.º 3
0
    def initAlgorithm(self, config=None):
        self.predicates = (('intersects', self.tr('intersects')),
                           ('contains', self.tr('contains')),
                           ('equals', self.tr('equals')), ('touches',
                                                           self.tr('touches')),
                           ('overlaps', self.tr('overlaps')),
                           ('within', self.tr('within')), ('crosses',
                                                           self.tr('crosses')))

        self.reversed_predicates = {
            'intersects': 'intersects',
            'contains': 'within',
            'isEqual': 'isEqual',
            'touches': 'touches',
            'overlaps': 'overlaps',
            'within': 'contains',
            'crosses': 'crosses'
        }

        self.methods = [
            self.
            tr('Create separate feature for each located feature (one-to-many)'
               ),
            self.
            tr('Take attributes of the first located feature only (one-to-one)'
               )
        ]

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT, self.tr('Input layer'),
                [QgsProcessing.TypeVectorAnyGeometry]))
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.JOIN, self.tr('Join layer'),
                [QgsProcessing.TypeVectorAnyGeometry]))

        predicate = QgsProcessingParameterEnum(
            self.PREDICATE,
            self.tr('Geometric predicate'),
            options=[p[1] for p in self.predicates],
            allowMultiple=True,
            defaultValue=[0])
        predicate.setMetadata({
            'widget_wrapper': {
                'class': 'processing.gui.wrappers.EnumWidgetWrapper',
                'useCheckBoxes': True,
                'columns': 2
            }
        })
        self.addParameter(predicate)
        self.addParameter(
            QgsProcessingParameterField(
                self.JOIN_FIELDS,
                self.tr('Fields to add (leave empty to use all fields)'),
                parentLayerParameterName=self.JOIN,
                allowMultiple=True,
                optional=True))
        self.addParameter(
            QgsProcessingParameterEnum(self.METHOD, self.tr('Join type'),
                                       self.methods))
        self.addParameter(
            QgsProcessingParameterBoolean(
                self.DISCARD_NONMATCHING,
                self.tr('Discard records which could not be joined'),
                defaultValue=False))
        self.addParameter(
            QgsProcessingParameterFeatureSink(self.OUTPUT,
                                              self.tr('Joined layer')))
Ejemplo n.º 4
0
    def initAlgorithm(self, config=None):
        self.predicates = (('intersects', self.tr('intersects')),
                           ('contains', self.tr('contains')),
                           ('isEqual', self.tr('equals')),
                           ('touches',
                            self.tr('touches')), ('overlaps',
                                                  self.tr('overlaps')),
                           ('within', self.tr('within')), ('crosses',
                                                           self.tr('crosses')))

        self.statistics = [('count', self.tr('count')),
                           ('unique', self.tr('unique')),
                           ('min', self.tr('min')), ('max', self.tr('max')),
                           ('range', self.tr('range')),
                           ('sum', self.tr('sum')), ('mean', self.tr('mean')),
                           ('median', self.tr('median')),
                           ('stddev', self.tr('stddev')),
                           ('minority', self.tr('minority')),
                           ('majority', self.tr('majority')),
                           ('q1', self.tr('q1')), ('q3', self.tr('q3')),
                           ('iqr', self.tr('iqr')),
                           ('empty', self.tr('empty')),
                           ('filled', self.tr('filled')),
                           ('min_length', self.tr('min_length')),
                           ('max_length', self.tr('max_length')),
                           ('mean_length', self.tr('mean_length'))]

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT, self.tr('Input layer'),
                [QgsProcessing.TypeVectorAnyGeometry]))
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.JOIN, self.tr('Join layer'),
                [QgsProcessing.TypeVectorAnyGeometry]))
        predicate = QgsProcessingParameterEnum(
            self.PREDICATE,
            self.tr('Geometric predicate'),
            options=[p[1] for p in self.predicates],
            allowMultiple=True,
            defaultValue=[0])
        predicate.setMetadata({
            'widget_wrapper': {
                'class': 'processing.gui.wrappers.EnumWidgetWrapper',
                'useCheckBoxes': True,
                'columns': 2
            }
        })
        self.addParameter(predicate)
        self.addParameter(
            QgsProcessingParameterField(
                self.JOIN_FIELDS,
                self.tr('Fields to summarise (leave empty to use all fields)'),
                parentLayerParameterName=self.JOIN,
                allowMultiple=True,
                optional=True))
        self.addParameter(
            QgsProcessingParameterEnum(
                self.SUMMARIES,
                self.tr(
                    'Summaries to calculate (leave empty to use all available)'
                ),
                options=[p[1] for p in self.statistics],
                allowMultiple=True,
                optional=True))
        self.addParameter(
            QgsProcessingParameterBoolean(
                self.DISCARD_NONMATCHING,
                self.tr('Discard records which could not be joined'),
                defaultValue=False))
        self.addParameter(
            QgsProcessingParameterFeatureSink(self.OUTPUT,
                                              self.tr('Joined layer')))
Ejemplo n.º 5
0
 def initAlgorithm(self, config=None):
     self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer'), [QgsProcessing.TypeVectorPoint]))
     self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Delaunay triangulation'), type=QgsProcessing.TypeVectorPolygon))
Ejemplo n.º 6
0
    def initAlgorithm(self, config=None):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """

        # We add the input vector features source. It can have any kind of
        # point.
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT, self.tr('Input Point Layer'),
                [QgsProcessing.TypeVectorPoint]))
        self.keys = [
            'accommodation', 'administrative-areas-buildings',
            'administrative-region', 'airport', 'ambulance-services',
            'amusement-holiday-park', 'atm-bank-exchange', 'bar-pub',
            'body-of-water', 'bookshop', 'building', 'business-industry',
            'business-services', 'camping', 'car-dealer-repair', 'car-rental',
            'casino', 'cinema', 'city-town-village',
            'clothing-accessories-shop', 'coffee', 'coffee-tea',
            'communication-media', 'dance-night-club', 'department-store',
            'eat-drink', 'education-facility', 'electronics-shop',
            'ev-charging-station', 'facilities', 'facility',
            'fair-convention-facility', 'ferry-terminal', 'fire-department',
            'food-drink', 'forest-heath-vegetation', 'going-out',
            'government-community-facility', 'hardware-house-garden-shop',
            'hospital-health-care-facility', 'hospital-health-care-facility',
            'hostel', 'hotel', 'intersection', 'kiosk-convenience-store',
            'landmark-attraction', 'leisure-outdoor', 'library', 'mall',
            'motel', 'mountain-hill', 'museum', 'natural-geographical',
            'outdoor-area-complex', 'parking-facility', 'petrol-station',
            'pharmacy', 'police-emergency', 'police-station', 'post-office',
            'postal-area', 'public-transport', 'railway-station', 'recreation',
            'religious-place', 'restaurant', 'service', 'shop', 'shopping',
            'sights-museums', 'snacks-fast-food', 'sport-outdoor-shop',
            'sports-facility-venue', 'street-square', 'taxi-stand', 'tea',
            'theatre-music-culture', 'toilet-rest-area', 'tourist-information',
            'transport', 'travel-agency', 'undersea-feature',
            'wine-and-liquor', 'zoo'
        ]
        self.addParameter(
            QgsProcessingParameterEnum(
                self.KEYS,
                self.tr('POI Categories'),
                options=self.keys,
                # defaultValue=0,
                optional=False,
                allowMultiple=True))
        # self.modes = [
        #    "walk", #indicates that the user is on foot.
        #    "drive", #indicates that the user is driving.
        #    "public_transport", #indicates that the user is on public transport.
        #    "bicycle", #indicates that the user is on bicycle.
        #    "none" #if the user is neither on foot nor driving.
        # ]
        # self.addParameter(
        #    QgsProcessingParameterEnum(
        #        self.MODES,
        #        self.tr('Traffic Mode'),
        #        options=self.modes,
        #        #defaultValue=0,
        #        optional=False,
        #        allowMultiple=False
        #    )
        # )
        # self.addParameter(
        #    QgsProcessingParameterNumber(
        #        self.RADIUS,
        #        self.tr('Radius around Points [m]'),
        # parentParameterName=self.INPUT,
        # options=self.keys,
        #        defaultValue=100,
        #        minValue=1,
        #        maxValue=100000,
        #    defaultUnit="DistanceMeters",
        #        optional=False,
        #    )#.setDefaultUnit(QgsUnitTypes.DistanceMeters)
        # )

        # 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(
            QgsProcessingParameterFeatureSink(self.OUTPUT,
                                              self.tr('POI layer')))
Ejemplo n.º 7
0
    def initAlgorithm(self, config=None):
        self.addParameter(
            QgsProcessingParameterFeatureSource(self.INPUT,
                                                self.tr('Input layer')))
        self.addParameter(
            QgsProcessingParameterExpression(
                self.GROUP_BY,
                self.tr('Group by expression (NULL to group all features)'),
                defaultValue='NULL',
                optional=False,
                parentLayerParameterName=self.INPUT))

        class ParameterAggregates(QgsProcessingParameterDefinition):
            def __init__(self,
                         name,
                         description,
                         parentLayerParameterName='INPUT'):
                super().__init__(name, description)
                self._parentLayerParameter = parentLayerParameterName

            def clone(self):
                copy = ParameterAggregates(self.name(), self.description(),
                                           self._parentLayerParameter)
                return copy

            def type(self):
                return 'aggregates'

            def checkValueIsAcceptable(self, value, context=None):
                if not isinstance(value, list):
                    return False
                for field_def in value:
                    if not isinstance(field_def, dict):
                        return False
                    if not field_def.get('input', False):
                        return False
                    if not field_def.get('aggregate', False):
                        return False
                    if not field_def.get('name', False):
                        return False
                    if not field_def.get('type', False):
                        return False
                return True

            def valueAsPythonString(self, value, context):
                return str(value)

            def asScriptCode(self):
                raise NotImplementedError()

            @classmethod
            def fromScriptCode(cls, name, description, isOptional, definition):
                raise NotImplementedError()

            def parentLayerParameter(self):
                return self._parentLayerParameter

        self.addParameter(
            ParameterAggregates(self.AGGREGATES,
                                description=self.tr('Aggregates')))
        self.parameterDefinition(self.AGGREGATES).setMetadata({
            'widget_wrapper':
            'processing.algs.qgis.ui.AggregatesPanel.AggregatesWidgetWrapper'
        })

        self.addParameter(
            QgsProcessingParameterFeatureSink(self.OUTPUT,
                                              self.tr('Aggregated')))
Ejemplo n.º 8
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(
            QgsProcessingParameterFeatureSink(self.OUTPUT,
                                              self.tr('Output OD Matrix'),
                                              QgsProcessing.TypeVectorLine),
            True)
Ejemplo n.º 9
0
 def initAlgorithm(self, config=None):
     self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
                                                           self.tr('Input layer')))
     self.addParameter(QgsProcessingParameterEnum(self.METHOD,
                                                  self.tr('Calculate using'), options=self.calc_methods, defaultValue=0))
     self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Added geom info')))
Ejemplo n.º 10
0
    def initAlgorithm(self, config):

        currentPath = getCurrentPath(self)
        FULL_PATH_A01 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA01'][1]))
        FULL_PATH_A02 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA02'][1]))
        FULL_PATH_A03 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA03'][1]))
        FULL_PATH_A04 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA04'][1]))
        FULL_PATH_A05 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA05'][1]))
        FULL_PATH_A06 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA06'][1]))
        FULL_PATH_A07 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA07'][1]))
        FULL_PATH_A08 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA08'][1]))
        FULL_PATH_A09 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA09'][1]))
        FULL_PATH_A10 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA10'][1]))
        FULL_PATH_A11 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA11'][1]))
        FULL_PATH_A12 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA12'][1]))
        FULL_PATH_A13 = buildFullPathName(
            currentPath, nameWithOuputExtension(NAMES_INDEX['IA13'][1]))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.STUDY_AREA_GRID,
                self.tr(TEXT_GRID_INPUT),
                [QgsProcessing.TypeVectorPolygon],
                optional=OPTIONAL_GRID_INPUT,
            ))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.BLOCKS,
                self.tr('Manzanas'), [QgsProcessing.TypeVectorPolygon],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterField(self.FIELD_POPULATION,
                                        self.tr('Población'),
                                        'poblacion',
                                        'BLOCKS',
                                        optional=True))

        self.addParameter(
            QgsProcessingParameterField(self.FIELD_HOUSING,
                                        self.tr('Viviendas'),
                                        'viviendas',
                                        'BLOCKS',
                                        optional=True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.CADASTRE,
                self.tr('Catastro'), [QgsProcessing.TypeVectorPolygon],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterField(self.CONSTRUCTION_AREA,
                                        self.tr('Area de construcción'),
                                        'Area Cons',
                                        'CADASTRE',
                                        optional=True))

        self.addParameter(
            QgsProcessingParameterField(
                self.FLOORS,
                self.tr('Pisos de construcción catastro'),
                'Pisos cons',
                'CADASTRE',
                optional=True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.BLOCKS_LAST,
                self.tr('Manzanas en el último año'),
                [QgsProcessing.TypeVectorPolygon],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterField(self.FIELD_POPULATION_LAST,
                                        self.tr('Población en el último año'),
                                        'poblacion',
                                        'BLOCKS_LAST',
                                        optional=True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.BLOCKS_BEGIN,
                self.tr('Manzanas en el año inicial'),
                [QgsProcessing.TypeVectorPolygon],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterField(self.FIELD_POPULATION_BEGIN,
                                        self.tr('Población en el último año'),
                                        'poblacion',
                                        'BLOCKS_BEGIN',
                                        optional=True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.BUILT_LAST,
                self.tr('Área edificada en el último año'),
                [QgsProcessing.TypeVectorPolygon],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.BUILT_BEGIN,
                self.tr('Área edificada en el año inicial'),
                [QgsProcessing.TypeVectorPolygon],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterNumber(
                self.YEARS, self.tr('Años entre el inicial y el final'),
                QgsProcessingParameterNumber.Integer, 10, False, 1, 99999999))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.EMPTY_PROPERTIES,
                self.tr('Predios vacíos'),
                [QgsProcessing.TypeVectorAnyGeometry],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.EDIFICACIONES,
                self.tr('Edificaciones'), [QgsProcessing.TypeVectorPolygon],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterField(
                self.FLOORS_EDIFICACIONES,
                self.tr('Pisos de construcción edificaciones'),
                'Pisos cons',
                'EDIFICACIONES',
                optional=True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(self.ROADS,
                                                self.tr('Red vial'),
                                                [QgsProcessing.TypeVectorLine],
                                                optional=True,
                                                defaultValue=''))

        self.addParameter(
            QgsProcessingParameterEnum(self.DISTANCE_OPTIONS,
                                       self.tr('Tipo de distancia'),
                                       options=['ISOCRONA', 'RADIAL'],
                                       allowMultiple=False,
                                       defaultValue=1))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.EDUCATION,
                self.tr('Educación'), [QgsProcessing.TypeVectorPoint],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.HEALTH,
                self.tr('Salud'), [QgsProcessing.TypeVectorPoint],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.APPROVAL,
                self.tr('Aprovisionamiento'), [QgsProcessing.TypeVectorPoint],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.SPORTS,
                self.tr('Deportivos recreativos'),
                [QgsProcessing.TypeVectorPoint],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.ADMIN_PUBLIC,
                self.tr('Gestión Pública'), [QgsProcessing.TypeVectorPoint],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.EQUIPMENT_PUBLIC_SPACE,
                self.tr('Espacios públicos abiertos'),
                [QgsProcessing.TypeVectorAnyGeometry],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.SHOP,
                self.tr('Tiendas de abarrotes, despensas, minimercado'),
                [QgsProcessing.TypeVectorPoint], '', True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.PHARMACY, self.tr('Farmacias y droguerías'),
                [QgsProcessing.TypeVectorPoint], '', True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.STATIONERY, self.tr('Papelerías y bazares'),
                [QgsProcessing.TypeVectorPoint], '', True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.BAKERY, self.tr('Panaderías, heladería y pastelería'),
                [QgsProcessing.TypeVectorPoint], '', True))
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.GAS,
                self.tr('Depósitos de distribución de cilindros de gas'),
                [QgsProcessing.TypeVectorPoint], '', True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.TERTIARYUSES,
                self.tr('Uos terciarios (comercio, servicios u oficinas)'),
                [QgsProcessing.TypeVectorPoint],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.TERTIARYUSES_ACTIVITIES,
                self.tr('Equipamientos de actividades'),
                [QgsProcessing.TypeVectorPoint],
                optional=True,
                defaultValue=""))

        self.addParameter(
            QgsProcessingParameterField(self.FIELD_ACTIVITIES,
                                        self.tr('Actividades'),
                                        'categoria',
                                        'TERTIARYUSES_ACTIVITIES',
                                        optional=True))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.ROADS_SINTAXIS,
                self.tr('Vías SINTAXIS ESPACIAL'),
                [QgsProcessing.TypeVectorLine],
                optional=True,
                defaultValue=""))

        # self.addParameter(
        #     QgsProcessingParameterField(
        #         self.FIELD_SINTAXIS,
        #         self.tr('Valor'),
        #         'NACH_slen', 'ROADS_SINTAXIS',
        #         optional = True
        #     )
        # )

        # ---------------------OUTPUTS---------------------------------
        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A01, self.tr('A01 Densidad neta de habitantes'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A01)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A02, self.tr('A02 Densidad neta de viviendas'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A02)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A03, self.tr('A03 Compacidad absoluta'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A03)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A04,
                self.tr('A04 Eficiencia en el uso del territorio'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A04)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A05, self.tr('A05 Área de predios vacíos'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A05)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A06, self.tr('A06 Proporción de la calle'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A06)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A07,
                self.tr('A07 Proximidad a servicios urbanos básicos'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A07)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A08,
                self.tr('A08 Proximidad al espacio público abierto'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A08)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A09,
                self.tr('A09 Cobertura de actividades comerciales cotinianas'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A09)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A10,
                self.tr('A10 Relación entre actividad y residencia'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A10)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A11, self.tr('A11 Complejidad urbana'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A11)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A12,
                self.tr('A12 Densidad de intersecciones peatonales'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A12)))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_A13, self.tr('A13 Accesibilidad al tejido'),
                QgsProcessing.TypeVectorAnyGeometry, str(FULL_PATH_A13)))
Ejemplo n.º 11
0
    def initAlgorithm(self, config):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """

        self.addParameter(
            QgsProcessingParameterVectorLayer(self.INPUT,
                                              self.tr('Layer to filter')))

        self.addParameter(
            QgsProcessingParameterField(
                self.FIELD,
                self.tr("Field selection"),
                QVariant(),
                self.INPUT,
                type=QgsProcessingParameterField.Numeric))

        self.addParameter(
            QgsProcessingParameterEnum(
                self.INPUT_METHOD, self.tr('Filtering method'),
                ['Normal distribution', 'Coefficient of Variation', 'IDW']))

        self.addParameter(
            QgsProcessingParameterEnum(
                self.INPUT_CONFIANCE,
                self.tr(
                    'Confidence interval (for normal distribution method)'),
                ['68%', '95%', '99,5%']))

        self.addParameter(
            QgsProcessingParameterNumber(
                self.INPUT_SD, self.tr('Number of standard deviations (IDW)'),
                QgsProcessingParameterNumber.Integer, 2))

        self.addParameter(
            QgsProcessingParameterNumber(self.INPUT_VOISINS,
                                         self.tr('Number of neighbours'),
                                         QgsProcessingParameterNumber.Integer,
                                         5))

        self.addParameter(
            QgsProcessingParameterNumber(
                self.INPUT_CV_MAX,
                self.
                tr('Maximum Coefficient of variation (for coefficient of variation method)'
                   ), QgsProcessingParameterNumber.Double, 2))
        self.addParameter(
            QgsProcessingParameterBoolean(
                self.BOOLEAN_DISTANCE,
                self.tr('Consider a distance-based neighbourhood')))

        self.addParameter(
            QgsProcessingParameterNumber(self.INPUT_DISTANCE,
                                         self.tr('Neighbourhood distance'),
                                         QgsProcessingParameterNumber.Double,
                                         5e-5))

        self.addParameter(
            QgsProcessingParameterBoolean(self.BOOLEAN,
                                          self.tr('Remove outliers')))

        self.addParameter(
            QgsProcessingParameterFeatureSink(self.OUTPUT,
                                              self.tr('Filtered layer')))
Ejemplo n.º 12
0
    def initAlgorithm(self, config=None):
        self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer'), [QgsProcessing.TypeVectorPoint]))
        self.addParameter(QgsProcessingParameterDistance(self.BUFFER, self.tr('Buffer region'), parentParameterName=self.INPUT,
                                                         minValue=0.0, maxValue=9999999999, defaultValue=0.0))

        self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Voronoi polygons'), type=QgsProcessing.TypeVectorPolygon))
 def initAlgorithm(self, config):
     self.addParameter(
         QgsProcessingParameterFeatureSource(
             self.PrmInputLayer, tr('Input point layer'),
             [QgsProcessing.TypeVectorPoint]))
     self.addParameter(
         QgsProcessingParameterEnum(self.PrmShapeType,
                                    tr('Shape type'),
                                    options=SHAPE_TYPE,
                                    defaultValue=0,
                                    optional=False))
     self.addParameter(
         QgsProcessingParameterField(
             self.PrmCuspsField,
             tr('Number of cusps field'),
             parentLayerParameterName=self.PrmInputLayer,
             type=QgsProcessingParameterField.Any,
             optional=True))
     self.addParameter(
         QgsProcessingParameterField(
             self.PrmStartingAngleField,
             tr('Starting angle field'),
             parentLayerParameterName=self.PrmInputLayer,
             type=QgsProcessingParameterField.Any,
             optional=True))
     self.addParameter(
         QgsProcessingParameterField(
             self.PrmRadiusField,
             tr('Radius field'),
             parentLayerParameterName=self.PrmInputLayer,
             type=QgsProcessingParameterField.Any,
             optional=True))
     self.addParameter(
         QgsProcessingParameterNumber(self.PrmCusps,
                                      tr('Number of cusps'),
                                      QgsProcessingParameterNumber.Integer,
                                      defaultValue=4,
                                      minValue=3,
                                      optional=True))
     self.addParameter(
         QgsProcessingParameterNumber(self.PrmStartingAngle,
                                      tr('Starting angle'),
                                      QgsProcessingParameterNumber.Double,
                                      defaultValue=0,
                                      optional=True))
     self.addParameter(
         QgsProcessingParameterNumber(self.PrmRadius,
                                      tr('Radius'),
                                      QgsProcessingParameterNumber.Double,
                                      defaultValue=40.0,
                                      minValue=0,
                                      optional=True))
     self.addParameter(
         QgsProcessingParameterEnum(self.PrmUnitsOfMeasure,
                                    tr('Radius units of measure'),
                                    options=DISTANCE_LABELS,
                                    defaultValue=0,
                                    optional=False))
     self.addParameter(
         QgsProcessingParameterNumber(self.PrmDrawingSegments,
                                      tr('Number of drawing segments'),
                                      QgsProcessingParameterNumber.Integer,
                                      defaultValue=720,
                                      minValue=4,
                                      optional=True))
     self.addParameter(
         QgsProcessingParameterBoolean(
             self.PrmExportInputGeometry,
             tr('Add input geometry fields to output table'),
             False,
             optional=True))
     self.addParameter(
         QgsProcessingParameterFeatureSink(self.PrmOutputLayer,
                                           tr('Output layer')))
    def initAlgorithm(self, config):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """

        self.addParameter(
            QgsProcessingParameterString(
                self.INPUT_KPI_LINK,
                self.tr('Dirección URL KoboToolBox)'),
                defaultValue='https://kf.kobotoolbox.org/'))

        self.addParameter(
            QgsProcessingParameterString(self.INPUT_USER,
                                         self.tr('Usuario KoboToolBox'),
                                         defaultValue=''))

        self.addParameter(
            QgsProcessingParameterString(self.INPUT_PASSWORD,
                                         self.tr('Contraseña KoboToolBox'),
                                         defaultValue=''))

        self.addParameter(
            QgsProcessingParameterString(
                self.INPUT_FORM_ID,
                self.tr('Código del Formulario'),
                defaultValue='aY4FQFrco8HsQDMjGqpCPQ'))

        self.addParameter(
            QgsProcessingParameterString(self.INPUT_COD_ESTUDIO,
                                         self.tr('Código del Estudio'),
                                         optional=True,
                                         defaultValue=''))

        self.addParameter(
            QgsProcessingParameterString(
                self.INPUT_NOMBRE_USUARIO,
                self.tr('Nombre de usuario evaluador'),
                optional=True))

        tipo_lev_param = QgsProcessingParameterEnum(
            self.INPUT_TIPO_LEVANTAMIENTO,
            self.tr('Tipo de Levantamiento'),
            options=self.tipos_levantamiento,
            allowMultiple=True,
            defaultValue=[0])
        tipo_lev_param.setMetadata({
            'widget_wrapper': {
                'class': 'processing.gui.wrappers.EnumWidgetWrapper',
                'useCheckBoxes': True,
                'columns': 3
            }
        })
        self.addParameter(tipo_lev_param)

        self.addParameter(
            QgsProcessingParameterEnum(self.INPUT_TITLE,
                                       'Cabecera',
                                       options=self.titles_type,
                                       allowMultiple=False,
                                       defaultValue=1))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_SEGMENTS,
                self.tr('eMAPS: Evaluación de SEGMENTOS'),
                type=QgsProcessing.TypeFile))

        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT_PARCELS,
                self.tr('eMAPS: Evaluación de LOTES'),
                type=QgsProcessing.TypeFile))
Ejemplo n.º 15
0
 def initAlgorithm(self, config=None):
     self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
                                                           self.tr('Input layer'), [QgsProcessing.TypeVectorLine]))
     self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT,
                                                         self.tr('Exploded'), QgsProcessing.TypeVectorLine))
Ejemplo n.º 16
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_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_MAP_LAYER
              or isinstance(self.param, QgsProcessingParameterMapLayer)):
            self.param = QgsProcessingParameterMapLayer(
                name, description, types=[self.datatypeCombo.currentData()])
        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_SCALE
              or isinstance(self.param, QgsProcessingParameterScale)):
            self.param = QgsProcessingParameterScale(
                name, description, self.defaultTextBox.text())
        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

        # Destination parameter
        elif (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)
Ejemplo n.º 17
0
    def initAlgorithm(self, config=None):

        self.addParameter(
            QgsProcessingParameterRasterLayer(self.INPUT,
                                              self.tr('Input image'))
        )

        self.addParameter(
            QgsProcessingParameterVectorDestination (
                self.OUTPUT_FOOTPRINT,
                self.tr('Image footprint'),
                QgsProcessing.TypeVectorPolygon
            )
        )

        self.addParameter(
            QgsProcessingParameterFeatureSink (
                self.OUTPUT_NADIR,
                self.tr('Drone nadir point'),
                QgsProcessing.TypeVectorPoint
            )
        )

        self.addParameter(
            QgsProcessingParameterCrs(
                self.SOURCE_CRS,
                self.tr('Source CRS'),
                defaultValue='EPSG:4326'
            )
        )

        self.addParameter(
            QgsProcessingParameterCrs(
                self.DESTINATION_CRS,
                self.tr('Destination CRS'),
                optional = True,
                defaultValue='ProjectCrs'
            )
        )

        # horizontar referred to flight direction => means wide angle
        self.addParameter(
            QgsProcessingParameterNumber(
                self.HORIZONTAL_FOV,
                self.tr('Wide camera angle'),
                type = QgsProcessingParameterNumber.Double,
                defaultValue = 84.0,
                minValue = 0,
                maxValue = 360
            )
        )

        # vertical referred to flight direction => means tall angle
        parameter = QgsProcessingParameterBoolean(self.USE_IMAGE_RATIO_FOR_VERTICAL_FOV,
                                                  self.tr('Calc vertical FOV using image ratio'),
                                                  defaultValue = True)
        parameter.setFlags(parameter.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(parameter)

        parameter = QgsProcessingParameterNumber(self.VERTICAL_FOV,
                                                 self.tr('Tall camera angle'),
                                                 type = QgsProcessingParameterNumber.Double,
                                                 defaultValue = 54.0,
                                                 minValue = 0,
                                                 maxValue = 360)
        parameter.setFlags(parameter.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(parameter)

        parameter = QgsProcessingParameterNumber(self.VERTICAL_FOV_MULTIPLIER,
                                                 self.tr('Empiric multiplier to fix tall FOV basing on image ratio'),
                                                 type = QgsProcessingParameterNumber.Double,
                                                 defaultValue = 0.855)
        parameter.setFlags(parameter.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(parameter)

        parameter = QgsProcessingParameterNumber(self.NADIR_TO_BOTTOM_OFFSET,
                                                 self.tr('Offset to add to bottom distance result'),
                                                 type = QgsProcessingParameterNumber.Double)
        parameter.setFlags(parameter.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(parameter)

        parameter = QgsProcessingParameterNumber(self.NADIR_TO_UPPPER_OFFSET,
                                                 self.tr('Offset to add to upper distance result'),
                                                 type = QgsProcessingParameterNumber.Double)
        parameter.setFlags(parameter.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(parameter)
Ejemplo n.º 18
0
 def initAlgorithm(self, config=None):
     self.addParameter(QgsProcessingParameterMapLayer(self.INPUT, self.tr('Input layer')))
     self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Extent'), type=QgsProcessing.TypeVectorPolygon))
Ejemplo n.º 19
0
    def initAlgorithm(self, config=None):
        """
        Definition of inputs and outputs of the algorithm, along with some other properties.
        """

        # We add the input vector layer. It can have any kind of geometry
        # It is a mandatory (not optional) one, hence the False argument

        self.addParameter(
            QgsProcessingParameterFeatureSource(self.INPUT,
                                                self.tr('Input layer'),
                                                [QgsProcessing.TypeVector],
                                                None, False))
        self.addParameter(
            QgsProcessingParameterField(self.FIELD_SEGMENT_ID,
                                        self.tr('Segment ID field'), None,
                                        self.INPUT,
                                        QgsProcessingParameterField.Any))

        # read server connections and prepare enum items
        self.connection_options.clear()
        default_graph_server = Settings.get_selected_graph_server()
        selected_index = 0
        for index, connection in enumerate(
                self.connection_manager.read_connections()):
            self.connection_options.append(connection.name)
            if selected_index == 0 and isinstance(default_graph_server, str)\
                    and connection.name == default_graph_server:
                selected_index = index
        self.addParameter(
            QgsProcessingParameterEnum(self.SERVER_NAME,
                                       self.tr('Server name'),
                                       self.connection_options, False,
                                       selected_index, False))

        default_graph_name = Settings.get_selected_graph_name()
        graph_name = ''
        if isinstance(default_graph_name, str):
            graph_name = default_graph_name
        self.addParameter(
            QgsProcessingParameterString(self.GRAPH_NAME,
                                         self.tr('Graph name'), graph_name,
                                         False, False))

        default_graph_version = Settings.get_selected_graph_version()
        graph_version = ''
        if isinstance(default_graph_version, str):
            graph_version = default_graph_version
        self.addParameter(
            QgsProcessingParameterString(self.GRAPH_VERSION,
                                         self.tr('Graph version'),
                                         graph_version, False, False))

        # We add a vector layer as output
        self.addParameter(
            QgsProcessingParameterFeatureSink(self.OUTPUT_SEGMENTS,
                                              self.tr('Segments'),
                                              QgsProcessing.TypeVectorLine))

        self.addOutput(
            QgsProcessingOutputNumber(self.OUTPUT_SEGMENT_COUNT,
                                      self.tr('Number of segments')))
        self.addOutput(
            QgsProcessingOutputNumber(
                self.OUTPUT_SEGMENT_WITH_GEOMETRY_COUNT,
                self.tr('Number of segments with geometry')))
Ejemplo n.º 20
0
    def initAlgorithm(self, config=None):
        self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
                                                              self.tr('Input layer')))

        self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Nodes'), QgsProcessing.TypeVectorPoint))
Ejemplo n.º 21
0
 def initAlgorithm(self, config=None):
     self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
                                                           self.tr('Input layer'), types=[QgsProcessing.TypeVectorLine]))
     self.addParameter(QgsProcessingParameterBoolean(self.KEEP_FIELDS,
                                                     self.tr('Keep table structure of line layer'), defaultValue=False, optional=True))
     self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Polygons from lines'), QgsProcessing.TypeVectorPolygon))
Ejemplo n.º 22
0
 def initAlgorithm(self, config=None):
     self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
                                                           self.tr('Input layer')))
     self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Cleaned')))
Ejemplo n.º 23
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)
Ejemplo n.º 24
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_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_NUMBER or isinstance(
                self.param,
            (QgsProcessingParameterNumber, QgsProcessingParameterDistance))):
            try:
                self.param = QgsProcessingParameterNumber(
                    name, description, QgsProcessingParameterNumber.Double,
                    self.defaultTextBox.text())
                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)
Ejemplo n.º 25
0
    def initAlgorithm(self, config=None):
        self.addParameter(QgsProcessingParameterMultipleLayers(self.LAYERS,
                                                               self.tr('Layers to merge'),
                                                               QgsProcessing.TypeVectorAnyGeometry))

        self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Merged')))
Ejemplo n.º 26
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'), self.tr('Fastest')]

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT, self.tr('Vector layer representing network'),
                [QgsProcessing.TypeVectorLine]))
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.START_POINTS, self.tr('Vector layer with start points'),
                [QgsProcessing.TypeVectorPoint]))
        self.addParameter(
            QgsProcessingParameterEnum(self.STRATEGY,
                                       self.tr('Path type to calculate'),
                                       self.STRATEGIES,
                                       defaultValue=0))
        self.addParameter(
            QgsProcessingParameterNumber(
                self.TRAVEL_COST,
                self.tr(
                    'Travel cost (distance for "Shortest", time for "Fastest")'
                ), QgsProcessingParameterNumber.Double, 0.0, False, 0))

        params = []
        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))
        params.append(
            QgsProcessingParameterDistance(self.TOLERANCE,
                                           self.tr('Topology tolerance'), 0.0,
                                           self.INPUT, False, 0))
        params.append(
            QgsProcessingParameterBoolean(
                self.INCLUDE_BOUNDS,
                self.tr('Include upper/lower bound points'),
                defaultValue=False))
        for p in params:
            p.setFlags(p.flags()
                       | QgsProcessingParameterDefinition.FlagAdvanced)
            self.addParameter(p)

        lines_output = QgsProcessingParameterFeatureSink(
            self.OUTPUT_LINES,
            self.tr('Service area (lines)'),
            QgsProcessing.TypeVectorLine,
            optional=True)
        lines_output.setCreateByDefault(True)
        self.addParameter(lines_output)

        nodes_output = QgsProcessingParameterFeatureSink(
            self.OUTPUT,
            self.tr('Service area (boundary nodes)'),
            QgsProcessing.TypeVectorPoint,
            optional=True)
        nodes_output.setCreateByDefault(False)
        self.addParameter(nodes_output)
Ejemplo n.º 27
0
    def initAlgorithm(self, config=None):
        self.predicates = (('intersects', self.tr('intersects')),
                           ('contains', self.tr('contains')),
                           ('isEqual', self.tr('equals')),
                           ('touches',
                            self.tr('touches')), ('overlaps',
                                                  self.tr('overlaps')),
                           ('within', self.tr('within')), ('crosses',
                                                           self.tr('crosses')))

        self.reversed_predicates = {
            'intersects': 'intersects',
            'contains': 'within',
            'isEqual': 'isEqual',
            'touches': 'touches',
            'overlaps': 'overlaps',
            'within': 'contains',
            'crosses': 'crosses'
        }

        self.methods = [
            self.
            tr('Create separate feature for each located feature (one-to-many)'
               ),
            self.
            tr('Take attributes of the first located feature only (one-to-one)'
               )
        ]

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT, self.tr('Input layer'),
                [QgsProcessing.TypeVectorAnyGeometry]))
        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.JOIN, self.tr('Join layer'),
                [QgsProcessing.TypeVectorAnyGeometry]))

        predicate = QgsProcessingParameterEnum(
            self.PREDICATE,
            self.tr('Geometric predicate'),
            options=[p[1] for p in self.predicates],
            allowMultiple=True,
            defaultValue=[0])
        predicate.setMetadata({
            'widget_wrapper': {
                'class': 'processing.gui.wrappers.EnumWidgetWrapper',
                'useCheckBoxes': True,
                'columns': 2
            }
        })
        self.addParameter(predicate)
        self.addParameter(
            QgsProcessingParameterField(
                self.JOIN_FIELDS,
                self.tr('Fields to add (leave empty to use all fields)'),
                parentLayerParameterName=self.JOIN,
                allowMultiple=True,
                optional=True))
        self.addParameter(
            QgsProcessingParameterEnum(self.METHOD, self.tr('Join type'),
                                       self.methods))
        self.addParameter(
            QgsProcessingParameterBoolean(
                self.DISCARD_NONMATCHING,
                self.tr('Discard records which could not be joined'),
                defaultValue=False))
        self.addParameter(
            QgsProcessingParameterString(self.PREFIX,
                                         self.tr('Joined field prefix'),
                                         optional=True))
        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT,
                self.tr('Joined layer'),
                QgsProcessing.TypeVectorAnyGeometry,
                defaultValue=None,
                optional=True,
                createByDefault=True))

        non_matching = QgsProcessingParameterFeatureSink(
            self.NON_MATCHING,
            self.tr('Unjoinable features from first layer'),
            QgsProcessing.TypeVectorAnyGeometry,
            defaultValue=None,
            optional=True,
            createByDefault=False)
        # TODO GUI doesn't support advanced outputs yet
        # non_matching.setFlags(non_matching.flags() | QgsProcessingParameterDefinition.FlagAdvanced )
        self.addParameter(non_matching)

        self.addOutput(
            QgsProcessingOutputNumber(
                self.JOINED_COUNT,
                self.tr("Number of joined features from input table")))
Ejemplo n.º 28
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'), self.tr('Fastest')]

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.INPUT, self.tr('Vector layer representing network'),
                [QgsProcessing.TypeVectorLine]))
        self.addParameter(
            QgsProcessingParameterPoint(self.START_POINT,
                                        self.tr('Start point')))
        self.addParameter(
            QgsProcessingParameterNumber(
                self.MAX_DIST,
                self.
                tr('Size of Iso-Area (distance or seconds depending on strategy)'
                   ), QgsProcessingParameterNumber.Double, 2500.0, False, 0,
                99999999.99))
        self.addParameter(
            QgsProcessingParameterEnum(self.STRATEGY,
                                       self.tr('Path type to calculate'),
                                       self.STRATEGIES,
                                       defaultValue=0))

        params = []
        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(
            QgsProcessingParameterFeatureSink(self.OUTPUT,
                                              self.tr('Output Pointcloud'),
                                              QgsProcessing.TypeVectorLine))
 def initAlgorithm(self, config):
     self.addParameter(
         QgsProcessingParameterFeatureSource(
             self.PrmInputLayer, tr('Input point layer'),
             [QgsProcessing.TypeVectorPoint]))
     self.addParameter(
         QgsProcessingParameterEnum(self.PrmShapeType,
                                    tr('Shape type'),
                                    options=SHAPE_TYPE,
                                    defaultValue=0,
                                    optional=False))
     self.addParameter(
         QgsProcessingParameterField(
             self.PrmSemiMajorAxisField,
             tr('Semi-major axis field'),
             parentLayerParameterName=self.PrmInputLayer,
             type=QgsProcessingParameterField.Any,
             optional=True))
     self.addParameter(
         QgsProcessingParameterField(
             self.PrmSemiMinorAxisField,
             tr('Semi-minor axis field'),
             parentLayerParameterName=self.PrmInputLayer,
             type=QgsProcessingParameterField.Any,
             optional=True))
     self.addParameter(
         QgsProcessingParameterField(
             self.PrmOrientationField,
             tr('Orientation of axis field'),
             parentLayerParameterName=self.PrmInputLayer,
             type=QgsProcessingParameterField.Any,
             optional=True))
     self.addParameter(
         QgsProcessingParameterNumber(self.PrmDefaultSemiMajorAxis,
                                      tr('Default semi-major axis'),
                                      QgsProcessingParameterNumber.Double,
                                      defaultValue=40.0,
                                      minValue=0.00001,
                                      optional=True))
     self.addParameter(
         QgsProcessingParameterNumber(self.PrmDefaultSemiMinorAxis,
                                      tr('Default semi-minor axis'),
                                      QgsProcessingParameterNumber.Double,
                                      defaultValue=20.0,
                                      minValue=0.00001,
                                      optional=True))
     self.addParameter(
         QgsProcessingParameterNumber(self.PrmDefaultOrientation,
                                      tr('Default orientation of axis'),
                                      QgsProcessingParameterNumber.Double,
                                      defaultValue=0,
                                      minValue=-360,
                                      maxValue=360,
                                      optional=True))
     self.addParameter(
         QgsProcessingParameterEnum(self.PrmUnitsOfMeasure,
                                    tr('Radius units'),
                                    options=DISTANCE_LABELS,
                                    defaultValue=0,
                                    optional=False))
     self.addParameter(
         QgsProcessingParameterNumber(
             self.PrmDrawingSegments,
             tr('Number of drawing segments (approximate)'),
             QgsProcessingParameterNumber.Integer,
             defaultValue=64,
             minValue=8,
             optional=True))
     self.addParameter(
         QgsProcessingParameterBoolean(
             self.PrmExportInputGeometry,
             tr('Add input geometry fields to output table'),
             False,
             optional=True))
     self.addParameter(
         QgsProcessingParameterFeatureSink(self.PrmOutputLayer,
                                           tr('Output layer')))
Ejemplo n.º 30
0
 def initAlgorithm(self, config):
     self.addParameter(
         QgsProcessingParameterFeatureSource(
             self.PrmInputLayer, tr('Input point vector layer'),
             [QgsProcessing.TypeVectorPoint]))
     self.addParameter(
         QgsProcessingParameterEnum(self.PrmOutputFormat,
                                    tr('Output format'),
                                    options=[
                                        tr('Coordinates in 2 fields'),
                                        tr('Coordinates in 1 field'),
                                        'GeoJSON', 'WKT', 'MGRS',
                                        'Plus Codes'
                                    ],
                                    defaultValue=0,
                                    optional=True))
     self.addParameter(
         QgsProcessingParameterString(
             self.PrmYFieldName,
             tr('Latitude (Y), GeoJSON, WKT, MGRS, or Plus Codes field name'
                ),
             defaultValue='y',
             optional=True))
     self.addParameter(
         QgsProcessingParameterString(self.PrmXFieldName,
                                      tr('Longitude (X) field name'),
                                      defaultValue='x',
                                      optional=True))
     self.addParameter(
         QgsProcessingParameterEnum(
             self.PrmCoordinateOrder,
             tr('Coordinate order when using 1 field'),
             options=[
                 tr('Lat,Lon (Y,X) - Google map order'),
                 tr('Lon,Lat (X,Y) order')
             ],
             defaultValue=0,
             optional=True))
     self.addParameter(
         QgsProcessingParameterEnum(
             self.PrmCoordinateDelimiter,
             tr('Coordinate delimiter when using 1 field'),
             options=[tr('Comma'),
                      tr('Space'),
                      tr('Tab'),
                      tr('Other')],
             defaultValue=0,
             optional=True))
     self.addParameter(
         QgsProcessingParameterString(
             self.PrmOtherDelimiter,
             tr('Other delimiter when using 1 field'),
             defaultValue='',
             optional=True))
     self.addParameter(
         QgsProcessingParameterEnum(
             self.PrmOutputCRSType,
             tr('Output CRS of coordinates added to a field'),
             options=[
                 tr('WGS 84'),
                 tr('Layer CRS'),
                 tr('Project CRS'),
                 tr('Custom CRS')
             ],
             defaultValue=0,
             optional=True))
     self.addParameter(
         QgsProcessingParameterCrs(
             self.PrmCustomCRS,
             tr('Custom CRS for coordinates added to a field'),
             'EPSG:4326',
             optional=True))
     self.addParameter(
         QgsProcessingParameterEnum(
             self.PrmWgs84NumberFormat,
             tr('Select Decimal or DMS degress for WGS 84 numbers'),
             options=[tr('Decimal degrees'),
                      tr('DMS'),
                      tr('DDMMSS')],
             defaultValue=0,
             optional=True))
     self.addParameter(
         QgsProcessingParameterNumber(
             self.PrmCoordinatePrecision,
             tr('Decimal number precision'),
             type=QgsProcessingParameterNumber.Integer,
             defaultValue=8,
             optional=True,
             minValue=0))
     self.addParameter(
         QgsProcessingParameterNumber(
             self.PrmDMSSecondPrecision,
             tr('DMS second precision'),
             type=QgsProcessingParameterNumber.Integer,
             defaultValue=0,
             optional=True,
             minValue=0))
     self.addParameter(
         QgsProcessingParameterNumber(
             self.PrmPlusCodesLength,
             'Plus Codes length',
             type=QgsProcessingParameterNumber.Integer,
             defaultValue=11,
             optional=False,
             minValue=10,
             maxValue=20))
     self.addParameter(
         QgsProcessingParameterFeatureSink(self.PrmOutputLayer,
                                           'Output layer'))
Ejemplo n.º 31
0
 def initAlgorithm(self, config=None):
     self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT_RASTER,
                                                         self.tr('Raster layer')))
     self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_VECTOR,
                                                           self.tr('Vector layer'), [QgsProcessing.TypeVectorLine]))
     self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Points along lines'), QgsProcessing.TypeVectorPoint))
Ejemplo n.º 32
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'),
                           self.tr('Fastest')
                           ]

        self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
                                                              self.tr('Vector layer representing network'),
                                                              [QgsProcessing.TypeVectorLine]))
        self.addParameter(QgsProcessingParameterPoint(self.START_POINT,
                                                      self.tr('Start point')))
        self.addParameter(QgsProcessingParameterEnum(self.STRATEGY,
                                                     self.tr('Path type to calculate'),
                                                     self.STRATEGIES,
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterNumber(self.TRAVEL_COST,
                                                       self.tr('Travel cost (distance for "Shortest", time for "Fastest")'),
                                                       QgsProcessingParameterNumber.Double,
                                                       0.0, False, 0))

        params = []
        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))
        params.append(QgsProcessingParameterDistance(self.TOLERANCE,
                                                     self.tr('Topology tolerance'),
                                                     0.0, self.INPUT, False, 0))
        params.append(QgsProcessingParameterBoolean(self.INCLUDE_BOUNDS,
                                                    self.tr('Include upper/lower bound points'),
                                                    defaultValue=False))

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

        lines_output = QgsProcessingParameterFeatureSink(self.OUTPUT_LINES,
                                                         self.tr('Service area (lines)'),
                                                         QgsProcessing.TypeVectorLine, optional=True)
        lines_output.setCreateByDefault(True)
        self.addParameter(lines_output)

        nodes_output = QgsProcessingParameterFeatureSink(self.OUTPUT,
                                                         self.tr('Service area (boundary nodes)'),
                                                         QgsProcessing.TypeVectorPoint, optional=True)
        nodes_output.setCreateByDefault(False)
        self.addParameter(nodes_output)
Ejemplo n.º 33
0
    def initAlgorithm(self, config):
        currentPath = getCurrentPath(self)
        self.CURRENT_PATH = currentPath        
        FULL_PATH = buildFullPathName(currentPath, nameWithOuputExtension(NAMES_INDEX['ID14'][1]))

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.BLOCKS,
                self.tr('Manzanas'),
                [QgsProcessing.TypeVectorPolygon]
            )
        )

        self.addParameter(
            QgsProcessingParameterField(
                self.DPA_MAN,
                self.tr('DPA Manzanas'),
                'dpa_manzan', 'BLOCKS'
            )
        )           

        self.addParameter(
            QgsProcessingParameterFile(
                self.CENSO_POBLACION,
                self.tr('Censo población'),
                extension='csv',
                defaultValue=""
            )
        ) 

     

        self.addParameter(
            QgsProcessingParameterFeatureSource(
                self.STUDY_AREA_GRID,
                self.tr(TEXT_GRID_INPUT),
                [QgsProcessing.TypeVectorPolygon],
                '', OPTIONAL_GRID_INPUT
            )
        )


        if OPTIONAL_GRID_INPUT:
            self.addParameter(
                QgsProcessingParameterNumber(
                    self.CELL_SIZE,
                    self.tr('Tamaño de la malla'),
                    QgsProcessingParameterNumber.Integer,
                    P_CELL_SIZE, False, 1, 99999999
                )
            )          


        self.addParameter(
            QgsProcessingParameterFeatureSink(
                self.OUTPUT,
                self.tr('Salida'),
                QgsProcessing.TypeVectorAnyGeometry,
                str(FULL_PATH)
            )
        )