mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
This commit sets the framework for allowing expression functions to use named parameters. Ie, instead of: clamp(1,2,3) you can use: clamp( min:=1, value:=2, max:=3) This also allows arguments to be switched, eg: clamp( value:=2, max:=3, min:=1) Additionally, it allows for a more structured definition of function parameters to handle optional arguments and default values for parameters. These are currently being done using a hacky infinite argument list. I've utilised the postgres ':=' syntax for specifying named arguments to avoid potential collisions which may arise with the equality test if we re-used just the '=' operator alone. Sponsored by North Road
9 lines
534 B
Plaintext
9 lines
534 B
Plaintext
{
|
|
"name": "randf",
|
|
"type": "function",
|
|
"description": "Returns a random float within the range specified by the minimum and maximum argument (inclusive).",
|
|
"arguments": [ {"arg":"min","optional":true,"default":"0.0","description":"an float representing the smallest possible random number desired"},
|
|
{"arg":"max","optional":true,"default":"1.0","description":"an float representing the largest possible random number desired"}],
|
|
"examples": [ { "expression":"randf(1, 10)", "returns":"4.59258286403147"}]
|
|
}
|