Skip to content
Permalink
Browse files

[gdaltools] More SIP API update

  • Loading branch information
m-kuhn committed Jun 17, 2013
1 parent 1f10010 commit 4386860998f981645707c067e9751bc4c58a025b
@@ -293,7 +293,7 @@ def getRasterSRS( parent, fileName ):
if processSRS.waitForFinished():
arr = processSRS.readAllStandardOutput()
processSRS.close()

arr = str(arr)
if arr == '':
return ''
@@ -545,7 +545,7 @@ def getSupportedRasters(self):
# XXX add check for SDTS; in that case we want (*CATD.DDF)

#TODO fix and test
#glob << QString("*." + extensions.replace("/", " *.")).split(" ")
#glob.append( QString("*." + extensions.replace("/", " *.")).split(" "))
glob.append(string.split("*." + string.replace(extensions,"/", " *."), sep=(" ")))

# Add only the first JP2 driver found to the filter list (it's the one GDAL uses)
@@ -837,7 +837,7 @@ def setProcessEnvironment(process):
if env.contains( QRegExp( "^%s=(.*)" % name, Qt.CaseInsensitive ) ):
env.replaceInStrings( QRegExp( "^%s=(.*)" % name, Qt.CaseInsensitive ), "%s=\\1%s%s" % (name, sep, gdalPath) )
else:
env << "%s=%s" % (name, val)
env.append( "%s=%s" % (name, val))
process.setEnvironment( env )


@@ -140,7 +140,7 @@ def getArgsModeExtent(self):
arguments = []
if self.noDataCheck.isChecked():
arguments.append("-a_nodata")
arguments << str(self.noDataSpin.value())
arguments.append( str(self.noDataSpin.value()))
if self.extentModeRadio.isChecked() and self.extentSelector.isCoordsValid():
rect = self.extentSelector.getExtent()
if rect != None:
@@ -99,7 +99,7 @@ def onLayersChanged(self):
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the file for DEM" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if inputFile.isEmpty():
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)

@@ -109,7 +109,7 @@ def fillInputFileEdit(self):
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 )
if outputFile.isEmpty():
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)

@@ -119,52 +119,52 @@ def fillOutputFileEdit(self):

def fillColorConfigFileEdit(self):
configFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the color configuration file" ))
if configFile.isEmpty():
if not configFile:
return
self.configSelector.setFilename(configFile)

def getArguments(self):
mode = self.modes[ self.modeCombo.currentIndex() ]
arguments = QStringList()
arguments << mode
arguments << self.getInputFileName()
arguments = []
arguments.append( mode)
arguments.append( self.getInputFileName())
if mode == "color-relief":
arguments << self.configSelector.filename()
arguments.append( self.configSelector.filename())
outputFn = self.getOutputFileName()
arguments << outputFn
arguments.append( outputFn)
if mode == "hillshade":
arguments << "-z" << str(self.hillshadeZFactorSpin.value())
arguments << "-s" << str(self.hillshadeScaleSpin.value())
arguments << "-az" << str(self.hillshadeAzimuthSpin.value())
arguments << "-alt" << str(self.hillshadeAltitudeSpin.value())
arguments.extend( "-z", self.hillshadeZFactorSpin.value())
arguments.extend( "-s" , self.hillshadeScaleSpin.value())
arguments.extend( "-az" , self.hillshadeAzimuthSpin.value())
arguments.extend( "-alt" , self.hillshadeAltitudeSpin.value())
elif mode == "slope":
if self.slopePercentCheck.isChecked():
arguments << "-p"
arguments << "-s" << str(self.slopeScaleSpin.value())
arguments.append( "-p")
arguments.extend( "-s" , self.slopeScaleSpin.value())
elif mode == "aspect":
if self.aspectTrigonometricCheck.isChecked():
arguments << "-trigonometric"
arguments.append( "-trigonometric")
if self.aspectZeroForFlatCheck.isChecked():
arguments << "-zero_for_flat"
arguments.append( "-zero_for_flat")
elif mode == "color-relief":
if self.colorAlphaCheck.isChecked():
arguments << "-alpha"
arguments.append( "-alpha")
if self.colorMatchGroupBox.isChecked():
if self.colorExactRadio.isChecked():
arguments << "-exact_color_entry"
arguments.append( "-exact_color_entry")
elif self.colorNearestRadio.isChecked():
arguments << "-nearest_color_entry"
arguments.append( "-nearest_color_entry")
if self.algorithmCheck.isChecked():
arguments << "-alg" << "ZevenbergenThorne"
arguments.extend( "-alg", "ZevenbergenThorne")
if self.computeEdgesCheck.isChecked():
arguments << "-compute_edges"
arguments.append( "-compute_edges")
if self.bandCheck.isChecked():
arguments << "-b" << str(self.bandSpin.value())
if not outputFn.isEmpty():
arguments << "-of" << self.outputFormat
arguments.extend( "-b" , self.bandSpin.value())
if outputFn:
arguments.extend( "-of", self.outputFormat)
if self.creationOptionsGroupBox.isChecked():
for opt in self.creationOptionsWidget.options():
arguments << "-co" << opt
arguments.extend( "-co", opt)
# set creation options filename/layer for validation
if self.inSelector.layer():
self.creationOptionsWidget.setRasterLayer(self.inSelector.layer())
@@ -111,15 +111,15 @@ def fillInputFile( self ):
self.tr( "Select the files to analyse" ),
Utils.FileFilter.allRastersFilter(),
lastUsedFilter )
if inputFile.isEmpty():
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
self.inSelector.setFilename( inputFile )

