mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-26 00:22:10 -05:00
Add parameter to skip layername in gdal:convertformat
This commit is contained in:
parent
3f00597bc6
commit
495af5a724
@ -25,6 +25,7 @@ import os
|
||||
|
||||
from qgis.core import (QgsProcessing,
|
||||
QgsProcessingException,
|
||||
QgsProcessingParameterBoolean,
|
||||
QgsProcessingParameterDefinition,
|
||||
QgsProcessingParameterFeatureSource,
|
||||
QgsProcessingParameterString,
|
||||
@ -35,6 +36,7 @@ from processing.algs.gdal.GdalUtils import GdalUtils
|
||||
|
||||
class ogr2ogr(GdalAlgorithm):
|
||||
INPUT = 'INPUT'
|
||||
IGNORE_LAYERNAME = 'IGNORE_LAYERNAME'
|
||||
OPTIONS = 'OPTIONS'
|
||||
OUTPUT = 'OUTPUT'
|
||||
|
||||
@ -46,6 +48,9 @@ class ogr2ogr(GdalAlgorithm):
|
||||
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='',
|
||||
@ -73,6 +78,7 @@ class ogr2ogr(GdalAlgorithm):
|
||||
|
||||
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)
|
||||
@ -91,6 +97,7 @@ class ogr2ogr(GdalAlgorithm):
|
||||
|
||||
arguments.append(output)
|
||||
arguments.append(ogrLayer)
|
||||
arguments.append(layerName)
|
||||
if not ignoreLayerName:
|
||||
arguments.append(layerName)
|
||||
|
||||
return ['ogr2ogr', GdalUtils.escapeAndJoin(arguments)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user