Logical functions
if_null
Arguments: [test: Nullable[Anything], else: Nullable[Anything]]
Returns: Anything
Returns the test value if it is non-null, otherwise returns the else value. This is useful for supplying a non-null default if a nullable expression yields null. For example, if_null(sum(value), 0) would return 0 if the sum function returns null.
if
Arguments: [condition: Nullable[Bool], then: Nullable[Anything], else: Nullable[Anything]]
Returns: Anything
A function that fills a similar role to an if statement in other programming languages, e.g. if(depth > 1, then: 'damaged', else: 'safe'). Either the then or the else argument is returned, depending on whether the condition expression evaluates to true or false.
In general, the return-type will be common to both the then and else expressions, or the ‘anything’ type will be used if there is no common type. If the condition argument is a ‘constant’ expression (i.e. always true or false), then either the then or else expression will always be used, and the return-type will match that.
The else argument is optional. For example if(false, 'foo') will return null and the return type will be a nullable version of the then argument’s type.
RiskScape functions evaluate their arguments before the function is called, which can be wasteful when an expression takes a while to run, e.g. a spatial lookup. To avoid this behaviour, the then and else arguments can be supplied as lambda expressions. These are only evaluated when the particular case applies. In the example of if(exposure.high_lsl_risk, () -> sample_intersections(exposure, landslide_susceptibility), else: 0) the sample_intersections function will only be called if the high_lsl_risk attribute is true, avoiding unnecessary computation.
if_then_else
Arguments: [condition: Nullable[Bool], then: Nullable[Anything], else: Nullable[Anything]]
Returns: Anything
Deprecated, if_then_else is the same as if. See if for function help.
is_null
Arguments: [Nullable[Anything]]
Returns: Bool
Returns true if the given argument is null, as per https://docs.geoserver.org/latest/en/user/filter/function_reference.html#comparison-functions
is_not_null
Arguments: [Nullable[Anything]]
Returns: Bool
Returns true if the given argument is not null, i.e. it contains a value
not
Arguments: [Bool]
Returns: Bool
Returns the negation of the given input