Skip to content
Permalink
Browse files
first take on porting ftools to vector iterator api
  • Loading branch information
jef-n committed Feb 1, 2013
1 parent 0d1f3d2 commit 2f23b1e83b92c79791f858a428f5d01765c1e5cc
@@ -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,
@@ -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)
@@ -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
@@ -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
@@ -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)

@@ -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:
@@ -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
Loading

0 comments on commit 2f23b1e

Please sign in to comment.