Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processing][SAGA] Fix output type for RGB Composite should be tif, n…
…ot sdat format (cherry picked from commit 71b32f0)
- Loading branch information
1 parent
3f0bc70
commit 1440ddd
Showing
4 changed files
with
110 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
*************************************************************************** | ||
SagaParameters.py | ||
--------------------- | ||
Date : December 2018 | ||
Copyright : (C) 2018 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
*************************************************************************** | ||
""" | ||
|
||
|
||
__author__ = 'Nyall Dawson' | ||
__date__ = 'December 2018' | ||
__copyright__ = '(C) 2018, Nyall Dawson' | ||
|
||
# This will get replaced with a git SHA1 when you do a git archive | ||
|
||
__revision__ = '$Format:%H$' | ||
|
||
import os | ||
import importlib | ||
from qgis.core import QgsProcessingParameterRasterDestination | ||
from processing.core.parameters import getParameterFromString | ||
|
||
|
||
class SagaImageOutputParam(QgsProcessingParameterRasterDestination): | ||
|
||
""" | ||
Custom raster destination parameter for SAGA algorithms which create a raster image | ||
output, instead of SAGA's usual 'sdat' raster grid outputs. | ||
These outputs differ from the usual SAGA outputs and are always generated as TIF files instead | ||
of sdat. | ||
""" | ||
|
||
def defaultFileExtension(self): | ||
return 'tif' | ||
|
||
def supportedOutputRasterLayerExtensions(self): | ||
return ['tif'] | ||
|
||
|
||
class Parameters: | ||
|
||
@staticmethod | ||
def is_parameter_line(line): | ||
""" | ||
Returns true if the given line corresponds to a SAGA parameter definition | ||
""" | ||
return line.startswith('SagaImageOutput') or line.startswith('QgsProcessingParameter') or line.startswith('Parameter') or line.startswith('*QgsProcessingParameter') | ||
|
||
@staticmethod | ||
def create_parameter_from_line(line): | ||
""" | ||
Creates a parameter from a definition line. | ||
""" | ||
if line.startswith('SagaImageOutput'): | ||
tokens = line.split("|") | ||
params = [t if str(t) != str(None) else None for t in tokens[1:]] | ||
if len(params) > 3: | ||
params[3] = True if params[3].lower() == 'true' else False | ||
if len(params) > 4: | ||
params[4] = True if params[4].lower() == 'true' else False | ||
return SagaImageOutputParam(*params) | ||
else: | ||
return getParameterFromString(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters