Skip to content

Commit

Permalink
[sextante] made ParameterTableField and ParameterString optional.
Browse files Browse the repository at this point in the history
Changed serializing format of ParameterTableField
  • Loading branch information
volaya committed Apr 12, 2013
1 parent 48c6acb commit 15953a7
Show file tree
Hide file tree
Showing 73 changed files with 104 additions and 101 deletions.
4 changes: 2 additions & 2 deletions python/plugins/sextante/algs/FieldPyculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def defineCharacteristics(self):
self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterString(self.FIELD_NAME, "Result field name", "NewField"))
self.addParameter(ParameterSelection(self.FIELD_TYPE, "Field type", self.TYPE_NAMES))
self.addParameter(ParameterNumber(self.FIELD_LENGTH, "Field lenght", 1, 255, 10))
self.addParameter(ParameterNumber(self.FIELD_LENGTH, "Field length", 1, 255, 10))
self.addParameter(ParameterNumber(self.FIELD_PRECISION, "Field precision", 0, 10, 0))
self.addParameter(ParameterString(self.GLOBAL, "Global expression", multiline = True))
self.addParameter(ParameterString(self.GLOBAL, "Global expression", multiline = True, optional = True))
self.addParameter(ParameterString(self.FORMULA, "Formula", "value = ", multiline = True))
self.addOutput(OutputVector(self.OUTPUT_LAYER, "Output layer"))

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/ftools/Dissolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def defineCharacteristics(self):
self.group = "Vector geometry tools"
self.addParameter(ParameterVector(Dissolve.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_POLYGON))
self.addParameter(ParameterBoolean(Dissolve.DISSOLVE_ALL, "Dissolve all (do not use field)", True))
self.addParameter(ParameterTableField(Dissolve.FIELD, "Unique ID field",Dissolve.INPUT ))
self.addParameter(ParameterTableField(Dissolve.FIELD, "Unique ID field",Dissolve.INPUT, optional=True ))
self.addOutput(OutputVector(Dissolve.OUTPUT, "Dissolved"))

#=========================================================
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ v.buffer
v.buffer.column - Creates a buffer around features of given type.
Vector (v.*)
ParameterVector|input|Input vector layer|-1|False
ParameterTableField|bufcolumn|Name of column to use for buffer distances|input
ParameterTableField|bufcolumn|Name of column to use for buffer distances|input|-1|False
ParameterNumber|scale|Scaling factor for attribute column values|None|None|1.0
ParameterString|tolerance|Maximum distance between theoretical arc and polygon segments as multiple of buffer|0.01
ParameterBoolean|-s|Make outside corners straight|False
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.class.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ v.class
v.class - Classifies attribute data, e.g. for thematic mapping.
Vector (v.*)
ParameterVector|map|Input vector layer|-1|False
ParameterTableField|column|Column name or expression|map
ParameterTableField|column|Column name or expression|map|-1|False
ParameterString|where|WHERE conditions of SQL statement without 'where' keyword|
ParameterSelection|algorithm|Algorithm to use for classification|int;std;qua;equ;dis
ParameterNumber|nbclasses|Number of classes to define|2.0|None|3
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.dissolve.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ v.dissolve
v.dissolve - Dissolves boundaries between adjacent areas sharing a common category number or attribute.
Vector (v.*)
ParameterVector|input|Input vector layer|-1|False
ParameterTableField|column|Name of column used to dissolve common boundaries|input
ParameterTableField|column|Name of column used to dissolve common boundaries|input|-1|False
OutputVector|output|Dissolved layer

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Vector (v.*)
ParameterVector|from|"from" input layer|0|False
ParameterVector|to|"to" input layer|-1|False
ParameterSelection|upload|Values describing the relation between two nearest features|to_attr
ParameterTableField|column|Column where values specified by 'upload' option will be uploaded|to
ParameterTableField|to_column|Column name of nearest feature|to
ParameterTableField|column|Column where values specified by 'upload' option will be uploaded|to|-1|False
ParameterTableField|to_column|Column name of nearest feature|to|-1|False
ParameterBoolean|-a|Calculate distances to all features within the threshold|False
OutputVector|output|Output layer
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.distance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Vector (v.*)
ParameterVector|from|"from" input layer|0|False
ParameterVector|to|"to" input layer|-1|False
ParameterSelection|upload|Values describing the relation between two nearest features|cat;dist;to_x;to_y;to_along;to_angle
ParameterTableField|column|Column where values specified by 'upload' option will be uploaded|to
ParameterTableField|column|Column where values specified by 'upload' option will be uploaded|to|-1|False
ParameterBoolean|-a|Calculate distances to all features within the threshold|False
OutputVector|output|Output layer

