[QGIS-Developer] Vector destination vs feature sink

Anita Graser anitagraser at gmx.at
Sun Oct 23 04:42:56 PDT 2022


Thank you very much, Thomas. This code comparison approach is very useful indeed. 

If FeatureSink covers all functions of VectorDestination and more, that still leaves me wonder what is the downside of a FeatureSink


"Note: Consider using the more flexible QgsProcessingParameterFeatureSink wherever possible."


i.e. where is it not possible to use a Feature Sink? Only in older versions of QGIS? 


Regards,
Anita


On Saturday, 22. October 2022 23:32:11 (+02:00), Thomas Gratier wrote:


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=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 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 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

-- 
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.com
www.wheregroup.com
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885

-- 
--
Anita Graser
Home: http://anitagraser.com
Twitter: @underdarkgis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20221023/beb88a67/attachment-0001.htm>


More information about the QGIS-Developer mailing list