35 changes: 25 additions & 10 deletions python/plugins/sextante/grass/GrassAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@

class GrassAlgorithm(GeoAlgorithm):



GRASS_MIN_AREA_PARAMETER = "GRASS_MIN_AREA_PARAMETER"
GRASS_SNAP_TOLERANCE_PARAMETER = "GRASS_SNAP_TOLERANCE_PARAMETER"
GRASS_REGION_EXTENT_PARAMETER = "GRASS_REGION_PARAMETER"
GRASS_REGION_CELLSIZE_PARAMETER = "GRASS_REGION_CELLSIZE_PARAMETER"

Expand Down Expand Up @@ -123,7 +123,12 @@ def defineCharacteristicsFromFile(self):
try:
line = line.strip("\n").strip()
if line.startswith("Parameter"):
self.addParameter(ParameterFactory.getFromString(line))
parameter = ParameterFactory.getFromString(line);
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
hasVectorOutput = True
if isinstance(parameter, ParameterMultipleInput) and parameter.datatype < 3:
hasVectorOutput = True
elif line.startswith("*Parameter"):
param = ParameterFactory.getFromString(line[1:])
param.isAdvanced = True
Expand All @@ -142,7 +147,13 @@ def defineCharacteristicsFromFile(self):
self.addParameter(ParameterExtent(self.GRASS_REGION_EXTENT_PARAMETER, "GRASS region extent"))
if hasRasterOutput:
self.addParameter(ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER, "GRASS region cellsize (leave 0 for default)", 0, None, 0.0))

if hasVectorOutput:
param = ParameterNumber(self.GRASS_SNAP_TOLERANCE_PARAMETER, "v.in.ogr snap tolerance (-1 = no snap)", -1, None, -1.0)
param.isAdvanced = True
self.addParameter(param)
ParameterNumber(self.GRASS_MIN_AREA_PARAMETER, "v.in.ogr min area", 0, None, 0.0001)
param.isAdvanced = True
self.addParameter(param)

def getDefaultCellsize(self):
cellsize = 0
Expand Down Expand Up @@ -252,7 +263,8 @@ def processAlgorithm(self, progress):
for param in self.parameters:
if param.value == None or param.value == "":
continue
if param.name == self.GRASS_REGION_CELLSIZE_PARAMETER or param.name == self.GRASS_REGION_EXTENT_PARAMETER:
if (param.name == self.GRASS_REGION_CELLSIZE_PARAMETER or param.name == self.GRASS_REGION_EXTENT_PARAMETER
or param.name == self.GRASS_MIN_AREA_PARAMETER or param.name == self.GRASS_SNAP_TOLERANCE_PARAMETER):
continue
if isinstance(param, (ParameterRaster, ParameterVector)):
value = param.value
Expand Down Expand Up @@ -364,11 +376,14 @@ def exportVectorLayer(self, orgFilename):
destFilename = self.getTempFilename()
self.exportedLayers[orgFilename]= destFilename
command = "v.in.ogr"
command += " min_area=-1"
command +=" dsn=\"" + os.path.dirname(filename) + "\""
command +=" layer=" + os.path.basename(filename)[:-4]
command +=" output=" + destFilename;
command +=" --overwrite -o"
min_area = self.getParameterValue(self.GRASS_MIN_AREA_PARAMETER);
command += " min_area=" + str(min_area)
snap = self.getParameterValue(self.GRASS_SNAP_TOLERANCE_PARAMETER);
command += " snap=" + str(snap)
command += " dsn=\"" + os.path.dirname(filename) + "\""
command += " layer=" + os.path.basename(filename)[:-4]
command += " output=" + destFilename;
command += " --overwrite -o"
return command

def setSessionProjectionFromProject(self, commands):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/r.mode.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
r.mode
r.mode - Finds the mode of values in a cover map within areas assigned the same category value in a user-specified base map.
r.mode - Finds the mode of values in a cover layer within areas assigned the same category value in a user-specified base layer.
Raster (r.*)
ParameterRaster|base|Base layer to be reclassified|False
ParameterRaster|cover|Categories layer|False
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/r.neighbors.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
r.neighbors
r.neighbors - Makes each cell category value a function of the category values assigned to the cells around it, and stores new cell values in an output raster map layer.
r.neighbors - Makes each cell category value a function of the category values assigned to the cells around it
Raster (r.*)
ParameterRaster|input|Input raster layer|False
ParameterSelection|method|Neighborhood operation|average;median;mode;minimum;maximum;stddev;sum;variance;diversity;interspersion
Expand Down
8 changes: 0 additions & 8 deletions python/plugins/sextante/grass/description/r.out.arc.txt

This file was deleted.

12 changes: 0 additions & 12 deletions python/plugins/sextante/grass/description/r.out.ascii.txt

This file was deleted.

