Esempio n. 1
0
    def defineCharacteristics(self):
        self.name = 'Stream Drop Analysis'
        self.cmdName = 'dropanalysis'
        self.group = 'Stream Network Analysis tools'

        self.addParameter(ParameterRaster(self.D8_CONTRIB_AREA_GRID,
                          'D8 Contributing Area Grid', False))
        self.addParameter(ParameterRaster(self.D8_FLOW_DIR_GRID,
                          'D8 Flow Direction Grid', False))
        self.addParameter(ParameterRaster(self.PIT_FILLED_GRID,
                          'Pit Filled Elevation Grid', False))
        self.addParameter(ParameterRaster(self.ACCUM_STREAM_SOURCE_GRID,
                          'Contributing Area Grid', False))
        self.addParameter(ParameterVector(self.OUTLETS_SHAPE,
                          'Outlets Shapefile',
                          [ParameterVector.VECTOR_TYPE_POINT], False))
        self.addParameter(ParameterNumber(self.MIN_TRESHOLD,
                          'Minimum Threshold', 0, None, 5))
        self.addParameter(ParameterNumber(self.MAX_THRESHOLD,
                          'Maximum Threshold', 0, None, 500))
        self.addParameter(ParameterNumber(self.TRESHOLD_NUM,
                          'Number of Threshold Values', 0, None, 10))
        self.addParameter(ParameterSelection(self.STEP_TYPE,
                          'Spacing for Threshold Values', self.STEPS, 0))
        self.addOutput(OutputFile(self.DROP_ANALYSIS_FILE,
                       'D-Infinity Drop to Stream Grid'))
Esempio n. 2
0
    def defineCharacteristics(self):
        self.name = 'D-Infinity Transport Limited Accumulation - 2'
        self.cmdName = 'dinftranslimaccum'
        self.group = 'Specialized Grid Analysis tools'

        self.addParameter(
            ParameterRaster(self.DINF_FLOW_DIR_GRID,
                            'D-Infinity Flow Direction Grid', False))
        self.addParameter(
            ParameterRaster(self.SUPPLY_GRID, 'Supply Grid', False))
        self.addParameter(
            ParameterRaster(self.CAPACITY_GRID, 'Transport Capacity Grid',
                            False))
        self.addParameter(
            ParameterRaster(self.IN_CONCENTR_GRID, 'Input Concentration Grid',
                            False))
        self.addParameter(
            ParameterVector(self.OUTLETS_SHAPE, 'Outlets Shapefile',
                            [ParameterVector.VECTOR_TYPE_POINT], True))
        self.addParameter(
            ParameterBoolean(self.EDGE_CONTAM, 'Check for edge contamination',
                             True))

        self.addOutput(
            OutputRaster(self.TRANSP_LIM_ACCUM_GRID,
                         'Transport Limited Accumulation Grid'))
        self.addOutput(OutputRaster(self.DEPOSITION_GRID, 'Deposition Grid'))
        self.addOutput(
            OutputRaster(self.OUT_CONCENTR_GRID, 'Output Concentration Grid'))
Esempio n. 3
0
    def defineCharacteristics(self):
        self.name = 'Pairwise modelling'
        self.group = 'Circuitscape'

        self.addParameter(
            ParameterRaster(self.RESISTANCE_MAP, 'Raster resistance map'))
        self.addParameter(
            ParameterBoolean(
                self.IS_CONDUCTANCES,
                'Data represent conductances instead of resistances', False))
        self.addParameter(
            ParameterRaster(self.FOCAL_NODE, 'Focal node location'))
        self.addParameter(
            ParameterBoolean(self.WRITE_CURRENT_MAP, 'Create current map',
                             True))
        self.addParameter(
            ParameterBoolean(self.WRITE_VOLTAGE_MAP, 'Create voltage map',
                             True))
        self.addParameter(
            ParameterRaster(self.MASK, 'Raster mask file', optional=True))
        self.addParameter(
            ParameterRaster(self.SHORT_CIRCUIT,
                            'Raster short-circuit region file',
                            optional=True))
        self.addParameter(
            ParameterRaster(self.EXCLUDE_INCLUDE,
                            'File with focal node pairs to exclude/include',
                            optional=True))
        self.addParameter(
            ParameterBoolean(self.LOW_MEMORY, 'Run in low memory mode', False))

        self.addParameter(
            ParameterString(self.BASENAME, 'Output basename', 'csoutput'))

        self.addOutput(OutputDirectory(self.DIRECTORY, 'Output directory'))
