Expression Evaluator
The MapsGL expression evaluator: one implementation of the Mapbox-compatible expression language for both paint values and filters, mirroring MapsGL JS evaluateExpression.
Values are plain Kotlin: Double for numbers (JS has no integer type, and mixing Int and Double would make ["==", 5, 5.0] false), String, Boolean, List, Map and null. A missing property is null.
Time operators return Unix seconds, matching JS 1.9.4.
Supported operators:
Data:
literal,get,has,var,properties,zoom,coalesceComparison and logic:
==,!=,<,<=,>,>=,!,all,anyTypes:
to-number,to-string,to-boolean,to-date,to-time,to-locale-string,to-unit,typeof,number,string,boolean,objectMath:
+,-,*,/,%,^,abs,ceil,floor,round,min,max,sqrt,ln,ln2,log2,log10,sin,cos,tan,asin,acos,atan,e,piStrings and arrays:
at,in,regex,index-of,length,slice,concat,downcase,upcaseControl flow:
step,interpolate,case,match,letTime:
map-time(and its aliasestime,mapTime,timeline),now
format, geometry-type and interpolate-hcl / interpolate-lab are not evaluated.
Functions
Evaluates expression against context.
Evaluates expression, or returns null when it cannot be evaluated.
Evaluates a filter to a boolean, using JS truthiness: a feature is kept when the result is truthy. A filter that fails to evaluate drops the feature rather than admitting everything.