i'm developping a plugin (under QGis 2.8.1) for traffic assignment where I want to show the results of my simulation at each time step. Right now I'm using Time Manager plugin but it gets very slow when my layer has hundreds of thousands of attributes. In my case I know exactly what feature IDs I want to show at each time step so I thought it would be easy to make it faster. Then I tried 2 solutions:
Here is what I tried: at each time step of my loop I set the ordered list of indexes of attributes to show (they are always ordered in my case) indexes = list(j for j in range(index_start, index_end)) then I tried 2 solutions:
my_layer.setSubsetString("fid>=indexes AND fid<=indexes[-1]")
request = QgsFeatureRequest().setFilterFids(indexes) my_layer.getFeatures(request)
self.iface.mapCanvas().refresh() to refresh the view
Solution 1 works as it refresh the view with the right filtered features but it is even slower than using a SQL expression not based on the indexes.
Solution 2 is fast but the display of the layer doesn't change.
Any idea why?