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"))
 def defineCharacteristics(self):
     self.name = "Split RGB bands"
     self.group = "Grid - Tools"
     self.addParameter(
         ParameterRaster(SplitRGBBands.INPUT, "Input layer", False))
     self.addOutput(OutputRaster(SplitRGBBands.R, "Output R band layer"))
     self.addOutput(OutputRaster(SplitRGBBands.G, "Output G band layer"))
     self.addOutput(OutputRaster(SplitRGBBands.B, "Output B band layer"))
예제 #3
0
    def buildParametersDialog(self):
        for input in self.process.inputs:
            inputType = type(input)
            if inputType == VectorInput:
                self.addParameter(ParameterVector(str(input.identifier), str(input.title), ParameterVector.VECTOR_TYPE_ANY, input.minOccurs == 0))
            elif inputType == MultipleVectorInput:
                self.addParameter(ParameterMultipleInput(str(input.identifier), str(input.title), ParameterVector.VECTOR_TYPE_ANY, input.minOccurs == 0))
            elif inputType == StringInput:
                self.addParameter(ParameterString(str(input.identifier), str(input.title)))
            elif inputType == TextInput:
                self.addParameter(ParameterString(str(input.identifier), str(input.title)))
            elif inputType == RasterInput:
                self.addParameter(ParameterRaster(str(input.identifier), str(input.title), input.minOccurs == 0))
            elif inputType == MultipleRasterInput:
                self.addParameter(ParameterMultipleInput(str(input.identifier), str(input.title), ParameterMultipleInput.TYPE_RASTER, input.minOccurs == 0))
            elif inputType == FileInput:
                #self.addParameter(ParameterFile(str(input.identifier), str(input.title), False, input.minOccurs == 0))
                self.addParameter(ParameterFile(str(input.identifier), str(input.title)))
            elif inputType == MultipleFileInput:
                pass #Not supported
            elif inputType == SelectionInput:
                self.addParameter(ParameterSelection(str(input.identifier), str(input.title), input.valList))
            elif inputType == ExtentInput:
                self.addParameter(ParameterExtent(str(input.identifier), str(input.title)))
            elif inputType == CrsInput:
                self.addParameter(ParameterCrs(str(input.identifier), "Projection", None))

        for output in self.process.outputs:
            outputType = type(output)
            if outputType == VectorOutput:
                self.addOutput(OutputVector(str(output.identifier), str(output.title)))
            elif outputType == RasterOutput:
                self.addOutput(OutputRaster(str(output.identifier), str(output.title)))
            elif outputType == StringOutput:
                self.addOutput(OutputString(str(output.identifier), str(output.title)))
예제 #4
0
 def defineCharacteristics(self):
     self.name = "Merge"
     self.group = "[GDAL] Miscellaneous"
     self.addParameter(ParameterMultipleInput(merge.INPUT, "Input layers", ParameterMultipleInput.TYPE_RASTER))
     self.addParameter(ParameterBoolean(merge.PCT, "Grab pseudocolor table from first layer", False))
     self.addParameter(ParameterBoolean(merge.SEPARATE, "Layer stack", False))
     self.addOutput(OutputRaster(merge.OUTPUT, "Output layer"))
