[QGIS-Developer] (Postgis)VectorLayer based on QgsFeatureRequest?

Richard Duivenvoorde rdmailings at duif.net
Mon Jan 11 05:50:10 PST 2021


Hi Devs,

I have this project in which there is (a set of different) moving cars (in time and position), but I only want to show (and able to edit in a plugin) the LAST POSITION of the cars.

In QGIS gui you can NOT use 'limit' or 'order' parts in the filter clause, I can only filter on car-ID (or so) (would be nice to have I think...).

In PyQGIS you can create a featureIterator based on a QgsFeatureRequest in which you CAN set limit and order of the set to iterate over...

My question is: can I create a VectorLayer, based on a QgsFeatureRequest? 
In this way you can (at least in python) create a much finer grained 'filter' for a certain layer.

I looked into the api and did some googling, and hope that I just missed it...

I have thought about creating a VIEW in the db for this (that is with an ordering on time and limit 1), and then with a filter=xxx in QGIS gui, I can at least see my subset's.
But I think it is actually stronger to sort of have an real (editable) layer in QGIS for that?

Regards,

Richard Duivenvoorde

[0] https://qgis.org/pyqgis/master/core/QgsFeatureRequest.html


More information about the QGIS-Developer mailing list