Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify other_field checker
  • Loading branch information
dericke authored and nyalldawson committed Feb 20, 2021
1 parent 97880d7 commit 26ad7c6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 41 deletions.
22 changes: 6 additions & 16 deletions python/plugins/processing/algs/gdal/Buffer.py
Expand Up @@ -114,24 +114,14 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

output, outputFormat = GdalUtils.ogrConnectionStringAndFormat(outFile, context)

other_fields = []
for f in fields:
if f.name() == geometry:
continue
other_fields.append('"{}"'.format(f.name()))

if other_fields:
other_fields = ',*'
else:
other_fields = ''
other_fields_exist = any(
True for f in fields
if f.name() != geometry
)

arguments = []
arguments.append(output)
arguments.append(ogrLayer)
arguments.append('-dialect')
arguments.append('sqlite')
arguments.append('-sql')
other_fields = ',*' if other_fields_exist else ''

arguments = [output, ogrLayer, '-dialect', 'sqlite', '-sql']
if dissolve or fieldName:
sql = 'SELECT ST_Union(ST_Buffer({}, {})) AS {}{} FROM "{}"'.format(geometry, distance, geometry, other_fields, layerName)
else:
Expand Down
15 changes: 5 additions & 10 deletions python/plugins/processing/algs/gdal/Dissolve.py
Expand Up @@ -124,17 +124,12 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

output, outputFormat = GdalUtils.ogrConnectionStringAndFormat(outFile, context)

other_fields = []
for f in fields:
if f.name() == geometry:
continue
other_fields_exist = any(
True for f in fields
if f.name() != geometry
)

other_fields.append('"{}"'.format(f.name()))

if other_fields:
other_fields = ',*'
else:
other_fields = ''
other_fields = ',*' if other_fields_exist else ''

arguments = [
output,
Expand Down
16 changes: 6 additions & 10 deletions python/plugins/processing/algs/gdal/OffsetCurve.py
Expand Up @@ -96,16 +96,12 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

output, outputFormat = GdalUtils.ogrConnectionStringAndFormat(outFile, context)

other_fields = []
for f in fields:
if f.name() == geometry:
continue
other_fields.append('"{}"'.format(f.name()))

if other_fields:
other_fields = ',*'
else:
other_fields = ''
other_fields_exist = any(
True for f in fields
if f.name() != geometry
)

other_fields = ',*' if other_fields_exist else ''

arguments = [
output,
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/algs/gdal/PointsAlongLines.py
Expand Up @@ -100,13 +100,13 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

output, outputFormat = GdalUtils.ogrConnectionStringAndFormat(outFile, context)

other_fields = [
f'"{f.name()}"'
for f in fields
other_fields_exist = any(
f for f in fields
if f.name() != geometry
]
)

other_fields = ',*' if other_fields_exist else ''

other_fields = ',*' if other_fields else ''
arguments = [
output,
ogrLayer,
Expand Down

0 comments on commit 26ad7c6

Please sign in to comment.