@@ -40,7 +40,9 @@ def __init__(self, iface):
40
40
(self .cacheSpin , SIGNAL ("valueChanged(int)" ), self .cacheCheck ),
41
41
( [self .widthSpin , self .heightSpin ], SIGNAL ( "valueChanged(int)" ), self .resizeGroupBox ),
42
42
(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" )
44
46
]
45
47
)
46
48
@@ -49,6 +51,7 @@ def __init__(self, iface):
49
51
self .connect (self .selectOutputFileButton , SIGNAL ("clicked()" ), self .fillOutputFileEdit )
50
52
self .connect (self .selectSourceSRSButton , SIGNAL ("clicked()" ), self .fillSourceSRSEdit )
51
53
self .connect (self .selectTargetSRSButton , SIGNAL ("clicked()" ), self .fillTargetSRSEdit )
54
+ self .connect (self .selectCutlineFileButton , SIGNAL ("clicked()" ), self .fillCutlineFile )
52
55
self .connect ( self .batchCheck , SIGNAL ( "stateChanged( int )" ), self .switchToolMode )
53
56
54
57
@@ -90,12 +93,19 @@ def switchToolMode( self ):
90
93
91
94
def onLayersChanged (self ):
92
95
self .fillInputLayerCombo ()
96
+ self .fillCutlineLayerCombo ()
93
97
94
98
def fillInputLayerCombo (self ):
95
99
self .inputLayerCombo .clear ()
96
- ( self .layers , names ) = Utils .LayerRegistry .instance ().getRasterLayers ()
100
+ ( self .inputLayers , names ) = Utils .LayerRegistry .instance ().getRasterLayers ()
97
101
self .inputLayerCombo .addItems ( names )
98
102
103
+ def fillCutlineLayerCombo (self ):
104
+ self .cutlineLayerCombo .clear ()
105
+ ( self .cutlineLayers , names ) = Utils .LayerRegistry .instance ().getVectorLayers ()
106
+ self .cutlineLayerCombo .addItems ( names )
107
+
108
+
99
109
def fillInputFile (self ):
100
110
lastUsedFilter = Utils .FileFilter .lastUsedRasterFilter ()
101
111
inputFile = Utils .FileDialog .getOpenFileName (self , self .tr ( "Select the input file for Warp" ), Utils .FileFilter .allRastersFilter (), lastUsedFilter )
@@ -119,6 +129,17 @@ def fillOutputFileEdit(self):
119
129
self .outputFormat = Utils .fillRasterOutputFormat ( lastUsedFilter , outputFile )
120
130
self .outputFileEdit .setText (outputFile )
121
131
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
+
122
143
def fillInputDir ( self ):
123
144
inputDir = Utils .FileDialog .getExistingDirectory ( self , self .tr ( "Select the input directory with files to Warp" ))
124
145
if inputDir .isEmpty ():
@@ -187,6 +208,13 @@ def getArguments(self):
187
208
if not nodata .isEmpty ():
188
209
arguments << "-dstnodata"
189
210
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"
190
218
if self .isBatchEnabled ():
191
219
return arguments
192
220
@@ -199,12 +227,17 @@ def getArguments(self):
199
227
200
228
def getInputFileName (self ):
201
229
if self .inputLayerCombo .currentIndex () >= 0 :
202
- return self .layers [self .inputLayerCombo .currentIndex ()].source ()
230
+ return self .inputLayers [self .inputLayerCombo .currentIndex ()].source ()
203
231
return self .inputLayerCombo .currentText ()
204
232
205
233
def getOutputFileName (self ):
206
234
return self .outputFileEdit .text ()
207
235
236
+ def getCutlineFileName (self ):
237
+ if self .cutlineLayerCombo .currentIndex () >= 0 :
238
+ return self .cutlineLayers [self .cutlineLayerCombo .currentIndex ()].source ()
239
+ return self .cutlineLayerCombo .currentText ()
240
+
208
241
def addLayerIntoCanvas (self , fileInfo ):
209
242
self .iface .addRasterLayer (fileInfo .filePath ())
210
243
0 commit comments