[QGIS-Developer] How to retrieve enum-input value in processing

Etienne Trimaille etienne.trimaille at gmail.com
Fri Dec 13 05:34:08 PST 2019


On which QGIS version are you?

I made this ticket a few weeks ago. You will see that the enum will give
its index and not the string as you can think.
https://github.com/qgis/QGIS/issues/32452

Nyall did some PR in 3.11.

You need to use a CASE WHEN in your expression. You can open Nyall's model
to check.

Le ven. 13 déc. 2019 à 12:25, Richard Duivenvoorde <rdmailings at duif.net> a
écrit :

> Just received a question from a user:
>
> He has a small processing model and wants to use an 'enum' (text) input
> in the model as value for a new column. Which in the column  is created
> by the 'field calculator' algorithm.
>
> But we cannot find out how to get the 'chosen' value out of the
> 'enum'-input (which are always 'strings'). Whatever we try the value of
> the new column records are always NULL
>
> To reproduce:
> - create an fresh model with an input vector layer
> - create in 'enum' input call it 'choice' with 2 values 'blue', 'red'
> - use the 'field calculator' algorithm to create a new string field
> we thought that '@choice' would be the Formula (being the value of the
> 'choice' input...
>
> BUT: the column is never filled with 'red' or 'blue'...
>
> Anybody a clue?
>
> Regards,
>
> Richard Duivenvoorde
>
> ps looking into
> https://qgis.org/api/classQgsProcessingParameterEnum.html#details
> and
> https://qgis.org/api/qgsprocessingparameters_8cpp_source.html
> dit not reveal anything to me...
> _______________________________________________
> 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/20191213/7d779f1e/attachment-0001.html>


More information about the QGIS-Developer mailing list