Re: [Qgis-developer] Feature count don't increase

Alexander Bruy voltron at ua.fm
Tue Oct 7 10:27:42 EDT 2008


Many thanks for your reply, Carson.
> Have you tried vlayer.updateFeatureCount() ?
>
Yes, I try to use vLayer.commitChanges() and vLayer.updateFeatureCount(),
but this take no effect. Code is:

lstFeatures = []
lstLayers = []
self.layermap = QgsMapLayerRegistry.instance().mapLayers()
for (name, layer) in self.layermap.iteritems():
	lstLayers.append(name)
vLayer = self.layermap[lstLayers[0]]
# for debug: show feature count before adding
#QMessageBox.information(self.iface.getMainWindow(), "Debug", str(vLayer.featureCount()))
provider = vLayer.getDataProvider()
provider.reset()
ft = QgsFeature()
geom = QgsGeometry.fromPloygon([lstCoord])
ft.setGeometry(geom)
lstFeatures.append(ft)
# commit changes
provider.addFeatures(lstFeatures)
self.iface.getMapCanvas.refresh()
#vLayer.commitChanges()
vLayer.updateFeatureCount()
# for debug: show feature count after adding
#QMessageBox.information(self.iface.getMainWindow(), "Debug", str(vLayer.featureCount()))

>From http://spatialserver.net:3001/ I download qgsAzimuth.zip archieve with plugin and test it: create new feature and try to zoom to full extent of the layer. New feature appears on map and in attribute table, but feature count don't increase too.
Сan it is related to that addition takes place through "qgsDataProvider" not throught "QgsVectorLayer"? 

Best regards,
 Alexander Bruy

voltron at ua.fm

-- реклама -----------------------------------------------------------
http://FREEhost.com.ua - доступный хостинг, домен в подарок



More information about the Qgis-developer mailing list