evaluateExpression<T> function

T? evaluateExpression<T>(
  1. Expression<T>? expression,
  2. Map<String, Object?> properties
)

Evaluates a mapstyler Expression against feature properties.

For LiteralExpression returns the literal value directly. For FunctionExpression evaluates the function against properties.

Supported functions currently include:

  • structured expressions: property, case, step, interpolate
  • numeric functions: add, subtract, multiply, divide, modulo, pow, abs, ceil, floor, round, sqrt, log, exp, min, max, pi, rint, acos, asin, atan, atan2, cos, sin, tan, toDegrees, toRadians
  • string functions: strConcat, strToLowerCase, strToUpperCase, strTrim, strLength, strSubstring, strReplace, strIndexOf, strStartsWith, strEndsWith, strMatches, numberFormat
  • boolean functions: all, any, between, equalTo, notEqualTo, greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo, in, parseBoolean, not

Unknown functions evaluate to null.

Implementation

T? evaluateExpression<T>(
  Expression<T>? expression,
  Map<String, Object?> properties,
) {
  if (expression == null) return null;
  return compileExpressionEvaluator(expression)(properties);
}