mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
Merge pull request #16 from alexbruy/master
mask option for gdal_polygonize tool
This commit is contained in:
commit
45cc8a7fea
@ -25,15 +25,18 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
|
|||||||
[
|
[
|
||||||
(self.inSelector, SIGNAL("filenameChanged()")),
|
(self.inSelector, SIGNAL("filenameChanged()")),
|
||||||
(self.outSelector, SIGNAL("filenameChanged()")),
|
(self.outSelector, SIGNAL("filenameChanged()")),
|
||||||
|
(self.maskSelector, SIGNAL("filenameChanged()"), self.maskCheck),
|
||||||
(self.fieldEdit, SIGNAL("textChanged(const QString &)"), self.fieldCheck)
|
(self.fieldEdit, SIGNAL("textChanged(const QString &)"), self.fieldCheck)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
|
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
|
||||||
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
|
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
|
||||||
|
self.connect(self.maskSelector, SIGNAL("selectClicked()"), self.fillMaskFileEdit)
|
||||||
|
|
||||||
def onLayersChanged(self):
|
def onLayersChanged(self):
|
||||||
self.inSelector.setLayers( Utils.LayerRegistry.instance().getRasterLayers() )
|
self.inSelector.setLayers( Utils.LayerRegistry.instance().getRasterLayers() )
|
||||||
|
self.maskSelector.setLayers( Utils.LayerRegistry.instance().getRasterLayers() )
|
||||||
|
|
||||||
def fillInputFileEdit(self):
|
def fillInputFileEdit(self):
|
||||||
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
|
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
|
||||||
@ -55,10 +58,23 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
|
|||||||
self.outSelector.setFilename(outputFile)
|
self.outSelector.setFilename(outputFile)
|
||||||
self.lastEncoding = encoding
|
self.lastEncoding = encoding
|
||||||
|
|
||||||
|
def fillMaskFileEdit(self):
|
||||||
|
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
|
||||||
|
maskFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the input file for Polygonize" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
|
||||||
|
if maskFile.isEmpty():
|
||||||
|
return
|
||||||
|
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
|
||||||
|
|
||||||
|
self.maskSelector.setFilename(maskFile)
|
||||||
|
|
||||||
def getArguments(self):
|
def getArguments(self):
|
||||||
arguments = QStringList()
|
arguments = QStringList()
|
||||||
arguments << self.getInputFileName()
|
arguments << self.getInputFileName()
|
||||||
outputFn = self.getOutputFileName()
|
outputFn = self.getOutputFileName()
|
||||||
|
maskFn = self.getMaskFileName()
|
||||||
|
if self.maskCheck.isChecked() and not maskFn.isEmpty():
|
||||||
|
arguments << "-mask"
|
||||||
|
arguments << maskFn
|
||||||
if not outputFn.isEmpty():
|
if not outputFn.isEmpty():
|
||||||
arguments << "-f"
|
arguments << "-f"
|
||||||
arguments << self.outputFormat
|
arguments << self.outputFormat
|
||||||
@ -75,6 +91,9 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
|
|||||||
def getInputFileName(self):
|
def getInputFileName(self):
|
||||||
return self.inSelector.filename()
|
return self.inSelector.filename()
|
||||||
|
|
||||||
|
def getMaskFileName(self):
|
||||||
|
return self.maskSelector.filename()
|
||||||
|
|
||||||
def addLayerIntoCanvas(self, fileInfo):
|
def addLayerIntoCanvas(self, fileInfo):
|
||||||
vl = self.iface.addVectorLayer(fileInfo.filePath(), fileInfo.baseName(), "ogr")
|
vl = self.iface.addVectorLayer(fileInfo.filePath(), fileInfo.baseName(), "ogr")
|
||||||
if vl != None and vl.isValid():
|
if vl != None and vl.isValid():
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>449</width>
|
<width>446</width>
|
||||||
<height>94</height>
|
<height>121</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -19,50 +19,56 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Polygonize (Raster to vector)</string>
|
<string>Polygonize (Raster to vector)</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<widget class="QLabel" name="label">
|
||||||
<item row="0" column="0">
|
<property name="text">
|
||||||
<widget class="QLabel" name="label">
|
<string>&Input file (raster)</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>&Input file (raster)</string>
|
<property name="buddy">
|
||||||
</property>
|
<cstring>inSelector</cstring>
|
||||||
<property name="buddy">
|
</property>
|
||||||
<cstring>inSelector</cstring>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="0" column="1">
|
||||||
</item>
|
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
|
||||||
<item row="1" column="0">
|
</item>
|
||||||
<widget class="QLabel" name="label_2">
|
<item row="1" column="0">
|
||||||
<property name="text">
|
<widget class="QLabel" name="label_2">
|
||||||
<string>&Output file for polygons (shapefile)</string>
|
<property name="text">
|
||||||
</property>
|
<string>&Output file for polygons (shapefile)</string>
|
||||||
<property name="buddy">
|
</property>
|
||||||
<cstring>outSelector</cstring>
|
<property name="buddy">
|
||||||
</property>
|
<cstring>outSelector</cstring>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
</widget>
|
||||||
<item row="2" column="0">
|
</item>
|
||||||
<widget class="QCheckBox" name="fieldCheck">
|
<item row="1" column="1">
|
||||||
<property name="text">
|
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
|
||||||
<string>&Field name</string>
|
</item>
|
||||||
</property>
|
<item row="2" column="0">
|
||||||
</widget>
|
<widget class="QCheckBox" name="fieldCheck">
|
||||||
</item>
|
<property name="text">
|
||||||
<item row="2" column="1">
|
<string>&Field name</string>
|
||||||
<widget class="QLineEdit" name="fieldEdit">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>DN</string>
|
</item>
|
||||||
</property>
|
<item row="2" column="1">
|
||||||
</widget>
|
<widget class="QLineEdit" name="fieldEdit">
|
||||||
</item>
|
<property name="text">
|
||||||
<item row="0" column="1">
|
<string>DN</string>
|
||||||
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
|
</property>
|
||||||
</item>
|
</widget>
|
||||||
<item row="1" column="1">
|
</item>
|
||||||
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
|
<item row="3" column="0">
|
||||||
</item>
|
<widget class="QCheckBox" name="maskCheck">
|
||||||
</layout>
|
<property name="text">
|
||||||
|
<string>Use mask</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="GdalToolsInOutSelector" name="maskSelector" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user