Hi Nathan Thanks for clarifying that, I’ll try to put my faith in the layer. My question is then, why does the layer only respond with 2 features when I ask it for max 3 features, since 4 – 1 = 3?
Does it find 3 features, determine that one of them has been deleted and only returns the two living features?` Regards, Casper From: Nathan Woodrow [mailto:[email protected]] Sent: 30. august 2016 14:50 To: Casper Børgesen (CABO) Cc: QGIS Developer Mailing List Subject: Re: [Qgis-developer] Python and strange results using layer(.dataProvider()).getFeatures(...) If you haven't saved the layer after you did the delete the provider still thinks there is 4 features. The layer itself and the edit buffer sit above the data provider. Generally you should trust the layer as it knows the state of the edit buffer. On Tue, Aug 30, 2016 at 10:32 PM, Casper Børgesen (CABO) <[email protected]<mailto:[email protected]>> wrote: Hi, I have a point SHAPE layer with 4 points on a line (just to make them easy to number in this example, and the layer is created in QGIS). 1. Start editing. 2. Delete point number 3. 3. In the python console do the following: >>> len(list(iface.mapCanvas().currentLayer().getFeatures())) 3 >>> len(list(iface.mapCanvas().currentLayer().dataProvider().getFeatures())) 4 >>> req = QgsFeatureRequest() >>> req = req.setLimit(3) >>> len(list(iface.mapCanvas().currentLayer().getFeatures(req))) 2 >>> len(list(iface.mapCanvas().currentLayer().dataProvider().getFeatures(req))) 3 If I access the features using the data provider with no request, I get too many features back. If I use a request when getting features directly from the layer, I get too few features back. I guess the layer directly gives me the best result, but it chokes when the request is limited. Who can I trust when getting features during an editing session? Or should I approach this in another way? Regards, Casper Using QGIS master (d3882d5) in Windows 7, x64 _______________________________________________ Qgis-developer mailing list [email protected]<mailto:[email protected]> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________ Qgis-developer mailing list [email protected] List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
