<div dir="ltr"><div dir="auto">Hi Richard, </div><div>have you considered something like this (maybe not the optimal way)</div><div><br></div><div>req = QgsFeatureRequest()<br>req.setLimit(10)<br><br>sink, dest = QgsProcessingUtils.createFeatureSink(<br>    uri,<br>    QgsProcessingContext(),<br>    source_layer.fields(),<br>    source_layer.wkbType(),<br>    source_layer.crs()<br>)<br><br>sink.addFeatures(source_layer.getFeatures(req), QgsFeatureSink.FastInsert)<br><br>del sink<br></div><div><br></div><div>Regards,</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 11 janv. 2021 à 14:50, Richard Duivenvoorde <<a href="mailto:rdmailings@duif.net" target="_blank">rdmailings@duif.net</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Devs,<br>
<br>
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.<br>
<br>
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...).<br>
<br>
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...<br>
<br>
My question is: can I create a VectorLayer, based on a QgsFeatureRequest? <br>
In this way you can (at least in python) create a much finer grained 'filter' for a certain layer.<br>
<br>
I looked into the api and did some googling, and hope that I just missed it...<br>
<br>
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.<br>
But I think it is actually stronger to sort of have an real (editable) layer in QGIS for that?<br>
<br>
Regards,<br>
<br>
Richard Duivenvoorde<br>
<br>
[0] <a href="https://qgis.org/pyqgis/master/core/QgsFeatureRequest.html" rel="noreferrer noreferrer" target="_blank">https://qgis.org/pyqgis/master/core/QgsFeatureRequest.html</a><br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" rel="noreferrer" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>