Skip to content

Commit

Permalink
[processing] explisitly load outputs as raster or vector depending on
Browse files Browse the repository at this point in the history
output type. Don't rely on extension or other indirect attributes
  • Loading branch information
alexbruy committed May 26, 2017
1 parent cea93fa commit cd7dfda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions python/plugins/processing/gui/Postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ def handleAlgorithmResults(alg, progress=None, showResults=True):
name = os.path.basename(out.value)
else:
name = out.description

isRaster = True if isinstance(out, OutputRaster) else False
dataobjects.load(out.value, name, alg.crs,
RenderingStyles.getStyle(alg.commandLineName(),
out.name))
RenderingStyles.getStyle(alg.commandLineName(), out.name),
isRaster)
except Exception:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
"Error loading result layer:\n" + traceback.format_exc())
Expand Down
5 changes: 2 additions & 3 deletions python/plugins/processing/tools/dataobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def loadList(layers):
load(layer)


def load(fileName, name=None, crs=None, style=None):
def load(fileName, name=None, crs=None, style=None, isRaster=False):
"""Loads a layer/table into the current project, given its file.
"""

Expand All @@ -170,8 +170,7 @@ def load(fileName, name=None, crs=None, style=None):
if name is None:
name = os.path.split(fileName)[1]

suffix = os.path.splitext(fileName)[1][1:]
if suffix in getSupportedOutputRasterLayerExtensions():
if isRaster:
qgslayer = QgsRasterLayer(fileName, name)
if qgslayer.isValid():
if crs is not None and qgslayer.crs() is None:
Expand Down

0 comments on commit cd7dfda

Please sign in to comment.