Merge pull request #472 from jdugge/master

Interface elements for specifying raster resolution in GDAL Rasterize plugin
This commit is contained in:
Werner Macho 2013-04-27 10:37:31 -07:00
commit 370828c2c7
2 changed files with 170 additions and 19 deletions

View File

@ -47,6 +47,8 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
# set the default QSpinBoxes and QProgressBar value
self.widthSpin.setValue(3000)
self.heightSpin.setValue(3000)
self.horizresSpin.setValue(1)
self.vertresSpin.setValue(1)
self.lastEncoding = Utils.getLastUsedEncoding()
@ -55,13 +57,16 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.attributeComboBox, SIGNAL("currentIndexChanged(int)")),
( [self.widthSpin, self.heightSpin], SIGNAL( "valueChanged(int)" ), self.resizeGroupBox, "1.8.0" ),
( [self.widthSpin, self.heightSpin], SIGNAL( "valueChanged(int)" )),
( [self.horizresSpin, self.vertresSpin], SIGNAL( "valueChanged(double)" ))
]
)
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.inSelector, SIGNAL("layerChanged()"), self.fillFieldsCombo)
self.connect(self.radioSetSize, SIGNAL("toggled(bool)"), self.someValueChanged)
self.connect(self.radioSetResolution, SIGNAL("toggled(bool)"), self.someValueChanged)
def onLayersChanged(self):
self.inSelector.setLayers( Utils.LayerRegistry.instance().getVectorLayers() )
@ -101,24 +106,28 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
self.outSelector.setFilename(outputFile)
# required either -ts or -tr to create the output file
# 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)
QMessageBox.information( self, self.tr( "Output size or resolution required" ), self.tr( "The output file doesn't exist. You must set up the output size or resolution to create it." ) )
self.radioSetSize.setChecked(True)
def getArguments(self):
arguments = QStringList()
if self.attributeComboBox.currentIndex() >= 0:
arguments << "-a"
arguments << self.attributeComboBox.currentText()
if self.resizeGroupBox.isChecked():
if self.radioSetSize.isChecked():
arguments << "-ts"
arguments << str( self.widthSpin.value() )
arguments << str( self.heightSpin.value() )
if self.radioSetResolution.isChecked():
arguments << "-tr"
arguments << str( self.horizresSpin.value() )
arguments << str( self.vertresSpin.value() )
inputFn = self.getInputFileName()
if not inputFn.isEmpty():
arguments << "-l"
arguments << "-l"
arguments << QFileInfo( inputFn ).baseName()
arguments << inputFn
arguments << self.getOutputFileName()

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>509</width>
<height>165</height>
<height>261</height>
</rect>
</property>
<property name="sizePolicy">
@ -71,19 +71,42 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="resizeGroupBox">
<property name="title">
<string>New size (required if output file doens't exist)</string>
<widget class="QRadioButton" name="radioKeepSize">
<property name="text">
<string>Keep existing raster size and resolution</string>
</property>
<property name="checkable">
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioSetSize">
<property name="text">
<string>Raster size in pixels</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
</widget>
</item>
<item>
<widget class="QWidget" name="widgetSize" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -95,15 +118,15 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item>
<widget class="QSpinBox" name="widthSpin">
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_12">
<item>
<widget class="QLabel" name="labelHeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -118,7 +141,7 @@
</property>
</widget>
</item>
<item row="0" column="3">
<item>
<widget class="QSpinBox" name="heightSpin">
<property name="maximum">
<number>999999</number>
@ -128,6 +151,92 @@
</layout>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioSetResolution">
<property name="text">
<string>Raster resolution in map units per pixel</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widgetResolution" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelHorizontal">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Horizontal</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="horizresSpin">
<property name="decimals">
<number>8</number>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelVertical">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Vertical</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="vertresSpin">
<property name="inputMethodHints">
<set>Qt::ImhNone</set>
</property>
<property name="decimals">
<number>8</number>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@ -139,5 +248,38 @@
</customwidget>
</customwidgets>
<resources/>
<connections/>
<connections>
<connection>
<sender>radioSetSize</sender>
<signal>toggled(bool)</signal>
<receiver>widgetSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>254</x>
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>254</x>
<y>163</y>
</hint>
</hints>
</connection>
<connection>
<sender>radioSetResolution</sender>
<signal>toggled(bool)</signal>
<receiver>widgetResolution</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>254</x>
<y>198</y>
</hint>
<hint type="destinationlabel">
<x>254</x>
<y>233</y>
</hint>
</hints>
</connection>
</connections>
</ui>