Re: [Qgis-developer] Feature count don't increase
Alexander Bruy
voltron at ua.fm
Thu Oct 9 11:22:50 EDT 2008
Carson,
many thanks for your help!
>Although, based on the test below, this appears to be 'fixed'/not
>nessesasry in QGS 1.0.0
Yes, your code works from QGIS Python console in both versions (1.0.0 preview 1 and 0.11.0), but when this code with some changes (geometry builds from list of coordinates) runs from Python plugin feature count don't changes and zoom to full extent don't work correctly (only old features zooming).
I run next test from console (with new empty layer, on Windows XP SP2, Python 2.5.2, Qgis 1.0.0 and 0.11.0):
>>> mc = iface.mapCanvas()
>>> vLayer = mc.getZpos(0)
>>> vLayer.featureCount()
0
>>> provider = vLayer.dataProvider()
>>> provider.name()
ogr
>>> lstCoord = []
>>> lstCoord.append(QgsPoint(5295480.10,5291778.46))
>>> lstCoord.append(QgsPoint(5295506.65,5291781.13))
>>> lstCoord.append(QgsPoint(5295512.19,5291821.17))
>>> lstCoord.append(QgsPoint(5295475.22,5291820.33))
>>> geom = QgsGeometry.fromPolygon([lstCoord])
>>> fet = QgsFeature()
>>> fet.setGeometry(geom)
>>> provider.addFeatures([fet])
(True, [<qgis.core.QgsFeature object at 0x03727660>])
>>> vLayer.featureCount()
0
>>> vLayer.updateFeatureCount()
-1
>>> vLayer.featureCount()
0
>>> vLayer.updateExtents()
>>> vLayer.featureCount()
0
I have no ideas for this. Maybe, it's necessary manually flush(save) changes to disk/database and then re-read layer?
Best regards,
Alexander
voltron at ua.fm
-- реклама -----------------------------------------------------------
http://FREEhost.com.ua - доступный хостинг, домен в подарок
More information about the Qgis-developer
mailing list