|
59 | 59 | from processing.algs.gdal.warp import warp
|
60 | 60 | from processing.algs.gdal.fillnodata import fillnodata
|
61 | 61 | from processing.algs.gdal.rearrange_bands import rearrange_bands
|
| 62 | +from processing.algs.gdal.gdaladdo import gdaladdo |
| 63 | + |
62 | 64 | from processing.tools.system import isWindows
|
63 | 65 |
|
64 | 66 | from qgis.core import (QgsProcessingContext,
|
@@ -2369,6 +2371,75 @@ def testPointsAlongLines(self):
|
2369 | 2371 | '-dialect sqlite -sql "SELECT ST_Line_Interpolate_Point(geometry, 0.2) AS geometry,* FROM \'polys2\'" ' +
|
2370 | 2372 | '-f "ESRI Shapefile"'])
|
2371 | 2373 |
|
| 2374 | + def testGdalAddo(self): |
| 2375 | + context = QgsProcessingContext() |
| 2376 | + feedback = QgsProcessingFeedback() |
| 2377 | + source = os.path.join(testDataPath, 'dem.tif') |
| 2378 | + |
| 2379 | + with tempfile.TemporaryDirectory() as outdir: |
| 2380 | + alg = gdaladdo() |
| 2381 | + alg.initAlgorithm() |
| 2382 | + |
| 2383 | + # defaults |
| 2384 | + self.assertEqual( |
| 2385 | + alg.getConsoleCommands({'INPUT': source, |
| 2386 | + 'LEVELS': '2 4 8 16', |
| 2387 | + 'CLEAN': False, |
| 2388 | + 'RESAMPLING': 0, |
| 2389 | + 'FORMAT': 0}, context, feedback), |
| 2390 | + ['gdaladdo', |
| 2391 | + source + ' ' + '-r nearest 2 4 8 16']) |
| 2392 | + |
| 2393 | + # with "clean" option |
| 2394 | + self.assertEqual( |
| 2395 | + alg.getConsoleCommands({'INPUT': source, |
| 2396 | + 'LEVELS': '2 4 8 16', |
| 2397 | + 'CLEAN': True, |
| 2398 | + 'RESAMPLING': 0, |
| 2399 | + 'FORMAT': 0}, context, feedback), |
| 2400 | + ['gdaladdo', |
| 2401 | + source + ' ' + '-r nearest -clean 2 4 8 16']) |
| 2402 | + |
| 2403 | + # ovr format |
| 2404 | + self.assertEqual( |
| 2405 | + alg.getConsoleCommands({'INPUT': source, |
| 2406 | + 'LEVELS': '2 4 8 16', |
| 2407 | + 'CLEAN': False, |
| 2408 | + 'RESAMPLING': 0, |
| 2409 | + 'FORMAT': 1}, context, feedback), |
| 2410 | + ['gdaladdo', |
| 2411 | + source + ' ' + '-r nearest -ro 2 4 8 16']) |
| 2412 | + |
| 2413 | + # Erdas format |
| 2414 | + self.assertEqual( |
| 2415 | + alg.getConsoleCommands({'INPUT': source, |
| 2416 | + 'LEVELS': '2 4 8 16', |
| 2417 | + 'CLEAN': False, |
| 2418 | + 'RESAMPLING': 0, |
| 2419 | + 'FORMAT': 2}, context, feedback), |
| 2420 | + ['gdaladdo', |
| 2421 | + source + ' ' + '-r nearest --config USE_RRD YES 2 4 8 16']) |
| 2422 | + |
| 2423 | + # custom resampling method format |
| 2424 | + self.assertEqual( |
| 2425 | + alg.getConsoleCommands({'INPUT': source, |
| 2426 | + 'LEVELS': '2 4 8 16', |
| 2427 | + 'CLEAN': False, |
| 2428 | + 'RESAMPLING': 4, |
| 2429 | + 'FORMAT': 0}, context, feedback), |
| 2430 | + ['gdaladdo', |
| 2431 | + source + ' ' + '-r cubicspline 2 4 8 16']) |
| 2432 | + |
| 2433 | + # more levels |
| 2434 | + self.assertEqual( |
| 2435 | + alg.getConsoleCommands({'INPUT': source, |
| 2436 | + 'LEVELS': '2 4 8 16 32 64', |
| 2437 | + 'CLEAN': False, |
| 2438 | + 'RESAMPLING': 0, |
| 2439 | + 'FORMAT': 0}, context, feedback), |
| 2440 | + ['gdaladdo', |
| 2441 | + source + ' ' + '-r nearest 2 4 8 16 32 64']) |
| 2442 | + |
2372 | 2443 |
|
2373 | 2444 | class TestGdalOgrToPostGis(unittest.TestCase):
|
2374 | 2445 |
|
|
0 commit comments