[QGIS Commit] r14450 - in trunk/qgis/python/plugins/GdalTools: .
tools
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Oct 29 18:07:56 EDT 2010
Author: brushtyler
Date: 2010-10-29 15:07:56 -0700 (Fri, 29 Oct 2010)
New Revision: 14450
Modified:
trunk/qgis/python/plugins/GdalTools/__init__.py
trunk/qgis/python/plugins/GdalTools/tools/doMerge.py
trunk/qgis/python/plugins/GdalTools/tools/doTranslate.py
trunk/qgis/python/plugins/GdalTools/tools/doWarp.py
Log:
applied the patch suggested in ticket #3151,
fix in translate to use the GdalTools_utils to get the crs,
managed invalid extent in merge tool
Modified: trunk/qgis/python/plugins/GdalTools/__init__.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/__init__.py 2010-10-29 21:40:17 UTC (rev 14449)
+++ trunk/qgis/python/plugins/GdalTools/__init__.py 2010-10-29 22:07:56 UTC (rev 14450)
@@ -22,7 +22,7 @@
def description():
return "Integrate gdal tools into qgis"
def version():
- return "Version 1.2.10"
+ return "Version 1.2.15"
def qgisMinimumVersion():
return "1.0"
def classFactory(iface):
Modified: trunk/qgis/python/plugins/GdalTools/tools/doMerge.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doMerge.py 2010-10-29 21:40:17 UTC (rev 14449)
+++ trunk/qgis/python/plugins/GdalTools/tools/doMerge.py 2010-10-29 22:07:56 UTC (rev 14450)
@@ -18,6 +18,7 @@
BasePluginWidget.__init__(self, self.iface, "gdal_merge.py")
self.outputFormat = Utils.fillRasterOutputFormat()
+ self.extent = None
self.setParamsStatus(
[
@@ -33,6 +34,7 @@
self.connect(self.selectInputFilesButton, SIGNAL("clicked()"), self.fillInputFilesEdit)
self.connect(self.selectOutputFileButton, SIGNAL("clicked()"), self.fillOutputFileEdit)
+ self.connect(self.intersectCheck, SIGNAL("stateChanged(int)"), self.refreshExtent)
def fillInputFilesEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
@@ -42,13 +44,27 @@
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inputFilesEdit.setText(files.join(","))
+ self.intersectCheck.setEnabled( files.count() > 1 )
+ self.refreshExtent()
+ def refreshExtent(self):
+ files = self.inputFilesEdit.text().split( "," )
if files.count() < 2:
self.intersectCheck.setChecked( False )
- self.intersectCheck.setEnabled( False )
- else:
- self.intersectCheck.setEnabled( True )
- (self.xmax, self.ymax, self.xmin, self.ymin) = self.getExtent()
+ self.extent = None
+ return
+
+ self.extent = self.getExtent()
+ self.someValueChanged()
+
+ if not self.intersectCheck.isChecked():
+ return
+
+ if self.extent == None:
+ QMessageBox.warning( self, self.tr( "Error retrieving the extent" ), self.tr( 'GDAL was unable to retrieve the extent from any file. \nThe "Use intersected extent" option will be unchecked.' ) )
+ self.intersectCheck.setChecked( False )
+ elif self.extent.isEmpty():
+ QMessageBox.warning( self, self.tr( "Empty extent" ), self.tr( 'The computed extent is empty. \nDisable the "Use intersected extent" option to have a nonempty output.' ) )
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
@@ -63,8 +79,12 @@
def getArguments(self):
arguments = QStringList()
if self.intersectCheck.isChecked():
- arguments << "-ul_lr"
- arguments << str( self.xmin ) << str( self.ymax ) << str( self.xmax ) << str( self.ymin )
+ if self.extent != None:
+ arguments << "-ul_lr"
+ arguments << str( self.extent.xMinimum() )
+ arguments << str( self.extent.yMaximum() )
+ arguments << str( self.extent.xMaximum() )
+ arguments << str( self.extent.yMinimum() )
if self.noDataCheck.isChecked():
arguments << "-n"
arguments << str(self.noDataSpin.value())
@@ -117,21 +137,14 @@
files = self.inputFilesEdit.text().split( "," )
i = 0
- while i < files.count():
- if i == 0:
- rect1 = self.getRectangle( files[ 0 ] )
- rect2 = self.getRectangle( files[ 1 ] )
- res = rect1.intersect( rect2 )
- rect1 = res
- i = 2
+ res = rect2 = None
+ for fileName in files:
+ if res == None:
+ res = self.getRectangle( fileName )
continue
- rect2 = self.getRectangle( files[ i ] )
- res = rect1.intersect( rect2 )
- i = i + 1
+ rect2 = self.getRectangle( fileName )
+ if rect2 == None:
+ continue
+ res = res.intersect( rect2 )
- xMax = res.xMaximum()
- xMin = res.xMinimum()
- yMax = res.yMaximum()
- yMin = res.yMinimum()
-
- return ( xMax, yMax, xMin, yMin )
+ return res
Modified: trunk/qgis/python/plugins/GdalTools/tools/doTranslate.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doTranslate.py 2010-10-29 21:40:17 UTC (rev 14449)
+++ trunk/qgis/python/plugins/GdalTools/tools/doTranslate.py 2010-10-29 22:07:56 UTC (rev 14450)
@@ -114,12 +114,12 @@
return
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
- # get SRS for target file if necessary and possible
- self.targetSRSEdit.setText( Utils.getRasterSRS( self, inputFile ) )
-
self.inputLayerCombo.setCurrentIndex(-1)
self.inputLayerCombo.setEditText( inputFile )
+ # get SRS for target file if necessary and possible
+ self.refreshTargetSRS()
+
def fillInputDir( self ):
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files to Translate" ))
if inputDir.isEmpty():
@@ -154,10 +154,13 @@
self.outputFileEdit.setText( outputDir )
def fillTargetSRSEditDefault(self, index):
- if index >= 0 and index in self.layers:
- layer = self.layers[index]
- self.targetSRSEdit.setText("EPSG:" + str(layer.srs().epsg()))
+ if index < 0:
+ return
+ self.refreshTargetSRS()
+ def refreshTargetSRS(self):
+ self.targetSRSEdit.setText( Utils.getRasterSRS( self, self.getInputFileName() ) )
+
def fillTargetSRSEdit(self):
dialog = SRSDialog( "Select the target SRS" )
if dialog.exec_():
Modified: trunk/qgis/python/plugins/GdalTools/tools/doWarp.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doWarp.py 2010-10-29 21:40:17 UTC (rev 14449)
+++ trunk/qgis/python/plugins/GdalTools/tools/doWarp.py 2010-10-29 22:07:56 UTC (rev 14450)
@@ -44,6 +44,7 @@
]
)
+ self.connect(self.inputLayerCombo, SIGNAL("currentIndexChanged(int)"), self.fillSourceSRSEditDefault)
self.connect(self.selectInputFileButton, SIGNAL("clicked()"), self.fillInputFile)
self.connect(self.selectOutputFileButton, SIGNAL("clicked()"), self.fillOutputFileEdit)
self.connect(self.selectSourceSRSButton, SIGNAL("clicked()"), self.fillSourceSRSEdit)
@@ -100,12 +101,12 @@
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
- # get SRS for source file if necessary and possible
- self.sourceSRSEdit.setText( Utils.getRasterSRS( self, inputFile ) )
-
self.inputLayerCombo.setCurrentIndex(-1)
self.inputLayerCombo.setEditText(inputFile)
+ # get SRS for source file if necessary and possible
+ self.refreshSourceSRS()
+
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
@@ -144,6 +145,16 @@
if dialog.exec_():
self.sourceSRSEdit.setText(dialog.getProjection())
+ def fillSourceSRSEditDefault(self, index):
+ if index < 0:
+ return
+ self.refreshSourceSRS()
+
+ def refreshSourceSRS(self):
+ crs = Utils.getRasterSRS( self, self.getInputFileName() )
+ self.sourceSRSEdit.setText( crs )
+ self.sourceSRSCheck.setChecked( not crs.isEmpty() )
+
def fillTargetSRSEdit(self):
dialog = SRSDialog( "Select the target SRS" )
if dialog.exec_():
@@ -164,7 +175,7 @@
arguments << "-wm"
arguments << str(self.cacheSpin.value())
if self.resizeGroupBox.isChecked():
- arguments << "-ts"
+ arguments << "-ts"
arguments << str( self.widthSpin.value() )
arguments << str( self.heightSpin.value() )
if self.multithreadCheck.isChecked():
More information about the QGIS-commit
mailing list