Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add parameter to skip layername in gdal:convertformat
  • Loading branch information
benoitblanc authored and nyalldawson committed Dec 9, 2021
1 parent 3f00597 commit 495af5a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/plugins/processing/algs/gdal/ogr2ogr.py
Expand Up @@ -25,6 +25,7 @@

from qgis.core import (QgsProcessing,
QgsProcessingException,
QgsProcessingParameterBoolean,
QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterString,
Expand All @@ -35,6 +36,7 @@

class ogr2ogr(GdalAlgorithm):
INPUT = 'INPUT'
IGNORE_LAYERNAME = 'IGNORE_LAYERNAME'
OPTIONS = 'OPTIONS'
OUTPUT = 'OUTPUT'

Expand All @@ -46,6 +48,9 @@ def initAlgorithm(self, config=None):
self.tr('Input layer'),
types=[QgsProcessing.TypeVector]))

self.addParameter(QgsProcessingParameterBoolean(self.IGNORE_LAYERNAME,
self.tr('Ignore layer name'), defaultValue=False))

options_param = QgsProcessingParameterString(self.OPTIONS,
self.tr('Additional creation options'),
defaultValue='',
Expand Down Expand Up @@ -73,6 +78,7 @@ def commandName(self):

def getConsoleCommands(self, parameters, context, feedback, executing=True):
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback, executing)
ignoreLayerName = self.parameterAsBoolean(parameters, self.IGNORE_LAYERNAME, context)
options = self.parameterAsString(parameters, self.OPTIONS, context)
outFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
self.setOutputValue(self.OUTPUT, outFile)
Expand All @@ -91,6 +97,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

arguments.append(output)
arguments.append(ogrLayer)
arguments.append(layerName)
if not ignoreLayerName:
arguments.append(layerName)

return ['ogr2ogr', GdalUtils.escapeAndJoin(arguments)]

0 comments on commit 495af5a

Please sign in to comment.