Skip to content
Permalink
Browse files

[sextante]Saga algorithms can now have harcoded values in description.

Modified SAGA descriptions accordingly and fixed Layer importer to avoid duplicated extensions
  • Loading branch information
volaya committed Mar 28, 2013
1 parent ea6573a commit 7a1c6445e82dec83fae86171a5bccb2e34ca2eec
@@ -49,7 +49,11 @@ def exportVectorLayer(layer):
It also export to a new file if the original one contains non-ascii characters'''
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
output = SextanteUtils.getTempFilenameInTempFolder(os.path.basename(unicode(layer.source())) + ".shp")
filename = os.path.basename(unicode(layer.source()))
idx = filename.rfind(".")
if idx != -1:
filename = filename[:idx]
output = SextanteUtils.getTempFilenameInTempFolder(filename + ".shp")
#output = SextanteUtils.getTempFilename("shp")
provider = layer.dataProvider()
useSelection = SextanteConfig.getSetting(SextanteConfig.USE_SELECTED)
@@ -86,6 +86,7 @@ def getIcon(self):
return QIcon(os.path.dirname(__file__) + "/../images/saga.png")

def defineCharacteristicsFromFile(self):
self.hardcodedStrings = []
lines = open(self.descriptionFile)
line = lines.readline().strip("\n").strip()
self.name = line
@@ -100,7 +101,9 @@ def defineCharacteristicsFromFile(self):
self.group = SagaGroupNameDecorator.getDecoratedName(self.undecoratedGroup)
while line != "":
line = line.strip("\n").strip()
if line.startswith("Parameter"):
if line.startswith("Hardcoded"):
self.hardcodedStrings.append(line[len("Harcoded|")+1:])
elif line.startswith("Parameter"):
self.addParameter(ParameterFactory.getFromString(line))
elif line.startswith("DontResample"):
self.resample = False
@@ -234,21 +237,25 @@ def processAlgorithm(self, progress):
command = self.undecoratedGroup + " \"" + self.cmdname + "\""
else:
command = "lib" + self.undecoratedGroup + " \"" + self.cmdname + "\""


if self.hardcodedStrings:
for s in self.hardcodedStrings:
command += " " + s

for param in self.parameters:
if param.value is None:
continue
if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable)):
value = param.value
if value in self.exportedLayers.keys():
command+=(" -" + param.name + " \"" + self.exportedLayers[value] + "\"")
command += (" -" + param.name + " \"" + self.exportedLayers[value] + "\"")
else:
command+=(" -" + param.name + " \"" + value + "\"")
command += (" -" + param.name + " \"" + value + "\"")
elif isinstance(param, ParameterMultipleInput):
s = param.value
for layer in self.exportedLayers.keys():
s = s.replace(layer, self.exportedLayers[layer])
command+=(" -" + param.name + " \"" + s + "\"");
command += (" -" + param.name + " \"" + s + "\"");
elif isinstance(param, ParameterBoolean):
if param.value:
command+=(" -" + param.name);
@@ -80,7 +80,7 @@ def createAlgsList(self):
else:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile)
except Exception,e:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile)
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile +"\n" + str(e))
self.preloadedAlgs.append(SplitRGBBands())

def _loadAlgorithms(self):
@@ -1,15 +1,8 @@
Cut Shapes Layer
shapes_tools
ParameterMultipleInput|SHAPES|Shapes|-1|False
ParameterVector|SHAPES|Vector layer to cut|-1|False
ParameterSelection|METHOD|Method|[0] completely contained;[1] intersects;[2] center
ParameterSelection|TARGET|Extent|[0] user defined;[1] grid project[do not use this option!];[2] shapes layer extent;[3] polygons
ParameterNumber|CUT_AX|Left|None|None|0.0
ParameterNumber|CUT_BX|Right|None|None|0.0
ParameterNumber|CUT_AY|Bottom|None|None|0.0
ParameterNumber|CUT_BY|Top|None|None|0.0
ParameterNumber|CUT_DX|Horizontal Range|None|None|0.0
ParameterNumber|CUT_DY|Vertical Range|None|None|0.0
ParameterVector|SHAPES_SHAPES|Shapes|-1|False
ParameterVector|POLYGONS_POLYGONS|Polygons|-1|False
OutputVector|CUT|Cut
Hardcoded|-TARGET 3
ParameterVector|POLYGONS_POLYGONS|Cutting polygons|-1|False
OutputVector|CUT|Result
OutputVector|EXTENT|Extent
@@ -4,8 +4,8 @@ ParameterVector|IN|Shapes|-1|False
ParameterNumber|DX|dX|None|None|0.0
ParameterNumber|DY|dY|None|None|0.0
ParameterNumber|ANGLE|Angle|None|None|0.0
ParameterNumber|SCALEX|Scale Factor X|None|None|0.0
ParameterNumber|SCALEY|Scale Factor Y|None|None|0.0
ParameterNumber|SCALEX|Scale Factor X|None|None|1.0
ParameterNumber|SCALEY|Scale Factor Y|None|None|1.0
ParameterNumber|ANCHORX|X|None|None|0.0
ParameterNumber|ANCHORY|Y|None|None|0.0
OutputVector|OUT|Output

0 comments on commit 7a1c644

Please sign in to comment.
You can’t perform that action at this time.