These functions provide convenient one-line methods for evaluating expressions.
Boolean Boolean(value) -> BooleanFunction bundle: Core
Attempts to convert the given non-boolean value to a boolean value. For example a text value of 'true' would become true
.
Parameter
Return value: Boolean
Examples
Use dark colors for code blocks Copy
1
2
// returns `true`
Boolean('true')
Use dark colors for code blocks Copy
1
2
// returns `false`. A value of 1 would return `true`
Boolean(0)
Use dark colors for code blocks Copy
1
2
// returns `false`
Boolean('hello')
Decode Decode(expression, [compare1, return1, ..., compareN, returnN], default) -> Any
Function bundle: Core
Evaluates an expression to a value and compares the result value with the value of subsequent parameters. If the expression evaluates to a matching value, it returns the subsequent parameter value. If no matches are found, then the default
value will be returned. This is similar to a switch/case statement.
Parameters
Return value: Any
Returns the matched return value. If no matches are found, then the default
value is returned.
Example
Use dark colors for code blocks Copy
1
2
3
// returns a meaningful value when a field contains coded values
var code = $feature.codedValue;
var decodedValue = Decode(code, 1, 'Residential', 2, 'Commercial', 3, 'Mixed', 'Other');
DefaultValue DefaultValue(value, defaultValue) -> Any
Function bundle: Core
Returns a specified default value if an empty value is detected.
Parameters
null
or ''
. This may be a value of any type. However, if this value is an empty array, then the empty array will be returned.value
is empty. The data type of defaultValue
must match the data type of value
.Return value: Any
If value
is empty, then the defaultValue
is returned. Otherwise, the value of value
is returned.
Example
Use dark colors for code blocks Copy
1
2
3
// If a feature has no value in the POP_2000 field
// then 'no data' is returned
DefaultValue($feature.POP_2000, 'no data')
Equals Equals(value1, value2) -> Boolean
Function bundle: Core
Indicates if two values are equal. Object types (i.e. Arrays, Features, Dictionaries, Geometry) will return true only if they are the same object.
Parameters
Return value: Boolean
Example
Compares if two values are equal
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
Equals(1, "1") // returns false
var testVal = "test";
Equals(testVal, "test") // returns true
var array1 = Array(5);
var array2 = Array(5);
Equals(array1, array2); // returns false
Equals(array1, array1); // returns true
IIf IIf(condition, trueValue, falseValue) -> Any
Function bundle: Core
Returns a given value if a conditional expression evaluates to true
, and returns an alternate value if that condition evaluates to false
.
Parameters
true
or false
.condition
evaluates to true
. This may be a value of any type.condition
evaluates to false
. This may be a value of any type.Return value: Any
If condition
is true
, then the trueValue
is returned. Otherwise, the value of falseValue
is returned.
Example
Use dark colors for code blocks Copy
1
2
3
4
// returns 'below' if the value is less than 1,000,000.
// if the value is more than 1,000,000, then returns 'above'
var population = $feature.POP_2007;
IIf(population < 1000000, 'below', 'above');
IsEmpty IsEmpty(value) -> Boolean
Function bundle: Core
Returns true
if the provided value is null
or an empty text (e.g. ''
). Returns false
for all other cases, including empty arrays and dictionaries.
Parameter
null
or ''
. This may be a value of any type.Return value: Boolean
Examples
Use dark colors for code blocks Copy
1
2
// Returns true
IsEmpty(null)
Use dark colors for code blocks Copy
1
2
// Returns false
IsEmpty('hello world')
IsNan IsNan(value) -> Boolean
Function bundle: Core
Indicates whether the input value is not a number (NaN). A number is considered NaN in one of the following scenarios: - 0/0
- Infinity / Infinity
- Infinity * 0
- Any operation in which NaN is an operand - Casting a non-numeric text or undefined
to a number
Parameter
Return value: Boolean
Examples
Use dark colors for code blocks Copy
1
2
// Returns true
IsNan(Infinity / Infinity)
Use dark colors for code blocks Copy
1
2
// Returns false
IsNan('4')
TypeOf TypeOf(value) -> Text
Function bundle: Core
Returns the type of the input value. Will return one of the following types: Array, Date, Text, Boolean, Number, Dictionary, Feature, FeatureSet, Point, Polygon, Polyline, Multipoint, Extent, Function, Unrecognized Type.
Parameter
Return value: Text
Examples
prints 'Boolean'
Use dark colors for code blocks Copy
prints 'Date'
Use dark colors for code blocks Copy
When When(expression1, result1, [expression2, result2, ..., expressionN, resultN]?, defaultValue) -> AnyFunction bundle: Core
Evaluates a series of conditional expressions until one evaluates to true
.
Parameters
true
then result1
will be returned.expression1
evaluates to true
. This may be a value of any type.true
. This may be a value of any type.false
. This may be a value of any type.Return value: Any
Example
Reclassify a numeric field value to a generic ranking (text).
If all expressions are false
, then 'n/a' is returned
Use dark colors for code blocks Copy
1
2
var density = $feature.densityField;
var ranking = When(density < 50, 'low', density >=50 && density < 100, 'medium', density >= 100, 'high', 'n/a');
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4