2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.normal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ v.normal - Tests for normality for points.
Vector (v.*)
ParameterVector|map|point vector defining sample points|-1|False
ParameterString|tests|Lists of tests (1-15): e.g. 1,3-8,13|1-3
ParameterTableField|column|Attribute column|map
ParameterTableField|column|Attribute column|map|-1|False
ParameterBoolean|-r|Use only points in current region|True
ParameterBoolean|-l|lognormal|False
OutputHTML|html|Output
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.reclass.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ v.reclass - Changes vector category values for an existing vector map according
Vector (v.*)
ParameterVector|input|Input layer|-1|False
ParameterString|type|Feature type|point,line,boundary,centroid
ParameterTableField|column|The name of the column whose values are to be used as new categories|input
ParameterTableField|column|The name of the column whose values are to be used as new categories|input|-1|False
ParameterFile|rules|Reclass rule file|False
OutputVector|output|Reclassified layer

2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.sample.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ v.sample
v.sample - Samples a raster layer at vector point locations.
Vector (v.*)
ParameterVector|input|Vector layer defining sample points|0|False
ParameterTableField|column|Vector layer attribute column to use for comparison|input
ParameterTableField|column|Vector layer attribute column to use for comparison|input|-1|False
ParameterRaster|raster|Raster map to be sampled|False
ParameterNumber|z|Sampled raster values will be multiplied by this factor|None|None|1.0
ParameterBoolean|-b|Bilinear interpolation (default is nearest neighbor)|False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ParameterNumber|sie|Length of each spline step in the east-west direction|None|N
ParameterNumber|sin|Length of each spline step in the north-south direction|None|None|4
ParameterSelection|method|Spline interpolation algorithm|bilinear;bicubic
ParameterNumber|lambda_i|Tykhonov regularization parameter (affects smoothing)|None|None|1
ParameterTableField|column|Attribute table column with values to interpolate|input
ParameterTableField|column|Attribute table column with values to interpolate|input|-1|False
ParameterBoolean|-c|Find the best Tykhonov regularizing parameter using a "leave-one-out" cross validation method|False
ParameterBoolean|-e|Estimate point density and distance|False
OutputVector|output|Output vector layer
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.surf.idw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Vector (v.*)
ParameterVector|input|Input vector layer|0|False
ParameterNumber|npoints|Number of interpolation points|None|None|12
ParameterNumber|power|Power parameter; greater values assign greater influence to closer points|None|None|2.0
ParameterTableField|column|Attribute table column with values to interpolate|input
ParameterTableField|column|Attribute table column with values to interpolate|input|-1|False
ParameterBoolean|-n|Don't index points by raster cell|False
OutputRaster|output|Output raster
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Vector (v.*)
ParameterVector|input|Input vector layer|0|False
ParameterString|where|WHERE conditions of SQL statement without 'where' keyword|
ParameterRaster|maskmap|Name of the raster map used as mask|True
ParameterTableField|zcolumn|Name of the attribute column with values to be used for approximation|input
ParameterTableField|zcolumn|Name of the attribute column with values to be used for approximation|input|-1|False
ParameterNumber|tension|Tension parameter|None|None|40
ParameterNumber|segmax|Maximum number of points in a segment|None|None|40
ParameterNumber|npmin|Minimum number of points for approximation in a segment (>segmax)|None|None|300
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.surf.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Vector (v.*)
ParameterVector|input|Input points layer|0|False
ParameterString|where|WHERE conditions of SQL statement without 'where' keyword|
ParameterRaster|maskmap|Name of the raster map used as mask|True
ParameterTableField|zcolumn|Name of the attribute column with values to be used for approximation|input
ParameterTableField|zcolumn|Name of the attribute column with values to be used for approximation|input|-1|False
ParameterNumber|tension|Tension parameter|None|None|40
ParameterNumber|segmax|Maximum number of points in a segment|None|None|40
ParameterNumber|npmin|Minimum number of points for approximation in a segment (>segmax)|None|None|300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ v.to.rast.attribute - Converts (rasterize) a vector layer into a raster layer.
Vector (v.*)
ParameterVector|input|Input vector layer|-1|False
ParameterSelection|use|Source of raster values|attr
ParameterTableField|column|Name of column for 'attr' parameter (data type must be numeric)|input|0
ParameterTableField|column|Name of column for 'attr' parameter (data type must be numeric)|input|0|-1|False
OutputRaster|output|Rasterized layer
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/v.univar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ v.univar - Calculates univariate statistics for attribute. Variance and standard
Vector (v.*)
ParameterVector|map|Name of input vector map|-1|False
ParameterString|type|Feature type|point,line,area
ParameterTableField|column|Column name|map
ParameterTableField|column|Column name|map|-1|False
ParameterString|where|WHERE conditions of SQL statement without 'where' keyword|
ParameterString|percentile|Percentile to calculate|90
ParameterBoolean|-g|Print the stats in shell script style|True
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/modeler/models/contours.model
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PARAMETER:ParameterNumber|NUMBER_INTERVAL|Interval|0.0|None|10.0
633.0,163.0
PARAMETER:ParameterNumber|NUMBER_CELLSIZEFORINTERMEDIATELAYER|Cellsize for intermediate layer|0.0|None|10.0
411.0,84.0
PARAMETER:ParameterTableField|TABLEFIELD_FIELD|Field|VECTORLAYER_SHAPES|-1
PARAMETER:ParameterTableField|TABLEFIELD_FIELD|Field|VECTORLAYER_SHAPES|-1|False
104.0,202.0
VALUE:HARDCODEDPARAMVALUE_LINE_TYPE_0===0
VALUE:HARDCODEDPARAMVALUE_ZMAX_2===10000.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NAME:Model using field input and autoextent
GROUP:[Test models]
PARAMETER:ParameterVector|VECTORLAYER_VECTOR|vector|2|False
120.0,60.0
PARAMETER:ParameterTableField|TABLEFIELD_FIELD|field|VECTORLAYER_VECTOR|-1
PARAMETER:ParameterTableField|TABLEFIELD_FIELD|field|VECTORLAYER_VECTOR|-1|False
340.0,60.0
VALUE:HARDCODEDPARAMVALUE_LINE_TYPE_0===0
VALUE:HARDCODEDPARAMVALUE_GRID_TYPE_0===3
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/modeler/models/fieldextent.model
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PARAMETER:ParameterVector|VECTORLAYER_LAYER|layer|-1|False
120.0,60.0
PARAMETER:ParameterExtent|EXTENT_EXTENT|extent|0,1,0,1
340.0,60.0
PARAMETER:ParameterTableField|TABLEFIELD_FIELD|field|VECTORLAYER_LAYER|-1
PARAMETER:ParameterTableField|TABLEFIELD_FIELD|field|VECTORLAYER_LAYER|-1|False
560.0,60.0
VALUE:HARDCODEDPARAMVALUE_LINE_TYPE_0===0
VALUE:HARDCODEDPARAMVALUE_GRID_TYPE_0===3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NAME:Model using numerical output
GROUP:[Test models]
PARAMETER:ParameterVector|VECTORLAYER_LAYER|layer|-1|False
120.0,60.0
PARAMETER:ParameterTableField|TABLEFIELD_FIELD|field|VECTORLAYER_LAYER|-1
PARAMETER:ParameterTableField|TABLEFIELD_FIELD|field|VECTORLAYER_LAYER|-1|False
340.0,60.0
VALUE:HARDCODEDPARAMVALUE_SEGMENTS_1===5
VALUE:HARDCODEDPARAMVALUE_DISSOLVE_1===True
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterString.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ParameterString(Parameter):
NEWLINE = "\n"
ESCAPED_NEWLINE = "\\n"

