mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-19 00:04:52 -04:00
[processing] expose resampling and format options in the gdaladdo
algorithm (fix #20432) These options actually were here but not added to the UI.
This commit is contained in:
parent
84d155eaf0
commit
3d33b9f1e2
@ -30,6 +30,7 @@ import os
|
|||||||
from qgis.PyQt.QtGui import QIcon
|
from qgis.PyQt.QtGui import QIcon
|
||||||
|
|
||||||
from qgis.core import (QgsProcessingException,
|
from qgis.core import (QgsProcessingException,
|
||||||
|
QgsProcessingParameterDefinition,
|
||||||
QgsProcessingParameterRasterLayer,
|
QgsProcessingParameterRasterLayer,
|
||||||
QgsProcessingParameterEnum,
|
QgsProcessingParameterEnum,
|
||||||
QgsProcessingParameterString,
|
QgsProcessingParameterString,
|
||||||
@ -88,6 +89,9 @@ class gdaladdo(GdalAlgorithm):
|
|||||||
options=self.formats,
|
options=self.formats,
|
||||||
allowMultiple=False,
|
allowMultiple=False,
|
||||||
defaultValue=0))
|
defaultValue=0))
|
||||||
|
for p in params:
|
||||||
|
p.setFlags(p.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
|
||||||
|
self.addParameter(p)
|
||||||
|
|
||||||
self.addOutput(QgsProcessingOutputRasterLayer(self.OUTPUT, self.tr('Pyramidized')))
|
self.addOutput(QgsProcessingOutputRasterLayer(self.OUTPUT, self.tr('Pyramidized')))
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ from processing.algs.gdal.translate import translate
|
|||||||
from processing.algs.gdal.warp import warp
|
from processing.algs.gdal.warp import warp
|
||||||
from processing.algs.gdal.fillnodata import fillnodata
|
from processing.algs.gdal.fillnodata import fillnodata
|
||||||
from processing.algs.gdal.rearrange_bands import rearrange_bands
|
from processing.algs.gdal.rearrange_bands import rearrange_bands
|
||||||
|
from processing.algs.gdal.gdaladdo import gdaladdo
|
||||||
|
|
||||||
from processing.tools.system import isWindows
|
from processing.tools.system import isWindows
|
||||||
|
|
||||||
from qgis.core import (QgsProcessingContext,
|
from qgis.core import (QgsProcessingContext,
|
||||||
@ -2369,6 +2371,75 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
|||||||
'-dialect sqlite -sql "SELECT ST_Line_Interpolate_Point(geometry, 0.2) AS geometry,* FROM \'polys2\'" ' +
|
'-dialect sqlite -sql "SELECT ST_Line_Interpolate_Point(geometry, 0.2) AS geometry,* FROM \'polys2\'" ' +
|
||||||
'-f "ESRI Shapefile"'])
|
'-f "ESRI Shapefile"'])
|
||||||
|
|
||||||
|
def testGdalAddo(self):
|
||||||
|
context = QgsProcessingContext()
|
||||||
|
feedback = QgsProcessingFeedback()
|
||||||
|
source = os.path.join(testDataPath, 'dem.tif')
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory() as outdir:
|
||||||
|
alg = gdaladdo()
|
||||||
|
alg.initAlgorithm()
|
||||||
|
|
||||||
|
# defaults
|
||||||
|
self.assertEqual(
|
||||||
|
alg.getConsoleCommands({'INPUT': source,
|
||||||
|
'LEVELS': '2 4 8 16',
|
||||||
|
'CLEAN': False,
|
||||||
|
'RESAMPLING': 0,
|
||||||
|
'FORMAT': 0}, context, feedback),
|
||||||
|
['gdaladdo',
|
||||||
|
source + ' ' + '-r nearest 2 4 8 16'])
|
||||||
|
|
||||||
|
# with "clean" option
|
||||||
|
self.assertEqual(
|
||||||
|
alg.getConsoleCommands({'INPUT': source,
|
||||||
|
'LEVELS': '2 4 8 16',
|
||||||
|
'CLEAN': True,
|
||||||
|
'RESAMPLING': 0,
|
||||||
|
'FORMAT': 0}, context, feedback),
|
||||||
|
['gdaladdo',
|
||||||
|
source + ' ' + '-r nearest -clean 2 4 8 16'])
|
||||||
|
|
||||||
|
# ovr format
|
||||||
|
self.assertEqual(
|
||||||
|
alg.getConsoleCommands({'INPUT': source,
|
||||||
|
'LEVELS': '2 4 8 16',
|
||||||
|
'CLEAN': False,
|
||||||
|
'RESAMPLING': 0,
|
||||||
|
'FORMAT': 1}, context, feedback),
|
||||||
|
['gdaladdo',
|
||||||
|
source + ' ' + '-r nearest -ro 2 4 8 16'])
|
||||||
|
|
||||||
|
# Erdas format
|
||||||
|
self.assertEqual(
|
||||||
|
alg.getConsoleCommands({'INPUT': source,
|
||||||
|
'LEVELS': '2 4 8 16',
|
||||||
|
'CLEAN': False,
|
||||||
|
'RESAMPLING': 0,
|
||||||
|
'FORMAT': 2}, context, feedback),
|
||||||
|
['gdaladdo',
|
||||||
|
source + ' ' + '-r nearest --config USE_RRD YES 2 4 8 16'])
|
||||||
|
|
||||||
|
# custom resampling method format
|
||||||
|
self.assertEqual(
|
||||||
|
alg.getConsoleCommands({'INPUT': source,
|
||||||
|
'LEVELS': '2 4 8 16',
|
||||||
|
'CLEAN': False,
|
||||||
|
'RESAMPLING': 4,
|
||||||
|
'FORMAT': 0}, context, feedback),
|
||||||
|
['gdaladdo',
|
||||||
|
source + ' ' + '-r cubicspline 2 4 8 16'])
|
||||||
|
|
||||||
|
# more levels
|
||||||
|
self.assertEqual(
|
||||||
|
alg.getConsoleCommands({'INPUT': source,
|
||||||
|
'LEVELS': '2 4 8 16 32 64',
|
||||||
|
'CLEAN': False,
|
||||||
|
'RESAMPLING': 0,
|
||||||
|
'FORMAT': 0}, context, feedback),
|
||||||
|
['gdaladdo',
|
||||||
|
source + ' ' + '-r nearest 2 4 8 16 32 64'])
|
||||||
|
|
||||||
|
|
||||||
class TestGdalOgrToPostGis(unittest.TestCase):
|
class TestGdalOgrToPostGis(unittest.TestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user