[QGIS-Developer] Vector destination vs feature sink

Thomas Gratier osgeo.mailinglist at gmail.com
Sat Oct 22 14:32:11 PDT 2022


Hi,

Although, I do know the intend to recommend one against the other, doing
some code differences helps to sort out things.
They both inherits from same classes but the constructor for
QgsProcessingParameterFeatureSink accepts an additionnal arg bool
supportsAppend
<https://api.qgis.org/api/3.22/classQgsProcessingParameterFeatureSink.html#acae2863d5dab37aec4c5466d7d3a84d9>
=false

You also find the additional methods in QgsProcessingParameterFeatureSink
to manipulate the same supportsAppend.

```
a = QgsProcessingParameterVectorDestination(
  'OUTPUT',
  'Sortie'
)

b = QgsProcessingParameterFeatureSink(
  'OUTPUT',
  'Sortie'
)

methods_a = dir(a)
methods_b = dir(b)
common_methods = set(methods_a).intersection(methods_b)
print(common_methods)

only_in_a = set(methods_a).difference(methods_b)
print(only_in_a)

only_in_b = set(methods_b).difference(methods_a)
print(only_in_b)
```

Regards

Thomas Gratier

Le ven. 21 oct. 2022 à 18:07, Anita Graser via QGIS-Developer <
qgis-developer at lists.osgeo.org> a écrit :

> Thank you Stefan,
>
> I saw that note but was hoping some developer could shed light on what
> they mean by "more flexible" and "wherever possible". I guess otherwise
> it's just trial and error.
>
> Regards,
> Anita
>
>
> On Wednesday, 19. October 2022 07:44:05 (+02:00), Stefan Giese
> (WhereGroup) wrote:
>
> Hi Anita,
>
> they are very similar, but the API Documentation says to
> QgsProcessingParameterVectorDestination: "Note: Consider using the more
> flexible QgsProcessingParameterFeatureSink
> <https://api.qgis.org/api/3.22/classQgsProcessingParameterFeatureSink.html>
> wherever possible." (
> https://api.qgis.org/api/3.22/classQgsProcessingParameterVectorDestination.html#details
> )
>
> Best regards
>
> Stefan
> Am 18.10.2022 um 20:35 schrieb Anita Graser via QGIS-Developer:
>
> Hi.
>
> Does any one of you know the real difference between
> QgsProcessingParameterVectorDestination versus
> QgsProcessingParameterFeatureSink? They seem to be used interchangably in
> the resources I can find.
>
> Thank you.
>
> Anita
>
> _______________________________________________
> QGIS-Developer mailing listQGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> --
> Mit freundlichen Grüßen
> Stefan Giese
> Projektleiter/Consultant
> ---------------------------------------------
> Aufwind durch Wissen!
> Jetzt neu: Web-Seminare und Online-Schulungen
> bei der www.foss-academy.com
> ---------------------------------------------
> WhereGroup GmbH
> Schwimmbadstr. 2
> 79100 Freiburg
> Germany
>
> Tel.: +49 (0)761 / 519 102 - 61
> Fax: +49 (0)761 / 519 102 - 11
> stefan.giese at wheregroup.comwww.wheregroup.com
> Geschäftsführer:
> Olaf Knopp, Peter Stamm
> Amtsgericht Bonn, HRB 9885
>
>
> --
> --
> Anita Graser
> Home: http://anitagraser.com
> Twitter: @underdarkgis
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20221022/68febc0b/attachment.htm>


More information about the QGIS-Developer mailing list