Skip to content
Permalink
Browse files
[BACKPORT] fix broken Assign projection functionality in GDALTools and
improve handling output file extension
  • Loading branch information
alexbruy committed Nov 13, 2011
1 parent 19501c6 commit aaae4898a90864d91df61fc14300eb64d30d0f67
Showing with 22 additions and 11 deletions.
  1. +22 −11 python/plugins/GdalTools/tools/doProjection.py
@@ -41,9 +41,6 @@ def __init__( self, iface ):
self.connect( self.batchCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode )
self.connect( self.recurseCheck, SIGNAL( "stateChanged( int )" ), self.enableRecurse )

#QObject.disconnect( self.base.buttonBox.button( QDialogButtonBox.Ok ), SIGNAL( "clicked()" ), self.onRun )
#QObject.connect( self.base.buttonBox.button( QDialogButtonBox.Ok ), SIGNAL( "clicked()" ), self.checkLayer )

def switchToolMode( self ):
self.setCommandViewerEnabled( not self.batchCheck.isChecked() )
self.progressBar.setVisible( self.batchCheck.isChecked() )
@@ -102,11 +99,32 @@ def getArguments( self ):
inputFn = self.getInputFileName()
arguments << inputFn
self.tempFile = QString( inputFn )
self.needOverwrite = False
if not self.tempFile.isEmpty():
self.tempFile = self.tempFile.replace( QRegExp( "\.[a-zA-Z]{2,4}$" ), ".tif" ).append( ".tmp" )
if self.tempFile.toLower().contains( QRegExp( "\.tif{1,2}" ) ):
self.tempFile = self.tempFile.replace( QRegExp( "\.[a-zA-Z]{2,4}$" ), ".tif" ).append( ".tmp" )
self.needOverwrite = True
else:
self.tempFile = self.tempFile.replace( QRegExp( "\.[a-zA-Z]{2,4}$" ), ".tif" )
arguments << self.tempFile
return arguments

def finished( self ):
outFn = self.getOutputFileName()
if self.needOverwrite:
oldFile = QFile( outFn )
newFile = QFile( self.tempFile )
if oldFile.remove():
newFile.rename( outFn )

fileInfo = QFileInfo( outFn )
if fileInfo.exists():
if self.base.loadCheckBox.isChecked():
self.addLayerIntoCanvas( fileInfo )
QMessageBox.information( self, self.tr( "Finished" ), self.tr( "Processing completed." ) )
else:
QMessageBox.warning( self, self.tr( "Warning" ), self.tr( "%1 not created." ).arg( outFn ) )

def getInputFileName(self):
return self.inSelector.filename()

@@ -149,10 +167,3 @@ def updateProgress(self, index, total):
self.progressBar.setValue(index + 1)
else:
self.progressBar.setValue(0)

def finished( self ):
oldFile = QFile( self.getInputFileName() )
newFile = QFile( self.tempFile )
if oldFile.remove():
newFile.rename( self.getInputFileName() )

0 comments on commit aaae489

Please sign in to comment.