[QGIS-Developer] Issues with QgsProcessingParameterFeatureSource

Nyall Dawson nyall.dawson at gmail.com
Fri Jul 6 17:38:07 PDT 2018


"
On Sat, 7 Jul 2018 at 03:26, C Hamilton <adenaculture at gmail.com> wrote:
>
> I'm trying to convert one of my Shape Tools algorithms to a processing algorithm. My existing input layer either accepts a point vector layer or a NoGeometry table. I was guessing that the proper way to implement this is:
>
> self.addParameter(
>     QgsProcessingParameterFeatureSource(
>         self.PrmInputLayer,
>         'Input layer',
>         [QgsProcessing.TypeFile, QgsProcessing.TypeVectorPoint])
> )
>
> TypeFile seems to do nothing. It certainly does not show the CSV file I have loaded that has no geometry. It filters the files so that only point layers are available. Interestingly if I use just TypeFile it seems to select all vector layer types.

TypeFile is not correct here - from the docs, TypeFile = "Files (i.e.
non map layer sources, such as text files)". There's actually no way
to show only Point layers OR Geometry-less tables. The closest is
TypeVector, which will show all vector sources, including
points/line/polygons AND no geometry tables.

But -- I'd question why you'd want to restrict your algorithm inputs
to Point/NoGeometry only in the first place. If your algorithm can
work with NoGeometry tables, it should also work with inputs with
Lines and Polygon geometries, and just ignore those. Otherwise you're
putting an artificial limitation on the inputs which can be used,
which is sure to annoy users somewhere down the line!

Nyall


More information about the QGIS-Developer mailing list