Skip to content

Commit fc5f70c

Browse files
committedMay 17, 2016
Processing - Support tables with no geometry in OutputVector
1 parent 63d23d2 commit fc5f70c

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed
 

‎python/plugins/processing/core/GeoAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def checkOutputFileExtensions(self):
354354
out.value = out.value + '.' + exts[0]
355355
else:
356356
ext = out.value[idx + 1:]
357-
if ext not in exts:
357+
if ext not in exts + ['dbf']:
358358
out.value = out.value + '.' + exts[0]
359359

360360
def resolveTemporaryOutputs(self):

‎python/plugins/processing/core/outputs.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,34 @@ class OutputVector(Output):
250250
encoding = None
251251
compatible = None
252252

253-
def getFileFilter(self, alg):
253+
def __init__(self, name='', description='', hidden=False, base_input=None):
254+
Output.__init__(self, name, description, hidden)
255+
self.base_input = base_input
256+
self.base_layer = None
257+
258+
def hasGeometry(self):
259+
if self.base_layer is None:
260+
return True
261+
return dataobjects.canUseVectorLayer(self.base_layer, [-1])
262+
263+
def getSupportedOutputVectorLayerExtensions(self):
254264
exts = dataobjects.getSupportedOutputVectorLayerExtensions()
265+
if not self.hasGeometry():
266+
exts = ['dbf'] + [ext for ext in exts if ext in VectorWriter.nogeometry_extensions]
267+
return exts
268+
269+
def getFileFilter(self, alg):
270+
exts = self.getSupportedOutputVectorLayerExtensions()
255271
for i in range(len(exts)):
256272
exts[i] = self.tr('%s files (*.%s)', 'OutputVector') % (exts[i].upper(), exts[i].lower())
257273
return ';;'.join(exts)
258274

259275
def getDefaultFileExtension(self, alg):
260-
supported = alg.provider.getSupportedOutputVectorLayerExtensions()
261-
default = ProcessingConfig.getSetting(ProcessingConfig.DEFAULT_OUTPUT_VECTOR_LAYER_EXT)
276+
supported = self.getSupportedOutputVectorLayerExtensions()
277+
if self.hasGeometry():
278+
default = ProcessingConfig.getSetting(ProcessingConfig.DEFAULT_OUTPUT_VECTOR_LAYER_EXT)
279+
else:
280+
default = 'dbf'
262281
ext = default if default in supported else supported[0]
263282
return ext
264283

@@ -271,9 +290,8 @@ def getCompatibleFileName(self, alg):
271290
temporary file with a supported file format, to be used to
272291
generate the output result.
273292
"""
274-
275293
ext = self.value[self.value.rfind('.') + 1:]
276-
if ext in alg.provider.getSupportedOutputVectorLayerExtensions():
294+
if ext in self.getSupportedOutputVectorLayerExtensions():
277295
return self.value
278296
else:
279297
if self.compatible is None:
@@ -307,4 +325,5 @@ def getVectorWriter(self, fields, geomType, crs, options=None):
307325
w = VectorWriter(self.value, self.encoding, fields, geomType,
308326
crs, options)
309327
self.layer = w.layer
328+
self.value = w.destination
310329
return w

0 commit comments

Comments
 (0)
Please sign in to comment.