Skip to content
Permalink
Browse files

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


git-svn-id: http://svn.osgeo.org/qgis/trunk@14450 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler
brushtyler committed Oct 29, 2010
1 parent 3b12d74 commit 6253fb72febad3b037895e9d0055ba6840fd0905
@@ -22,7 +22,7 @@ def name():
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):
@@ -18,6 +18,7 @@ def __init__(self, iface):
BasePluginWidget.__init__(self, self.iface, "gdal_merge.py")

self.outputFormat = Utils.fillRasterOutputFormat()
self.extent = None

self.setParamsStatus(
[
@@ -33,6 +34,7 @@ def __init__(self, iface):

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 @@ def fillInputFilesEdit(self):
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 fillOutputFileEdit(self):
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 @@ def getExtent( self ):
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

xMax = res.xMaximum()
xMin = res.xMinimum()
yMax = res.yMaximum()
yMin = res.yMinimum()
rect2 = self.getRectangle( fileName )
if rect2 == None:
continue
res = res.intersect( rect2 )

return ( xMax, yMax, xMin, yMin )
return res
@@ -114,12 +114,12 @@ def fillInputFile( self ):
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,9 +154,12 @@ def fillOutputDir( self ):
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" )
@@ -44,6 +44,7 @@ def __init__(self, iface):
]
)

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 @@ def fillInputFile(self):
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 @@ def fillSourceSRSEdit(self):
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 @@ def getArguments(self):
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():

0 comments on commit 6253fb7

Please sign in to comment.
You can’t perform that action at this time.