[QGIS-Developer] Processing Feature Sink Questions

C Hamilton adenaculture at gmail.com
Wed Aug 29 07:01:45 PDT 2018


 > 3) I see no 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
>             }

> You can omit these from the returned dictionary in this case - so if
> you're recording the counts of features added to each sink, only add
> entries to the results dictionary where the count is > 0.

This almost did what was needed. It looks like calling

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

is what determines what layers are added to QGIS and not the dictionary I
return. I guess I'm going to need to call parameterAsSink the first time I
have data to be added. This is going to make the code more messy, but I
don't know another way to prevent empty layers from being added.

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


More information about the QGIS-Developer mailing list