Class MBExpression

All Implemented Interfaces:
Expression, Function
Direct Known Subclasses:
MBColor, MBDecision, MBFeatureData, MBHeatmap, MBLookup, MBMath, MBRampsScalesCurves, MBString, MBTypes, MBVariableBinding, MBZoom

public abstract class MBExpression extends FunctionImpl
The value for any layout property, paint property, or filter may be specified as an expression. An expression defines a formula for computing the value of the property using the operators described below: -Mathematical operators for performing arithmetic and other operations on numeric values -Logical operators for manipulating boolean values and making conditional decisions -String operators for manipulating strings -Data operators, providing access to the properties of source features -Camera operators, providing access to the parameters defining the current map view

Expressions are represented as JSON arrays. The first element of an expression array is a string naming the expression operator, e.g. "*"or "case". Subsequent elements (if any) are the arguments to the expression. Each argument is either a literal value (a string, number, boolean, or null), or another expression array.

  • Field Details

    • json

      protected final JSONArray json
    • name

      protected final String name
    • ff

      protected final FilterFactory ff
    • parse

      protected final MBObjectParser parse
    • transformer

      protected final MBStyleTransformer transformer
    • colors

      public static final List<String> colors
    • decisions

      public static final List<String> decisions
    • featureData

      public static final List featureData
    • heatMap

      public static final List heatMap
    • lookUp

      public static final List lookUp
    • math

      public static final List math
    • ramps

      public static final List ramps
    • string

      public static final List string
    • types

      public static final List types
    • variableBindings

      public static final List variableBindings
    • zoom

      public static final List zoom
  • Constructor Details

    • MBExpression

      protected MBExpression(JSONArray json)
      Please use factory method create(JSONArray)
      Parameters:
      json - definition
  • Method Details

    • getName

      public String getName()
      Description copied from class: FunctionImpl
      Gets the name of this function.
      Specified by:
      getName in interface Function
      Overrides:
      getName in class FunctionImpl
      Returns:
      the name of the function.
    • create

      public static MBExpression create(JSONArray json)
      Factory method used to produce the correct MBExpression subclass for the provided JSONArray.
      Parameters:
      json - definition
      Returns:
      MBExpression
    • canCreate

      public static boolean canCreate(String name)
    • getExpression

      public abstract Expression getExpression()
      Determines which expression to use.
    • transformLiteral

      public Expression transformLiteral(Expression ex)
      A function to evaluate a given parameter as an expression and use the MBStyleTransformer to transform Mapbox tokens into CQL expressions.
      Returns:
      cq; text expression
    • transformExpression

      public static Expression transformExpression(JSONArray json)
      Creates an MBExpression and calls the associated function.
    • throwUnexpectedArgumentCount

      protected void throwUnexpectedArgumentCount(String expression, int argCount) throws MBFormatException
      Throws:
      MBFormatException
    • throwInsufficientArgumentCount

      protected void throwInsufficientArgumentCount(String expression, int argCount) throws MBFormatException
      Throws:
      MBFormatException