def __init__(self, name="", description="", default="", multiline = False):
def __init__(self, name="", description="", default="", multiline = False, optional = False):
Parameter.__init__(self, name, description)
self.default = default
self.value = None
Expand Down
17 changes: 10 additions & 7 deletions python/plugins/sextante/parameters/ParameterTableField.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ParameterTableField(Parameter):
DATA_TYPE_STRING = 1
DATA_TYPE_ANY = -1

def __init__(self, name="", description="", parent=None, datatype=-1):
def __init__(self, name="", description="", parent=None, datatype=-1, optional=False):
Parameter.__init__(self, name, description)
self.parent = parent
self.value = None
Expand All @@ -42,18 +42,21 @@ def getValueAsCommandLineParameter(self):

def getAsScriptCode(self):
return "##" + self.name + "=field " + str(self.parent)

def setValue(self, field):
if len(field) > 0:
self.value = str(field)
else:
return self.optional
return True

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
"|" + str(self.parent) + "|" + str(self.datatype)


def deserialize(self, s):
tokens = s.split("|")
if len(tokens) == 4:
return ParameterTableField(tokens[0], tokens[1], tokens[2], int(tokens[3]))
else:
return ParameterTableField(tokens[0], tokens[1], tokens[2])
tokens = s.split("|")
return ParameterTableField(tokens[0], tokens[1], tokens[2], int(tokens[3]), tokens[4] == str(True))