Esempio n. 4
0
    def defineCharacteristics(self):
        self.name = 'One-to-all / All-to-one modelling'
        self.group = 'Circuitscape'

        self.addParameter(
            ParameterSelection(self.MODE, 'Modelling mode', self.MODES, 0))
        self.addParameter(
            ParameterRaster(self.RESISTANCE_MAP, 'Raster resistance map'))
        self.addParameter(
            ParameterBoolean(
                self.IS_CONDUCTANCES,
                'Data represent conductances instead of resistances', False))
        self.addParameter(
            ParameterRaster(self.FOCAL_NODE, 'Focal node location'))
        self.addParameter(
            ParameterBoolean(self.WRITE_CURRENT_MAP, 'Create current map',
                             True))
        self.addParameter(
            ParameterBoolean(self.WRITE_VOLTAGE_MAP, 'Create voltage map',
                             True))
        self.addParameter(
            ParameterRaster(self.MASK, 'Raster mask file', optional=True))
        self.addParameter(
            ParameterRaster(self.SHORT_CIRCUIT,
                            'Raster short-circuit region file',
                            optional=True))
        self.addParameter(
            ParameterRaster(self.SOURCE_STRENGTH,
                            'Source strength file',
                            optional=True))

        self.addParameter(
            ParameterString(self.BASENAME, 'Output basename', 'csoutput'))

        self.addOutput(OutputDirectory(self.DIRECTORY, 'Output directory'))
Esempio n. 5
0
 def defineCharacteristics(self):
     self.name = 'Raster calculator'
     self.cmdname = 'Grid Calculator'
     self.undecoratedGroup = "grid_calculus"
     self.group = SagaGroupNameDecorator.getDecoratedName(self.undecoratedGroup)
     grids = ParameterRaster(self.GRIDS, 'Input layers', True)
     grids.hidden = True
     self.addParameter(grids)
     self.addParameter(ParameterMultipleInput(self.XGRIDS, 'Input layers',
                       ParameterMultipleInput.TYPE_RASTER, False))
     self.addParameter(ParameterString(self.FORMULA, "Formula"))
     self.addOutput(OutputRaster(self.RESULT, "Result"))
Esempio n. 6
0
    def defineCharacteristics(self):
        self.name = 'Range Shifts'
        self.cmdName = 'rangeshift'
        self.group = 'Data Analysis'

        self.addParameter(
            ParameterRaster(self.BASELINE, "Baseline Grid", False))
        self.addParameter(
            ParameterRaster(self.PREDICTION, "Prediction Grid", False))
        self.addParameter(
            ParameterNumber(self.QUANT, "Quantile distance from Median", 10,
                            None, 1))

        self.addOutput(OutputRaster(self.RESULTS, 'Range Shift Map'))
Esempio n. 7
0
    def defineCharacteristics(self):
        self.name = 'Fill nodata'
        self.group = '[GDAL] Analysis'
        self.addParameter(ParameterRaster(self.INPUT, 'Input layer', False))
        self.addParameter(ParameterNumber(self.DISTANCE, 'Search distance', 0,
                          9999, 100))
        self.addParameter(ParameterNumber(self.ITERATIONS, 'Smooth iterations'
                          , 0, 9999, 0))
        self.addParameter(ParameterNumber(self.BAND, 'Band to operate on', 1,
                          9999, 1))
        self.addParameter(ParameterRaster(self.MASK, 'Validity mask', True))
        self.addParameter(ParameterBoolean(self.NO_DEFAULT_MASK,
                          'Do not use default validity mask', False))

        self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))
