[Qgis-developer] [QGIS-Processing] Define optional parameters in Script

René-Luc Dhont rldhont at gmail.com
Wed Oct 28 06:31:16 PDT 2015

Hi victor,

I'd like to add optional parameter in Model.
I replied in the PR and I would like to know where changes are needed.


Le 24/10/2015 15:35, Victor Olaya a écrit :
> I replied in the PR in gitHub ;-)
> 2015-10-23 18:17 GMT+02:00 René-Luc Dhont <rldhont at gmail.com>:
>> Hi victor,
>> Because codes are sometimes better than text, I made a pull-request to
>> propose optional parameters in script and model.
>> https://github.com/qgis/QGIS/pull/2396
>> In my code, all parameters can be optional or not required and didn't modify
>> the parameters value setter.
>> I don't know if optional number, string or extent has to be None or default
>> value if it is not set by the user.
>> Reviews are welcome
>> Regards,
>> René-Luc
>> Le 11/09/2015 13:44, Victor Olaya a écrit :
>>> Aside from the syntax...I am not sure it is a good idea...
>>> I mean, it is a good idea to allow optional parameters...but that is a
>>> big change in the current semantics of Processing algorithms. Some
>>> params can be optional (layers, tables), and have a setting for that.
>>> When they are not used, their value is None, but the value has to be
>>> passed (so an optional layer param is a layer param that can be None).
>>> Allowing optional parameters would require some importante changes in
>>> many places in Processing, specially in the modeler, so i would
>>> suggest some more discussion about this.
>>> Not sure if that can maybe be added to the WPS plugin part, so nothing
>>> changes in Processing, but the WPS service exposes the parameters as
>>> optional and then fills the values with a default one before actually
>>> callin gprocessing.
>>> Hope this helps
>>> 2015-09-11 11:28 GMT+02:00 kimaidou <kimaidou at gmail.com>:
>>>> Hi
>>>> I would personaly use the second : add a new property for each input. If
>>>> not
>>>> given, this means the input is mandatory, if "opt" is present, make it
>>>> optionnal.
>>>> Cheers,
>>>> Michael
>>>> 2015-08-28 14:53 GMT+02:00 René-Luc Dhont <rldhont at gmail.com>:
>>>>> Hi Victor,
>>>>> I'm working on porting QGIS Processing to Web Processing Service, and I
>>>>> have found that all parameters in a QGIS Processing script are
>>>>> mandatory.
>>>>> It would be useful to power define some parameters as optional.
>>>>> I think that I can propose some code but I'd like to know what is your
>>>>> preferred way of defining optional parameters :
>>>>> * an header line started by 'optional' with a list of parameter name
>>>>> separated by comma
>>>>> ##optional=SEGMENTS,DISTANCE
>>>>> * an extra value at the end of the header line
>>>>> ##SEGMENTS=number 5 opt
>>>>> Thanks
>>>>> _______________________________________________
>>>>> Qgis-developer mailing list
>>>>> Qgis-developer at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>> _______________________________________________
>>>> Qgis-developer mailing list
>>>> Qgis-developer at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer

More information about the Qgis-developer mailing list