def __str__(self):
return self.name + " <" + self.__module__.split(".")[-1] +" from " + self.parent + ">"
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Add Polygon Attributes to Points
shapes_points
ParameterVector|INPUT|Points|0|False
ParameterVector|POLYGONS|Polygons|2|False
ParameterTableField|FIELD|Attribute|POLYGONS
ParameterTableField|FIELD|Attribute|POLYGONS|-1|False
OutputVector|OUTPUT|Result
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Aggregate Point Observations
shapes_points
ParameterVector|REFERENCE|Reference Points|-1|False
ParameterTableField|REFERENCE_ID|ID|REFERENCE
ParameterTableField|REFERENCE_ID|ID|REFERENCE|-1|False
ParameterTable|OBSERVATIONS|Observations|False
ParameterTableField|X|X|OBSERVATIONS
ParameterTableField|Y|Y|OBSERVATIONS
ParameterTableField|TRACK|Track|OBSERVATIONS
ParameterTableField|DATE|Date|OBSERVATIONS
ParameterTableField|TIME|Time|OBSERVATIONS
ParameterTableField|PARAMETER|Parameter|OBSERVATIONS
ParameterTableField|X|X|OBSERVATIONS|-1|False
ParameterTableField|Y|Y|OBSERVATIONS|-1|False
ParameterTableField|TRACK|Track|OBSERVATIONS|-1|False
ParameterTableField|DATE|Date|OBSERVATIONS|-1|False
ParameterTableField|TIME|Time|OBSERVATIONS|-1|False
ParameterTableField|PARAMETER|Parameter|OBSERVATIONS|-1|False
ParameterNumber|EPS_TIME|Maximum Time Span (Seconds)|None|None|60.0
ParameterNumber|EPS_SPACE|Maximum Distance|None|None|0.002
OutputTable|AGGREGATED|Aggregated
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
B-Spline Approximation
grid_spline
ParameterVector|SHAPES|Points|0|False
ParameterTableField|FIELD|Attribute|SHAPES
ParameterTableField|FIELD|Attribute|SHAPES|-1|False
ParameterSelection|TARGET|Target Grid|[0] user defined
ParameterNumber|LEVEL|Resolution|None|None|1.0
Extent USER_XMIN USER_XMAX USER_YMIN USER_YMAX
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Change Date Format
table_tools
ParameterTable|TABLE|Table|False
ParameterTableField|FIELD|Date Field|TABLE
ParameterTableField|FIELD|Date Field|TABLE|-1|False
ParameterSelection|FMT_IN|Input Format|[0] dd.mm.yy;[1] yy.mm.dd;[2] dd:mm:yy;[3] yy:mm:dd;[4] ddmmyyyy, fix size;[5] yyyymmdd, fix size;[6] ddmmyy, fix size;[7] yymmdd, fix size;[8] Julian Day
ParameterSelection|FMT_OUT|Output Format|[0] dd.mm.yy;[1] yy.mm.dd;[2] dd:mm:yy;[3] yy:mm:dd;[4] ddmmyyyy, fix size;[5] yyyymmdd, fix size;[6] ddmmyy, fix size;[7] yymmdd, fix size;[8] Julian Day
OutputTable|OUTPUT|Output
12 changes: 6 additions & 6 deletions python/plugins/sextante/saga/description/ChangeDetection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Change Detection
imagery_classification
ParameterRaster|INITIAL|Initial State|False
ParameterTable|INI_LUT|Look-up Table|True
ParameterTableField|INI_LUT_MIN|Value|INI_LUT
ParameterTableField|INI_LUT_MAX|Value (Maximum)|INI_LUT
ParameterTableField|INI_LUT_NAM|Name|INI_LUT
ParameterTableField|INI_LUT_MIN|Value|INI_LUT|-1|False
ParameterTableField|INI_LUT_MAX|Value (Maximum)|INI_LUT|-1|False
ParameterTableField|INI_LUT_NAM|Name|INI_LUT|-1|False
ParameterRaster|FINAL|Final State|False
ParameterTable|FIN_LUT|Look-up Table|True
ParameterTableField|FIN_LUT_MIN|Value|FIN_LUT
ParameterTableField|FIN_LUT_MAX|Value (Maximum)|FIN_LUT
ParameterTableField|FIN_LUT_NAM|Name|FIN_LUT
ParameterTableField|FIN_LUT_MIN|Value|FIN_LUT|-1|False
ParameterTableField|FIN_LUT_MAX|Value (Maximum)|FIN_LUT|-1|False
ParameterTableField|FIN_LUT_NAM|Name|FIN_LUT|-1|False
ParameterBoolean|NOCHANGE |Report Unchanged Classes|True
ParameterSelection|OUTPUT|Output as...|[0] cells;[1] percent;[2] area
OutputRaster|CHANGE|Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Change Time Format
table_tools
ParameterTable|TABLE|Table|False
ParameterTableField|FIELD|Time Field|TABLE
ParameterTableField|FIELD|Time Field|TABLE|-1|False
ParameterSelection|FMT_IN|Input Format|[0] hh.mm.ss;[1] hh:mm:ss;[2] hhmmss, fix size;[3] hours;[4] minutes;[5] seconds
ParameterSelection|FMT_OUT|Output Format|[0] hh.mm.ss;[1] hh:mm:ss;[2] hhmmss, fix size;[3] hours;[4] minutes;[5] seconds
OutputTable|OUTPUT|Output
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Clip Points with Polygons
shapes_points
ParameterVector|POINTS|Points|0|False
ParameterVector|POLYGONS|Polygons|2|False
ParameterTableField|FIELD|Add Attribute to Clipped Points|POLYGONS
ParameterTableField|FIELD|Add Attribute to Clipped Points|POLYGONS|-1|False
ParameterSelection|METHOD|Clipping Options|[0] one layer for all points;[1] separate layer for each polygon
OutputVector|CLIPS|Clipped Points
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Convert Points to Line(s)
shapes_lines
ParameterVector|POINTS|Points|0|False
ParameterTableField|ORDER|Order by...|POINTS
ParameterTableField|SEPARATE|Separate by...|POINTS
ParameterTableField|ORDER|Order by...|POINTS|-1|False
ParameterTableField|SEPARATE|Separate by...|POINTS|-1|False
OutputVector|LINES|Lines
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Convert Table to Points
shapes_points
ParameterTable|TABLE|Table|False
ParameterTableField|X|X|TABLE
ParameterTableField|Y|Y|TABLE
ParameterTableField|X|X|TABLE|-1|False
ParameterTableField|Y|Y|TABLE|-1|False
OutputVector|POINTS|Points