[QGIS Commit] r15125 - trunk/qgis/python/plugins/GdalTools/tools
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Feb 3 18:18:42 EST 2011
Author: brushtyler
Date: 2011-02-03 15:18:42 -0800 (Thu, 03 Feb 2011)
New Revision: 15125
Modified:
trunk/qgis/python/plugins/GdalTools/tools/doClipper.py
Log:
fixed #3449 making sure the clipping result has the layers order as in TOC
Modified: trunk/qgis/python/plugins/GdalTools/tools/doClipper.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doClipper.py 2011-02-03 15:08:37 UTC (rev 15124)
+++ trunk/qgis/python/plugins/GdalTools/tools/doClipper.py 2011-02-03 23:18:42 UTC (rev 15125)
@@ -53,8 +53,10 @@
def fillInputFiles(self):
self.inputFiles = QStringList()
- # for each active layer
- for i in range(self.canvas.layerCount()):
+ # Reversed list to have the topmost layer as the last one in the list
+ # because "In areas of overlap, the last image will be copied over
+ # earlier ones" (see http://www.gdal.org/gdal_merge.html).
+ for i in range(self.canvas.layerCount()-1, -1, -1):
layer = self.canvas.layer(i)
# only raster layers, but not WMS ones
if layer.type() == layer.RasterLayer and ( not layer.usesProvider() ):
@@ -70,6 +72,9 @@
if self.isVisible() and self.warningDialog.isHidden():
msg = QString( self.tr("No active raster layers. You must add almost one raster layer to continue.") )
self.warningDialog.showMessage(msg)
+
+ # refresh command when there are no active layers
+ self.someValueChanged()
else:
self.warningDialog.hide()
self.extentSelector.start()
@@ -114,6 +119,15 @@
if not self.outputFileEdit.text().isEmpty():
arguments << "-o"
arguments << self.outputFileEdit.text()
+
+ if self.pctCheck.isChecked() and len(self.inputFiles) > 1:
+ # The topmost layer in the TOC is the last one in the list (see above),
+ # but I want to grab the pseudocolor table from the first image (the
+ # topmost layer in the TOC).
+ # Workaround: duplicate the last layer inserting it also as the first
+ # one to grab the pseudocolor table from it.
+ arguments << self.inputFiles[ len(self.inputFiles)-1 ]
+
arguments << self.inputFiles
return arguments
More information about the QGIS-commit
mailing list