Skip to content
Permalink
Browse files

[processing]fixes in saga filename handling

fixed saga buffer description
  • Loading branch information
volaya committed Sep 13, 2013
1 parent 2e3765b commit 99857bcfd239b87350d91c78b958ad66e9ce40fc
@@ -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)
@@ -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 + "\"");
@@ -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:
@@ -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
@@ -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)
@@ -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

0 comments on commit 99857bc

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