Nyall Dawson ae00eb965c [FEATURE] Allow expression functions to use named parameters
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
2016-04-04 13:59:13 +10:00

14 lines
541 B
Plaintext

{
"name": "azimuth",
"type": "function",
"description": "Returns the north-based azimuth as the angle in radians measured clockwise from the vertical on point_a to point_b.",
"arguments": [
{"arg":"point_a","description":"point geometry"},
{"arg":"point_b","description":"point geometry"}
],
"examples": [
{ "expression":"degrees( azimuth( make_point(25, 45), make_point(75, 100) ) )", "returns":"42.273689"},
{ "expression":"degrees( azimuth( make_point(75, 100), make_point(25,45) ) )", "returns":"222.273689"}
]
}