Expression
An Expression that evaluates to a value of type T.
The functions to create expressions are defined in the dev.sargunv.maplibrecompose.expressions.dsl
package.
Most functions are named the same as in the MapLibre style specification, a few have been renamed to be Kotlin-idiomatic or made into extension functions (to an Expression).
Function overview
Literals
Decision
switch - if-else / switch-case
coalesce - get first non-null value
not, all, any - boolean operators, also available as infix and, or
Ramps, scales, curves
step - produce stepped results
interpolate - produce interpolation
interpolateHcl - produce interpolation in HCL color space
interpolateLab - produce interpolation in CIELAB color space
Math
Inputs, feature data
zoom - get current zoom level
heatmapDensity - get heatmap density
feature.
get - get feature attributefeature.
has - check presence of feature attributefeature.
properties - get all feature attributesfeature.
state - get property from feature statefeature.
geometryType - get feature's geometry typefeature.
id - get feature idfeature.
lineProgress - progress along a gradient linefeature.
accumulated - value of accumulated cluster property so farfeature.
within - check whether feature is within geometryfeature.
distance - distance of feature to geometry
Collections
Expression<ListValue<T>>.
get - get value at indexExpression<ListValue<T>>.
contains - check whether list contains valueExpression<ListValue<T>>.
indexOf - check where the list contains valueExpression<ListValue<T>>.
slice - return a sub-listExpression<ListValue<T>>.
length - list lengthExpression<MapValue<T>>.
get - get valueExpression<MapValue<T>>.
has - check presence of key
Strings
Expression<StringValue>.
contains - check if string contains anotherExpression<StringValue>.
indexOf - check where string contains anotherExpression<StringValue>.
substring - return a sub-stringExpression<StringValue>.
length - string lengthExpression<StringValue>.
isScriptSupported - whether string is expected to render correctlyExpression<StringValue>.
uppercase - uppercase the stringExpression<StringValue>.
lowercase - lowercase the stringExpression<StringValue>.
+ - concatenate the stringresolvedLocale - return locale
Format
Color
rgbColor - create color from components
Expression<ColorValue>.
toRgbaComponents - deconstruct color into components
Image
image - image for use in
iconImage
Variable binding
withVariable - define variable within expression
Inheritors
Properties
Converts a numeric Expression to a DpValue expression.
Converts a numeric Expression to an TextUnitValue expression in EM
Converts a numeric Expression in milliseconds to a MillisecondsValue expression.
Converts a numeric Expression in seconds to a MillisecondsValue expression.
Converts a numeric Expression to an TextUnitValue expression in SP.
Functions
Returns whether both this and other expressions are true
.
Asserts that this value is a boolean.
Asserts that this is a list of numbers of length 2.
Asserts that this value is an entry of the enum specified by T.
Asserts that this value is a map.
Asserts that this value is a number.
Asserts that this is a list of numbers of length 2.
Asserts that this is a list of numbers of length 4.
Asserts that this value is a string.
Asserts that this is a list of numbers, optionally with a specific length.
Transform this expression into the equivalent CompiledExpression.
Returns whether this list contains the item.
Returns whether this string contains the substring.
Converts this expression to a boolean expression.
Converts this expression to a color expression.
Converts this expression to a number.
Converts this expression to a string.
Returns the result of floating point division of this number expression by divisor.
Returns whether this expression is equal to other.
Converts this number into a string representation using the provided formatting rules.
Returns the item at index.
Returns the value corresponding the given key or null
if it is not present in this map.
Returns whether this expression is strictly greater than other.
Returns whether this expression is greater than or equal to other.
Returns whether the given key is in this map.
Returns the first index at which the item is located in this list, or -1
if it cannot be found. Accepts an optional startIndex from where to begin the search.
Returns the first index at which the substring is located in this string, or -1
if it cannot be found. Accepts an optional startIndex from where to begin the search.
Returns true
if this string is expected to render legibly. Returns false
if this string contains sections that cannot be rendered without potential loss of meaning (e.g. Indic scripts that require complex text shaping).
Gets the length of a this list.
Gets the length of this string.
Returns this string converted to lowercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.
Returns whether this expression is strictly less than other.
Returns whether this string expression is less than or equal to other.
Returns the result of subtracting other from this number expression.
Returns whether this expression is not equal to other.
Negates this expression.
Returns whether any of this or the other expressions are true
.
Returns the sum of this number expression with other.
Concatenates this string expression with other.
Returns the result of raising this number expression to the power of exponent.
Returns the remainder after integer division of this number expression by divisor.
Returns the items in this list from the startIndex (inclusive) to the end of this list if endIndex is not specified or null
, otherwise to endIndex (exclusive).
Returns a substring from this string from the startIndex (inclusive) to the end of the string if endIndex is not specified or null
, otherwise to endIndex (exclusive).
Returns the product of this number expression with other.
Returns a four-element list, containing the color's red, green, blue, and alpha components, in that order.
Returns a string describing the type of this expression.
Negates this number expression.
Returns this string converted to uppercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.