Esempio n. 8
0
    def defineCharacteristics(self):
        self.name = 'Hillshade'
        self.group = '[GDAL] Analysis'
        self.addParameter(ParameterRaster(self.INPUT, 'Input layer'))
        self.addParameter(ParameterNumber(self.BAND, 'Band number', 1, 99, 1))
        self.addParameter(
            ParameterBoolean(self.COMPUTE_EDGES, 'Compute edges', False))
        self.addParameter(
            ParameterBoolean(
                self.ZEVENBERGEN,
                "Use Zevenbergen&Thorne formula (instead of the Horn's one)",
                False))
        self.addParameter(
            ParameterNumber(self.Z_FACTOR, 'Z factor (vertical exaggeration)',
                            0.0, 99999999.999999, 1.0))
        self.addParameter(
            ParameterNumber(self.SCALE,
                            'Scale (ratio of vert. units to horiz.)', 0.0,
                            99999999.999999, 1.0))
        self.addParameter(
            ParameterNumber(self.AZIMUTH, 'Azimuth of the light', 0.0, 359.0,
                            315.0))
        self.addParameter(
            ParameterNumber(self.ALTITUDE, 'Altitude of the light', 0.0,
                            99999999.999999, 45.0))

        self.addOutput(OutputRaster(self.OUTPUT, 'Output file'))
Esempio n. 9
0
 def defineCharacteristics(self):
     self.name = 'From Datum 73 to ETRS89-PTTM06 Raster'
     self.group = 'Raster Datum Transformations'
     self.addParameter(ParameterRaster(self.INPUT, 'Input layer', False))
     self.addParameter(ParameterSelection(self.GRID, 'NTv2 Grid to use (source)',
                       self.GRID_OPTIONS))
     self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))
Esempio n. 10
0
 def defineCharacteristics(self):
     self.name = 'Create constant raster layer'
     self.group = 'Raster tools'
     self.addParameter(ParameterRaster(self.INPUT, 'Reference layer'))
     self.addParameter(
         ParameterNumber(self.NUMBER, 'Constant value', default=1.0))
     self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))
Esempio n. 11
0
 def defineCharacteristics(self):
     self.addBaseParameters()
     self.name = "Import raster into GeoServer"
     self.group = "GeoServer management tools"
     self.addParameter(ParameterRaster(self.INPUT, "Layer to import"))
     self.addParameter(ParameterString(self.WORKSPACE, "Workspace"))
     self.addParameter(ParameterString(self.NAME, "Store name"))
Esempio n. 12
0
 def defineCharacteristics(self):
     self.name = "Create constant raster layer"
     self.group = "Raster tools"
     self.addParameter(ParameterRaster(self.INPUT, "Reference layer"))
     self.addParameter(
         ParameterNumber(self.NUMBER, "Constant value", default=1.0))
     self.addOutput(OutputRaster(self.OUTPUT, "Output layer"))
Esempio n. 13
0
    def defineCharacteristics(self):
        self.name = 'Length Area Stream Source'
        self.cmdName = 'lengtharea'
        self.group = 'Stream Network Analysis tools'

        self.addParameter(ParameterRaster(self.LENGTH_GRID, 'Length Grid',
                          False))
        self.addParameter(ParameterRaster(self.CONTRIB_AREA_GRID,
                          'Contributing Area Grid', False))
        self.addParameter(ParameterNumber(self.THRESHOLD, 'Threshold', 0,
                          None, 0.03))
        self.addParameter(ParameterNumber(self.EXPONENT, 'Exponent', 0, None,
                          1.3))

        self.addOutput(OutputRaster(self.STREAM_SOURCE_GRID,
                       'Stream Source Grid'))
Esempio n. 14
0
 def defineCharacteristics(self):
     self.name = "Mean based on band indexes"
     self.group = "[permaclim]"
     self.addParameter(ParameterRaster(BandMean.INPUT, "Weekly mean layer"))
     self.addParameter(ParameterNumber(BandMean.FIRST_BAND, "First Band", default=1))
     self.addParameter(ParameterNumber(BandMean.LAST_BAND, "Last Band", default=2))
     self.addOutput(OutputRaster(BandMean.OUTPUT, "Layer with the mean of the choosed bands"))
