@@ -141,7 +141,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
141
141
else :
142
142
QtGui .QMessageBox .warning (self , self .tr ("Eliminate" ), self .tr ("Could not delete features" ))
143
143
return None
144
-
144
+
145
145
# ANALYZE
146
146
start = 20.00
147
147
progressBar .setValue (start )
@@ -160,7 +160,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
160
160
for fid2Eliminate in inLayer .selectedFeaturesIds ():
161
161
feat = QgsFeature ()
162
162
163
- if inLayer .featureAtId ( fid2Eliminate , feat , True , False ):
163
+ if inLayer .getFeatures ( QgsFeatureRequest (). setFilterFid ( fid2Eliminate ). setSubsetOfAttributes ([]) ). nextFeature ( feat ):
164
164
geom2Eliminate = feat .geometry ()
165
165
bbox = geom2Eliminate .boundingBox ()
166
166
outLayer .select (bbox , False ) # make a new selection
@@ -171,7 +171,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
171
171
for selFid in outLayer .selectedFeaturesIds ():
172
172
selFeat = QgsFeature ()
173
173
174
- if outLayer .featureAtId ( selFid , selFeat , True , False ):
174
+ if outLayer .getFeatures ( QgsFeatureRequest (). setFilterFid ( selFid ). setSubsetOfAttributes ([]) ). nextFeature ( selFeat ):
175
175
selGeom = selFeat .geometry ()
176
176
177
177
if geom2Eliminate .intersects (selGeom ): # we have a candidate
@@ -190,7 +190,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
190
190
max = selValue
191
191
mergeWithFid = selFid
192
192
mergeWithGeom = QgsGeometry (selGeom ) # deep copy of the geometry
193
-
193
+
194
194
if mergeWithFid != None : # a successful candidate
195
195
newGeom = mergeWithGeom .combine (geom2Eliminate )
196
196
@@ -206,16 +206,16 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
206
206
else :
207
207
QtGui .QMessageBox .warning (self , self .tr ("Eliminate" ),
208
208
self .tr ("Could not replace geometry of feature with id %1" ).arg ( mergeWithFid ))
209
- return None
210
-
209
+ return None
210
+
211
211
start = start + add
212
212
progressBar .setValue (start )
213
213
# end for fid2Eliminate
214
214
215
215
# deselect features that are already eliminated in inLayer
216
216
for aFid in fidsToDeselect :
217
217
inLayer .deselect (aFid , False )
218
-
218
+
219
219
#end while
220
220
221
221
if inLayer .selectedFeatureCount () > 0 :
@@ -232,7 +232,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
232
232
233
233
QtGui .QMessageBox .information (self , self .tr ("Eliminate" ),
234
234
self .tr ("Could not eliminate features with these ids:\n %1" ).arg (fidList ))
235
- else :
235
+ else :
236
236
QtGui .QMessageBox .warning (self , self .tr ("Eliminate" ), self .tr ("Could not add features" ))
237
237
238
238
# stop editing outLayer and commit any pending changes
0 commit comments