Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing]fixes in saga filename handling
fixed saga buffer description
  • Loading branch information
volaya committed Sep 14, 2013
1 parent 2e3765b commit 99857bc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
6 changes: 3 additions & 3 deletions python/plugins/processing/saga/SagaAlgorithm.py
Expand Up @@ -290,7 +290,7 @@ def processAlgorithm(self, progress):
for out in self.outputs:
if isinstance(out, OutputRaster):
filename = out.getCompatibleFileName(self)
filename = tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
filename += ".sgrd"
command+=(" -" + out.name + " \"" + filename + "\"");
if isinstance(out, OutputVector):
filename = out.getCompatibleFileName(self)
Expand All @@ -305,7 +305,7 @@ def processAlgorithm(self, progress):
for out in self.outputs:
if isinstance(out, OutputRaster):
filename = out.getCompatibleFileName(self)
filename2 = tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
filename2 = filename + ".sgrd"
formatIndex = 1 if saga208 else 4
if isWindows() or isMac() or not saga208:
commands.append("io_gdal 1 -GRIDS \"" + filename2 + "\" -FORMAT " + str(formatIndex) +" -TYPE 0 -FILE \"" + filename + "\"");
Expand Down Expand Up @@ -383,7 +383,7 @@ def exportRasterLayer(self, source):
if layer:
filename = str(layer.name())
else:
filename = source.rstrip(".sgrd")
filename = os.path.basename(filename)
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
filename = ''.join(c for c in filename if c in validChars)
if len(filename) == 0:
Expand Down
15 changes: 7 additions & 8 deletions python/plugins/processing/saga/description/2.1_ShapesBuffer.txt
@@ -1,11 +1,10 @@
Shapes Buffer
Shapes Buffer (Attribute distance)|Shapes Buffer
shapes_tools
ParameterVector|SHAPES|Shapes|-1|False
ParameterSelection|BUF_TYPE|Buffer Distance|[0] fixed value;[1] attribute field
ParameterNumber|BUF_DIST|Buffer Distance (Fixed)|None|None|100.0
ParameterTableField|BUF_FIELD|Buffer Distance (Attribute)|SHAPES|-1|False
ParameterNumber|BUF_SCALE|Scaling Factor for Attribute Value|None|None|1.0
ParameterNumber|BUF_ZONES|Number of Buffer Zones|1.0|None|1.0
ParameterNumber|DCIRCLE|Circle Point Distance [Degree]|None|None|5.0
ParameterTableField|DIST_FIELD|Buffer Distance|SHAPES|-1|False
ParameterNumber|DIST_SCALE|Scaling Factor for Attribute Value|None|None|1.0
ParameterNumber|NZONES|Number of Buffer Zones|1.0|None|1.0
ParameterNumber|DARC|Arc Vertex Distance [Degree]|0.01|45.0|5.0
ParameterBoolean|DISSOLVE |Dissolve Buffers|True
OutputVector|BUFFER|Buffer
ParameterBoolean|POLY_INNER |Inner Buffer|False
OutputVector|BUFFER|Buffer
@@ -0,0 +1,9 @@
Shapes Buffer (Fixed distance)|Shapes Buffer
shapes_tools
ParameterVector|SHAPES|Shapes|-1|False
ParameterNumber|DIST_FIELD_DEFAULT|Buffer distance|0.0|None|100.0
ParameterNumber|NZONES|Number of Buffer Zones|1.0|None|1.0
ParameterNumber|DARC|Arc Vertex Distance [Degree]|0.01|45.0|5.0
ParameterBoolean|DISSOLVE |Dissolve Buffers|True
ParameterBoolean|POLY_INNER |Inner Buffer|False
OutputVector|BUFFER|Buffer
@@ -1,6 +1,4 @@
from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from processing.core.VectorWriter import VectorWriter

#Here we define the input and outputs
Expand All @@ -12,7 +10,7 @@
#And here is the body of the algorithm
#=======================================

#input layers values are always a string with its location.
#input layers values are always a string with its source.
#That string can be converted into a QGIS object (a QgsVectorLayer in this case))
#using the processing.getObject() method
vectorLayer = processing.getObject(input)
Expand All @@ -22,11 +20,12 @@
#First we create the output layer.
#To do so, we create a ProcessingVectorWriter, that we can later use to add features.
provider = vectorLayer.dataProvider()

writer = VectorWriter(output, None, provider.fields(), provider.geometryType(), vectorLayer.crs())

#Now we take the selected features and add them to the output layer
selection = vectorLayer.selectedFeatures()
for feat in selection:
features = processing.features(vectorLayer)
for feat in features:
writer.addFeature(feat)
del writer

Expand Down

0 comments on commit 99857bc

Please sign in to comment.