6 changes: 3 additions & 3 deletions python/plugins/sextante/grass/description/r.out.ppm.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
r.out.ppm
r.out.ppm - Converts a GRASS raster map to a PPM image file at the pixel resolution of the currently defined region.
r.out.ppm - Converts a raster layer to a PPM image file at the pixel resolution of the currently defined region.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterRaster|input|Input raster layer|False
ParameterBoolean|-G|Output greyscale instead of color|True
OutputFile|output|Name for new PPM file (use '-' for stdout)
OutputFile|output|Output PPM file
8 changes: 4 additions & 4 deletions python/plugins/sextante/grass/description/r.out.vrml.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
r.out.vrml
r.out.vrml - Export a raster map to the Virtual Reality Modeling Language (VRML)
r.out.vrml - Export a raster layer to the Virtual Reality Modeling Language (VRML)
Raster (r.*)
ParameterRaster|elev|Name of elevation map|False
ParameterRaster|color|Name of color file|False
ParameterRaster|elev|Elevation layer|False
ParameterRaster|color|Color layer|False
ParameterNumber|exag|Vertical exaggeration|None|None|1.0
OutputFile|output|Name for new VRML file
OutputFile|output|Output VRML file
4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/description/r.patch.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
r.patch
r.patch - Creates a composite raster map layer by using one (or more) map layer(s) to fill in areas of "no data" in another map layer.
r.patch - Creates a composite raster layer by using one (or more) layer(s) to fill in areas of "no data" in another map layer.
Raster (r.*)
ParameterMultipleInput|input|Raster maps to be patched together|3|False
ParameterMultipleInput|input|Raster layers to be patched together|3|False
ParameterBoolean|-z|Use zero (0) for transparency instead of NULL|False
OutputRaster|output|Result
1 change: 0 additions & 1 deletion python/plugins/sextante/grass/description/r.plane.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
r.plane
r.plane - Creates raster plane map given dip (inclination), aspect (azimuth) and one point.
Raster (r.*)

ParameterNumber|dip|Dip of plane. Value must be between -90 and 90 degrees|None|None|0.0
ParameterNumber|azimuth|Azimuth of the plane. Value must be between 0 and 360 degrees|None|None|0.0
ParameterNumber|easting|Easting coordinate of a point on the plane|None|None|0.0
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/description/r.quant.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
r.quant
r.quant - Produces the quantization file for a floating-point map.
Raster (r.*)
ParameterMultipleInput|input|Raster map(s) to be quantized|1.0|False
ParameterRaster|basemap|Base map to take quant rules from|False
ParameterMultipleInput|input|Raster layer(s) to be quantized|1.0|False
ParameterRaster|basemap|Base layer to take quant rules from|False
ParameterRange|fprange|Floating point range: dmin,dmax|0,1
ParameterRange|range|Integer range: min,max|1,255
ParameterBoolean|-t|Truncate floating point data|False
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/r.quantile.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
r.quantile
r.quantile - Compute quantiles using two passes.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterRaster|input|Input raster layer|False
ParameterNumber|quantiles|Number of quantiles|2|None|4
*ParameterBoolean|-r|Generate recode rules based on quantile-defined intervals|False
OutputHTML|html|Output report
6 changes: 3 additions & 3 deletions python/plugins/sextante/grass/description/r.random.cells.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
r.random.cells
r.random.cells - Generates random cell values with spatial dependence.
Raster (r.*)
ParameterNumber|distance|Maximum distance of spatial correlation (value(s) >= 0.0)|None|None|0.0
ParameterNumber|seed|Random seed (SEED_MIN >= value >= SEED_MAX) (default [random])|None|None|0.0
OutputRaster|output|Name for output raster map
ParameterNumber|distance|Maximum distance of spatial correlation (value(s) >= 0.0)|0.0|None|0.0
*ParameterNumber|seed|Random seed (SEED_MIN >= value >= SEED_MAX) (default [random])|None|None|0.0
OutputRaster|output|Output raster layer
12 changes: 6 additions & 6 deletions python/plugins/sextante/grass/description/r.random.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
r.random
r.random - Creates a raster map layer and vector point map containing randomly located points.
r.random - Creates a raster layer and vector point map containing randomly located points.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterRaster|cover|Name of cover raster map|False
ParameterNumber|n|The number of points to allocate|None|None|10
OutputRaster|raster_output|Name for output raster map
OutputVector|vector_output|Name for output vector map
ParameterRaster|input|Input raster layer|False
ParameterRaster|cover|Input cover raster layer|False
ParameterNumber|n|The number of points to allocate|0|None|10
OutputRaster|raster_output|Output raster layer
OutputVector|vector_output|Output vector layer
2 changes: 1 addition & 1 deletion python/plugins/sextante/modeler/EditModelAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def isEnabled(self):
return isinstance(self.alg, ModelerAlgorithm)

def execute(self):
dlg = ModelerDialog(self.alg)
dlg = ModelerDialog(self.alg.getCopy())
dlg.exec_()
if dlg.update:
self.toolbox.updateTree()