예제 #5
0
 def defineCharacteristics(self):
     self.name = "rgb2pct"
     self.group = "[GDAL] Conversion"
     self.addParameter(ParameterRaster(rgb2pct.INPUT, "Input layer", False))
     self.addParameter(
         ParameterNumber(rgb2pct.NCOLORS, "Number of colors", 1, None, 2))
     self.addOutput(OutputRaster(rgb2pct.OUTPUT, "Output layer"))
    def defineCharacteristics(self):
        self.name = "D-Infinity Distance Down"
        self.cmdName = "dinfdistdown"
        self.group = "Specialized Grid Analysis tools"

        self.addParameter(
            ParameterRaster(self.DINF_FLOW_DIR_GRID,
                            "D-Infinity Flow Direction Grid", False))
        self.addParameter(
            ParameterRaster(self.PIT_FILLED_GRID, "Pit Filled Elevation Grid",
                            False))
        self.addParameter(
            ParameterRaster(self.STREAM_GRID, "Stream Raster Grid", False))
        self.addParameter(
            ParameterRaster(self.WEIGHT_PATH_GRID, "Weight Path Grid", True))
        self.addParameter(
            ParameterSelection(self.STAT_METHOD, "Statistical Method",
                               self.STATISTICS, 2))
        self.addParameter(
            ParameterSelection(self.DIST_METHOD, "Distance Method",
                               self.DISTANCE, 1))
        self.addParameter(
            ParameterBoolean(self.EDGE_CONTAM, "Check for edge contamination",
                             True))

        self.addOutput(
            OutputRaster(self.DIST_DOWN_GRID,
                         "D-Infinity Drop to Stream Grid"))
    def defineCharacteristics(self):
        self.name = "D-Infinity Distance Up"
        self.cmdName = "dinfdistup"
        self.group = "Specialized Grid Analysis tools"

        self.addParameter(
            ParameterRaster(self.DINF_FLOW_DIR_GRID,
                            "D-Infinity Flow Direction Grid", False))
        self.addParameter(
            ParameterRaster(self.PIT_FILLED_GRID, "Pit Filled Elevation Grid",
                            False))
        self.addParameter(ParameterRaster(self.SLOPE_GRID, "Slope Grid",
                                          False))
        self.addParameter(
            ParameterSelection(self.STAT_METHOD, "Statistical Method",
                               self.STATISTICS, 2))
        self.addParameter(
            ParameterSelection(self.DIST_METHOD, "Distance Method",
                               self.DISTANCE, 1))
        self.addParameter(
            ParameterNumber(self.THRESHOLD, "Proportion Threshold", 0, None,
                            0.5))
        self.addParameter(
            ParameterBoolean(self.EDGE_CONTAM, "Check for edge contamination",
                             True))

        self.addOutput(
            OutputRaster(self.DIST_UP_GRID, "D-Infinity Distance Up"))
예제 #8
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"))
예제 #9
0
 def defineCharacteristicsFromFile(self):
     ScriptAlgorithm.defineCharacteristicsFromFile(self)
     self.parameters.insert(
         0, ParameterRaster("input_filename", "Input image", False))
     self.outputs.append(OutputRaster("output_filename", "Output image"))
     self.script = self.LOAD_LAYER_SCRIPT + self.script + self.SAVE_LAYER_SCRIPT
     self.cmdname = self.name
     self.name = AlgNames.getName(self.name)
예제 #10
0
 def defineCharacteristics(self):
     self.name = "Translate (convert format)"
     self.group = "[GDAL] Conversion"
     self.addParameter(
         ParameterRaster(translate.INPUT, "Input layer", False))
     self.addParameter(
         ParameterString(translate.EXTRA, "Additional creation parameters"))
     self.addOutput(OutputRaster(translate.OUTPUT, "Output layer"))
예제 #11
0
 def defineCharacteristics(self):
     self.name = "Build pyramids (overviews)"
     self.group = "[GDAL] Miscellaneous"
     self.addParameter(ParameterRaster(gdaladdo.INPUT, "Input layer",
                                       False))
     self.addParameter(
         ParameterString(gdaladdo.LEVELS, "Overview levels", "2 4 8 16"))
     self.addOutput(OutputRaster(gdaladdo.OUTPUT, "Output layer", True))
예제 #12
0
 def defineCharacteristics(self):
     self.name = "las2dem"
     self.group = "Tools"
     self.addParameter(ParameterFile(las2dem.INPUT, "Input las layer"))
     self.addParameter(
         ParameterBoolean(las2dem.INTENSITY,
                          "Use intensity instead of elevation", False))
     self.addOutput(OutputRaster(las2dem.OUTPUT, "Output dem layer"))
     self.addCommonParameters()
예제 #13
0
 def defineCharacteristics(self):
     self.name = "Warp (reproject)"
     self.group = "[GDAL] Projections"
     self.addParameter(ParameterRaster(warp.INPUT, "Input layer", False))
     self.addParameter(ParameterCrs(warp.SOURCE_SRS, "Source SRS (EPSG Code)", "EPSG:4326"))
     self.addParameter(ParameterCrs(warp.DEST_SRS, "Destination SRS (EPSG Code)", "EPSG:4326"))
     self.addParameter(ParameterNumber(warp.TR, "Output file resolution in target georeferenced units (leave 0 for no change)", 0.0, None, 0.0))
     self.addParameter(ParameterSelection(warp.METHOD, "Resampling method", warp.METHOD_OPTIONS))
     self.addParameter(ParameterString(warp.EXTRA, "Additional creation parameters", " "))
     self.addOutput(OutputRaster(warp.OUTPUT, "Output layer"))
