MvtExpressionParser

Parses Mapbox-GL JSON expression arrays into MvtExpression trees. Supports the subset documented on MvtExpression (literals + sources + comparisons + boolean + arithmetic + case/match/step + interpolate + coercion).

Two typed entry-points cover the paint-property use cases:

  • parseFloat — for numeric properties (line-width, text-size, text-halo-width).

  • parseColor — for color properties (fill-color, line-color, text-color).

Sub-expressions used inside conditionals/branches are parsed via parseAny, whose concrete value type depends on the leaf literals encountered.

Unsupported operators return null; the caller decides whether that falls back to a default or skips the property entirely.

Functions

Link copied to clipboard
fun parseAny(el: JsonElement, parseColor: (String) -> Color??): MvtExpression<*>?

Parse a JSON value/array with no target-type hint. Used for sub-expressions.

Link copied to clipboard
fun parseColor(el: JsonElement, parseColor: (String) -> Color?): MvtExpression<Color>?

Parse a JSON value/array as a Color-valued expression.

Link copied to clipboard
fun parseFloat(el: JsonElement): MvtExpression<Float>?

Parse a JSON value/array as a Float-valued expression.