예제 #1
0
def getOutputFromString(s):
    try:
        if "|" in s and s.startswith("Output"):
            tokens = s.split("|")
            params = [t if str(t) != "None" else None for t in tokens[1:]]
            clazz = getattr(sys.modules[__name__], tokens[0])
            return clazz(*params)
        else:
            tokens = s.split("=")
            if not tokens[1].lower()[:len('output')] == 'output':
                return None

            name = tokens[0]
            description = tokens[0]

            token = tokens[1].strip()[len('output') + 1:]
            out = None

            if token.lower().strip().startswith('outputraster'):
                out = QgsProcessingOutputRasterLayer(name, description)
            elif token.lower().strip() == 'outputvector':
                out = QgsProcessingOutputVectorLayer(name, description)
            elif token.lower().strip() == 'outputlayer':
                out = QgsProcessingOutputMapLayer(name, description)
            elif token.lower().strip() == 'outputmultilayers':
                out = QgsProcessingOutputMultipleLayers(name, description)
#            elif token.lower().strip() == 'vector point':
#                out = OutputVector(datatype=[dataobjects.TYPE_VECTOR_POINT])
#            elif token.lower().strip() == 'vector line':
#                out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_LINE])
#            elif token.lower().strip() == 'vector polygon':
#                out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_POLYGON])
#            elif token.lower().strip().startswith('table'):
#                out = OutputTable()
            elif token.lower().strip().startswith('outputhtml'):
                out = QgsProcessingOutputHtml(name, description)
#            elif token.lower().strip().startswith('file'):
#                out = OutputFile()
#                ext = token.strip()[len('file') + 1:]
#                if ext:
#                    out.ext = ext
            elif token.lower().strip().startswith('outputfolder'):
                out = QgsProcessingOutputFolder(name, description)
            elif token.lower().strip().startswith('outputnumber'):
                out = QgsProcessingOutputNumber(name, description)
            elif token.lower().strip().startswith('outputstring'):
                out = QgsProcessingOutputString(name, description)
#            elif token.lower().strip().startswith('extent'):
#                out = OutputExtent()

            return out
    except:
        return None
예제 #2
0
 def initAlgorithm(self, config=None):
     self.addParameter(
         QgsProcessingParameterFeatureSource(self.DAMSELFISH_FILE,
                                             "Damselfish file"))
     self.addParameter(
         QgsProcessingParameterFeatureSource(self.REEF_FILE, "Reef file"))
     #self.addParameter(QgsProcessingParameterField(
     #    self.attribute, "Attribute"))
     self.addParameter(
         QgsProcessingParameterFolderDestination(self.OUTPUT_DIRECTORY,
                                                 "Output folder"))
     self.addOutput(QgsProcessingOutputFolder(self.OUTPUT, ""))
예제 #3
0
파일: VectorSplit.py 프로젝트: arx-it/QGIS
    def __init__(self):
        super().__init__()

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

        self.addParameter(QgsProcessingParameterField(self.FIELD,
                                                      self.tr('Unique ID field'), None, self.INPUT))

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

        self.addOutput(QgsProcessingOutputFolder(self.OUTPUT, self.tr('Output directory')))
예제 #4
0
    def initAlgorithm(self, config=None):
        self.addParameter(
            QgsProcessingParameterFeatureSource(self.INPUT,
                                                self.tr('Input layer')))

        self.addParameter(
            QgsProcessingParameterField(self.FIELD, self.tr('Unique ID field'),
                                        None, self.INPUT))

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

        self.addOutput(
            QgsProcessingOutputFolder(self.OUTPUT,
                                      self.tr('Output directory')))
예제 #5
0
    def initAlgorithm(self, config=None):
        self.methods = (
            (self.tr('Nearest neighbour'), 'near'),
            (self.tr('Bilinear'), 'bilinear'),
            (self.tr('Cubic'), 'cubic'),
            (self.tr('Cubic spline'), 'cubicspline'),
            (self.tr('Lanczos windowed sinc'), 'lanczos'),
        )

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

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

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

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

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

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

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

        self.addOutput(
            QgsProcessingOutputFolder(self.OUTPUT,
                                      self.tr('Output directory')))

        output_csv_param = QgsProcessingParameterFileDestination(
            self.OUTPUT_CSV,
            self.tr(
                'CSV file containing the tile(s) georeferencing information'),
            'CSV files (*.csv)',
            optional=True)
        output_csv_param.setCreateByDefault(False)
        self.addParameter(output_csv_param)
