[QGIS-Developer] Issues with QgsProcessingParameterFeatureSource

C Hamilton adenaculture at gmail.com
Mon Jul 9 07:44:52 PDT 2018


The function I am working with is the XY to Line utility which expects each
record in the data to have two location points. This could be in the form
of just a NoGeometry table with two coordinates as part of the fields or it
could be a point layer with one of the points represented by the layer
geometry and the other within the table data. I guess I will need to open
it up to include Lines and Polygons, but I don't think the source of this
data would ever be a line or polygon, but who knows what users may do.

On Fri, Jul 6, 2018 at 8:38 PM, Nyall Dawson <nyall.dawson at gmail.com> wrote:

> "
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180709/1a1fcc2d/attachment.html>


More information about the QGIS-Developer mailing list