Skip to content

Commit

Permalink
first take on porting ftools to vector iterator api
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 1, 2013
1 parent 0d1f3d2 commit 2f23b1e
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 456 deletions.
1 change: 1 addition & 0 deletions debian/control.raring
Expand Up @@ -31,6 +31,7 @@ Build-Depends:
python-qt4-dev (>=4.1.0),
python-sip (>= 4.5.0),
python-sip-dev (>= 4.5.0),
libpython2.7-dev,
libosgearth-dev,
libopenscenegraph-dev,
git,
Expand Down
16 changes: 8 additions & 8 deletions python/plugins/fTools/tools/doEliminate.py
Expand Up @@ -141,7 +141,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
else:
QtGui.QMessageBox.warning(self, self.tr("Eliminate"), self.tr("Could not delete features"))
return None

# ANALYZE
start = 20.00
progressBar.setValue(start)
Expand All @@ -160,7 +160,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
for fid2Eliminate in inLayer.selectedFeaturesIds():
feat = QgsFeature()

if inLayer.featureAtId(fid2Eliminate, feat, True, False):
if inLayer.getFeatures( QgsFeatureRequest().setFilterFid( fid2Eliminate ).setSubsetOfAttributes([]) ).nextFeature( feat ):
geom2Eliminate = feat.geometry()
bbox = geom2Eliminate.boundingBox()
outLayer.select(bbox, False) # make a new selection
Expand All @@ -171,7 +171,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
for selFid in outLayer.selectedFeaturesIds():
selFeat = QgsFeature()

if outLayer.featureAtId(selFid, selFeat, True, False):
if outLayer.getFeatures( QgsFeatureRequest().setFilterFid( selFid ).setSubsetOfAttributes([]) ).nextFeature( selFeat ):
selGeom = selFeat.geometry()

if geom2Eliminate.intersects(selGeom): # we have a candidate
Expand All @@ -190,7 +190,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
max = selValue
mergeWithFid = selFid
mergeWithGeom = QgsGeometry(selGeom) # deep copy of the geometry

if mergeWithFid != None: # a successful candidate
newGeom = mergeWithGeom.combine(geom2Eliminate)

Expand All @@ -206,16 +206,16 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):
else:
QtGui.QMessageBox.warning(self, self.tr("Eliminate"),
self.tr("Could not replace geometry of feature with id %1").arg( mergeWithFid ))
return None
return None

start = start + add
progressBar.setValue(start)
# end for fid2Eliminate

# deselect features that are already eliminated in inLayer
for aFid in fidsToDeselect:
inLayer.deselect(aFid, False)

#end while

if inLayer.selectedFeatureCount() > 0:
Expand All @@ -232,7 +232,7 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName):

QtGui.QMessageBox.information(self, self.tr("Eliminate"),
self.tr("Could not eliminate features with these ids:\n%1").arg(fidList))
else:
else:
QtGui.QMessageBox.warning(self, self.tr("Eliminate"), self.tr("Could not add features"))

# stop editing outLayer and commit any pending changes
Expand Down

0 comments on commit 2f23b1e

Please sign in to comment.