[QGIS Commit] r15469 - trunk/qgis/python/plugins/GdalTools/tools
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Mar 13 19:21:00 EDT 2011
Author: brushtyler
Date: 2011-03-13 16:21:00 -0700 (Sun, 13 Mar 2011)
New Revision: 15469
Modified:
trunk/qgis/python/plugins/GdalTools/tools/doRasterize.py
trunk/qgis/python/plugins/GdalTools/tools/doTileIndex.py
trunk/qgis/python/plugins/GdalTools/tools/doTranslate.py
trunk/qgis/python/plugins/GdalTools/tools/widgetRasterize.ui
Log:
added raster creation in rasterize tool, to fix #3545
Modified: trunk/qgis/python/plugins/GdalTools/tools/doRasterize.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doRasterize.py 2011-03-13 22:15:32 UTC (rev 15468)
+++ trunk/qgis/python/plugins/GdalTools/tools/doRasterize.py 2011-03-13 23:21:00 UTC (rev 15469)
@@ -18,13 +18,18 @@
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_rasterize")
+ # set the default QSpinBoxes and QProgressBar value
+ self.widthSpin.setValue(3000)
+ self.heightSpin.setValue(3000)
+
self.lastEncoding = Utils.getLastUsedEncoding()
self.setParamsStatus(
[
(self.inputLayerCombo, [SIGNAL("currentIndexChanged(int)"), SIGNAL("editTextChanged(const QString &)")] ),
(self.outputFileEdit, SIGNAL("textChanged(const QString &)")),
- (self.attributeComboBox, SIGNAL("currentIndexChanged(int)"))
+ (self.attributeComboBox, SIGNAL("currentIndexChanged(int)")),
+ ( [self.widthSpin, self.heightSpin], SIGNAL( "valueChanged(int)" ), self.resizeGroupBox, "1.8.0" ),
]
)
@@ -63,18 +68,34 @@
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
- outputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
+
+ # rasterize supports output file creation for GDAL 1.8
+ gdalVersion = Utils.GdalConfig.version()
+ fileDialogFunc = Utils.FileDialog.getSaveFileName
+ if gdalVersion < "1.8.0":
+ fileDialogFunc = Utils.FileDialog.getOpenFileName
+ outputFile = fileDialogFunc(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if outputFile.isEmpty():
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFileEdit.setText(outputFile)
+ # required either -ts or -tr to create the output file
+ if gdalVersion >= "1.8.0":
+ if not QFileInfo(outputFile).exists():
+ QMessageBox.information( self, self.tr( "Output size required" ), self.tr( "The output file doesn't exist. You must set up the output size to create it." ) )
+ self.resizeGroupBox.setChecked(True)
+
def getArguments(self):
arguments = QStringList()
if self.attributeComboBox.currentIndex() >= 0:
arguments << "-a"
arguments << self.attributeComboBox.currentText()
+ if self.resizeGroupBox.isChecked():
+ arguments << "-ts"
+ arguments << str( self.widthSpin.value() )
+ arguments << str( self.heightSpin.value() )
if self.inputLayerCombo.currentIndex() >= 0:
arguments << "-l"
arguments << QFileInfo(self.layers[ self.inputLayerCombo.currentIndex() ].source()).baseName()
Modified: trunk/qgis/python/plugins/GdalTools/tools/doTileIndex.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doTileIndex.py 2011-03-13 22:15:32 UTC (rev 15468)
+++ trunk/qgis/python/plugins/GdalTools/tools/doTileIndex.py 2011-03-13 23:21:00 UTC (rev 15469)
@@ -25,8 +25,8 @@
#( self.recurseCheck, SIGNAL( "stateChanged( int )" ),
( self.outputFileEdit, SIGNAL( "textChanged( const QString & )" ) ),
( self.indexFieldEdit, SIGNAL( "textChanged( const QString & )" ), self.indexFieldCheck),
- ( self.absolutePathCheck, SIGNAL( "stateChanged( int )" ) ),
- ( self.skipDifferentProjCheck, SIGNAL( "stateChanged( int )" ) )
+ ( self.absolutePathCheck, SIGNAL( "stateChanged( int )" ), None, "1.5.0" ),
+ ( self.skipDifferentProjCheck, SIGNAL( "stateChanged( int )" ), None, "1.5.0" )
]
)
Modified: trunk/qgis/python/plugins/GdalTools/tools/doTranslate.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doTranslate.py 2011-03-13 22:15:32 UTC (rev 15468)
+++ trunk/qgis/python/plugins/GdalTools/tools/doTranslate.py 2011-03-13 23:21:00 UTC (rev 15469)
@@ -184,9 +184,9 @@
arguments << "-co"
arguments << opt
if self.outsizeCheck.isChecked() and self.outsizeSpin.value() != 100:
- arguments << "-outsize"
- arguments << self.outsizeSpin.text()
- arguments << self.outsizeSpin.text()
+ arguments << "-outsize"
+ arguments << self.outsizeSpin.text()
+ arguments << self.outsizeSpin.text()
if self.expandCheck.isChecked():
arguments << "-expand"
arguments << self.expand_method[self.expandCombo.currentIndex()]
Modified: trunk/qgis/python/plugins/GdalTools/tools/widgetRasterize.ui
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/widgetRasterize.ui 2011-03-13 22:15:32 UTC (rev 15468)
+++ trunk/qgis/python/plugins/GdalTools/tools/widgetRasterize.ui 2011-03-13 23:21:00 UTC (rev 15469)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>570</width>
- <height>119</height>
+ <width>509</width>
+ <height>214</height>
</rect>
</property>
<property name="sizePolicy">
@@ -21,7 +21,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <layout class="QGridLayout" name="gridLayout">
+ <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -82,7 +82,7 @@
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
- <string>&Output file for rasterized vectors (raster, must exists)</string>
+ <string>&Output file for rasterized vectors (raster)</string>
</property>
<property name="buddy">
<cstring>selectOutputFileButton</cstring>
@@ -112,6 +112,52 @@
</item>
</layout>
</item>
+ <item>
+ <widget class="QGroupBox" name="resizeGroupBox">
+ <property name="title">
+ <string>New size (required if output file doens't exist)</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Image width</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="widthSpin">
+ <property name="maximum">
+ <number>999999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Image height</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="heightSpin">
+ <property name="maximum">
+ <number>999999</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
More information about the QGIS-commit
mailing list