Skip to content

Commit 7a1c644

Browse files
committedMar 28, 2013
[sextante]Saga algorithms can now have harcoded values in description.
Modified SAGA descriptions accordingly and fixed Layer importer to avoid duplicated extensions
1 parent ea6573a commit 7a1c644

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed
 

‎python/plugins/sextante/core/LayerExporter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ def exportVectorLayer(layer):
4949
It also export to a new file if the original one contains non-ascii characters'''
5050
settings = QSettings()
5151
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
52-
output = SextanteUtils.getTempFilenameInTempFolder(os.path.basename(unicode(layer.source())) + ".shp")
52+
filename = os.path.basename(unicode(layer.source()))
53+
idx = filename.rfind(".")
54+
if idx != -1:
55+
filename = filename[:idx]
56+
output = SextanteUtils.getTempFilenameInTempFolder(filename + ".shp")
5357
#output = SextanteUtils.getTempFilename("shp")
5458
provider = layer.dataProvider()
5559
useSelection = SextanteConfig.getSetting(SextanteConfig.USE_SELECTED)

‎python/plugins/sextante/saga/SagaAlgorithm.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def getIcon(self):
8686
return QIcon(os.path.dirname(__file__) + "/../images/saga.png")
8787

8888
def defineCharacteristicsFromFile(self):
89+
self.hardcodedStrings = []
8990
lines = open(self.descriptionFile)
9091
line = lines.readline().strip("\n").strip()
9192
self.name = line
@@ -100,7 +101,9 @@ def defineCharacteristicsFromFile(self):
100101
self.group = SagaGroupNameDecorator.getDecoratedName(self.undecoratedGroup)
101102
while line != "":
102103
line = line.strip("\n").strip()
103-
if line.startswith("Parameter"):
104+
if line.startswith("Hardcoded"):
105+
self.hardcodedStrings.append(line[len("Harcoded|")+1:])
106+
elif line.startswith("Parameter"):
104107
self.addParameter(ParameterFactory.getFromString(line))
105108
elif line.startswith("DontResample"):
106109
self.resample = False
@@ -234,21 +237,25 @@ def processAlgorithm(self, progress):
234237
command = self.undecoratedGroup + " \"" + self.cmdname + "\""
235238
else:
236239
command = "lib" + self.undecoratedGroup + " \"" + self.cmdname + "\""
237-
240+
241+
if self.hardcodedStrings:
242+
for s in self.hardcodedStrings:
243+
command += " " + s
244+
238245
for param in self.parameters:
239246
if param.value is None:
240247
continue
241248
if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable)):
242249
value = param.value
243250
if value in self.exportedLayers.keys():
244-
command+=(" -" + param.name + " \"" + self.exportedLayers[value] + "\"")
251+
command += (" -" + param.name + " \"" + self.exportedLayers[value] + "\"")
245252
else:
246-
command+=(" -" + param.name + " \"" + value + "\"")
253+
command += (" -" + param.name + " \"" + value + "\"")
247254
elif isinstance(param, ParameterMultipleInput):
248255
s = param.value
249256
for layer in self.exportedLayers.keys():
250257
s = s.replace(layer, self.exportedLayers[layer])
251-
command+=(" -" + param.name + " \"" + s + "\"");
258+
command += (" -" + param.name + " \"" + s + "\"");
252259
elif isinstance(param, ParameterBoolean):
253260
if param.value:
254261
command+=(" -" + param.name);

‎python/plugins/sextante/saga/SagaAlgorithmProvider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def createAlgsList(self):
8080
else:
8181
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile)
8282
except Exception,e:
83-
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile)
83+
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile +"\n" + str(e))
8484
self.preloadedAlgs.append(SplitRGBBands())
8585

8686
def _loadAlgorithms(self):
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
Cut Shapes Layer
22
shapes_tools
3-
ParameterMultipleInput|SHAPES|Shapes|-1|False
3+
ParameterVector|SHAPES|Vector layer to cut|-1|False
44
ParameterSelection|METHOD|Method|[0] completely contained;[1] intersects;[2] center
5-
ParameterSelection|TARGET|Extent|[0] user defined;[1] grid project[do not use this option!];[2] shapes layer extent;[3] polygons
6-
ParameterNumber|CUT_AX|Left|None|None|0.0
7-
ParameterNumber|CUT_BX|Right|None|None|0.0
8-
ParameterNumber|CUT_AY|Bottom|None|None|0.0
9-
ParameterNumber|CUT_BY|Top|None|None|0.0
10-
ParameterNumber|CUT_DX|Horizontal Range|None|None|0.0
11-
ParameterNumber|CUT_DY|Vertical Range|None|None|0.0
12-
ParameterVector|SHAPES_SHAPES|Shapes|-1|False
13-
ParameterVector|POLYGONS_POLYGONS|Polygons|-1|False
14-
OutputVector|CUT|Cut
5+
Hardcoded|-TARGET 3
6+
ParameterVector|POLYGONS_POLYGONS|Cutting polygons|-1|False
7+
OutputVector|CUT|Result
158
OutputVector|EXTENT|Extent

‎python/plugins/sextante/saga/description/TransformShapes.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ParameterVector|IN|Shapes|-1|False
44
ParameterNumber|DX|dX|None|None|0.0
55
ParameterNumber|DY|dY|None|None|0.0
66
ParameterNumber|ANGLE|Angle|None|None|0.0
7-
ParameterNumber|SCALEX|Scale Factor X|None|None|0.0
8-
ParameterNumber|SCALEY|Scale Factor Y|None|None|0.0
7+
ParameterNumber|SCALEX|Scale Factor X|None|None|1.0
8+
ParameterNumber|SCALEY|Scale Factor Y|None|None|1.0
99
ParameterNumber|ANCHORX|X|None|None|0.0
1010
ParameterNumber|ANCHORY|Y|None|None|0.0
1111
OutputVector|OUT|Output

0 commit comments

Comments
 (0)
Please sign in to comment.