mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
address comments, fix test
This commit is contained in:
parent
65d9911e8b
commit
5cd28034bd
@ -2,7 +2,7 @@
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
translate.py
|
||||
rearrange_bands.py
|
||||
---------------------
|
||||
Date : August 2018
|
||||
Copyright : (C) 2018 by Mathieu Pellerin
|
||||
|
@ -52,6 +52,7 @@ from processing.algs.gdal.retile import retile
|
||||
from processing.algs.gdal.translate import translate
|
||||
from processing.algs.gdal.warp import warp
|
||||
from processing.algs.gdal.fillnodata import fillnodata
|
||||
from processing.algs.gdal.rearrange_bands import rearrange_bands
|
||||
|
||||
from qgis.core import (QgsProcessingContext,
|
||||
QgsProcessingFeedback,
|
||||
@ -1532,6 +1533,33 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||
source + ' ' +
|
||||
'd:/temp/check.jpg'])
|
||||
|
||||
def testRearrangeBands(self):
|
||||
context = QgsProcessingContext()
|
||||
feedback = QgsProcessingFeedback()
|
||||
source = os.path.join(testDataPath, 'dem.tif')
|
||||
outsource = 'd:/temp/check.tif'
|
||||
|
||||
alg = rearrange_bands()
|
||||
alg.initAlgorithm()
|
||||
|
||||
# single band
|
||||
self.assertEqual(
|
||||
alg.getConsoleCommands({'INPUT': source,
|
||||
'BANDS': 1,
|
||||
'OUTPUT': outsource}, context, feedback),
|
||||
['gdal_translate', '-b 1 ' +
|
||||
'-ot Float32 -of GTiff ' +
|
||||
source + ' ' + outsource])
|
||||
|
||||
# three bands, re-ordered
|
||||
self.assertEqual(
|
||||
alg.getConsoleCommands({'INPUT': source,
|
||||
'BANDS': [3, 2, 1],
|
||||
'OUTPUT': outsource}, context, feedback),
|
||||
['gdal_translate', '-b 3 -b 2 -b 1 ' +
|
||||
'-ot Float32 -of GTiff ' +
|
||||
source + ' ' + outsource])
|
||||
|
||||
def testFillnodata(self):
|
||||
context = QgsProcessingContext()
|
||||
feedback = QgsProcessingFeedback()
|
||||
|
@ -1703,6 +1703,7 @@ void TestQgsProcessing::parameters()
|
||||
params.insert( QStringLiteral( "string" ), QStringLiteral( "a string" ) );
|
||||
params.insert( QStringLiteral( "double" ), 5.2 );
|
||||
params.insert( QStringLiteral( "int" ), 15 );
|
||||
params.insert( QStringLiteral( "ints" ), QVariant( QList<QVariant>() << 3 << 2 << 1 ) );
|
||||
params.insert( QStringLiteral( "bool" ), true );
|
||||
|
||||
QgsProcessingContext context;
|
||||
@ -1763,6 +1764,12 @@ void TestQgsProcessing::parameters()
|
||||
def->setName( QStringLiteral( "prop" ) );
|
||||
QCOMPARE( QgsProcessingParameters::parameterAsInt( def.get(), params, context ), 6 );
|
||||
|
||||
// as ints
|
||||
def->setName( QStringLiteral( "int" ) );
|
||||
QCOMPARE( QgsProcessingParameters::parameterAsInts( def.get(), params, context ), QList<int>() << 15 );
|
||||
def->setName( QStringLiteral( "ints" ) );
|
||||
QCOMPARE( QgsProcessingParameters::parameterAsInts( def.get(), params, context ), QList<int>() << 3 << 2 << 1 );
|
||||
|
||||
// as bool
|
||||
def->setName( QStringLiteral( "double" ) );
|
||||
QCOMPARE( QgsProcessingParameters::parameterAsBool( def.get(), params, context ), true );
|
||||
|
Loading…
x
Reference in New Issue
Block a user