Skip to content
Permalink
Browse files
use raster format and pyramid save widgets in gdaltools (translate, d…
…em, pyramids)
  • Loading branch information
etiennesky committed Jan 18, 2013
1 parent 0c0f088 commit c279ec220220209bb8a234c7c7994a31bd1a417c
@@ -60,15 +60,17 @@ def __init__(self, iface):
self.configSelector.setFilename(colorConfigFile)

self.outputFormat = Utils.fillRasterOutputFormat()
self.creationOptionsWidget.setFormat(self.outputFormat)

self.setParamsStatus(
[
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.computeEdgesCheck, SIGNAL("stateChanged(int)"), None, "1.8.0"),
(self.computeEdgesCheck, SIGNAL("stateChanged(int)"), None, 1800),
(self.bandSpin, SIGNAL("valueChanged(int)"), self.bandCheck),
(self.algorithmCheck, SIGNAL("stateChanged(int)"), None, "1.8.0"),
(self.creationOptionsTable, [SIGNAL("cellValueChanged(int, int)"), SIGNAL("rowRemoved()")], self.creationGroupBox),
(self.algorithmCheck, SIGNAL("stateChanged(int)"), None, 1800),
(self.creationOptionsWidget, SIGNAL("optionsChanged()")),
(self.creationOptionsGroupBox, SIGNAL("toggled(bool)")),
(self.modeCombo, SIGNAL("currentIndexChanged(int)")),
([self.hillshadeZFactorSpin, self.hillshadeScaleSpin, self.hillshadeAltitudeSpin, self.hillshadeAzimuthSpin], SIGNAL("valueChanged(double)")),
(self.slopeScaleSpin, SIGNAL("valueChanged(double)")),
@@ -102,6 +104,7 @@ def fillInputFileEdit(self):
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)

self.inSelector.setFilename(inputFile)
self.getArguments()

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
@@ -112,6 +115,7 @@ def fillOutputFileEdit(self):

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

def fillColorConfigFileEdit(self):
configFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the color configuration file" ))
@@ -158,9 +162,15 @@ def getArguments(self):
arguments << "-b" << str(self.bandSpin.value())
if not outputFn.isEmpty():
arguments << "-of" << self.outputFormat
if self.creationGroupBox.isChecked():
for opt in self.creationOptionsTable.options():
if self.creationOptionsGroupBox.isChecked():
for opt in self.creationOptionsWidget.options():
arguments << "-co" << opt
# set creation options filename/layer for validation
if self.inSelector.layer():
self.creationOptionsWidget.setRasterLayer(self.inSelector.layer())
else:
self.creationOptionsWidget.setRasterFileName(self.getInputFileName())

return arguments

def getInputFileName(self):
@@ -54,21 +54,24 @@ def __init__( self, iface ):

self.setParamsStatus(
[
(self.inSelector, SIGNAL("filenameChanged()")),
( self.inSelector, SIGNAL("filenameChanged()")),
( self.algorithmCombo, SIGNAL( "currentIndexChanged( int )" ), self.algorithmCheck ),
( self.levelsEdit, SIGNAL( "textChanged( const QString & )" ) ),
( self.roModeCheck, SIGNAL( "stateChanged( int )" ), None, "1.6.0" ),
( self.roModeCheck, SIGNAL( "stateChanged( int )" ), None, 1600 ),
( self.rrdCheck, SIGNAL( "stateChanged(int)" ) ),
( self.jpegQualitySpin, SIGNAL( "valueChanged (int)" ) ),
( self.jpegQualityContainer, None, self.tiffjpegCheck),
( self.jpegQualityContainer, None, None, "1.7.0"),
( self.cleanCheck, SIGNAL( "stateChanged(int)" ), None, "1.7.0" )
( self.jpegQualityContainer, None, None, 1700),
( self.cleanCheck, SIGNAL( "stateChanged(int)" ), None, 1700 ),
( self.mPyramidOptionsWidget, SIGNAL( "overviewListChanged()" )),
( self.mPyramidOptionsWidget, SIGNAL( "someValueChanged()" ))
]
)

self.connect( self.inSelector, SIGNAL( "selectClicked()" ), self.fillInputFile )
self.connect( self.batchCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode )

self.init = False #workaround bug that pyramid options widgets are not initialized at first

# switch to batch or normal mode
def switchToolMode( self ):
@@ -101,6 +104,8 @@ def fillInputFile( self ):

self.inSelector.setFilename( inputFile )

self.mPyramidOptionsWidget.setRasterLayer(None)

def fillInputDir( self ):
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files" ))
if inputDir.isEmpty():
@@ -110,27 +115,44 @@ def fillInputDir( self ):