def fillOutputFile( 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 )
if outputFile.isEmpty():
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )

@@ -132,52 +132,52 @@ def fillMaskFile( self ):
self.tr( "Select the files to analyse" ),
Utils.FileFilter.allRastersFilter(),
lastUsedFilter )
if inputFile.isEmpty():
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
self.maskSelector.setFilename( inputFile )

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

def fillOutputDir( self ):
outputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the output directory to save the results to" ) )
if outputDir.isEmpty():
if not outputDir:
return
self.outSelector.setFilename( outputDir )

def getArguments(self):
arguments = QStringList()
arguments = []
maskFile = self.maskSelector.filename()
if self.distanceCheck.isChecked() and self.distanceSpin.value() != 0:
arguments << "-md"
arguments << self.distanceSpin.text()
arguments.append( "-md")
arguments.append( self.distanceSpin.text())
if self.smoothCheck.isChecked() and self.smoothSpin.value() != 0:
arguments << "-si"
arguments << str( self.smoothSpin.value() )
arguments.append( "-si")
arguments.append( str( self.smoothSpin.value() ))
if self.bandCheck.isChecked() and self.bandSpin.value() != 0:
arguments << "-b"
arguments << str( self.bandSpin.value() )
if self.maskCheck.isChecked() and not maskFile.isEmpty():
arguments << "-mask"
arguments << maskFile
arguments.append( "-b")
arguments.append( str( self.bandSpin.value() ))
if self.maskCheck.isChecked() and maskFile:
arguments.append( "-mask")
arguments.append( maskFile)
if self.nomaskCheck.isChecked():
arguments << "-nomask"
arguments.append( "-nomask")
if self.isBatchEnabled():
if self.formatCombo.currentIndex() != 0:
arguments << "-of"
arguments << Utils.fillRasterOutputFormat( self.formatCombo.currentText() )
arguments.append( "-of")
arguments.append( Utils.fillRasterOutputFormat( self.formatCombo.currentText() ))
return arguments
else:
outputFn = self.getOutputFileName()
if not outputFn.isEmpty():
arguments << "-of"
arguments << self.outputFormat
arguments << self.getInputFileName()
arguments << outputFn
if outputFn:
arguments.append( "-of")
arguments.append( self.outputFormat)
arguments.append( self.getInputFileName())
arguments.append( outputFn)
return arguments

def onLayersChanged( self ):
@@ -206,7 +206,7 @@ def updateProgress(self, index, total):

def batchRun(self):
exts = self.formatCombo.currentText().remove( QRegExp('^.*\(') ).remove( QRegExp('\).*$') ).split( " " )
if not exts.isEmpty() and exts != "*" and exts != "*.*":
if exts and exts != "*" and exts != "*.*":
outExt = exts[ 0 ].remove( "*" )
else:
outExt = ".tif"
@@ -232,7 +232,7 @@ def batchRun(self):
outFile = re.sub( f, "\.[a-zA-Z0-9]{2,4}", outExt )
self.outFiles.append( outDir + "/" + outFile )

