Skip to content
Permalink
Browse files
[processing] take in account file extension when loading Processing
results (fix #16486)
  • Loading branch information
alexbruy committed May 12, 2017
1 parent aa0ce1c commit 3d3b6ecb1f2de18b55be4756dff48f05fb8863a7
Showing with 18 additions and 14 deletions.
  1. +18 −14 python/plugins/processing/tools/dataobjects.py
@@ -169,20 +169,9 @@ def load(fileName, name=None, crs=None, style=None):
settings.setValue('/Projections/defaultBehaviour', '')
if name is None:
name = os.path.split(fileName)[1]
qgslayer = QgsVectorLayer(fileName, name, 'ogr')
if qgslayer.isValid():
if crs is not None and qgslayer.crs() is None:
qgslayer.setCrs(crs, False)
if style is None:
if qgslayer.geometryType() == QGis.Point:
style = ProcessingConfig.getSetting(ProcessingConfig.VECTOR_POINT_STYLE)
elif qgslayer.geometryType() == QGis.Line:
style = ProcessingConfig.getSetting(ProcessingConfig.VECTOR_LINE_STYLE)
else:
style = ProcessingConfig.getSetting(ProcessingConfig.VECTOR_POLYGON_STYLE)
qgslayer.loadNamedStyle(style)
QgsMapLayerRegistry.instance().addMapLayers([qgslayer])
else:

suffix = os.path.splitext(fileName)[1][1:]
if suffix in getSupportedOutputRasterLayerExtensions():
qgslayer = QgsRasterLayer(fileName, name)
if qgslayer.isValid():
if crs is not None and qgslayer.crs() is None:
@@ -197,6 +186,21 @@ def load(fileName, name=None, crs=None, style=None):
settings.setValue('/Projections/defaultBehaviour', prjSetting)
raise RuntimeError('Could not load layer: ' + unicode(fileName)
+ '\nCheck the processing framework log to look for errors')
else:
qgslayer = QgsVectorLayer(fileName, name, 'ogr')
if qgslayer.isValid():
if crs is not None and qgslayer.crs() is None:
qgslayer.setCrs(crs, False)
if style is None:
if qgslayer.geometryType() == QGis.Point:
style = ProcessingConfig.getSetting(ProcessingConfig.VECTOR_POINT_STYLE)
elif qgslayer.geometryType() == QGis.Line:
style = ProcessingConfig.getSetting(ProcessingConfig.VECTOR_LINE_STYLE)
else:
style = ProcessingConfig.getSetting(ProcessingConfig.VECTOR_POLYGON_STYLE)
qgslayer.loadNamedStyle(style)
QgsMapLayerRegistry.instance().addMapLayers([qgslayer])

if prjSetting:
settings.setValue('/Projections/defaultBehaviour', prjSetting)

0 comments on commit 3d3b6ec

Please sign in to comment.