[QGIS-Developer] Run processing model on selected features only
matthias at opengis.ch
Thu Dec 14 01:53:04 PST 2017
On 12/14/17 10:15 AM, Nyall Dawson wrote:
> On 14 December 2017 at 17:45, Matthias Kuhn <matthias at opengis.ch> wrote:
>> When relations are involved, there needs to be a vector layer around to
>> work with these as far as I can see.
>> If this vector layer is promoted from a feature source parameter or
>> provided as vector layer input is a different question (I can live with
> What I've been wondering is whether we need some concept of "original
> layer id" in outputs generated by processing models. This could allow
> us to retrieve relation information and additionally editor widget
> config from the original source layer.
> It's bound to be requested soon that someone wants to run a model that
> does something like take a vector layer with a relation, change its
> geometry in some way, and then do something with related features.
> Regardless of whether we use vector layers or feature sources, that
> just isn't possible in models currently since the output from any
> other algorithms is a new layer, which has no knowledge of the
> original layer's relations or editor widget config. (Also layer
> metadata, which in some future release I'd like to see retained with
> every step of a model)
> I'm not sure the best way to handle this, but if it was available for
> the output layers it would be trivial to make it also available for
> feature sources, and through it allow models which use feature sources
> to take advantage of relations/editor widget config/etc.
> What do you think?
I think there are a couple of tricky things to solve here
- An algorithm can have multiple input parameters, which one would be
the original layer in this case
- Many things can change, on purpose or not. E.g. if the intermediate
layer is a shapefile, field names are corrupted and much of the original
layer meta information becomes useless
It might be better to bring interesting meta information into the
feature source, this already happens e.g. for fields (see
QgsField::editorWidgetSetup()). This keeps information under control and
Then some rules, like "using Relations with relation_aggregate is only
allowed directly on layer input". In other contexts, one will have to
resort to other aggregate constructs where one specifies involved layers
and fields explicitly and doesn't rely on project configuration.
More information about the QGIS-Developer