예제 #14
0
 def defineCharacteristics(self):
     self.name = "pct2rgb"
     self.group = "[GDAL] Conversion"
     self.addParameter(ParameterRaster(pct2rgb.INPUT, "Input layer", False))
     options = []
     for i in range(25):
         options.append(str(i + 1))
     self.addParameter(
         ParameterSelection(pct2rgb.NBAND, "Band to convert", options))
     self.addOutput(OutputRaster(pct2rgb.OUTPUT, "Output layer"))
 def defineCharacteristics(self):
     self.name = "Canopy Model"
     self.group = "Points"
     self.addParameter(ParameterFile(self.INPUT, "Input las layer"))
     self.addParameter(ParameterFile(self.GROUND, "Input ground DTM layer [optional, leave blank if not using it]"))
     self.addParameter(ParameterNumber(self.CELLSIZE, "Cellsize", 0, None, 10.0))
     self.addParameter(ParameterSelection(self.XYUNITS, "XY Units", self.UNITS))
     self.addParameter(ParameterSelection(self.ZUNITS, "Z Units", self.UNITS))
     self.addOutput(OutputRaster(self.OUTPUT, "Canopy model"))
     self.addAdvancedModifiers()
예제 #16
0
 def defineCharacteristics(self):
     self.name = "lasgrid"
     self.group = "Tools"
     self.addParameter(ParameterFile(lasgrid.INPUT, "Input las layer"))
     self.addParameter(
         ParameterBoolean(lasgrid.INTENSITY,
                          "Use intensity instead of elevation", False))
     self.addParameter(
         ParameterSelection(lasgrid.METHOD, "Method", lasgrid.METHODS))
     self.addOutput(OutputRaster(lasgrid.OUTPUT, "Output grid layer"))
     self.addCommonParameters()
예제 #17
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"))
예제 #18
0
    def defineCharacteristics(self):
        self.name = "Peuker Douglas"
        self.cmdName = "peukerdouglas"
        self.group = "Stream Network Analysis tools"

        self.addParameter(ParameterRaster(self.ELEVATION_GRID, "Elevation Grid", False))
        self.addParameter(ParameterNumber(self.CENTER_WEIGHT, "Center Smoothing Weight", 0, None, 0.4))
        self.addParameter(ParameterNumber(self.SIDE_WEIGHT, "Side Smoothing Weight", 0, None, 0.1))
        self.addParameter(ParameterNumber(self.DIAGONAL_WEIGHT, "Diagonal Smoothing Weight", 0, None, 0.05))

        self.addOutput(OutputRaster(self.STREAM_SOURCE_GRID, "Stream Source Grid"))
예제 #19
0
    def defineCharacteristics(self):
        self.name = "Slope Area Combination"
        self.cmdName = "slopearea"
        self.group = "Stream Network Analysis tools"

        self.addParameter(ParameterRaster(self.SLOPE_GRID, "Slope Grid", False))
        self.addParameter(ParameterRaster(self.AREA_GRID, "Contributing Area Grid", False))
        self.addParameter(ParameterNumber(self.SLOPE_EXPONENT, "Slope Exponent", 0, None, 2))
        self.addParameter(ParameterNumber(self.AREA_EXPONENT, "Area Exponent", 0, None, 1))

        self.addOutput(OutputRaster(self.SLOPE_AREA_GRID, "Slope Area Grid"))
예제 #20
0
파일: Cover.py 프로젝트: sdikiy/Quantum-GIS
 def defineCharacteristics(self):
     self.name = "Cover"
     self.group = "Points"
     self.addParameter(ParameterFile(self.INPUT, "Input las layer"))
     self.addParameter(ParameterFile(self.GROUND, "Input ground DTM layer"))
     self.addParameter(ParameterNumber(self.CELLSIZE, "Cellsize", 0, None, 10.0))
     self.addParameter(ParameterNumber(self.HEIGHTBREAK, "Heightbreak", 0, None, 10.0))
     self.addParameter(ParameterSelection(self.XYUNITS, "XY Units", self.UNITS))
     self.addParameter(ParameterSelection(self.ZUNITS, "Z Units", self.UNITS))
     self.addOutput(OutputRaster(self.OUTPUT, "Cover"))
     self.addAdvancedModifiers()
