Skip to content
Permalink
Browse files

[processing] refactor ogr buffer algorithm

  • Loading branch information
alexbruy committed Sep 16, 2016
1 parent 448961b commit 8bf95fea5e21528cee83e55d64239cf97148f62c
@@ -75,43 +75,40 @@ def defineCharacteristics(self):

def getConsoleCommands(self):
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = ogrConnectionString(inLayer)[1:-1]
layername = "'" + ogrLayerName(inLayer) + "'"
geometry = unicode(self.getParameterValue(self.GEOMETRY))
distance = unicode(self.getParameterValue(self.DISTANCE))
geometry = self.getParameterValue(self.GEOMETRY)
distance = self.getParameterValue(self.DISTANCE)
dissolveall = self.getParameterValue(self.DISSOLVEALL)
field = unicode(self.getParameterValue(self.FIELD))
field = self.getParameterValue(self.FIELD)
multi = self.getParameterValue(self.MULTI)
options = self.getParameterValue(self.OPTIONS)

ogrLayer = ogrConnectionString(inLayer)[1:-1]
layername = ogrLayerName(inLayer)

output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value

output = ogrConnectionString(outFile)
options = unicode(self.getParameterValue(self.OPTIONS))

arguments = []
arguments.append(output)
arguments.append(ogrLayer)
arguments.append(ogrLayerName(inLayer))
if dissolveall or field != 'None':
arguments.append('-dialect sqlite -sql "SELECT ST_Union(ST_Buffer(')
else:
arguments.append('-dialect sqlite -sql "SELECT ST_Buffer(')
arguments.append(geometry)
arguments.append(',')
arguments.append(distance)
if dissolveall or field != 'None':
arguments.append(')),*')
arguments.append('-dialect')
arguments.append('sqlite')
arguments.append('-sql')

if dissolveall or field is not None:
sql = "SELECT ST_Union(ST_Buffer({}, {})), * FROM '{}'".format(geometry, distance, layername)
else:
arguments.append('),*')
arguments.append('FROM')
arguments.append(layername)
if field != 'None':
arguments.append('GROUP')
arguments.append('BY')
arguments.append(field)
arguments.append('"')
if field != 'None' and multi:
sql = "SELECT ST_Buffer({}, {}), * FROM '{}'".format(geometry, distance, layername)

if field is not None:
sql = '{} GROUP BY {}'.format(sql, field)

arguments.append(sql)

if field is not None and multi:
arguments.append('-explodecollections')

if len(options) > 0:
@@ -89,7 +89,7 @@ def getConsoleCommands(self):
options = self.getParameterValue(self.OPTIONS)

ogrLayer = ogrConnectionString(inLayer)[1:-1]
layername = "'" + ogrLayerName(inLayer) + "'"
layername = ogrLayerName(inLayer)

output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value

0 comments on commit 8bf95fe

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