Esempio n. 15
0
 def defineCharacteristics(self):
     self.addBaseParameters()
     self.name = 'Import raster into GeoServer'
     self.group = 'GeoServer management tools'
     self.addParameter(ParameterRaster(self.INPUT, 'Layer to import'))
     self.addParameter(ParameterString(self.WORKSPACE, 'Workspace'))
     self.addParameter(ParameterString(self.NAME, 'Store name'))
Esempio n. 16
0
 def processParameterLine(self, line):
     param = None
     out = None
     line = line.replace('#', '')
     if line.lower().strip().startswith('report'):
         self.report = True
         self.addOutput(OutputHTML(RAlgorithm.KNITR_REPORT, 'HTML Report'))
         return
     if line.lower().strip().startswith('showplots'):
         self.showPlots = True
         self.addOutput(OutputHTML(RAlgorithm.RPLOTS, 'R Plots'))
         return
     if line.lower().strip().startswith('dontuserasterpackage'):
         self.useRasterPackage = False
         return
     if line.lower().strip().startswith('passfilenames'):
         self.passFileNames = True
         return
     if line.lower().strip().startswith('shapefilespackage'):
         self.useShapefilesPackage = True
         return
     tokens = line.split('=')
     desc = self.createDescriptiveName(tokens[0])
     if tokens[1].lower().strip() == 'group':
         self.group = tokens[0]
         return
     if tokens[1].lower().strip().startswith('raster'):
         param = ParameterRaster(tokens[0], desc, False)
     elif tokens[1].lower().strip() == 'vector':
         param = ParameterVector(tokens[0], desc,
                                 [ParameterVector.VECTOR_TYPE_ANY])
     elif tokens[1].lower().strip() == 'table':
         param = ParameterTable(tokens[0], desc, False)
     elif tokens[1].lower().strip().startswith('multiple raster'):
         param = ParameterMultipleInput(tokens[0], desc,
                 ParameterMultipleInput.TYPE_RASTER)
         param.optional = False
     elif tokens[1].lower().strip() == 'multiple vector':
         param = ParameterMultipleInput(tokens[0], desc,
                 ParameterMultipleInput.TYPE_VECTOR_ANY)
         param.optional = False
     elif tokens[1].lower().strip().startswith('selection'):
         options = tokens[1].strip()[len('selection'):].split(';')
         param = ParameterSelection(tokens[0], desc, options)
     elif tokens[1].lower().strip().startswith('boolean'):
         default = tokens[1].strip()[len('boolean') + 1:]
         param = ParameterBoolean(tokens[0], desc, default)
     elif tokens[1].lower().strip().startswith('number'):
         try:
             default = float(tokens[1].strip()[len('number') + 1:])
             param = ParameterNumber(tokens[0], desc, default=default)
         except:
             raise WrongScriptException('Could not load R script:'
                     + self.descriptionFile + '.\n Problem with line "'
                     + line + '"')
     elif tokens[1].lower().strip().startswith('field'):
         field = tokens[1].strip()[len('field') + 1:]
         found = False
         for p in self.parameters:
             if p.name == field:
                 found = True
                 break
         if found:
             param = ParameterTableField(tokens[0], desc, field)
     elif tokens[1].lower().strip() == 'extent':
         param = ParameterExtent(tokens[0], desc)
     elif tokens[1].lower().strip() == 'file':
         param = ParameterFile(tokens[0], desc, False)
     elif tokens[1].lower().strip() == 'folder':
         param = ParameterFile(tokens[0], desc, True)
     elif tokens[1].lower().strip().startswith('string'):
         default = tokens[1].strip()[len('string') + 1:]
         param = ParameterString(tokens[0], desc, default)
     elif tokens[1].lower().strip().startswith('output raster'):
         out = OutputRaster()
     elif tokens[1].lower().strip().startswith('output vector'):
         out = OutputVector()
     elif tokens[1].lower().strip().startswith('output table'):
         out = OutputTable()
     elif tokens[1].lower().strip().startswith('output file'):
         out = OutputFile()
     elif tokens[1].lower().strip().startswith('output string'):
         out = OutputString()
         self.outputStringExist = True
         self.outputStringName = tokens[0]
     elif tokens[1].lower().strip().startswith('output number'):
         out = OutputNumber()
         self.outputNumberBool = True
         self.outputNumberName = tokens[0]
         
     if param is not None:
         self.addParameter(param)
     elif out is not None:
         out.name = tokens[0]
         out.description = tokens[0]
         self.addOutput(out)
     else:
         raise WrongScriptException('Could not load R script:'
                                    + self.descriptionFile
                                    + '.\n Problem with line "' + line + '"'
                                    )
