Skip to content
Permalink
Browse files

[processing] added ‘supported’ parameter to exportVectorLayer

(cherry picked from commit 9c2721b)
  • Loading branch information
volaya authored and alexbruy committed May 28, 2016
1 parent 8778943 commit fa524a2e02f1a26202b11c5ef68c8b509e6d5315
@@ -50,10 +50,11 @@ def getCustomParametersDialog(self):
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(),

0 comments on commit fa524a2

Please sign in to comment.
You can’t perform that action at this time.