self.errors = QStringList()
self.errors = []
self.batchIndex = 0
self.batchTotal = len( self.inFiles )
self.setProgressRange( self.batchTotal )
@@ -102,7 +102,7 @@ def fillFieldsCombo(self):
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
inputFile, encoding = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the input file for Grid" ), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True)
if inputFile.isEmpty():
if not inputFile:
return
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)

@@ -114,44 +114,44 @@ def fillInputFileEdit(self):
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 )
if outputFile.isEmpty():
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)

self.outputFormat = Utils.fillRasterOutputFormat( lastUsedFilter, outputFile )
self.outSelector.setFilename(outputFile)

def getArguments(self):
arguments = QStringList()
arguments = []
if self.zfieldCheck.isChecked() and self.zfieldCombo.currentIndex() >= 0:
arguments << "-zfield"
arguments << self.zfieldCombo.currentText()
arguments.append( "-zfield")
arguments.append( self.zfieldCombo.currentText())
inputFn = self.getInputFileName()
if not inputFn.isEmpty():
arguments << "-l"
arguments << QFileInfo( inputFn ).baseName()
if inputFn:
arguments.append( "-l")
arguments.append( QFileInfo( inputFn ).baseName())
if self.extentGroup.isChecked():
rect = self.extentSelector.getExtent()
if rect != None:
arguments << "-txe"
arguments << str(rect.xMinimum())
arguments << str(rect.xMaximum())
arguments << "-tye"
arguments << str(rect.yMaximum())
arguments << str(rect.yMinimum())
arguments.append( "-txe")
arguments.append( str(rect.xMinimum()))
arguments.append( str(rect.xMaximum()))
arguments.append( "-tye")
arguments.append( str(rect.yMaximum()))
arguments.append( str(rect.yMinimum()))
if self.algorithmCheck.isChecked() and self.algorithmCombo.currentIndex() >= 0:
arguments << "-a"
arguments << self.algorithmArguments(self.algorithmCombo.currentIndex())
arguments.append( "-a")
arguments.append( self.algorithmArguments(self.algorithmCombo.currentIndex()))
if self.resizeGroupBox.isChecked():
arguments << "-outsize"
arguments << str( self.widthSpin.value() )
arguments << str( self.heightSpin.value() )
arguments.append( "-outsize")
arguments.append( str( self.widthSpin.value() ))
arguments.append( str( self.heightSpin.value() ))
outputFn = self.getOutputFileName()
if not outputFn.isEmpty():
arguments << "-of"
arguments << self.outputFormat
arguments << inputFn
arguments << outputFn
if outputFn:
arguments.append( "-of")
arguments.append( self.outputFormat)
arguments.append( inputFn)
arguments.append( outputFn)
return arguments

def getInputFileName(self):
@@ -165,7 +165,7 @@ def addLayerIntoCanvas(self, fileInfo):

def algorithmArguments(self, index):
algorithm = self.algorithm[index]
arguments = QStringList()
arguments = []
if algorithm == "invdist":
arguments.append(algorithm)
arguments.append("power=" + str(self.invdistPowerSpin.value()))
@@ -201,7 +201,7 @@ def algorithmArguments(self, index):
def loadFields(self, vectorFile = ''):
self.zfieldCombo.clear()

if vectorFile.isEmpty():
if not vectorFile:
return

try:
@@ -65,7 +65,7 @@ def onLayersChanged(self):
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the input file for Near Black" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
if inputFile.isEmpty():
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)

@@ -74,22 +74,22 @@ def fillInputFileEdit(self):
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)
if outputFile.isEmpty():
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)

self.outSelector.setFilename(outputFile)

def getArguments(self):
arguments = QStringList()
arguments = []
if self.whiteCheckBox.isChecked():
arguments << "-white"
arguments.append( "-white")
if self.nearCheck.isChecked():
arguments << "-near"
arguments << str(self.nearSpin.value())
arguments << "-o"
arguments << self.getOutputFileName()
arguments << self.getInputFileName()
arguments.append( "-near")
arguments.append( str(self.nearSpin.value()))
arguments.append( "-o")
arguments.append( self.getOutputFileName())
arguments.append( self.getInputFileName())
return arguments

def getOutputFileName(self):

0 comments on commit 4386860

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