replace old select calls with getFeatures method

This commit is contained in:
vinayan 2013-05-05 09:32:08 +05:30
parent d3f9dd5dc4
commit 5e4138261c

View File

@ -163,15 +163,13 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
if inLayer.getFeatures( QgsFeatureRequest().setFilterFid( fid2Eliminate ).setSubsetOfAttributes([]) ).nextFeature( feat ): if inLayer.getFeatures( QgsFeatureRequest().setFilterFid( fid2Eliminate ).setSubsetOfAttributes([]) ).nextFeature( feat ):
geom2Eliminate = feat.geometry() geom2Eliminate = feat.geometry()
bbox = geom2Eliminate.boundingBox() bbox = geom2Eliminate.boundingBox()
outLayer.select(bbox, False) # make a new selection fit = outLayer.getFeatures( QgsFeatureRequest().setFilterRect( bbox ) )
mergeWithFid = None mergeWithFid = None
mergeWithGeom = None mergeWithGeom = None
max = 0 max = 0
for selFid in outLayer.selectedFeaturesIds(): selFeat = QgsFeature()
selFeat = QgsFeature() while fit.nextFeature(selFeat):
if outLayer.getFeatures( QgsFeatureRequest().setFilterFid( selFid ).setSubsetOfAttributes([]) ).nextFeature( selFeat ):
selGeom = selFeat.geometry() selGeom = selFeat.geometry()
if geom2Eliminate.intersects(selGeom): # we have a candidate if geom2Eliminate.intersects(selGeom): # we have a candidate
@ -188,7 +186,7 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
if selValue > max: if selValue > max:
max = selValue max = selValue
mergeWithFid = selFid mergeWithFid = selFeat.id()
mergeWithGeom = QgsGeometry(selGeom) # deep copy of the geometry mergeWithGeom = QgsGeometry(selGeom) # deep copy of the geometry
if mergeWithFid != None: # a successful candidate if mergeWithFid != None: # a successful candidate
@ -213,8 +211,7 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
# end for fid2Eliminate # end for fid2Eliminate
# deselect features that are already eliminated in inLayer # deselect features that are already eliminated in inLayer
for aFid in fidsToDeselect: inLayer.deselect(fidsToDeselect)
inLayer.deselect(aFid, False)
#end while #end while