예제 #21
0
 def defineCharacteristics(self):
     self.name = "Warp (reproject)"
     self.group = "[GDAL] Projections"
     self.addParameter(ParameterRaster(warp.INPUT, "Input layer", False))
     self.addParameter(
         ParameterCrs(warp.SOURCE_SRS, "Source SRS (EPSG Code)", "4326"))
     self.addParameter(
         ParameterCrs(warp.DEST_SRS, "Destination SRS (EPSG Code)", "4326"))
     self.addParameter(
         ParameterSelection(warp.METHOD, "Resampling method",
                            warp.METHOD_OPTIONS))
     self.addOutput(OutputRaster(warp.OUTPUT, "Output layer"))
예제 #22
0
    def defineCharacteristics(self):
        self.name = "Grid Network"
        self.cmdName = "gridnet"
        self.group = "Basic Grid Analysis tools"

        self.addParameter(
            ParameterRaster(self.D8_FLOW_DIR_GRID, "D8 Flow Direction Grid",
                            False))
        self.addParameter(
            ParameterVector(self.OUTLETS_SHAPE, "Outlets Shapefile",
                            [ParameterVector.VECTOR_TYPE_POINT], True))
        self.addParameter(ParameterRaster(self.MASK_GRID, "Mask Grid", True))
        self.addParameter(
            ParameterNumber(self.THRESHOLD, "Proportion Threshold", 0, None,
                            100))

        self.addOutput(
            OutputRaster(self.LONGEST_LEN_GRID, "Longest Upslope Length Grid"))
        self.addOutput(
            OutputRaster(self.TOTAL_LEN_GRID, "Total Upslope Length Grid"))
        self.addOutput(
            OutputRaster(self.STRAHLER_GRID, "Strahler Network Order Grid"))
예제 #23
0
 def defineCharacteristics(self):
     self.name = "Translate (convert format)"
     self.group = "[GDAL] Conversion"
     self.addParameter(ParameterRaster(translate.INPUT, "Input layer", False))
     self.addParameter(ParameterNumber(translate.OUTSIZE, "Set the size of the output file (In pixels or %)", 1, None, 100))
     self.addParameter(ParameterBoolean(translate.OUTSIZE_PERC, "Output size is a percentage of input size", True))
     self.addParameter(ParameterString(translate.NO_DATA, "Nodata value, leave as none to take the nodata value from input", "none"))
     self.addParameter(ParameterSelection(translate.EXPAND, "Expand", ["none","gray","rgb","rgba"]))
     self.addParameter(ParameterCrs(translate.SRS, "Override the projection for the output file", None))
     self.addParameter(ParameterExtent(translate.PROJWIN, "Subset based on georeferenced coordinates"))
     self.addParameter(ParameterBoolean(translate.SDS, "Copy all subdatasets of this file to individual output files", False))
     self.addParameter(ParameterString(translate.EXTRA, "Additional creation parameters", ""))
     self.addOutput(OutputRaster(translate.OUTPUT, "Output layer"))
예제 #24
0
 def defineCharacteristics(self):
     self.name = "Nearblack"
     self.group = "[GDAL] Analysis"
     self.addParameter(
         ParameterRaster(nearblack.INPUT, "Input layer", False))
     self.addParameter(
         ParameterNumber(nearblack.NEAR, "How far from black (white)", 0,
                         None, 15))
     self.addParameter(
         ParameterBoolean(
             nearblack.WHITE,
             "Search for nearly white pixels instead of nearly black",
             False))
     self.addOutput(OutputRaster(nearblack.OUTPUT, "Output layer"))
예제 #25
0
 def defineCharacteristics(self):
     self.name = "translate"
     self.group = "Conversion"
     self.addParameter(ParameterRaster(translate.INPUT, "Input layer", False))
     self.addOutput(OutputRaster(translate.OUTPUT, "Output layer"))
예제 #26
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 + "\"")
예제 #27
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 +
                                       "\"")
예제 #28
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 + "\"")
예제 #29
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 + "\"")