예제 #6
0
    def initAlgorithm(self, config=None):
        self.profiles = ((self.tr('Mercator'), 'mercator'),
                         (self.tr('Geodetic'), 'geodetic'),
                         (self.tr('Raster'), 'raster'))

        self.methods = ((self.tr('Average'), 'average'),
                        (self.tr('Nearest neighbour'), 'near'),
                        (self.tr('Bilinear'), 'bilinear'),
                        (self.tr('Cubic'), 'cubic'),
                        (self.tr('Cubic spline'), 'cubicspline'),
                        (self.tr('Lanczos windowed sinc'), 'lanczos'),
                        (self.tr('Antialias'), 'antialias'))

        self.viewers = ((self.tr('All'), 'all'),
                        (self.tr('GoogleMaps'), 'google'),
                        (self.tr('OpenLayers'), 'openlayers'),
                        (self.tr('Leaflet'), 'leaflet'),
                        (self.tr('None'), 'none'))

        self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT, self.tr('Input layer')))
        self.addParameter(QgsProcessingParameterEnum(self.PROFILE,
                                                     self.tr('Tile cutting profile'),
                                                     options=[i[0] for i in self.profiles],
                                                     allowMultiple=False,
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterString(self.ZOOM,
                                                       self.tr('Zoom levels to render'),
                                                       defaultValue='',
                                                       optional=True))
        self.addParameter(QgsProcessingParameterEnum(self.VIEWER,
                                                     self.tr('Web viewer to generate'),
                                                     options=[i[0] for i in self.viewers],
                                                     allowMultiple=False,
                                                     defaultValue=0))
        self.addParameter(QgsProcessingParameterString(self.TITLE,
                                                       self.tr('Title of the map'),
                                                       optional=True))
        self.addParameter(QgsProcessingParameterString(self.COPYRIGHT,
                                                       self.tr('Copyright of the map'),
                                                       optional=True))

        params = []
        params.append(QgsProcessingParameterEnum(self.RESAMPLING,
                                                 self.tr('Resampling method'),
                                                 options=[i[0] for i in self.methods],
                                                 allowMultiple=False,
                                                 defaultValue=0))
        params.append(QgsProcessingParameterCrs(self.SOURCE_CRS,
                                                self.tr('The spatial reference system used for the source input data'),
                                                optional=True))
        params.append(QgsProcessingParameterNumber(self.NODATA,
                                                   self.tr('Transparency value to assign to the input data'),
                                                   type=QgsProcessingParameterNumber.Double,
                                                   defaultValue=0,
                                                   optional=True))
        params.append(QgsProcessingParameterString(self.URL,
                                                   self.tr('URL address where the generated tiles are going to be published'),
                                                   optional=True))
        params.append(QgsProcessingParameterString(self.GOOGLE_KEY,
                                                   self.tr('Google Maps API key (http://code.google.com/apis/maps/signup.html)'),
                                                   optional=True))
        params.append(QgsProcessingParameterString(self.BING_KEY,
                                                   self.tr('Bing Maps API key (https://www.bingmapsportal.com/)'),
                                                   optional=True))
        params.append(QgsProcessingParameterBoolean(self.RESUME,
                                                    self.tr('Generate only missing files'),
                                                    defaultValue=False))
        params.append(QgsProcessingParameterBoolean(self.KML,
                                                    self.tr('Generate KML for Google Earth'),
                                                    defaultValue=False))
        params.append(QgsProcessingParameterBoolean(self.NO_KML,
                                                    self.tr('Avoid automatic generation of KML files for EPSG:4326'),
                                                    defaultValue=False))
        for param in params:
            param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
            self.addParameter(param)

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

        self.addOutput(QgsProcessingOutputFolder(self.OUTPUT, self.tr('Output directory')))