[QGIS-Developer] Processing Feature Sink Questions

C Hamilton adenaculture at gmail.com
Tue Aug 28 13:03:22 PDT 2018

I am working on a processing routine that can take a source that
potentially has points, lines and polygons. I define 3 feature sinks for
the 3 geometries and they are optional. This example is for the points.

                tr('Output point layer'),

1) How doe I know in the processAlgorithm whether the user has this set a
feature sink to "Skip Output"?

2) I really don't know whether I have points, lines, and/or polygons until
I process the file and from the 3 feature sinks I just add the data to the
appropriate feature sink as I receive it . How do a get a count of the
number of features once I have processed the file from sinkPt or dest_id_pt?

        (sinkPt, dest_id_pt) = self.parameterAsSink(parameters,
            self.PrmPointOutputLayer, context, fields,
            QgsWkbTypes.Point, epsg4326)

"sinkPt" seems to only have the ability to add features and not count them.

3) I see to reason to return a layer to QGIS if it has no data which is the
reason to check the feature count. In the processAlgorithm return statement
do I only return those layers that have data?

        return {
            self.PrmPointOutputLayer: dest_id_pt,
            self.PrmLineOutputLayer: dest_id_line,
            self.PrmPolygonOutputLayer: dest_id_poly


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180828/e115646d/attachment.html>

More information about the QGIS-Developer mailing list