Skip to content
Permalink
Browse files

Merge pull request #5436 from alexbruy/processing-gdal-memory

 [processing] correctly handle layers without attributes in GDAL-based geoprocessing algorithms (fix #17287)
  • Loading branch information
nyalldawson committed Oct 26, 2017
2 parents 8c32520 + 4a51c40 commit 034baf1b53e7a4d2725e403aaff14d1d082db8d3
@@ -116,6 +116,11 @@ def getConsoleCommands(self, parameters, context, feedback):
continue
other_fields.append(f.name())

if other_fields:
other_fields = ', {}'.format(','.join(other_fields))
else:
other_fields = ''

arguments = []
arguments.append(output)
arguments.append(ogrLayer)
@@ -124,9 +129,9 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-sql')

if dissolve or fieldName:
sql = "SELECT ST_Union(ST_Buffer({}, {})) AS {}, {} FROM '{}'".format(geometry, distance, geometry, ','.join(other_fields), layerName)
sql = "SELECT ST_Union(ST_Buffer({}, {})) AS {}{} FROM '{}'".format(geometry, distance, geometry, other_fields, layerName)
else:
sql = "SELECT ST_Buffer({}, {}) AS {}, {} FROM '{}'".format(geometry, distance, geometry, ','.join(other_fields), layerName)
sql = "SELECT ST_Buffer({}, {}) AS {}{} FROM '{}'".format(geometry, distance, geometry, other_fields, layerName)

if fieldName:
sql = '{} GROUP BY {}'.format(sql, fieldName)
@@ -127,6 +127,11 @@ def getConsoleCommands(self, parameters, context, feedback):

other_fields.append(f.name())

if other_fields:
other_fields = ', {}'.format(','.join(other_fields))
else:
other_fields = ''

arguments = []
arguments.append(output)
arguments.append(ogrLayer)
@@ -148,12 +153,12 @@ def getConsoleCommands(self, parameters, context, feedback):
params = ','.join(tokens)
if params:
if self.parameterAsBool(parameters, self.KEEP_ATTRIBUTES, context):
sql = "SELECT ST_Union({}) AS {}, {}, {} FROM {} GROUP BY {}".format(geometry, geometry, ','.join(other_fields), params, layerName, fieldName)
sql = "SELECT ST_Union({}) AS {}{}, {} FROM {} GROUP BY {}".format(geometry, geometry, other_fields, params, layerName, fieldName)
else:
sql = "SELECT ST_Union({}) AS {}, {}, {} FROM {} GROUP BY {}".format(geometry, geometry, fieldName, params, layerName, fieldName)
else:
if self.parameterAsBool(parameters, self.KEEP_ATTRIBUTES, context):
sql = "SELECT ST_Union({}) AS {}, {} FROM {} GROUP BY {}".format(geometry, geometry, ','.join(other_fields), layerName, fieldName)
sql = "SELECT ST_Union({}) AS {}{} FROM {} GROUP BY {}".format(geometry, geometry, other_fields, layerName, fieldName)
else:
sql = "SELECT ST_Union({}) AS {}, {} FROM {} GROUP BY {}".format(geometry, geometry, fieldName, layerName, fieldName)

@@ -97,14 +97,19 @@ def getConsoleCommands(self, parameters, context, feedback):
continue
other_fields.append(f.name())

if other_fields:
other_fields = ', {}'.format(','.join(other_fields))
else:
other_fields = ''

arguments = []
arguments.append(output)
arguments.append(ogrLayer)
arguments.append('-dialect')
arguments.append('sqlite')
arguments.append('-sql')

sql = "SELECT ST_OffsetCurve({}, {}) AS {}, {} FROM '{}'".format(geometry, distance, geometry, ','.join(other_fields), layerName)
sql = "SELECT ST_OffsetCurve({}, {}) AS {}{} FROM '{}'".format(geometry, distance, geometry, other_fields, layerName)
arguments.append(sql)

if options:
@@ -126,6 +126,11 @@ def getConsoleCommands(self, parameters, context, feedback):
continue
other_fields.append(f.name())

if other_fields:
other_fields = ', {}'.format(','.join(other_fields))
else:
other_fields = ''

arguments = []
arguments.append(output)
arguments.append(ogrLayer)
@@ -134,9 +139,9 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-sql')

if dissolve or fieldName:
sql = "SELECT ST_Union(ST_SingleSidedBuffer({}, {}, {})) AS {}, {} FROM '{}'".format(geometry, distance, side, geometry, ','.join(other_fields), layerName)
sql = "SELECT ST_Union(ST_SingleSidedBuffer({}, {}, {})) AS {}{} FROM '{}'".format(geometry, distance, side, geometry, other_fields, layerName)
else:
sql = "SELECT ST_SingleSidedBuffer({}, {}, {}) AS {}, {} FROM '{}'".format(geometry, distance, side, geometry, ','.join(other_fields), layerName)
sql = "SELECT ST_SingleSidedBuffer({}, {}, {}) AS {}{} FROM '{}'".format(geometry, distance, side, geometry, other_fields, layerName)

if fieldName:
sql = '"{} GROUP BY {}"'.format(sql, fieldName)
@@ -102,14 +102,19 @@ def getConsoleCommands(self, parameters, context, feedback):
continue
other_fields.append(f.name())

if other_fields:
other_fields = ', {}'.format(','.join(other_fields))
else:
other_fields = ''

arguments = []
arguments.append(output)
arguments.append(ogrLayer)
arguments.append('-dialect')
arguments.append('sqlite')
arguments.append('-sql')

sql = "SELECT ST_Line_Interpolate_Point({}, {}) AS {}, {} FROM '{}'".format(geometry, distance, geometry, ','.join(other_fields), layerName)
sql = "SELECT ST_Line_Interpolate_Point({}, {}) AS {}{} FROM '{}'".format(geometry, distance, geometry, other_fields, layerName)
arguments.append(sql)

if options:

0 comments on commit 034baf1

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