Skip to content

Commit

Permalink
[feature] Add parameter for field selection to Postgis OGR importer
Browse files Browse the repository at this point in the history
  • Loading branch information
stev-0 authored and nyalldawson committed Aug 8, 2018
1 parent 53cbe26 commit 56e605b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/plugins/processing/algs/gdal/OgrToPostGis.py
Expand Up @@ -65,6 +65,7 @@ class OgrToPostGis(GdalAlgorithm):
SEGMENTIZE = 'SEGMENTIZE'
SPAT = 'SPAT'
CLIP = 'CLIP'
FIELDS = 'FIELDS'
WHERE = 'WHERE'
GT = 'GT'
OVERWRITE = 'OVERWRITE'
Expand Down Expand Up @@ -127,6 +128,10 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterBoolean(self.CLIP,
self.tr('Clip the input layer using the above (rectangle) extent'),
defaultValue=False))
self.addParameter(QgsProcessingParameterField(self.FIELDS,
self.tr('Fields to include (leave empty to use all fields)'),
parentLayerParameterName=self.INPUT,
allowMultiple=True, optional=True))
self.addParameter(QgsProcessingParameterString(self.WHERE,
self.tr('Select features using a SQL "WHERE" statement (Ex: column=\'value\')'),
defaultValue='', optional=True))
Expand Down Expand Up @@ -210,6 +215,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
segmentize = self.parameterAsString(parameters, self.SEGMENTIZE, context)
spat = self.parameterAsExtent(parameters, self.SPAT, context)
clip = self.parameterAsBool(parameters, self.CLIP, context)
include_fields = self.parameterAsFields(parameters, self.FIELDS, context)
fields_string = '-select "' + ','.join(include_fields) + '"'
where = self.parameterAsString(parameters, self.WHERE, context)
wherestring = '-where "' + where + '"'
gt = self.parameterAsString(parameters, self.GT, context)
Expand Down Expand Up @@ -244,6 +251,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(launderstring)
if append:
arguments.append('-append')
if include_fields:
arguments.append(fields_string)
if addfields:
arguments.append('-addfields')
if overwrite:
Expand Down

0 comments on commit 56e605b

Please sign in to comment.