mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-24 00:47:57 -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
14 lines
478 B
Plaintext
14 lines
478 B
Plaintext
{
|
|
"name": "round",
|
|
"type": "function",
|
|
"description": "Rounds a number to number of decimal places.",
|
|
"arguments": [
|
|
{"arg":"value","description":"decimal number to be rounded"},
|
|
{"arg":"places","optional":true,"default":"0","description":"Optional integer representing number of places to round decimals to. Can be negative."}
|
|
],
|
|
"examples": [
|
|
{ "expression":"round(1234.567, 2)", "returns":"1234.57"},
|
|
{ "expression":"round(1234.567)", "returns":"1235"}
|
|
]
|
|
}
|