def defineCharacteristics(self): self.name = "Bar plot" self.group = "Graphics" self.addParameter(ParameterTable(self.INPUT, "Input table")) self.addParameter(ParameterTableField(self.NAME_FIELD, "Category name field", self.INPUT)) self.addParameter(ParameterTableField(self.VALUE_FIELD, "Value field", self.INPUT)) self.addOutput(OutputHTML(self.OUTPUT, "Output"))
def defineCharacteristics(self): self.name = "Mean and standard deviation plot" self.group = "Graphics" self.addParameter(ParameterTable(self.INPUT, "Input table")) self.addParameter(ParameterTableField(self.NAME_FIELD, "Category name field", self.INPUT,ParameterTableField.DATA_TYPE_ANY)) self.addParameter(ParameterTableField(self.MEAN_FIELD, "Mean field", self.INPUT)) self.addParameter(ParameterTableField(self.STDDEV_FIELD, "StdDev field", self.INPUT)) self.addOutput(OutputHTML(self.OUTPUT, "Output"))
def defineCharacteristics(self): self.name = 'Return result of an SQL query on any layer' self.group = 'Filtering' self.addParameter( ParameterString(self.QUERY, 'SQL Query', 'SELECT * FROM input')) self.addParameter(ParameterTable(self.INPUT_TABLE, 'Input table')) self.addOutput(EpanetOutputTable(self.OUTPUT_TABLE, 'Output table')) pass
def defineCharacteristics(self): self.name = 'Maximum Entropy Modelling' self.cmdName = 'maxent' self.group = 'Species Distribution Modelling' self.addParameter(ParameterVector(self.SPECIES, 'Species localities',[ParameterVector.VECTOR_TYPE_POINT,ParameterTable],False)) # Allow point self.addParameter(ParameterTableField(Maxent.SPEC_COL, "Species Name", Maxent.SPECIES)) self.addParameter(ParameterMultipleInput(self.ENV,'Environmental layers',ParameterMultipleInput.TYPE_RASTER, False)) self.addParameter(ParameterTable(self.PARAM, '(Optional) MAXENT parameter file'))
def defineCharacteristics(self): self.name = 'Polar plot' self.group = 'Graphics' self.addParameter(ParameterTable(self.INPUT, 'Input table')) self.addParameter( ParameterTableField(self.NAME_FIELD, 'Category name field', self.INPUT)) self.addParameter( ParameterTableField(self.VALUE_FIELD, 'Value field', self.INPUT)) self.addOutput(OutputHTML(self.OUTPUT, 'Output'))
def defineCharacteristics(self): self.name = 'Mean and standard deviation plot' self.group = 'Graphics' self.addParameter(ParameterTable(self.INPUT, 'Input table')) self.addParameter( ParameterTableField(self.NAME_FIELD, 'Category name field', self.INPUT, ParameterTableField.DATA_TYPE_ANY)) self.addParameter( ParameterTableField(self.MEAN_FIELD, 'Mean field', self.INPUT)) self.addParameter( ParameterTableField(self.STDDEV_FIELD, 'StdDev field', self.INPUT)) self.addOutput(OutputHTML(self.OUTPUT, 'Output'))
def defineCharacteristics(self): self.name = "Points layer from table" self.group = "Vector creation tools" self.addParameter(ParameterTable(self.INPUT, "Input layer")) self.addParameter( ParameterTableField(self.XFIELD, "X field", self.INPUT, ParameterTableField.DATA_TYPE_ANY)) self.addParameter( ParameterTableField(self.YFIELD, "Y field", self.INPUT, ParameterTableField.DATA_TYPE_ANY)) self.addParameter( ParameterCrs(self.TARGET_CRS, "Target CRS", "EPSG:4326")) self.addOutput(OutputVector(self.OUTPUT, "Output layer"))
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 + "\"")
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 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 + '"')
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 + '"' )
def okPressed(self): description = unicode(self.nameTextBox.text()) if description.strip() == "": QMessageBox.critical(self, "Unable to define parameter", "Invalid parameter name") return if self.param is None: validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" safeName = ''.join(c for c in description if c in validChars) name = self.paramType.upper().replace(" ", "") + "_" + safeName.upper() else: name = self.param.name if self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or isinstance( self.param, ParameterBoolean): self.param = ParameterBoolean(name, description, self.yesNoCombo.currentIndex() == 0) elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or isinstance( self.param, ParameterTableField): if self.parentCombo.currentIndex() < 0: QMessageBox.critical(self, "Unable to define parameter", "Wrong or missing parameter values") return parent = self.parentCombo.itemData(self.parentCombo.currentIndex()) self.param = ParameterTableField(name, description, parent) elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or isinstance( self.param, ParameterRaster): self.param = ParameterRaster(name, description, self.yesNoCombo.currentIndex() == 1) elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE or isinstance( self.param, ParameterTable): self.param = ParameterTable(name, description, self.yesNoCombo.currentIndex() == 1) elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or isinstance( self.param, ParameterVector): self.param = ParameterVector( name, description, [self.shapetypeCombo.currentIndex() - 1], self.yesNoCombo.currentIndex() == 1) elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE or isinstance( self.param, ParameterMultipleInput): self.param = ParameterMultipleInput( name, description, self.datatypeCombo.currentIndex() - 1, self.yesNoCombo.currentIndex() == 1) elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_NUMBER or isinstance( self.param, ParameterNumber): try: vmin = str(self.minTextBox.text()).strip() if vmin == "": vmin = None else: vmin = float(vmin) vmax = str(self.maxTextBox.text()).strip() if vmax == "": vmax = None else: vmax = float(vmax) self.param = ParameterNumber( name, description, vmin, vmax, float(str(self.defaultTextBox.text()))) except: QMessageBox.critical(self, "Unable to define parameter", "Wrong or missing parameter values") return elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or isinstance( self.param, ParameterString): self.param = ParameterString(name, description, str(self.defaultTextBox.text())) elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXTENT or isinstance( self.param, ParameterExtent): self.param = ParameterExtent(name, description) elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE or isinstance( self.param, ParameterFile): isFolder = self.fileFolderCombo.currentIndex() == 1 self.param = ParameterFile(name, description, isFolder=isFolder) self.close()
def defineCharacteristics(self): self.name = 'Simulate flow in storm water conveyance systems' self.group = 'Simulation' self.addParameter(ParameterString(self.TITLE, 'Title', 'Swmm Simulation')) self.addParameter(ParameterTable(self.OPTIONS, 'Analysis options', True)) self.addParameter(ParameterTable(self.REPORT, 'Output reporting instructions', True)) self.addParameter(ParameterTable(self.FILES, 'Interface file options', True)) self.addParameter(ParameterTable(self.RAINGAGES, 'Rain gage information', True)) self.addParameter(ParameterTable(self.HYDROGRAPHS, 'Unit hydrograph data used to construct RDII inflows', True)) self.addParameter(ParameterTable(self.EVAPORATION, 'Evaporation data', True)) self.addParameter(ParameterTable(self.TEMPERATURE, 'Air temperature and snow melt data', True)) self.addParameter(ParameterVector(self.SUBCATCHMENTS, 'Basic subcatchment information', [ParameterVector.VECTOR_TYPE_POLYGON], True)) self.addParameter(ParameterTable(self.SUBAREAS, 'Subcatchment impervious/pervious sub-area data', True)) self.addParameter(ParameterTable(self.INFILTRATION, 'Subcatchment infiltration parameters', True)) self.addParameter(ParameterTable(self.LID_CONTROLS, 'Low impact development control information', True)) self.addParameter(ParameterTable(self.LID_USAGE, 'Assignment of LID controls to subcatchments', True)) self.addParameter(ParameterTable(self.AQUIFERS, 'Groundwater aquifer parameters', True)) self.addParameter(ParameterTable(self.GROUNDWATER, 'Subcatchment groundwater parameters', True)) self.addParameter(ParameterTable(self.SNOWPACKS, 'Subcatchment snow pack parameters', True)) self.addParameter(ParameterVector(self.JUNCTIONS, 'Junction node information', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter(ParameterTable(self.OUTFALLS, 'Outfall node information', True)) self.addParameter(ParameterVector(self.DIVIDERS, 'Flow divider node information', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter(ParameterVector(self.STORAGE, 'Storage node information', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter(ParameterVector(self.CONDUITS, 'Conduit link information', [ParameterVector.VECTOR_TYPE_LINE], True)) self.addParameter(ParameterVector(self.PUMPS, 'Pump link information', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter(ParameterVector(self.ORIFICES, 'Orifice link information', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter(ParameterVector(self.WEIRS, 'Weir link information', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter(ParameterVector(self.OUTLETS, 'Outlet link information', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter(ParameterTable(self.XSECTIONS, 'Conduit, orifice, and weir cross-section geometry', True)) self.addParameter(ParameterTable(self.TRANSECTS, 'Transect geometry for conduits with irregular cross-sections', True)) self.addParameter(ParameterTable(self.LOSSES, 'Conduit entrance/exit losses and flap valves', True)) self.addParameter(ParameterTable(self.CONTROLS, 'Rules that control pump and regulator operation', True)) self.addParameter(ParameterTable(self.POLLUTANTS, 'Pollutant information', True)) self.addParameter(ParameterTable(self.LANDUSES, 'Land use categories', True)) self.addParameter(ParameterTable(self.COVERAGES, 'Assignment of land uses to subcatchments', True)) self.addParameter(ParameterTable(self.BUILDUP, 'Buildup functions for pollutants and land uses', True)) self.addParameter(ParameterTable(self.WASHOFF, 'Washoff functions for pollutants and land uses', True)) self.addParameter(ParameterTable(self.TREATMENT, 'Pollutant removal functions at conveyance system nodes', True)) self.addParameter(ParameterTable(self.INFLOWS, 'External hydrograph/pollutograph inflow at nodes', True)) self.addParameter(ParameterTable(self.DWF, 'Baseline dry weather sanitary inflow at nodes', True)) self.addParameter(ParameterTable(self.PATTERNS, 'Periodic variation in dry weather inflow', True)) self.addParameter(ParameterTable(self.RDII, 'Rainfall-dependent I/I information at nodes', True)) self.addParameter(ParameterTable(self.LOADINGS, 'Initial pollutant loads on subcatchments', True)) self.addParameter(ParameterTable(self.CURVES, 'x-y tabular data referenced in other sections', True)) self.addParameter(ParameterTable(self.TIMESERIES, 'Time series data referenced in other sections', True)) self.addOutput(OutputVector(self.NODE_OUTPUT, 'Node output layer')) self.addOutput(OutputTable(self.NODE_TABLE_OUTPUT, 'Node output table')) self.addOutput(OutputVector(self.LINK_OUTPUT, 'Link output layer')) pass
def defineCharacteristics(self): self.name = 'Simulate flow in drinking water network' self.group = 'Simulation' self.addParameter( ParameterString(self.TITLE, 'Title', 'Epanet Simulation')) self.addParameter( ParameterVector(self.JUNCTIONS, 'Junctions layer', [ParameterVector.VECTOR_TYPE_POINT])) self.addParameter( ParameterVector(self.PIPES, 'Pipes layer', [ParameterVector.VECTOR_TYPE_LINE])) self.addParameter( ParameterVector(self.RESERVOIRS, 'Reservoir layer', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter( ParameterVector(self.TANKS, 'Tanks layer', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter( ParameterVector(self.PUMPS, 'Pumps layer', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter( ParameterVector(self.VALVES, 'Valves layer', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter( ParameterVector(self.EMITTERS, 'Emiters layer', [ParameterVector.VECTOR_TYPE_POINT], True)) self.addParameter(ParameterTable(self.DEMANDS, 'Demands table', True)) self.addParameter(ParameterTable(self.STATUS, 'Status table', True)) self.addParameter( ParameterTable(self.PATTERNS, 'Patterns table', True)) self.addParameter(ParameterTable(self.CURVES, 'Curves table', True)) self.addParameter( ParameterTable(self.CONTROLS, 'Controls table', True)) self.addParameter(ParameterTable(self.QUALITY, 'Quality table', True)) self.addParameter(ParameterTable(self.MIXING, 'Mixing table', True)) #self.addParameter(ParameterFile(self.ADDITIONAL_FILE, 'Epanet config file')) self.addParameter(ParameterTable(self.TIMES, 'Simulation Time')) self.addParameter(ParameterTable(self.RULES, 'Control rules', True)) self.addParameter(ParameterTable(self.ENERGY, 'Energy ', True)) self.addParameter(ParameterTable(self.REACTIONS, 'Reaction', True)) self.addParameter(ParameterTable(self.REPORT, 'Report options', True)) self.addParameter(ParameterTable(self.OPTIONS, 'Options', True)) #self.addOutput(OutputVector(self.NODE_OUTPUT, 'Node output layer')) #self.addOutput(OutputVector(self.LINK_OUTPUT, 'Link output layer')) self.addOutput( EpanetOutputTable(self.NODE_TABLE_OUTPUT, 'Node output table')) self.addOutput( EpanetOutputTable(self.LINK_TABLE_OUTPUT, 'Link output table')) self.addOutput( EpanetOutputTable(self.TIME_AGREGATE_NODE_TABLE_OUTPUT, 'Node output table (time agregates)')) self.addOutput( EpanetOutputTable(self.TIME_AGREGATE_LINK_TABLE_OUTPUT, 'Link output table (time agregates)')) pass
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 + "\"")