Skip to content

Commit 4f3e89a

Browse files
committedJan 24, 2013
added extra import parameters for vector layers in GRASS/SEXTANTE interface
minor fix to create a new instance when a model is edited
1 parent 16c64be commit 4f3e89a

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed
 

‎python/plugins/sextante/grass/GrassAlgorithm.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656

5757
class GrassAlgorithm(GeoAlgorithm):
5858

59-
60-
59+
GRASS_MIN_AREA_PARAMETER = "GRASS_MIN_AREA_PARAMETER"
60+
GRASS_SNAP_TOLERANCE_PARAMETER = "GRASS_SNAP_TOLERANCE_PARAMETER"
6161
GRASS_REGION_EXTENT_PARAMETER = "GRASS_REGION_PARAMETER"
6262
GRASS_REGION_CELLSIZE_PARAMETER = "GRASS_REGION_CELLSIZE_PARAMETER"
6363

@@ -123,7 +123,12 @@ def defineCharacteristicsFromFile(self):
123123
try:
124124
line = line.strip("\n").strip()
125125
if line.startswith("Parameter"):
126-
self.addParameter(ParameterFactory.getFromString(line))
126+
parameter = ParameterFactory.getFromString(line);
127+
self.addParameter(parameter)
128+
if isinstance(parameter, ParameterVector):
129+
hasVectorOutput = True
130+
if isinstance(parameter, ParameterMultipleInput) and parameter.datatype < 3:
131+
hasVectorOutput = True
127132
elif line.startswith("*Parameter"):
128133
param = ParameterFactory.getFromString(line[1:])
129134
param.isAdvanced = True
@@ -142,7 +147,13 @@ def defineCharacteristicsFromFile(self):
142147
self.addParameter(ParameterExtent(self.GRASS_REGION_EXTENT_PARAMETER, "GRASS region extent"))
143148
if hasRasterOutput:
144149
self.addParameter(ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER, "GRASS region cellsize (leave 0 for default)", 0, None, 0.0))
145-
150+
if hasVectorOutput:
151+
param = ParameterNumber(self.GRASS_SNAP_TOLERANCE_PARAMETER, "v.in.ogr snap tolerance (-1 = no snap)", -1, None, -1.0)
152+
param.isAdvanced = True
153+
self.addParameter(param)
154+
ParameterNumber(self.GRASS_MIN_AREA_PARAMETER, "v.in.ogr min area", 0, None, 0.0001)
155+
param.isAdvanced = True
156+
self.addParameter(param)
146157

147158
def getDefaultCellsize(self):
148159
cellsize = 0
@@ -252,7 +263,8 @@ def processAlgorithm(self, progress):
252263
for param in self.parameters:
253264
if param.value == None or param.value == "":
254265
continue
255-
if param.name == self.GRASS_REGION_CELLSIZE_PARAMETER or param.name == self.GRASS_REGION_EXTENT_PARAMETER:
266+
if (param.name == self.GRASS_REGION_CELLSIZE_PARAMETER or param.name == self.GRASS_REGION_EXTENT_PARAMETER
267+
or param.name == self.GRASS_MIN_AREA_PARAMETER or param.name == self.GRASS_SNAP_TOLERANCE_PARAMETER):
256268
continue
257269
if isinstance(param, (ParameterRaster, ParameterVector)):
258270
value = param.value
@@ -364,11 +376,14 @@ def exportVectorLayer(self, orgFilename):
364376
destFilename = self.getTempFilename()
365377
self.exportedLayers[orgFilename]= destFilename
366378
command = "v.in.ogr"
367-
command += " min_area=-1"
368-
command +=" dsn=\"" + os.path.dirname(filename) + "\""
369-
command +=" layer=" + os.path.basename(filename)[:-4]
370-
command +=" output=" + destFilename;
371-
command +=" --overwrite -o"
379+
min_area = self.getParameterValue(self.GRASS_MIN_AREA_PARAMETER);
380+
command += " min_area=" + str(min_area)
381+
snap = self.getParameterValue(self.GRASS_SNAP_TOLERANCE_PARAMETER);
382+
command += " snap=" + str(snap)
383+
command += " dsn=\"" + os.path.dirname(filename) + "\""
384+
command += " layer=" + os.path.basename(filename)[:-4]
385+
command += " output=" + destFilename;
386+
command += " --overwrite -o"
372387
return command
373388

374389
def setSessionProjectionFromProject(self, commands):

‎python/plugins/sextante/modeler/EditModelAction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def isEnabled(self):
3636
return isinstance(self.alg, ModelerAlgorithm)
3737

3838
def execute(self):
39-
dlg = ModelerDialog(self.alg)
39+
dlg = ModelerDialog(self.alg.getCopy())
4040
dlg.exec_()
4141
if dlg.update:
4242
self.toolbox.updateTree()

0 commit comments

Comments
 (0)
Please sign in to comment.