Skip to content

Commit 36fc12a

Browse files
author
brushtyler
committedMar 14, 2011
added -cutline option to gdaltools warp tool, to fix #3066
git-svn-id: http://svn.osgeo.org/qgis/trunk@15476 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fa9f666 commit 36fc12a

File tree

3 files changed

+80
-13
lines changed

3 files changed

+80
-13
lines changed
 

‎python/plugins/GdalTools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def name():
2222
def description():
2323
return "Integrate gdal tools into qgis"
2424
def version():
25-
return "Version 1.2.22"
25+
return "Version 1.2.23"
2626
def qgisMinimumVersion():
2727
return "1.0"
2828
def icon():

‎python/plugins/GdalTools/tools/doWarp.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def __init__(self, iface):
4040
(self.cacheSpin, SIGNAL("valueChanged(int)"), self.cacheCheck),
4141
( [self.widthSpin, self.heightSpin], SIGNAL( "valueChanged(int)" ), self.resizeGroupBox ),
4242
(self.multithreadCheck, SIGNAL("stateChanged(int)")),
43-
(self.noDataEdit, SIGNAL( "textChanged( const QString & )" ), self.noDataCheck)
43+
(self.noDataEdit, SIGNAL( "textChanged( const QString & )" ), self.noDataCheck),
44+
(self.cutlineLayerCombo, [SIGNAL("currentIndexChanged(int)"), SIGNAL("editTextChanged(const QString &)")], self.cutlineCheck, "1.6.0"),
45+
(self.selectCutlineFileButton, None, self.cutlineCheck, "1.6.0")
4446
]
4547
)
4648

@@ -49,6 +51,7 @@ def __init__(self, iface):
4951
self.connect(self.selectOutputFileButton, SIGNAL("clicked()"), self.fillOutputFileEdit)
5052
self.connect(self.selectSourceSRSButton, SIGNAL("clicked()"), self.fillSourceSRSEdit)
5153
self.connect(self.selectTargetSRSButton, SIGNAL("clicked()"), self.fillTargetSRSEdit)
54+
self.connect(self.selectCutlineFileButton, SIGNAL("clicked()"), self.fillCutlineFile)
5255
self.connect( self.batchCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode )
5356

5457

@@ -90,12 +93,19 @@ def switchToolMode( self ):
9093

9194
def onLayersChanged(self):
9295
self.fillInputLayerCombo()
96+
self.fillCutlineLayerCombo()
9397

9498
def fillInputLayerCombo(self):
9599
self.inputLayerCombo.clear()
96-
( self.layers, names ) = Utils.LayerRegistry.instance().getRasterLayers()
100+
( self.inputLayers, names ) = Utils.LayerRegistry.instance().getRasterLayers()
97101
self.inputLayerCombo.addItems( names )
98102

103+
def fillCutlineLayerCombo(self):
104+
self.cutlineLayerCombo.clear()
105+
( self.cutlineLayers, names ) = Utils.LayerRegistry.instance().getVectorLayers()
106+
self.cutlineLayerCombo.addItems( names )
107+
108+
99109
def fillInputFile(self):
100110
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
101111
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the input file for Warp" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
@@ -119,6 +129,17 @@ def fillOutputFileEdit(self):
119129
self.outputFormat = Utils.fillRasterOutputFormat( lastUsedFilter, outputFile )
120130
self.outputFileEdit.setText(outputFile)
121131

132+
def fillCutlineFile(self):
133+
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
134+
cutlineFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the cutline file" ), Utils.FileFilter.allVectorsFilter(), lastUsedFilter )
135+
if cutlineFile.isEmpty():
136+
return
137+
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
138+
139+
self.cutlineLayerCombo.setCurrentIndex(-1)
140+
self.cutlineLayerCombo.setEditText(cutlineFile)
141+
142+
122143
def fillInputDir( self ):
123144
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files to Warp" ))
124145
if inputDir.isEmpty():
@@ -187,6 +208,13 @@ def getArguments(self):
187208
if not nodata.isEmpty():
188209
arguments << "-dstnodata"
189210
arguments << nodata
211+
if self.cutlineCheck.isChecked():
212+
cutline = self.getCutlineFileName()
213+
if not cutline.isEmpty():
214+
arguments << "-q"
215+
arguments << "-cutline"
216+
arguments << cutline
217+
arguments << "-dstalpha"
190218
if self.isBatchEnabled():
191219
return arguments
192220

