[QGIS-Developer] Python QgsProcessingLagorithm.parameterAsSink return values

Nyall Dawson nyall.dawson at gmail.com
Wed Feb 14 06:07:47 PST 2018


On 15 February 2018 at 00:13, G. Allegri <giohappy at gmail.com> wrote:
> I'm trying to follow the code that produces the two return values from
> QgsProcessingLagorithm.parameterAsSink in Python. I can't find where the sip
> interface (or whatever) changes the API return value to the two returned
> values "sink" and "dest_id".
>
> Where does it happen?

This is the "destinationIdentifier" argument from the c++ API - sip
automatically converts arguments passed by reference like this into
return values. The PyQGIS docs show it a bit clearer.

> What does the second parameter (destination id) refer to?

Per the docs: "The destinationIdentifier argument will be set to a
string which can be used to retrieve the layer corresponding to the
sink,". It's a unique text identifier which processing uses to later
retrieve the result (and to pass on to following algorithms in a
model). The important thing here is that when your algorithm returns
its result dictionary, it should contain an entry for the output with
the corresponding destinationIdentifier as the value.

Here's a good example:

making the sink:
https://github.com/qgis/QGIS/blob/master/python/plugins/processing/algs/qgis/CheckValidity.py#L126

including it in the results:
https://github.com/qgis/QGIS/blob/master/python/plugins/processing/algs/qgis/CheckValidity.py#L196

Nyall

>
> Thanks,
> Giovanni
>
>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list