Skip to content
Permalink
Browse files

added raster creation in rasterize tool, to fix #3545

git-svn-id: http://svn.osgeo.org/qgis/trunk@15469 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler
brushtyler committed Mar 13, 2011
1 parent 6e2d9c6 commit 63a41df84483fe49dce39dd3cdeab5abf887430c
@@ -18,13 +18,18 @@ def __init__(self, iface):
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 fillInputFileEdit(self):

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()
@@ -25,8 +25,8 @@ def __init__( self, iface ):
#( 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" )
]
)

@@ -184,9 +184,9 @@ def getArguments(self):
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()]
@@ -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>&amp;Output file for rasterized vectors (raster, must exists)</string>
<string>&amp;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/>

0 comments on commit 63a41df

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