@@ -199,12 +227,17 @@ def getArguments(self):
199227

200228
def getInputFileName(self):
201229
if self.inputLayerCombo.currentIndex() >= 0:
202-
return self.layers[self.inputLayerCombo.currentIndex()].source()
230+
return self.inputLayers[self.inputLayerCombo.currentIndex()].source()
203231
return self.inputLayerCombo.currentText()
204232

205233
def getOutputFileName(self):
206234
return self.outputFileEdit.text()
207235

236+
def getCutlineFileName(self):
237+
if self.cutlineLayerCombo.currentIndex() >= 0:
238+
return self.cutlineLayers[self.cutlineLayerCombo.currentIndex()].source()
239+
return self.cutlineLayerCombo.currentText()
240+
208241
def addLayerIntoCanvas(self, fileInfo):
209242
self.iface.addRasterLayer(fileInfo.filePath())
210243

‎python/plugins/GdalTools/tools/widgetWarp.ui

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>415</width>
10-
<height>417</height>
10+
<height>453</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -19,15 +19,15 @@
1919
<property name="windowTitle">
2020
<string>Warp</string>
2121
</property>
22-
<layout class="QVBoxLayout" name="verticalLayout">
23-
<item>
22+
<layout class="QGridLayout" name="gridLayout">
23+
<item row="0" column="0">
2424
<widget class="QCheckBox" name="batchCheck">
2525
<property name="text">
2626
<string>Batch mode (for processing whole directory)</string>
2727
</property>
2828
</widget>
2929
</item>
30-
<item>
30+
<item row="1" column="0">
3131
<layout class="QGridLayout" name="gridLayout_2">
3232
<item row="0" column="0">
3333
<widget class="QLabel" name="label">
@@ -203,14 +203,14 @@
203203
</property>
204204
</widget>
205205
</item>
206-
<item row="6" column="0">
206+
<item row="7" column="0">
207207
<widget class="QCheckBox" name="cacheCheck">
208208
<property name="text">
209209
<string>&amp;Memory used for caching</string>
210210
</property>
211211
</widget>
212212
</item>
213-
<item row="6" column="1">
213+
<item row="7" column="1">
214214
<widget class="QSpinBox" name="cacheSpin">
215215
<property name="suffix">
216216
<string>MB</string>
@@ -223,9 +223,43 @@
223223
</property>
224224
</widget>
225225
</item>
226+
<item row="6" column="0">
227+
<widget class="QCheckBox" name="cutlineCheck">
228+
<property name="text">
229+
<string>Cutline</string>
230+
</property>
231+
</widget>
232+
</item>
233+
<item row="6" column="1">
234+
<layout class="QHBoxLayout" name="horizontalLayout_5">
235+
<item>
236+
<widget class="QComboBox" name="cutlineLayerCombo">
237+
<property name="sizePolicy">
238+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
239+
<horstretch>0</horstretch>
240+
<verstretch>0</verstretch>
241+
</sizepolicy>
242+
</property>
243+
<property name="editable">
244+
<bool>true</bool>
245+
</property>
246+
<property name="insertPolicy">
247+
<enum>QComboBox::NoInsert</enum>
248+
</property>
249+
</widget>
250+
</item>
251+
<item>
252+
<widget class="QPushButton" name="selectCutlineFileButton">
253+
<property name="text">
254+
<string>Select...</string>
255+
</property>
256+
</widget>
257+
</item>
258+
</layout>
259+
</item>
226260
</layout>
227261
</item>
228-
<item>
262+
<item row="2" column="0">
229263
<widget class="QGroupBox" name="resizeGroupBox">
230264
<property name="title">
231265
<string>Resize</string>
@@ -283,10 +317,10 @@
283317
</layout>
284318
</widget>
285319
</item>
286-
<item>
320+
<item row="3" column="0">
287321
<widget class="QProgressBar" name="progressBar"/>
288322
</item>
289-
<item>
323+
<item row="4" column="0">
290324
<widget class="QCheckBox" name="multithreadCheck">
291325
<property name="text">
292326
<string>Use m&amp;ultithreaded warping implementation</string>

0 commit comments

Comments
 (0)
Please sign in to comment.