def getArguments( self ):
arguments = QStringList()
if self.algorithmCheck.isChecked() and self.algorithmCombo.currentIndex() >= 0:
arguments << "-r"
arguments << self.resampling_method[self.algorithmCombo.currentIndex()]
if self.roModeCheck.isChecked():

arguments << "-r"
arguments << self.mPyramidOptionsWidget.resamplingMethod();

format = self.mPyramidOptionsWidget.pyramidsFormat()
if format == QgsRasterDataProvider.PyramidsGTiff:
arguments << "-ro"
if self.rrdCheck.isChecked():
elif format == QgsRasterDataProvider.PyramidsErdas:
arguments << "--config" << "USE_RRD" << "YES"
if self.tiffjpegCheck.isChecked():
arguments << "--config" << "COMPRESS_OVERVIEW" << "JPEG" << "--config" << "PHOTOMETRIC_OVERVIEW" << "YCBCR" << "--config" << "INTERLEAVE_OVERVIEW" << "PIXEL"
if self.jpegQualityContainer.isVisible():
arguments << "--config" << "JPEG_QUALITY_OVERVIEW" << self.jpegQualitySpin.cleanText()

for option in self.mPyramidOptionsWidget.configOptions():
(k,v) = option.split("=")
arguments << "--config" << str(k) << str(v)

if self.cleanCheck.isChecked():
arguments << "-clean"

if self.isBatchEnabled():
return arguments

arguments << self.getInputFileName()
if not self.levelsEdit.text().isEmpty():
arguments << self.levelsEdit.text().split( " " )

if len(self.mPyramidOptionsWidget.overviewList()) == 0:
arguments << "[levels]"
for level in self.mPyramidOptionsWidget.overviewList():
arguments << str(level)

# set creation options filename/layer for validation
if self.init:
if self.isBatchEnabled():
self.mPyramidOptionsWidget.setRasterLayer(None)
elif self.inSelector.layer():
self.mPyramidOptionsWidget.setRasterLayer(self.inSelector.layer())
else:
self.mPyramidOptionsWidget.setRasterFileName(self.getInputFileName())
else:
arguments << "2" << "4" << "8" << "16" << "32"
self.init = True

return arguments

def getInputFileName( self ):
@@ -67,10 +67,10 @@ def __init__(self, iface):
(self.outSelector, SIGNAL("filenameChanged()")),
(self.targetSRSEdit, SIGNAL("textChanged(const QString &)"), self.targetSRSCheck),
(self.selectTargetSRSButton, None, self.targetSRSCheck),
(self.creationOptionsTable, [SIGNAL("cellValueChanged(int, int)"), SIGNAL("rowRemoved()")], self.creationGroupBox),
(self.creationOptionsWidget, SIGNAL("optionsChanged()")),
(self.outsizeSpin, SIGNAL("valueChanged(const QString &)"), self.outsizeCheck),
(self.nodataSpin, SIGNAL("valueChanged(int)"), self.nodataCheck),
(self.expandCombo, SIGNAL("currentIndexChanged(int)"), self.expandCheck, "1.6.0"),
(self.expandCombo, SIGNAL("currentIndexChanged(int)"), self.expandCheck, 1600),
(self.sdsCheck, SIGNAL("stateChanged(int)")),
(self.srcwinEdit, SIGNAL("textChanged(const QString &)"), self.srcwinCheck),
(self.prjwinEdit, SIGNAL("textChanged(const QString &)"), self.prjwinCheck)
@@ -188,10 +188,9 @@ def getArguments(self):
if self.targetSRSCheck.isChecked() and not self.targetSRSEdit.text().isEmpty():
arguments << "-a_srs"
arguments << self.targetSRSEdit.text()
if self.creationGroupBox.isChecked():
for opt in self.creationOptionsTable.options():
arguments << "-co"
arguments << opt
if self.creationOptionsGroupBox.isChecked():
for opt in self.creationOptionsWidget.options():
arguments << "-co" << opt
if self.outsizeCheck.isChecked() and self.outsizeSpin.value() != 100:
arguments << "-outsize"
arguments << self.outsizeSpin.text()
@@ -244,6 +243,13 @@ def getArguments(self):
arguments << self.outputFormat
arguments << self.getInputFileName()
arguments << outputFn

# set creation options filename/layer for validation
if self.inSelector.layer():
self.creationOptionsWidget.setRasterLayer(self.inSelector.layer())
else:
self.creationOptionsWidget.setRasterFileName(self.getInputFileName())

return arguments

def getInputFileName(self):

0 comments on commit c279ec2

Please sign in to comment.