|
41 | 41 | from processing.algs.gdal.GridInverseDistanceNearestNeighbor import GridInverseDistanceNearestNeighbor
|
42 | 42 | from processing.algs.gdal.GridLinear import GridLinear
|
43 | 43 | from processing.algs.gdal.GridNearestNeighbor import GridNearestNeighbor
|
| 44 | +from processing.algs.gdal.buildvrt import buildvrt |
44 | 45 | from processing.algs.gdal.hillshade import hillshade
|
45 | 46 | from processing.algs.gdal.ogr2ogr import ogr2ogr
|
46 | 47 | from processing.algs.gdal.proximity import proximity
|
@@ -638,6 +639,56 @@ def testGdalCalc(self):
|
638 | 639 | 'OUTPUT': output}, context, feedback),
|
639 | 640 | ['gdal_calc', '--calc "{}" --format JPEG --type Float32 -A {} --A_band 1 --outfile {}'.format(formula, source, output)])
|
640 | 641 |
|
| 642 | + def testBuildVrt(self): |
| 643 | + context = QgsProcessingContext() |
| 644 | + feedback = QgsProcessingFeedback() |
| 645 | + source = os.path.join(testDataPath, 'dem.tif') |
| 646 | + alg = buildvrt() |
| 647 | + alg.initAlgorithm() |
| 648 | + |
| 649 | + commands = alg.getConsoleCommands({'LAYERS': [source], |
| 650 | + 'OUTPUT': 'd:/temp/test.vrt'}, context, feedback) |
| 651 | + self.assertEqual(len(commands), 2) |
| 652 | + self.assertEqual(commands[0], 'gdalbuildvrt') |
| 653 | + self.assertIn('-resolution average', commands[1]) |
| 654 | + self.assertIn('-separate', commands[1]) |
| 655 | + self.assertNotIn('-allow_projection_difference', commands[1]) |
| 656 | + self.assertIn('-input_file_list', commands[1]) |
| 657 | + self.assertIn('d:/temp/test.vrt', commands[1]) |
| 658 | + |
| 659 | + commands = alg.getConsoleCommands({'LAYERS': [source], |
| 660 | + 'RESOLUTION': 2, |
| 661 | + 'OUTPUT': 'd:/temp/test.vrt'}, context, feedback) |
| 662 | + self.assertEqual(len(commands), 2) |
| 663 | + self.assertEqual(commands[0], 'gdalbuildvrt') |
| 664 | + self.assertIn('-resolution lowest', commands[1]) |
| 665 | + self.assertIn('-separate', commands[1]) |
| 666 | + self.assertNotIn('-allow_projection_difference', commands[1]) |
| 667 | + self.assertIn('-input_file_list', commands[1]) |
| 668 | + self.assertIn('d:/temp/test.vrt', commands[1]) |
| 669 | + |
| 670 | + commands = alg.getConsoleCommands({'LAYERS': [source], |
| 671 | + 'SEPARATE': False, |
| 672 | + 'OUTPUT': 'd:/temp/test.vrt'}, context, feedback) |
| 673 | + self.assertEqual(len(commands), 2) |
| 674 | + self.assertEqual(commands[0], 'gdalbuildvrt') |
| 675 | + self.assertIn('-resolution average', commands[1]) |
| 676 | + self.assertNotIn('-allow_projection_difference', commands[1]) |
| 677 | + self.assertNotIn('-separate', commands[1]) |
| 678 | + self.assertIn('-input_file_list', commands[1]) |
| 679 | + self.assertIn('d:/temp/test.vrt', commands[1]) |
| 680 | + |
| 681 | + commands = alg.getConsoleCommands({'LAYERS': [source], |
| 682 | + 'PROJ_DIFFERENCE': True, |
| 683 | + 'OUTPUT': 'd:/temp/test.vrt'}, context, feedback) |
| 684 | + self.assertEqual(len(commands), 2) |
| 685 | + self.assertEqual(commands[0], 'gdalbuildvrt') |
| 686 | + self.assertIn('-resolution average', commands[1]) |
| 687 | + self.assertIn('-allow_projection_difference', commands[1]) |
| 688 | + self.assertIn('-separate', commands[1]) |
| 689 | + self.assertIn('-input_file_list', commands[1]) |
| 690 | + self.assertIn('d:/temp/test.vrt', commands[1]) |
| 691 | + |
641 | 692 | def testGdalTindex(self):
|
642 | 693 | context = QgsProcessingContext()
|
643 | 694 | feedback = QgsProcessingFeedback()
|
|
0 commit comments