Skip to content

Commit

Permalink
fix GdalTools assign and extract projection
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed Jun 14, 2013
1 parent 5e98be1 commit 684aa98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions python/plugins/GdalTools/tools/doExtractProj.py
Expand Up @@ -79,14 +79,14 @@ def switchToolMode( self ):
def fillInputFileEdit( self ):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName( self, self.tr( "Select the file to analyse" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
if inputFile.isEmpty():
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
self.inSelector.setFilename( inputFile )

def fillInputDir( self ):
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files to Assign projection" ))
if inputDir.isEmpty():
if not inputDir:
return
self.inSelector.setFilename( inputDir )

Expand Down
25 changes: 13 additions & 12 deletions python/plugins/GdalTools/tools/doProjection.py
Expand Up @@ -34,6 +34,7 @@
import GdalTools_utils as Utils

import os.path
import re


class GdalToolsDialog( QWidget, Ui_Widget, BaseBatchWidget ):
Expand Down Expand Up @@ -96,14 +97,14 @@ def enableRecurse( self ):
def fillInputFileEdit( self ):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName( self, self.tr( "Select the file to analyse" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
if inputFile.isEmpty():
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
self.inSelector.setFilename( inputFile )

def fillInputDir( self ):
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files to Assign projection" ))
if inputDir.isEmpty():
if not inputDir:
return
self.inSelector.setFilename( inputDir )

Expand All @@ -113,24 +114,24 @@ def fillDesiredSRSEdit( self ):
self.desiredSRSEdit.setText( dialog.getProjection() )

def getArguments( self ):
arguments = QStringList()
if not self.desiredSRSEdit.text().isEmpty():
arguments << "-t_srs"
arguments << self.desiredSRSEdit.text()
arguments = []
if self.desiredSRSEdit.text():
arguments.append("-t_srs")
arguments.append(self.desiredSRSEdit.text())
if self.batchCheck.isChecked():
return arguments

inputFn = self.getInputFileName()
arguments << inputFn
arguments.append(inputFn)
self.tempFile = inputFn
self.needOverwrite = False
if not self.tempFile.isEmpty():
if self.tempFile.toLower().contains( QRegExp( "\.tif{1,2}" ) ):
self.tempFile = self.tempFile.replace( QRegExp( "\.[a-zA-Z]{2,4}$" ), ".tif" ).append( ".tmp" )
if self.tempFile:
if self.tempFile.lower().endswith(".tif") or self.tempFile.lower().endswith(".tiff") :
self.tempFile = re.sub("\.[a-zA-Z]{2,4}$", ".tif", self.tempFile) + ".tmp"
self.needOverwrite = True
else:
self.tempFile = self.tempFile.replace( QRegExp( "\.[a-zA-Z]{2,4}$" ), ".tif" )
arguments << self.tempFile
self.tempFile = re.sub("\.[a-zA-Z]{2,4}$", ".tif", self.tempFile)
arguments.append(self.tempFile)
return arguments

def finished( self ):
Expand Down

0 comments on commit 684aa98

Please sign in to comment.