Esempio n. 17
0
    def processParameterLine(self, line):
        param = None
        out = None
        line = line.replace('#', '')

        # If the line is in the format of the text description files for
        # normal algorithms, then process it using parameter and output
        # factories
        if '|' in line:
            self.processDescriptionParameterLine(line)
            return
        tokens = line.split('=', 1)
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == 'group':
            self.group = tokens[0]
            return
        if tokens[1].lower().strip() == 'name':
            self.name = tokens[0]
            return
        if tokens[1].lower().strip() == 'raster':
            param = ParameterRaster(tokens[0], desc, False)
        elif tokens[1].lower().strip() == 'vector':
            param = ParameterVector(tokens[0], desc,
                                    [ParameterVector.VECTOR_TYPE_ANY])
        elif tokens[1].lower().strip() == 'vector point':
            param = ParameterVector(tokens[0], desc,
                                    [ParameterVector.VECTOR_TYPE_POINT])
        elif tokens[1].lower().strip() == 'vector line':
            param = ParameterVector(tokens[0], desc,
                                    [ParameterVector.VECTOR_TYPE_LINE])
        elif tokens[1].lower().strip() == 'vector polygon':
            param = ParameterVector(tokens[0], desc,
                                    [ParameterVector.VECTOR_TYPE_POLYGON])
        elif tokens[1].lower().strip() == 'table':
            param = ParameterTable(tokens[0], desc, False)
        elif tokens[1].lower().strip() == 'multiple raster':
            param = ParameterMultipleInput(tokens[0], desc,
                    ParameterMultipleInput.TYPE_RASTER)
            param.optional = False
        elif tokens[1].lower().strip() == 'multiple vector':
            param = ParameterMultipleInput(tokens[0], desc,
                    ParameterMultipleInput.TYPE_VECTOR_ANY)
            param.optional = False
        elif tokens[1].lower().strip().startswith('selection'):
            options = tokens[1].strip()[len('selection '):].split(';')
            param = ParameterSelection(tokens[0], desc, options)
        elif tokens[1].lower().strip().startswith('boolean'):
            default = tokens[1].strip()[len('boolean') + 1:]
            param = ParameterBoolean(tokens[0], desc, default)
        elif tokens[1].lower().strip() == 'extent':
            param = ParameterExtent(tokens[0], desc)
        elif tokens[1].lower().strip() == 'file':
            param = ParameterFile(tokens[0], desc, False)
        elif tokens[1].lower().strip() == 'folder':
            param = ParameterFile(tokens[0], desc, True)
        elif tokens[1].lower().strip().startswith('number'):
            default = tokens[1].strip()[len('number') + 1:]
            param = ParameterNumber(tokens[0], desc, default=default)
        elif tokens[1].lower().strip().startswith('field'):
            field = tokens[1].strip()[len('field') + 1:]
            found = False
            for p in self.parameters:
                if p.name == field:
                    found = True
                    break
            if found:
                param = ParameterTableField(tokens[0], tokens[0], field)
        elif tokens[1].lower().strip().startswith('string'):
            default = tokens[1].strip()[len('string') + 1:]
            param = ParameterString(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith('crs'):
            default = tokens[1].strip()[len('crs') + 1:]
            if not default:
                default = 'EPSG:4326'
            param = ParameterCrs(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith('output raster'):
            out = OutputRaster()
        elif tokens[1].lower().strip().startswith('output vector'):
            out = OutputVector()
        elif tokens[1].lower().strip().startswith('output table'):
            out = OutputTable()
        elif tokens[1].lower().strip().startswith('output html'):
            out = OutputHTML()
        elif tokens[1].lower().strip().startswith('output file'):
            out = OutputFile()
        elif tokens[1].lower().strip().startswith('output number'):
            out = OutputNumber()
        elif tokens[1].lower().strip().startswith('output string'):
            out = OutputString()

        if param is not None:
            self.addParameter(param)
        elif out is not None:
            out.name = tokens[0]
            out.description = tokens[0]
            self.addOutput(out)
        else:
            raise WrongScriptException('Could not load script:'
                                       + self.descriptionFile
                                       + '.\n Problem with line "' + line + '"'
                                       )
Esempio n. 18
0
    def processParameterLine(self,line):
        param = None
        out = None
        line = line.replace("#", "");
        if line.lower().strip().startswith("showplots"):
            self.showPlots = True
            self.addOutput(OutputHTML(RAlgorithm.RPLOTS, "R Plots"));
            return
        if line.lower().strip().startswith("dontuserasterpackage"):
            self.useRasterPackage = False
            return
        if line.lower().strip().startswith("passfilenames"):
            self.passFileNames = True
            return
        tokens = line.split("=");
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == "group":
            self.group = tokens[0]
            return
        if tokens[1].lower().strip().startswith("raster"):
            param = ParameterRaster(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "vector":
            param = ParameterVector(tokens[0],  desc, [ParameterVector.VECTOR_TYPE_ANY])
        elif tokens[1].lower().strip() == "table":
            param = ParameterTable(tokens[0], desc, False)
        elif tokens[1].lower().strip().startswith("multiple raster"):
            param = ParameterMultipleInput(tokens[0], desc, ParameterMultipleInput.TYPE_RASTER)
            param.optional = False
        elif tokens[1].lower().strip() == "multiple vector":
            param = ParameterMultipleInput(tokens[0], desc, ParameterMultipleInput.TYPE_VECTOR_ANY)
            param.optional = False
        elif tokens[1].lower().strip().startswith("selection"):
            options = tokens[1].strip()[len("selection"):].split(";")
            param = ParameterSelection(tokens[0],  desc, options);
        elif tokens[1].lower().strip().startswith("boolean"):
            default = tokens[1].strip()[len("boolean")+1:]
            param = ParameterBoolean(tokens[0],  desc, default)
        elif tokens[1].lower().strip().startswith("number"):
            try:
                default = float(tokens[1].strip()[len("number")+1:])
                param = ParameterNumber(tokens[0],  desc, default=default)
            except:
                raise WrongScriptException("Could not load R script:" + self.descriptionFile + ".\n Problem with line \"" + line + "\"")
        elif tokens[1].lower().strip().startswith("field"):
            field = tokens[1].strip()[len("field")+1:]
            found = False
            for p in self.parameters:
                if p.name == field:
                    found = True
                    break
            if found:
                param = ParameterTableField(tokens[0],  tokens[0], field)
        elif tokens[1].lower().strip() == "extent":
            param = ParameterExtent(tokens[0],  desc)
        elif tokens[1].lower().strip() == "file":
            param = ParameterFile(tokens[0],  desc, False)
        elif tokens[1].lower().strip() == "folder":
            param = ParameterFile(tokens[0],  desc, True)
        elif tokens[1].lower().strip().startswith("string"):
            default = tokens[1].strip()[len("string")+1:]
            param = ParameterString(tokens[0],  desc, default)
        elif tokens[1].lower().strip().startswith("output raster"):
            out = OutputRaster()
        elif tokens[1].lower().strip().startswith("output vector"):
            out = OutputVector()
        elif tokens[1].lower().strip().startswith("output table"):
            out = OutputTable()
        elif tokens[1].lower().strip().startswith("output file"):
            out = OutputFile()

        if param != None:
            self.addParameter(param)
        elif out != None:
            out.name = tokens[0]
            out.description = tokens[0]
            self.addOutput(out)
        else:
            raise WrongScriptException("Could not load R script:" + self.descriptionFile + ".\n Problem with line \"" + line + "\"")
Esempio n. 19
0
    def processParameterLine(self,line):
        param = None
        out = None
        line = line.replace("#", "");
        # If the line is in the format of the text description files for normal algorithms,
        # then process it using parameter and output factories
        if '|' in line:
            self.processDescriptionParameterLine(line)
            return
        tokens = line.split("=");
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == "group":
            self.group = tokens[0]
            return
        if tokens[1].lower().strip() == "name":
            self.name = tokens[0]
            return
        if tokens[1].lower().strip() == "raster":
            param = ParameterRaster(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "vector":
            param = ParameterVector(tokens[0],  desc, [ParameterVector.VECTOR_TYPE_ANY])
        elif tokens[1].lower().strip() == "table":
            param = ParameterTable(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "multiple raster":
            param = ParameterMultipleInput(tokens[0], desc, ParameterMultipleInput.TYPE_RASTER)
            param.optional = False
        elif tokens[1].lower().strip() == "multiple vector":
            param = ParameterMultipleInput(tokens[0], desc, ParameterMultipleInput.TYPE_VECTOR_ANY)
            param.optional = False
        elif tokens[1].lower().strip().startswith("selection"):
            options = tokens[1].strip()[len("selection "):].split(";")
            param = ParameterSelection(tokens[0],  desc, options);
        elif tokens[1].lower().strip().startswith("boolean"):
            default = tokens[1].strip()[len("boolean")+1:]
            param = ParameterBoolean(tokens[0],  desc, default)
        elif tokens[1].lower().strip() == "extent":
            param = ParameterExtent(tokens[0],  desc)
        elif tokens[1].lower().strip() == "file":
            param = ParameterFile(tokens[0],  desc, False)
        elif tokens[1].lower().strip() == "folder":
            param = ParameterFile(tokens[0],  desc, True)
        elif tokens[    1].lower().strip().startswith("number"):
            default = tokens[1].strip()[len("number")+1:]
            param = ParameterNumber(tokens[0],  desc, default=default)
        elif tokens[1].lower().strip().startswith("field"):
            field = tokens[1].strip()[len("field")+1:]
            found = False
            for p in self.parameters:
                if p.name == field:
                    found = True
                    break
            if found:
                param = ParameterTableField(tokens[0],  tokens[0], field)
        elif tokens[1].lower().strip().startswith("string"):
            default = tokens[1].strip()[len("string")+1:]
            param = ParameterString(tokens[0],  desc, default)
        elif tokens[1].lower().strip().startswith("output raster"):
            out = OutputRaster()
        elif tokens[1].lower().strip().startswith("output vector"):
            out = OutputVector()
        elif tokens[1].lower().strip().startswith("output table"):
            out = OutputTable()
        elif tokens[1].lower().strip().startswith("output html"):
            out = OutputHTML()
        elif tokens[1].lower().strip().startswith("output file"):
            out = OutputFile()
        elif tokens[1].lower().strip().startswith("output number"):
            out = OutputNumber()
        elif tokens[1].lower().strip().startswith("output string"):
            out = OutputString()

        if param != None:
            self.addParameter(param)
        elif out != None:
            out.name = tokens[0]
            out.description = tokens[0]
            self.addOutput(out)
        else:
            raise WrongScriptException("Could not load script:" + self.descriptionFile + ".\n Problem with line \"" + line + "\"")
Esempio n. 20
0
    def processParameterLine(self, line):
        param = None
        out = None
        line = line.replace("#", "")

        # If the line is in the format of the text description files for
        # normal algorithms, then process it using parameter and output
        # factories
        if "|" in line:
            self.processDescriptionParameterLine(line)
            return
        if line == "nomodeler":
            self.showInModeler = False
            return
        tokens = line.split("=", 1)
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == "group":
            self.group = tokens[0]
            return
        if tokens[1].lower().strip() == "name":
            self.name = tokens[0]
            return
        if tokens[1].lower().strip() == "raster":
            param = ParameterRaster(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "vector":
            param = ParameterVector(tokens[0], desc, [ParameterVector.VECTOR_TYPE_ANY])
        elif tokens[1].lower().strip() == "vector point":
            param = ParameterVector(tokens[0], desc, [ParameterVector.VECTOR_TYPE_POINT])
        elif tokens[1].lower().strip() == "vector line":
            param = ParameterVector(tokens[0], desc, [ParameterVector.VECTOR_TYPE_LINE])
        elif tokens[1].lower().strip() == "vector polygon":
            param = ParameterVector(tokens[0], desc, [ParameterVector.VECTOR_TYPE_POLYGON])
        elif tokens[1].lower().strip() == "table":
            param = ParameterTable(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "multiple raster":
            param = ParameterMultipleInput(tokens[0], desc, ParameterMultipleInput.TYPE_RASTER)
            param.optional = False
        elif tokens[1].lower().strip() == "multiple vector":
            param = ParameterMultipleInput(tokens[0], desc, ParameterMultipleInput.TYPE_VECTOR_ANY)
            param.optional = False
        elif tokens[1].lower().strip().startswith("selection"):
            options = tokens[1].strip()[len("selection ") :].split(";")
            param = ParameterSelection(tokens[0], desc, options)
        elif tokens[1].lower().strip().startswith("boolean"):
            default = tokens[1].strip()[len("boolean") + 1 :]
            param = ParameterBoolean(tokens[0], desc, default)
        elif tokens[1].lower().strip() == "extent":
            param = ParameterExtent(tokens[0], desc)
        elif tokens[1].lower().strip() == "file":
            param = ParameterFile(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "folder":
            param = ParameterFile(tokens[0], desc, True)
        elif tokens[1].lower().strip().startswith("number"):
            default = tokens[1].strip()[len("number") + 1 :]
            param = ParameterNumber(tokens[0], desc, default=default)
        elif tokens[1].lower().strip().startswith("field"):
            field = tokens[1].strip()[len("field") + 1 :]
            found = False
            for p in self.parameters:
                if p.name == field:
                    found = True
                    break
            if found:
                param = ParameterTableField(tokens[0], desc, field)
        elif tokens[1].lower().strip().startswith("string"):
            default = tokens[1].strip()[len("string") + 1 :]
            param = ParameterString(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith("longstring"):
            default = tokens[1].strip()[len("longstring") + 1 :]
            param = ParameterString(tokens[0], desc, default, multiline=True)
        elif tokens[1].lower().strip().startswith("crs"):
            default = tokens[1].strip()[len("crs") + 1 :]
            if not default:
                default = "EPSG:4326"
            param = ParameterCrs(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith("output raster"):
            out = OutputRaster()
        elif tokens[1].lower().strip().startswith("output vector"):
            out = OutputVector()
        elif tokens[1].lower().strip().startswith("output table"):
            out = OutputTable()
        elif tokens[1].lower().strip().startswith("output html"):
            out = OutputHTML()
        elif tokens[1].lower().strip().startswith("output file"):
            out = OutputFile()
            subtokens = tokens[1].split(" ")
            if len(subtokens > 2):
                out.ext = subtokens[2]
        elif tokens[1].lower().strip().startswith("output directory"):
            out = OutputDirectory()
        elif tokens[1].lower().strip().startswith("output number"):
            out = OutputNumber()
        elif tokens[1].lower().strip().startswith("output string"):
            out = OutputString()

        if param is not None:
            self.addParameter(param)
        elif out is not None:
            out.name = tokens[0]
            out.description = desc
            self.addOutput(out)
        else:
            raise WrongScriptException(
                "Could not load script:" + self.descriptionFile or "" + '.\n Problem with line "' + line + '"'
            )