mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] added ‘supported’ parameter to exportVectorLayer
This commit is contained in:
parent
ebf434037f
commit
9c2721b08b
@ -50,10 +50,11 @@ class GdalAlgorithm(GeoAlgorithm):
|
||||
def processAlgorithm(self, progress):
|
||||
commands = self.getConsoleCommands()
|
||||
layers = dataobjects.getVectorLayers()
|
||||
supported = dataobjects.getSupportedOutputVectorLayerExtensions()
|
||||
for i, c in enumerate(commands):
|
||||
for layer in layers:
|
||||
if layer.source() in c:
|
||||
c = c.replace(layer.source(), dataobjects.exportVectorLayer(layer))
|
||||
c = c.replace(layer.source(), dataobjects.exportVectorLayer(layer, supported))
|
||||
|
||||
commands[i] = c
|
||||
GdalUtils.runGdal(commands, progress)
|
||||
|
@ -271,7 +271,7 @@ def getObjectFromUri(uri, forceLoad=True):
|
||||
return None
|
||||
|
||||
|
||||
def exportVectorLayer(layer):
|
||||
def exportVectorLayer(layer, supported=None):
|
||||
"""Takes a QgsVectorLayer and returns the filename to refer to it,
|
||||
which allows external apps which support only file-based layers to
|
||||
use it. It performs the necessary export in case the input layer
|
||||
@ -285,6 +285,7 @@ def exportVectorLayer(layer):
|
||||
a new file if the original one contains non-ascii characters.
|
||||
"""
|
||||
|
||||
supported = supported or ["shp"]
|
||||
settings = QSettings()
|
||||
systemEncoding = settings.value('/UI/encoding', 'System')
|
||||
|
||||
@ -317,7 +318,7 @@ def exportVectorLayer(layer):
|
||||
unicode(layer.source()).decode('ascii')
|
||||
except UnicodeEncodeError:
|
||||
isASCII = False
|
||||
if not unicode(layer.source()).endswith('shp') or not isASCII:
|
||||
if not os.path.splitext()[1] in supported or not isASCII:
|
||||
writer = QgsVectorFileWriter(
|
||||
output, systemEncoding,
|
||||
layer.pendingFields(), provider.geometryType(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user