fix_1814.diff
python/plugins/fTools/tools/frmGeoprocessing.ui (working copy) | ||
---|---|---|
1 |
<ui version="4.0" > |
|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
2 | 3 |
<class>Dialog</class> |
3 |
<widget class="QDialog" name="Dialog" >
|
|
4 |
<property name="geometry" >
|
|
4 |
<widget class="QDialog" name="Dialog"> |
|
5 |
<property name="geometry"> |
|
5 | 6 |
<rect> |
6 | 7 |
<x>0</x> |
7 | 8 |
<y>0</y> |
8 | 9 |
<width>422</width> |
9 |
<height>405</height>
|
|
10 |
<height>448</height>
|
|
10 | 11 |
</rect> |
11 | 12 |
</property> |
12 |
<property name="sizePolicy" >
|
|
13 |
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
|
|
13 |
<property name="sizePolicy"> |
|
14 |
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
|
14 | 15 |
<horstretch>0</horstretch> |
15 | 16 |
<verstretch>0</verstretch> |
16 | 17 |
</sizepolicy> |
17 | 18 |
</property> |
18 |
<property name="windowTitle" >
|
|
19 |
<property name="windowTitle"> |
|
19 | 20 |
<string>Geoprocessing</string> |
20 | 21 |
</property> |
21 |
<layout class="QGridLayout" name="gridLayout" >
|
|
22 |
<item row="0" column="0" colspan="2" >
|
|
23 |
<layout class="QVBoxLayout" >
|
|
22 |
<layout class="QGridLayout" name="gridLayout"> |
|
23 |
<item row="0" column="0" colspan="2"> |
|
24 |
<layout class="QVBoxLayout"> |
|
24 | 25 |
<item> |
25 |
<widget class="QLabel" name="label_1" >
|
|
26 |
<property name="text" >
|
|
26 |
<widget class="QLabel" name="label_1"> |
|
27 |
<property name="text"> |
|
27 | 28 |
<string>Input vector layer</string> |
28 | 29 |
</property> |
29 | 30 |
</widget> |
30 | 31 |
</item> |
31 | 32 |
<item> |
32 |
<widget class="QComboBox" name="inShapeA" >
|
|
33 |
<property name="sizePolicy" >
|
|
34 |
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
|
33 |
<widget class="QComboBox" name="inShapeA"> |
|
34 |
<property name="sizePolicy"> |
|
35 |
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
35 | 36 |
<horstretch>0</horstretch> |
36 | 37 |
<verstretch>0</verstretch> |
37 | 38 |
</sizepolicy> |
... | ... | |
40 | 41 |
</item> |
41 | 42 |
</layout> |
42 | 43 |
</item> |
43 |
<item row="3" column="0" colspan="2" >
|
|
44 |
<layout class="QVBoxLayout" > |
|
44 |
<item row="2" column="0">
|
|
45 |
<layout class="QVBoxLayout" name="verticalLayout">
|
|
45 | 46 |
<item> |
46 |
<widget class="QLabel" name="label_2" > |
|
47 |
<property name="text" > |
|
47 |
<widget class="QCheckBox" name="useSelectedA"> |
|
48 |
<property name="text"> |
|
49 |
<string>Use only selected features</string> |
|
50 |
</property> |
|
51 |
</widget> |
|
52 |
</item> |
|
53 |
</layout> |
|
54 |
</item> |
|
55 |
<item row="3" column="0" colspan="2"> |
|
56 |
<layout class="QVBoxLayout"> |
|
57 |
<item> |
|
58 |
<widget class="QLabel" name="label_2"> |
|
59 |
<property name="text"> |
|
48 | 60 |
<string>Intersect layer</string> |
49 | 61 |
</property> |
50 | 62 |
</widget> |
51 | 63 |
</item> |
52 | 64 |
<item> |
53 |
<widget class="QComboBox" name="inShapeB" >
|
|
54 |
<property name="sizePolicy" >
|
|
55 |
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
|
65 |
<widget class="QComboBox" name="inShapeB"> |
|
66 |
<property name="sizePolicy"> |
|
67 |
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
56 | 68 |
<horstretch>0</horstretch> |
57 | 69 |
<verstretch>0</verstretch> |
58 | 70 |
</sizepolicy> |
... | ... | |
61 | 73 |
</item> |
62 | 74 |
</layout> |
63 | 75 |
</item> |
64 |
<item row="5" column="0" colspan="2" >
|
|
65 |
<layout class="QHBoxLayout" >
|
|
76 |
<item row="4" column="0">
|
|
77 |
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
66 | 78 |
<item> |
67 |
<layout class="QHBoxLayout" > |
|
79 |
<widget class="QCheckBox" name="useSelectedB"> |
|
80 |
<property name="text"> |
|
81 |
<string>Use only selected features</string> |
|
82 |
</property> |
|
83 |
</widget> |
|
84 |
</item> |
|
85 |
</layout> |
|
86 |
</item> |
|
87 |
<item row="7" column="0" colspan="2"> |
|
88 |
<layout class="QHBoxLayout"> |
|
89 |
<item> |
|
90 |
<layout class="QHBoxLayout"> |
|
68 | 91 |
<item> |
69 |
<widget class="QRadioButton" name="rdoBuffer" >
|
|
70 |
<property name="text" >
|
|
92 |
<widget class="QRadioButton" name="rdoBuffer"> |
|
93 |
<property name="text"> |
|
71 | 94 |
<string>Buffer distance</string> |
72 | 95 |
</property> |
73 |
<property name="checked" >
|
|
96 |
<property name="checked"> |
|
74 | 97 |
<bool>true</bool> |
75 | 98 |
</property> |
76 | 99 |
</widget> |
... | ... | |
78 | 101 |
</layout> |
79 | 102 |
</item> |
80 | 103 |
<item> |
81 |
<widget class="QLineEdit" name="param" >
|
|
82 |
<property name="enabled" >
|
|
104 |
<widget class="QLineEdit" name="param"> |
|
105 |
<property name="enabled"> |
|
83 | 106 |
<bool>true</bool> |
84 | 107 |
</property> |
85 |
<property name="sizePolicy" >
|
|
86 |
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
|
108 |
<property name="sizePolicy"> |
|
109 |
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
87 | 110 |
<horstretch>0</horstretch> |
88 | 111 |
<verstretch>0</verstretch> |
89 | 112 |
</sizepolicy> |
90 | 113 |
</property> |
91 |
<property name="layoutDirection" >
|
|
114 |
<property name="layoutDirection"> |
|
92 | 115 |
<enum>Qt::LeftToRight</enum> |
93 | 116 |
</property> |
94 |
<property name="text" >
|
|
117 |
<property name="text"> |
|
95 | 118 |
<string/> |
96 | 119 |
</property> |
97 |
<property name="cursorPosition" >
|
|
120 |
<property name="cursorPosition"> |
|
98 | 121 |
<number>0</number> |
99 | 122 |
</property> |
100 | 123 |
</widget> |
101 | 124 |
</item> |
102 | 125 |
</layout> |
103 | 126 |
</item> |
104 |
<item row="6" column="0" colspan="2" >
|
|
105 |
<layout class="QVBoxLayout" >
|
|
127 |
<item row="9" column="0" colspan="2">
|
|
128 |
<layout class="QVBoxLayout"> |
|
106 | 129 |
<item> |
107 |
<layout class="QHBoxLayout" >
|
|
130 |
<layout class="QHBoxLayout"> |
|
108 | 131 |
<item> |
109 |
<widget class="QRadioButton" name="rdoField" >
|
|
110 |
<property name="text" >
|
|
132 |
<widget class="QRadioButton" name="rdoField"> |
|
133 |
<property name="text"> |
|
111 | 134 |
<string>Buffer distance field</string> |
112 | 135 |
</property> |
113 | 136 |
</widget> |
114 | 137 |
</item> |
115 | 138 |
<item> |
116 |
<widget class="QLabel" name="label_4" >
|
|
117 |
<property name="text" >
|
|
139 |
<widget class="QLabel" name="label_4"> |
|
140 |
<property name="text"> |
|
118 | 141 |
<string>Dissolve field</string> |
119 | 142 |
</property> |
120 | 143 |
</widget> |
121 | 144 |
</item> |
122 | 145 |
<item> |
123 | 146 |
<spacer> |
124 |
<property name="orientation" >
|
|
147 |
<property name="orientation"> |
|
125 | 148 |
<enum>Qt::Horizontal</enum> |
126 | 149 |
</property> |
127 |
<property name="sizeHint" stdset="0" >
|
|
150 |
<property name="sizeHint" stdset="0"> |
|
128 | 151 |
<size> |
129 | 152 |
<width>40</width> |
130 | 153 |
<height>20</height> |
... | ... | |
135 | 158 |
</layout> |
136 | 159 |
</item> |
137 | 160 |
<item> |
138 |
<widget class="QComboBox" name="attrib" >
|
|
139 |
<property name="enabled" >
|
|
161 |
<widget class="QComboBox" name="attrib"> |
|
162 |
<property name="enabled"> |
|
140 | 163 |
<bool>false</bool> |
141 | 164 |
</property> |
142 |
<property name="sizePolicy" >
|
|
143 |
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
|
165 |
<property name="sizePolicy"> |
|
166 |
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
144 | 167 |
<horstretch>0</horstretch> |
145 | 168 |
<verstretch>0</verstretch> |
146 | 169 |
</sizepolicy> |
... | ... | |
149 | 172 |
</item> |
150 | 173 |
</layout> |
151 | 174 |
</item> |
152 |
<item row="7" column="0" >
|
|
153 |
<layout class="QHBoxLayout" >
|
|
154 |
<property name="spacing" >
|
|
175 |
<item row="10" column="0">
|
|
176 |
<layout class="QHBoxLayout"> |
|
177 |
<property name="spacing"> |
|
155 | 178 |
<number>6</number> |
156 | 179 |
</property> |
157 |
<property name="margin" >
|
|
180 |
<property name="margin"> |
|
158 | 181 |
<number>0</number> |
159 | 182 |
</property> |
160 | 183 |
<item> |
161 |
<widget class="QCheckBox" name="mergeOutput" >
|
|
162 |
<property name="enabled" >
|
|
184 |
<widget class="QCheckBox" name="mergeOutput"> |
|
185 |
<property name="enabled"> |
|
163 | 186 |
<bool>true</bool> |
164 | 187 |
</property> |
165 |
<property name="text" >
|
|
188 |
<property name="text"> |
|
166 | 189 |
<string>Dissolve buffer results</string> |
167 | 190 |
</property> |
168 | 191 |
</widget> |
169 | 192 |
</item> |
170 | 193 |
</layout> |
171 | 194 |
</item> |
172 |
<item row="8" column="0" >
|
|
195 |
<item row="11" column="0">
|
|
173 | 196 |
<spacer> |
174 |
<property name="orientation" >
|
|
197 |
<property name="orientation"> |
|
175 | 198 |
<enum>Qt::Vertical</enum> |
176 | 199 |
</property> |
177 |
<property name="sizeHint" stdset="0" >
|
|
200 |
<property name="sizeHint" stdset="0"> |
|
178 | 201 |
<size> |
179 | 202 |
<width>20</width> |
180 | 203 |
<height>40</height> |
... | ... | |
182 | 205 |
</property> |
183 | 206 |
</spacer> |
184 | 207 |
</item> |
185 |
<item row="9" column="0" colspan="2" >
|
|
186 |
<layout class="QVBoxLayout" >
|
|
208 |
<item row="12" column="0" colspan="2">
|
|
209 |
<layout class="QVBoxLayout"> |
|
187 | 210 |
<item> |
188 |
<widget class="QLabel" name="label_5" >
|
|
189 |
<property name="text" >
|
|
211 |
<widget class="QLabel" name="label_5"> |
|
212 |
<property name="text"> |
|
190 | 213 |
<string>Output shapefile</string> |
191 | 214 |
</property> |
192 | 215 |
</widget> |
193 | 216 |
</item> |
194 | 217 |
<item> |
195 |
<layout class="QHBoxLayout" >
|
|
218 |
<layout class="QHBoxLayout"> |
|
196 | 219 |
<item> |
197 |
<widget class="QLineEdit" name="outShape" >
|
|
198 |
<property name="readOnly" >
|
|
220 |
<widget class="QLineEdit" name="outShape"> |
|
221 |
<property name="readOnly"> |
|
199 | 222 |
<bool>true</bool> |
200 | 223 |
</property> |
201 | 224 |
</widget> |
202 | 225 |
</item> |
203 | 226 |
<item> |
204 |
<widget class="QPushButton" name="btnBrowse" >
|
|
205 |
<property name="text" >
|
|
227 |
<widget class="QPushButton" name="btnBrowse"> |
|
228 |
<property name="text"> |
|
206 | 229 |
<string>Browse</string> |
207 | 230 |
</property> |
208 | 231 |
</widget> |
... | ... | |
211 | 234 |
</item> |
212 | 235 |
</layout> |
213 | 236 |
</item> |
214 |
<item row="10" column="0" >
|
|
215 |
<widget class="QProgressBar" name="progressBar" >
|
|
216 |
<property name="value" >
|
|
237 |
<item row="13" column="0">
|
|
238 |
<widget class="QProgressBar" name="progressBar"> |
|
239 |
<property name="value"> |
|
217 | 240 |
<number>0</number> |
218 | 241 |
</property> |
219 |
<property name="alignment" >
|
|
242 |
<property name="alignment"> |
|
220 | 243 |
<set>Qt::AlignCenter</set> |
221 | 244 |
</property> |
222 |
<property name="orientation" >
|
|
245 |
<property name="orientation"> |
|
223 | 246 |
<enum>Qt::Horizontal</enum> |
224 | 247 |
</property> |
225 | 248 |
</widget> |
226 | 249 |
</item> |
227 |
<item row="10" column="1" >
|
|
228 |
<widget class="QDialogButtonBox" name="buttonBox_2" >
|
|
229 |
<property name="standardButtons" >
|
|
250 |
<item row="13" column="1">
|
|
251 |
<widget class="QDialogButtonBox" name="buttonBox_2"> |
|
252 |
<property name="standardButtons"> |
|
230 | 253 |
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set> |
231 | 254 |
</property> |
232 | 255 |
</widget> |
233 | 256 |
</item> |
234 |
<item row="2" column="0" >
|
|
235 |
<layout class="QVBoxLayout" name="verticalLayout" >
|
|
257 |
<item row="6" column="0">
|
|
258 |
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
236 | 259 |
<item> |
237 |
<widget class="QCheckBox" name="useSelectedA" >
|
|
238 |
<property name="text" >
|
|
239 |
<string>Use only selected features</string>
|
|
260 |
<widget class="QLabel" name="lblSegments">
|
|
261 |
<property name="text"> |
|
262 |
<string>Segments to approximate</string>
|
|
240 | 263 |
</property> |
241 | 264 |
</widget> |
242 | 265 |
</item> |
243 |
</layout> |
|
244 |
</item> |
|
245 |
<item row="4" column="0" > |
|
246 |
<layout class="QVBoxLayout" name="verticalLayout_2" > |
|
247 | 266 |
<item> |
248 |
<widget class="QCheckBox" name="useSelectedB" >
|
|
249 |
<property name="text" >
|
|
250 |
<string>Use only selected features</string>
|
|
267 |
<widget class="QSpinBox" name="spnSegments">
|
|
268 |
<property name="minimum">
|
|
269 |
<number>5</number>
|
|
251 | 270 |
</property> |
271 |
<property name="value"> |
|
272 |
<number>5</number> |
|
273 |
</property> |
|
252 | 274 |
</widget> |
253 | 275 |
</item> |
254 | 276 |
</layout> |
... | ... | |
263 | 285 |
<receiver>attrib</receiver> |
264 | 286 |
<slot>setEnabled(bool)</slot> |
265 | 287 |
<hints> |
266 |
<hint type="sourcelabel" >
|
|
288 |
<hint type="sourcelabel"> |
|
267 | 289 |
<x>96</x> |
268 | 290 |
<y>167</y> |
269 | 291 |
</hint> |
270 |
<hint type="destinationlabel" >
|
|
292 |
<hint type="destinationlabel"> |
|
271 | 293 |
<x>104</x> |
272 | 294 |
<y>222</y> |
273 | 295 |
</hint> |
... | ... | |
279 | 301 |
<receiver>param</receiver> |
280 | 302 |
<slot>setEnabled(bool)</slot> |
281 | 303 |
<hints> |
282 |
<hint type="sourcelabel" >
|
|
304 |
<hint type="sourcelabel"> |
|
283 | 305 |
<x>61</x> |
284 | 306 |
<y>133</y> |
285 | 307 |
</hint> |
286 |
<hint type="destinationlabel" >
|
|
308 |
<hint type="destinationlabel"> |
|
287 | 309 |
<x>380</x> |
288 | 310 |
<y>155</y> |
289 | 311 |
</hint> |
... | ... | |
295 | 317 |
<receiver>Dialog</receiver> |
296 | 318 |
<slot>reject()</slot> |
297 | 319 |
<hints> |
298 |
<hint type="sourcelabel" >
|
|
320 |
<hint type="sourcelabel"> |
|
299 | 321 |
<x>272</x> |
300 | 322 |
<y>383</y> |
301 | 323 |
</hint> |
302 |
<hint type="destinationlabel" >
|
|
324 |
<hint type="destinationlabel"> |
|
303 | 325 |
<x>246</x> |
304 | 326 |
<y>279</y> |
305 | 327 |
</hint> |
... | ... | |
311 | 333 |
<receiver>Dialog</receiver> |
312 | 334 |
<slot>accept()</slot> |
313 | 335 |
<hints> |
314 |
<hint type="sourcelabel" >
|
|
336 |
<hint type="sourcelabel"> |
|
315 | 337 |
<x>341</x> |
316 | 338 |
<y>382</y> |
317 | 339 |
</hint> |
318 |
<hint type="destinationlabel" >
|
|
340 |
<hint type="destinationlabel"> |
|
319 | 341 |
<x>335</x> |
320 | 342 |
<y>270</y> |
321 | 343 |
</hint> |
python/plugins/fTools/tools/doGeoprocessing.py (working copy) | ||
---|---|---|
24 | 24 |
self.cancel_close = self.buttonBox_2.button( QDialogButtonBox.Close ) |
25 | 25 |
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) |
26 | 26 |
self.progressBar.setValue (0 ) |
27 |
|
|
27 | ||
28 | 28 |
def checkA( self ): |
29 | 29 |
inputLayer = unicode( self.inShapeA.currentText() ) |
30 | 30 |
if inputLayer != "": |
... | ... | |
33 | 33 |
self.useSelectedA.setCheckState( Qt.Checked ) |
34 | 34 |
else: |
35 | 35 |
self.useSelectedA.setCheckState( Qt.Unchecked ) |
36 |
|
|
36 | ||
37 | 37 |
def checkB( self ): |
38 | 38 |
inputLayer = unicode( self.inShapeB.currentText() ) |
39 | 39 |
if inputLayer != "": |
... | ... | |
42 | 42 |
self.useSelectedB.setCheckState( Qt.Checked ) |
43 | 43 |
else: |
44 | 44 |
self.useSelectedB.setCheckState( Qt.Unchecked ) |
45 |
|
|
45 | ||
46 | 46 |
def update( self ): |
47 | 47 |
self.attrib.clear() |
48 | 48 |
inputLayer = unicode( self.inShapeA.currentText() ) |
... | ... | |
53 | 53 |
self.attrib.addItem( unicode( changedField[i].name() ) ) |
54 | 54 |
if self.myFunction == 4: |
55 | 55 |
self.attrib.addItem( "--- " + self.tr( "Dissolve all" ) + " ---" ) |
56 |
|
|
56 | ||
57 | 57 |
def accept( self ): |
58 | 58 |
if self.inShapeA.currentText() == "": |
59 | 59 |
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Please specify an input layer" ) ) |
... | ... | |
77 | 77 |
else: |
78 | 78 |
self.outShape.clear() |
79 | 79 |
if self.attrib.isEnabled(): |
80 |
self.geoprocessing( self.inShapeA.currentText(), self.inShapeB.currentText(),
|
|
80 |
self.geoprocessing( self.inShapeA.currentText(), self.inShapeB.currentText(), |
|
81 | 81 |
unicode( self.attrib.currentText() ), self.mergeOutput.checkState(), self.useSelectedA.checkState(), |
82 |
self.useSelectedB.checkState() ) |
|
82 |
self.useSelectedB.checkState(), self.spnSegments.value() )
|
|
83 | 83 |
else: |
84 | 84 |
if self.param.isEnabled() and self.param.isVisible(): |
85 | 85 |
parameter = float( self.param.text() ) |
86 | 86 |
else: |
87 | 87 |
parameter = None |
88 |
self.geoprocessing( self.inShapeA.currentText(), self.inShapeB.currentText(),
|
|
89 |
parameter, self.mergeOutput.checkState(), self.useSelectedA.checkState(), self.useSelectedB.checkState() ) |
|
90 |
|
|
88 |
self.geoprocessing( self.inShapeA.currentText(), self.inShapeB.currentText(), |
|
89 |
parameter, self.mergeOutput.checkState(), self.useSelectedA.checkState(), self.useSelectedB.checkState(), self.spnSegments.value() )
|
|
90 | ||
91 | 91 |
def outFile( self ): |
92 | 92 |
self.outShape.clear() |
93 | 93 |
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self ) |
94 | 94 |
if self.shapefileName is None or self.encoding is None: |
95 | 95 |
return |
96 | 96 |
self.outShape.setText( QString( self.shapefileName ) ) |
97 |
|
|
97 | ||
98 | 98 |
def manageGui( self ): |
99 | 99 |
if self.myFunction == 1: # Buffer |
100 | 100 |
self.label_2.hide() |
... | ... | |
110 | 110 |
self.rdoField.setText( self.tr( "Create convex hulls based on input field" ) ) |
111 | 111 |
self.label_4.hide() |
112 | 112 |
self.param.hide() |
113 |
self.lblSegments.hide() |
|
114 |
self.spnSegments.hide() |
|
113 | 115 |
self.setWindowTitle( self.tr( "Convex hull(s)" ) ) |
114 | 116 |
self.mergeOutput.hide() |
115 | 117 |
elif self.myFunction == 4: # Dissolve |
... | ... | |
121 | 123 |
self.param.hide() |
122 | 124 |
self.rdoField.hide() |
123 | 125 |
self.mergeOutput.hide() |
126 |
self.lblSegments.hide() |
|
127 |
self.spnSegments.hide() |
|
124 | 128 |
self.setWindowTitle( self.tr( "Dissolve" ) ) |
125 | 129 |
else: |
126 | 130 |
self.rdoBuffer.hide() |
... | ... | |
129 | 133 |
self.rdoField.hide() |
130 | 134 |
self.attrib.hide() |
131 | 135 |
self.mergeOutput.hide() |
136 |
self.lblSegments.hide() |
|
137 |
self.spnSegments.hide() |
|
132 | 138 |
if self.myFunction == 3: # Difference |
133 | 139 |
self.label_2.setText( self.tr( "Difference layer" ) ) |
134 | 140 |
self.setWindowTitle( self.tr( "Difference" ) ) |
... | ... | |
149 | 155 |
myListB = [] |
150 | 156 |
self.inShapeA.clear() |
151 | 157 |
self.inShapeB.clear() |
152 |
|
|
158 | ||
153 | 159 |
if self.myFunction == 5 or self.myFunction == 8 or self.myFunction == 3: |
154 | 160 |
myListA = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] ) |
155 | 161 |
myListB = ftools_utils.getLayerNames( [ QGis.Polygon ] ) |
... | ... | |
175 | 181 |
#7: Symetrical Difference |
176 | 182 |
#8: Clip |
177 | 183 | |
178 |
def geoprocessing( self, myLayerA, myLayerB, myParam, myMerge, mySelectionA, mySelectionB ): |
|
184 |
def geoprocessing( self, myLayerA, myLayerB, myParam, myMerge, mySelectionA, mySelectionB, mySegments ):
|
|
179 | 185 |
check = QFile( self.shapefileName ) |
180 | 186 |
if check.exists(): |
181 | 187 |
if not QgsVectorFileWriter.deleteShapeFile( self.shapefileName ): |
182 | 188 |
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Unable to delete existing shapefile." ) ) |
183 | 189 |
return |
184 | 190 |
self.buttonOk.setEnabled( False ) |
185 |
self.testThread = geoprocessingThread( self.iface.mainWindow(), self, self.myFunction, myLayerA,
|
|
186 |
myLayerB, myParam, myMerge, mySelectionA, mySelectionB, self.shapefileName, self.encoding ) |
|
191 |
self.testThread = geoprocessingThread( self.iface.mainWindow(), self, self.myFunction, myLayerA, |
|
192 |
myLayerB, myParam, myMerge, mySelectionA, mySelectionB, mySegments, self.shapefileName, self.encoding )
|
|
187 | 193 |
QObject.connect( self.testThread, SIGNAL( "runFinished(PyQt_PyObject)" ), self.runFinishedFromThread ) |
188 | 194 |
QObject.connect( self.testThread, SIGNAL( "runStatus(PyQt_PyObject)" ), self.runStatusFromThread ) |
189 | 195 |
QObject.connect( self.testThread, SIGNAL( "runRange(PyQt_PyObject)" ), self.runRangeFromThread ) |
... | ... | |
191 | 197 |
QObject.connect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread ) |
192 | 198 |
self.testThread.start() |
193 | 199 |
return True |
194 |
|
|
200 | ||
195 | 201 |
def cancelThread( self ): |
196 | 202 |
self.testThread.stop() |
197 | 203 |
self.buttonOk.setEnabled( True ) |
198 |
|
|
204 | ||
199 | 205 |
def runFinishedFromThread( self, results ): |
200 | 206 |
self.testThread.stop() |
201 | 207 |
self.buttonOk.setEnabled( True ) |
... | ... | |
226 | 232 |
if addToTOC == QMessageBox.Yes: |
227 | 233 |
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ): |
228 | 234 |
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( self.shapefileName ) )) |
229 |
|
|
235 | ||
230 | 236 |
def runStatusFromThread( self, status ): |
231 | 237 |
self.progressBar.setValue( status ) |
232 |
|
|
238 | ||
233 | 239 |
def runRangeFromThread( self, range_vals ): |
234 | 240 |
self.progressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] ) |
235 |
|
|
241 | ||
236 | 242 |
class geoprocessingThread( QThread ): |
237 |
def __init__( self, parentThread, parentObject, function, myLayerA, myLayerB,
|
|
238 |
myParam, myMerge, mySelectionA, mySelectionB, myName, myEncoding ): |
|
243 |
def __init__( self, parentThread, parentObject, function, myLayerA, myLayerB, |
|
244 |
myParam, myMerge, mySelectionA, mySelectionB, mySegments, myName, myEncoding ):
|
|
239 | 245 |
QThread.__init__( self, parentThread ) |
240 | 246 |
self.parent = parentObject |
241 | 247 |
self.running = False |
... | ... | |
246 | 252 |
self.myMerge = myMerge |
247 | 253 |
self.mySelectionA = mySelectionA |
248 | 254 |
self.mySelectionB = mySelectionB |
255 |
self.mySegments = int( mySegments ) |
|
249 | 256 |
self.myName = myName |
250 | 257 |
self.myEncoding = myEncoding |
251 |
|
|
258 | ||
252 | 259 |
def run( self ): |
253 | 260 |
self.running = True |
254 | 261 |
self.vlayerA = ftools_utils.getVectorLayerByName( self.myLayerA ) |
... | ... | |
276 | 283 |
geos, feature, match = self.clip() |
277 | 284 |
self.emit( SIGNAL( "runFinished(PyQt_PyObject)" ), (geos, feature, match, error) ) |
278 | 285 |
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 ) |
279 |
|
|
286 | ||
280 | 287 |
def stop(self): |
281 | 288 |
self.running = False |
282 |
|
|
289 | ||
283 | 290 |
def buffering( self, useField ): |
284 | 291 |
GEOS_EXCEPT = True |
285 | 292 |
FEATURE_EXCEPT = True |
... | ... | |
287 | 294 |
allAttrs = vproviderA.attributeIndexes() |
288 | 295 |
vproviderA.select( allAttrs ) |
289 | 296 |
fields = vproviderA.fields() |
290 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
|
297 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding, |
|
291 | 298 |
fields, QGis.WKBPolygon, vproviderA.crs() ) |
292 | 299 |
outFeat = QgsFeature() |
293 | 300 |
inFeat = QgsFeature() |
... | ... | |
311 | 318 |
value = self.myParam |
312 | 319 |
inGeom = QgsGeometry( inFeat.geometry() ) |
313 | 320 |
try: |
314 |
outGeom = inGeom.buffer( float( value ), 5 )
|
|
321 |
outGeom = inGeom.buffer( float( value ), self.mySegments )
|
|
315 | 322 |
if first: |
316 | 323 |
tempGeom = QgsGeometry( outGeom ) |
317 | 324 |
first = False |
... | ... | |
341 | 348 |
value = self.myParam |
342 | 349 |
inGeom = QgsGeometry( inFeat.geometry() ) |
343 | 350 |
try: |
344 |
outGeom = inGeom.buffer( float( value ), 5 )
|
|
351 |
outGeom = inGeom.buffer( float( value ), self.mySegments )
|
|
345 | 352 |
try: |
346 | 353 |
outFeat.setGeometry( outGeom ) |
347 | 354 |
outFeat.setAttributeMap( atMap ) |
... | ... | |
370 | 377 |
value = self.myParam |
371 | 378 |
inGeom = QgsGeometry( inFeat.geometry() ) |
372 | 379 |
try: |
373 |
outGeom = inGeom.buffer( float( value ), 5 )
|
|
380 |
outGeom = inGeom.buffer( float( value ), self.mySegments )
|
|
374 | 381 |
if first: |
375 | 382 |
tempGeom = QgsGeometry( outGeom ) |
376 | 383 |
first = False |
... | ... | |
401 | 408 |
value = self.myParam |
402 | 409 |
inGeom = QgsGeometry( inFeat.geometry() ) |
403 | 410 |
try: |
404 |
outGeom = inGeom.buffer( float( value ), 5 )
|
|
411 |
outGeom = inGeom.buffer( float( value ), self.mySegments )
|
|
405 | 412 |
try: |
406 | 413 |
outFeat.setGeometry( outGeom ) |
407 | 414 |
outFeat.setAttributeMap( atMap ) |
... | ... | |
416 | 423 |
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement ) |
417 | 424 |
del writer |
418 | 425 |
return GEOS_EXCEPT, FEATURE_EXCEPT, True |
419 |
|
|
426 | ||
420 | 427 |
def convex_hull(self, useField ): |
421 | 428 |
GEOS_EXCEPT = True |
422 | 429 |
FEATURE_EXCEPT = True |
... | ... | |
424 | 431 |
allAttrsA = vproviderA.attributeIndexes() |
425 | 432 |
vproviderA.select(allAttrsA) |
426 | 433 |
fields = vproviderA.fields() |
427 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
|
434 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding, |
|
428 | 435 |
fields, QGis.WKBPolygon, vproviderA.crs() ) |
429 | 436 |
inFeat = QgsFeature() |
430 | 437 |
outFeat = QgsFeature() |
431 | 438 |
inGeom = QgsGeometry() |
432 | 439 |
outGeom = QgsGeometry() |
433 | 440 |
nElement = 0 |
434 |
|
|
441 | ||
435 | 442 |
# there is selection in input layer |
436 | 443 |
if self.mySelectionA: |
437 | 444 |
nFeat = self.vlayerA.selectedFeatureCount() |
... | ... | |
548 | 555 |
GEOS_EXCEPT = False |
549 | 556 |
del writer |
550 | 557 |
return GEOS_EXCEPT, FEATURE_EXCEPT, True |
551 |
|
|
558 | ||
552 | 559 |
def dissolve( self, useField ): |
553 | 560 |
GEOS_EXCEPT = True |
554 | 561 |
FEATURE_EXCEPT = True |
555 | 562 |
vproviderA = self.vlayerA.dataProvider() |
556 | 563 |
allAttrsA = vproviderA.attributeIndexes() |
557 | 564 |
fields = vproviderA.fields() |
558 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
|
565 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding, |
|
559 | 566 |
fields, vproviderA.geometryType(), vproviderA.crs() ) |
560 | 567 |
inFeat = QgsFeature() |
561 | 568 |
outFeat = QgsFeature() |
... | ... | |
685 | 692 |
writer.addFeature( outFeat ) |
686 | 693 |
del writer |
687 | 694 |
return GEOS_EXCEPT, FEATURE_EXCEPT, True |
688 |
|
|
695 | ||
689 | 696 |
def difference( self ): |
690 | 697 |
GEOS_EXCEPT = True |
691 | 698 |
FEATURE_EXCEPT = True |
... | ... | |
703 | 710 |
crs_match = None |
704 | 711 |
else: |
705 | 712 |
crs_match = crsA == crsB |
706 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
|
713 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding, |
|
707 | 714 |
fields, vproviderA.geometryType(), vproviderA.crs() ) |
708 | 715 |
inFeatA = QgsFeature() |
709 | 716 |
inFeatB = QgsFeature() |
... | ... | |
842 | 849 |
continue |
843 | 850 |
del writer |
844 | 851 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match |
845 |
|
|
852 | ||
846 | 853 |
def intersect( self ): |
847 | 854 |
GEOS_EXCEPT = True |
848 | 855 |
FEATURE_EXCEPT = True |
... | ... | |
864 | 871 |
if not longNames.isEmpty(): |
865 | 872 |
message = QString( 'Following field names are longer than 10 characters:\n%1' ).arg( longNames.join( '\n' ) ) |
866 | 873 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message |
867 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
|
874 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding, |
|
868 | 875 |
fields, vproviderA.geometryType(), vproviderA.crs() ) |
869 | 876 |
if writer.hasError(): |
870 | 877 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage() |
... | ... | |
984 | 991 |
geom = QgsGeometry( inFeatA.geometry() ) |
985 | 992 |
atMapA = inFeatA.attributeMap() |
986 | 993 |
intersects = index.intersects( geom.boundingBox() ) |
987 |
for id in intersects:
|
|
994 |
for id in intersects: |
|
988 | 995 |
vproviderB.featureAtId( int( id ), inFeatB , True, allAttrsB ) |
989 | 996 |
tmpGeom = QgsGeometry( inFeatB.geometry() ) |
990 | 997 |
try: |
... | ... | |
1010 | 1017 |
del writer |
1011 | 1018 |
print crs_match |
1012 | 1019 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None |
1013 |
|
|
1020 | ||
1014 | 1021 |
def union( self ): |
1015 | 1022 |
GEOS_EXCEPT = True |
1016 | 1023 |
FEATURE_EXCEPT = True |
... | ... | |
1032 | 1039 |
if not longNames.isEmpty(): |
1033 | 1040 |
message = QString( 'Following field names are longer than 10 characters:\n%1' ).arg( longNames.join( '\n' ) ) |
1034 | 1041 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message |
1035 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
|
1042 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding, |
|
1036 | 1043 |
fields, vproviderA.geometryType(), vproviderA.crs() ) |
1037 | 1044 |
if writer.hasError(): |
1038 | 1045 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage() |
... | ... | |
1144 | 1151 |
nElement += 1 |
1145 | 1152 |
del writer |
1146 | 1153 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None |
1147 |
|
|
1154 | ||
1148 | 1155 |
def symetrical_difference( self ): |
1149 | 1156 |
GEOS_EXCEPT = True |
1150 | 1157 |
FEATURE_EXCEPT = True |
... | ... | |
1166 | 1173 |
if not longNames.isEmpty(): |
1167 | 1174 |
message = QString( 'Following field names are longer than 10 characters:\n%1' ).arg( longNames.join( '\n' ) ) |
1168 | 1175 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message |
1169 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
|
1176 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding, |
|
1170 | 1177 |
fields, vproviderA.geometryType(), vproviderA.crs() ) |
1171 | 1178 |
if writer.hasError(): |
1172 | 1179 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage() |
... | ... | |
1237 | 1244 |
continue |
1238 | 1245 |
del writer |
1239 | 1246 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None |
1240 |
|
|
1247 | ||
1241 | 1248 |
def clip( self ): |
1242 | 1249 |
GEOS_EXCEPT = True |
1243 | 1250 |
FEATURE_EXCEPT = True |
... | ... | |
1255 | 1262 |
else: |
1256 | 1263 |
crs_match = crsA == crsB |
1257 | 1264 |
fields = vproviderA.fields() |
1258 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
|
1265 |
writer = QgsVectorFileWriter( self.myName, self.myEncoding, |
|
1259 | 1266 |
fields, vproviderA.geometryType(), vproviderA.crs() ) |
1260 | 1267 |
inFeatA = QgsFeature() |
1261 | 1268 |
inFeatB = QgsFeature() |
... | ... | |
1410 | 1417 |
continue |
1411 | 1418 |
except: |
1412 | 1419 |
GEOS_EXCEPT = False |
1413 |
continue
|
|
1420 |
continue |
|
1414 | 1421 |
# we have no selection in overlay layer |
1415 | 1422 |
else: |
1416 | 1423 |
while vproviderA.nextFeature( inFeatA ): |
... | ... | |
1455 | 1462 |
continue |
1456 | 1463 |
except: |
1457 | 1464 |
GEOS_EXCEPT = False |
1458 |
continue
|
|
1465 |
continue |
|
1459 | 1466 |
del writer |
1460 | 1467 |
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match |
1461 | 1468 |