Class Expression
- Direct Known Subclasses:
Expression.ExpressionLiteral,Expression.Interpolator
- Element
- 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.
Data expression: a data expression is any expression that access feature data -- that is, any expression that uses one of the data operators:get,has,id,geometry-type, or properties. Data expressions allow a feature's properties to determine its appearance. They can be used to differentiate features within the same layer and to create data visualizations.
Camera expression: a camera expression is any expression that uses the zoom operator. Such expressions allow the the appearance of a layer to change with the map's zoom level. Camera expressions can be used to create the appearance of depth and to control data density.
Composition: a single expression may use a mix of data operators, camera operators, and other operators. Such composite expressions allows a layer's appearance to be determined by a combination of the zoom level and individual feature properties.
Example expression:
FillLayer fillLayer = new FillLayer("layer-id", "source-id");
fillLayer.setProperties(
fillColor(
interpolate( linear(), zoom(),
stop(12, step(get("stroke-width"),
color(Color.BLACK),
stop(1f, color(Color.RED)),
stop(2f, color(Color.WHITE)),
stop(3f, color(Color.BLUE))
)),
stop(15, step(get("stroke-width"),
color(Color.BLACK),
stop(1f, color(Color.YELLOW)),
stop(2f, color(Color.LTGRAY)),
stop(3f, color(Color.CYAN))
)),
stop(18, step(get("stroke-width"),
color(Color.BLACK),
stop(1f, color(Color.WHITE)),
stop(2f, color(Color.GRAY)),
stop(3f, color(Color.GREEN))
))
)
)
);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classExpression array type.static final classConverts a JsonArray or a raw expression to a Java expression.static classExpressionLiteral wraps an object to be used as a literal in an expression.static classHolds format entries used in aformat(FormatEntry...)expression.static classHolds format options used in aformatEntry(Expression, FormatOption...)that builds aformat(FormatEntry...)expression.static classExpression interpolator type.static classHolds format options used in anumberFormat(Number, NumberFormatOption...)expression.static classExpression stop type. -
Constructor Summary
ConstructorsConstructorDescriptionExpression(String operator, Expression... arguments) Creates an expression from its operator and varargs expressions. -
Method Summary
Modifier and TypeMethodDescriptionstatic Expressionabs(Expression expression) Returns the absolute value of the input.static ExpressionReturns the absolute value of the input.static ExpressionGets the value of a cluster property accumulated so far.static Expressionacos(Expression number) Returns the arccosine of the input.static ExpressionReturns the arccosine of the input.static Expressionall(Expression... input) Returns `true` if all the inputs are `true`, `false` otherwise.static Expressionany(Expression... input) Returns `true` if any of the inputs are `true`, `false` otherwise.static Expressionarray(Expression input) Asserts that the input is an array (optionally with a specific item type and length).static Expressionasin(Expression number) Returns the arcsine of the input.static ExpressionReturns the arcsine of the input.static Expressionat(Expression number, Expression expression) Retrieves an item from an array.static Expressionat(Number number, Expression expression) Retrieves an item from an array.static Expressionatan(Expression number) Returns the arctangent of the input.static ExpressionReturns the arctangent of the input.static Expressionbool(Expression... input) Asserts that the input value is a boolean.static Expressionceil(Expression expression) Returns the smallest integer that is greater than or equal to the input.static ExpressionReturns the smallest integer that is greater than or equal to the input.static Expressioncoalesce(Expression... input) Evaluates each expression in turn until the first non-null value is obtained, and returns that value.static Expressioncollator(boolean caseSensitive, boolean diacriticSensitive) Returns a collator for use in locale-dependent comparison operations.static ExpressionReturns a collator for use in locale-dependent comparison operations.static Expressioncollator(Expression caseSensitive, Expression diacriticSensitive) Returns a collator for use in locale-dependent comparison operations.static Expressioncollator(Expression caseSensitive, Expression diacriticSensitive, Expression locale) Returns a collator for use in locale-dependent comparison operations.static Expressioncolor(int color) Expression literal utility method to convert a color int to an color expressionstatic Expressionconcat(Expression... input) Returns a string consisting of the concatenation of the inputs.static ExpressionReturns a string consisting of the concatenation of the inputs.static Expressioncos(Expression number) Returns the cosine of the input.static ExpressionReturns the cosine of the input.static Expression.InterpolatorcubicBezier(Expression x1, Expression y1, Expression x2, Expression y2) Interpolates using the cubic bezier curve defined by the given control points.static Expression.InterpolatorcubicBezier(Number x1, Number y1, Number x2, Number y2) Interpolates using the cubic bezier curve defined by the given control points.static Expressiondistance(com.trimblemaps.geojson.GeoJson geoJson) Retrieves the shortest distance between two geometries.static Expressiondivision(Expression first, Expression second) Returns the result of floating point division of the first input by the second.static ExpressionReturns the result of floating point division of the first input by the second.static Expressiondowncase(Expression input) Returns the input string converted to lowercase.static ExpressionReturns the input string converted to lowercase.static Expressione()Returns the mathematical constant e.static Expressioneq(Expression compareOne, boolean compareTwo) Returns true if the input values are equal, false otherwise.static Expressioneq(Expression compareOne, Expression compareTwo) Returns true if the input values are equal, false otherwise.static Expressioneq(Expression compareOne, Expression compareTwo, Expression collator) Returns true if the input values are equal, false otherwise.static Expressioneq(Expression compareOne, Number compareTwo) Returns true if the input values are equal, false otherwise.static Expressioneq(Expression compareOne, String compareTwo) Returns true if the input values are equal, false otherwise.static Expressioneq(Expression compareOne, String compareTwo, Expression collator) Returns true if the input values are equal, false otherwise.booleanIndicates whether some other object is "equal to" this one.static Expression.Interpolatorexponential(Expression expression) Interpolates exponentially between the stops just less than and just greater than the input.static Expression.Interpolatorexponential(Number base) Interpolates exponentially between the stops just less than and just greater than the input.static Expressionfloor(Expression expression) Returns the largest integer that is less than or equal to the input.static ExpressionReturns the largest integer that is less than or equal to the input.static Expressionformat(Expression.FormatEntry... formatEntries) Returns formatted text containing annotations for use in mixed-format text-field entries.static Expression.FormatEntryformatEntry(Expression text) Returns a format entry that can be used informat(FormatEntry...)to create formatted text fields.static Expression.FormatEntryformatEntry(Expression text, Expression.FormatOption... formatOptions) Returns a format entry that can be used informat(FormatEntry...)to create formatted text fields.static Expression.FormatEntryformatEntry(String text) Returns a format entry that can be used informat(FormatEntry...)to create formatted text fields.static Expression.FormatEntryformatEntry(String text, Expression.FormatOption... formatOptions) Returns a format entry that can be used informat(FormatEntry...)to create formatted text fields.static ExpressionGets the feature's geometry type: Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon.static Expressionget(Expression input) Retrieves a property value from the current feature's properties, or from another object if a second argument is provided.static Expressionget(Expression key, Expression object) Retrieves a property value from another object.static ExpressionRetrieves a property value from the current feature's properties, or from another object if a second argument is provided.static Expressionget(String key, Expression object) Retrieves a property value from another object.static Expressiongt(Expression compareOne, Expression compareTwo) Returns true if the first input is strictly greater than the second, false otherwise.static Expressiongt(Expression compareOne, Expression compareTwo, Expression collator) Returns true if the first input is strictly greater than the second, false otherwise.static Expressiongt(Expression compareOne, Number compareTwo) Returns true if the first input is strictly greater than the second, false otherwise.static Expressiongt(Expression compareOne, String compareTwo) Returns true if the first input is strictly greater than the second, false otherwise.static Expressiongt(Expression compareOne, String compareTwo, Expression collator) Returns true if the first input is strictly greater than the second, false otherwise.static Expressiongte(Expression compareOne, Expression compareTwo) Returns true if the first input is greater than or equal to the second, false otherwise.static Expressiongte(Expression compareOne, Expression compareTwo, Expression collator) Returns true if the first input is greater than or equal to the second, false otherwise.static Expressiongte(Expression compareOne, Number compareTwo) Returns true if the first input is greater than or equal to the second, false otherwise.static Expressiongte(Expression compareOne, String compareTwo) Returns true if the first input is greater than or equal to the second, false otherwise.static Expressiongte(Expression compareOne, String compareTwo, Expression collator) Returns true if the first input is greater than or equal to the second, false otherwise.static Expressionhas(Expression key) Tests for the presence of an property value in the current feature's properties.static Expressionhas(Expression key, Expression object) Tests for the presence of an property value from another object.static ExpressionTests for the presence of an property value in the current feature's properties.static Expressionhas(String key, Expression object) Tests for the presence of an property value from another object.inthashCode()Returns a hash code value for the expression.static ExpressionGets the kernel density estimation of a pixel in a heatmap layer, which is a relative measure of how many data points are crowded around a particular pixel.static Expressionid()Gets the feature's id, if it has one.static Expressionimage(Expression input) Returns image expression for use in '*-pattern' and 'icon-image' layer properties.static Expressionin(Expression needle, Expression haystack) Retrieves whether an item exists in an array or a substring exists in a string.static Expressionin(Number needle, Expression haystack) Retrieves whether an item exists in an array or a substring exists in a string.static Expressionin(String needle, Expression haystack) Retrieves whether an item exists in an array or a substring exists in a string.static ExpressionindexOf(Expression keyword, Expression input) Returns the first position at which a `needle` can be found in a `haystack`.static ExpressionindexOf(Expression keyword, Expression input, Expression fromIndex) Returns the first position at which a `needle` can be found in a `haystack`.static Expressioninterpolate(Expression.Interpolator interpolation, Expression number, Expression... stops) Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\").static Expressioninterpolate(Expression.Interpolator interpolation, Expression number, Expression.Stop... stops) Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\").static ExpressionisSupportedScript(Expression expression) Returns true if the input string is expected to render legibly.static ExpressionisSupportedScript(String string) Returns true if the input string is expected to render legibly.static Expressionlength(Expression expression) Gets the length of an array or string.static ExpressionGets the length of an array or string.static Expressionlet(Expression... input) Binds input to named variables, which can then be referenced in the result expression usingvar(String)orvar(Expression).static Expression.Interpolatorlinear()interpolates linearly between the pair of stops just less than and just greater than the input.static ExpressionGets the progress along a gradient line.static Expressionliteral(boolean bool) Create a literal boolean expression.static ExpressionCreate a literal number expression.static ExpressionCreate a literal object expression.static ExpressionCreate a literal array expressionstatic ExpressionCreate a literal string expression.static Expressionln(Expression number) Returns the natural logarithm of the input.static ExpressionReturns the natural logarithm of the input.static Expressionln2()Returns mathematical constant ln(2).static Expressionlog10(Expression number) Returns the base-ten logarithm of the input.static ExpressionReturns the base-ten logarithm of the input.static Expressionlog2(Expression number) Returns the base-two logarithm of the input.static ExpressionReturns the base-two logarithm of the input.static Expressionlt(Expression compareOne, Expression compareTwo) Returns true if the first input is strictly less than the second, false otherwise.static Expressionlt(Expression compareOne, Expression compareTwo, Expression collator) Returns true if the first input is strictly less than the second, false otherwise.static Expressionlt(Expression compareOne, Number compareTwo) Returns true if the first input is strictly less than the second, false otherwise.static Expressionlt(Expression compareOne, String compareTwo) Returns true if the first input is strictly less than the second, false otherwise.static Expressionlt(Expression compareOne, String compareTwo, Expression collator) Returns true if the first input is strictly less than the second, false otherwise.static Expressionlte(Expression compareOne, Expression compareTwo) Returns true if the first input is less than or equal to the second, false otherwise.static Expressionlte(Expression compareOne, Expression compareTwo, Expression collator) Returns true if the first input is less than or equal to the second, false otherwise.static Expressionlte(Expression compareOne, Number compareTwo) Returns true if the first input is less than or equal to the second, false otherwise.static Expressionlte(Expression compareOne, String compareTwo) Returns true if the first input is less than or equal to the second, false otherwise.static Expressionlte(Expression compareOne, String compareTwo, Expression collator) Returns true if the first input is less than or equal to the second, false otherwise.static Expressionmatch(Expression... input) Selects the output whose label value matches the input value, or the fallback value if no match is found.static Expressionmatch(Expression input, Expression defaultOutput, Expression.Stop... stops) Selects the output whose label value matches the input value, or the fallback value if no match is found.static Expressionmax(Expression... numbers) Returns the maximum value of the inputs.static ExpressionReturns the maximum value of the inputs.static Expressionmin(Expression... numbers) Returns the minimum value of the inputs.static ExpressionReturns the minimum value of the inputs.static Expressionmod(Expression first, Expression second) Returns the remainder after integer division of the first input by the second.static ExpressionReturns the remainder after integer division of the first input by the second.static Expressionneq(Expression compareOne, boolean compareTwo) Returns true if the input values are equal, false otherwise.static Expressionneq(Expression compareOne, Expression compareTwo) Returns true if the input values are not equal, false otherwise.static Expressionneq(Expression compareOne, Expression compareTwo, Expression collator) Returns true if the input values are not equal, false otherwise.static Expressionneq(Expression compareOne, Number compareTwo) Returns `true` if the input values are not equal, `false` otherwise.static Expressionneq(Expression compareOne, String compareTwo) Returns `true` if the input values are not equal, `false` otherwise.static Expressionneq(Expression compareOne, String compareTwo, Expression collator) Returns true if the input values are not equal, false otherwise.static Expressionnot(boolean input) Logical negation.static Expressionnot(Expression input) Logical negation.static Expressionnumber(Expression... input) Asserts that the input value is a number.static ExpressionnumberFormat(Expression number, Expression.NumberFormatOption... options) Converts the input number into a string representation using the providing formatting rules.static ExpressionnumberFormat(Number number, Expression.NumberFormatOption... options) Converts the input number into a string representation using the providing formatting rules.static Expressionobject(Expression input) Asserts that the input value is an object.static Expressionpi()Returns the mathematical constant pi.static Expressionpow(Expression first, Expression second) Returns the result of raising the first input to the power specified by the second.static ExpressionReturns the result of raising the first input to the power specified by the second.static Expressionproduct(Expression... numbers) Returns the product of the inputs.static ExpressionReturns the product of the inputs.static ExpressionGets the feature properties object.static ExpressionReturns a DSL equivalent of a raw expression.static ExpressionresolvedLocale(Expression collator) Returns the IETF language tag of the locale being used by the provided collator.static Expressionrgb(Expression red, Expression green, Expression blue) Creates a color value from red, green, and blue components, which must range between 0 and 255, and an alpha component of 1.static ExpressionCreates a color value from red, green, and blue components, which must range between 0 and 255, and an alpha component of 1.static Expressionrgba(Expression red, Expression green, Expression blue, Expression alpha) Creates a color value from red, green, blue components, which must range between 0 and 255, and an alpha component which must range between 0 and 1.static ExpressionCreates a color value from red, green, blue components, which must range between 0 and 255, and an alpha component which must range between 0 and 1.static Expressionround(Expression expression) Rounds the input to the nearest integer.static ExpressionRounds the input to the nearest integer.static Expressionsin(Expression number) Returns the sine of the input.static ExpressionReturns the sine of the input.static Expressionslice(Expression input, Expression fromIndex) Returns items from an array or a substring from a string from a specified start index.static Expressionslice(Expression input, Expression fromIndex, Expression toIndex) Returns items from an array or a substring from a string between a start index and an end index if set.static Expressionsqrt(Expression number) Returns the square root of the inputstatic ExpressionReturns the square root of the inputstatic Expressionstep(Expression input, Expression defaultOutput, Expression... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\").static Expressionstep(Expression input, Expression defaultOutput, Expression.Stop... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\").static Expressionstep(Expression input, Number defaultOutput, Expression... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\").static Expressionstep(Expression input, Number defaultOutput, Expression.Stop... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\").static Expressionstep(Number input, Expression defaultOutput, Expression... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\").static Expressionstep(Number input, Expression defaultOutput, Expression.Stop... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\").static Expressionstep(Number input, Number defaultOutput, Expression... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\").static Expressionstep(Number input, Number defaultOutput, Expression.Stop... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\").static Expression.StopProduces a stop value.static Expressionstring(Expression... input) Asserts that the input value is a string.static Expressionsubtract(Expression number) Returns the result of subtracting a number from 0.static Expressionsubtract(Expression first, Expression second) Returns the result of subtracting the second input from the first.static ExpressionReturns the result of subtracting a number from 0.static ExpressionReturns the result of subtracting the second input from the first.static Expressionsum(Expression... numbers) Returns the sum of the inputs.static ExpressionReturns the sum of the inputs.static ExpressionswitchCase(Expression... input) Selects the first output whose corresponding test condition evaluates to true.static Expressiontan(Expression number) Returns the tangent of the input.static ExpressionReturns the tangent of the input.Object[]toArray()Converts the expression to Object array representation.static ExpressiontoBool(Expression input) Converts the input value to a boolean.static ExpressiontoColor(Expression input) Converts the input value to a color.static ExpressiontoNumber(Expression input) Converts the input value to a number, if possible.static ExpressiontoRgba(Expression expression) Returns a four-element array containing the input color's red, green, blue, and alpha components, in that order.toString()Returns a string representation of the object that matches the definition set in the style specification.static ExpressiontoString(Expression input) Converts the input value to a string.static ExpressiontypeOf(Expression input) Returns a string describing the type of the given value.static Expressionupcase(Expression string) Returns the input string converted to uppercase.static ExpressionReturns the input string converted to uppercase.static Expressionvar(Expression expression) References variable bound using let.static ExpressionReferences variable bound using let.static Expressionwithin(com.trimblemaps.geojson.Polygon polygon) static Expressionzoom()Gets the current zoom level.
-
Constructor Details
-
Expression
Creates an expression from its operator and varargs expressions.- Parameters:
operator- the expression operatorarguments- expressions input
-
-
Method Details
-
literal
Create a literal number expression.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(literal(10.0f)) );- Parameters:
number- the number- Returns:
- the expression
-
literal
Create a literal string expression.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(literal("Text")) );- Parameters:
string- the string- Returns:
- the expression
-
literal
Create a literal boolean expression.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillAntialias(literal(true)) );- Parameters:
bool- the boolean- Returns:
- the expression
-
literal
Create a literal object expression.- Parameters:
object- the object- Returns:
- the expression
-
literal
Create a literal array expression- Parameters:
array- the array- Returns:
- the expression
-
color
Expression literal utility method to convert a color int to an color expressionExample usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor(color(Color.GREEN)) );- Parameters:
color- the int color- Returns:
- the color expression
-
rgb
public static Expression rgb(@NonNull Expression red, @NonNull Expression green, @NonNull Expression blue) Creates a color value from red, green, and blue components, which must range between 0 and 255, and an alpha component of 1.If any component is out of range, the expression is an error.
Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( rgb( literal(255.0f), literal(255.0f), literal(255.0f) ) ) );- Parameters:
red- red color expressiongreen- green color expressionblue- blue color expression- Returns:
- expression
-
rgb
Creates a color value from red, green, and blue components, which must range between 0 and 255, and an alpha component of 1.If any component is out of range, the expression is an error.
Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( rgb(255.0f, 255.0f, 255.0f) ) );- Parameters:
red- red color valuegreen- green color valueblue- blue color value- Returns:
- expression
-
rgba
public static Expression rgba(@NonNull Expression red, @NonNull Expression green, @NonNull Expression blue, @NonNull Expression alpha) Creates a color value from red, green, blue components, which must range between 0 and 255, and an alpha component which must range between 0 and 1.If any component is out of range, the expression is an error.
Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( rgba( literal(255.0f), literal(255.0f), literal(255.0f), literal(1.0f) ) ) );- Parameters:
red- red color valuegreen- green color valueblue- blue color valuealpha- alpha color value- Returns:
- expression
-
rgba
public static Expression rgba(@NonNull Number red, @NonNull Number green, @NonNull Number blue, @NonNull Number alpha) Creates a color value from red, green, blue components, which must range between 0 and 255, and an alpha component which must range between 0 and 1.If any component is out of range, the expression is an error.
Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( rgba(255.0f, 255.0f, 255.0f, 1.0f) ) );- Parameters:
red- red color valuegreen- green color valueblue- blue color valuealpha- alpha color value- Returns:
- expression
-
toRgba
Returns a four-element array containing the input color's red, green, blue, and alpha components, in that order.- Parameters:
expression- an expression to convert to a color- Returns:
- expression
-
eq
Returns true if the input values are equal, false otherwise. The inputs must be numbers, strings, or booleans, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( eq(get("keyToValue"), get("keyToOtherValue")) );- Parameters:
compareOne- the first expressioncompareTwo- the second expression- Returns:
- expression
-
eq
public static Expression eq(@NonNull Expression compareOne, @NonNull Expression compareTwo, @NonNull Expression collator) Returns true if the input values are equal, false otherwise. The inputs must be numbers, strings, or booleans, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( eq(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second expressioncollator- the collator expression- Returns:
- expression
-
eq
Returns true if the input values are equal, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( eq(get("keyToValue"), true) );- Parameters:
compareOne- the first expressioncompareTwo- the second boolean- Returns:
- expression
-
eq
Returns true if the input values are equal, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( eq(get("keyToValue"), "value") );- Parameters:
compareOne- the first expressioncompareTwo- the second number- Returns:
- expression
-
eq
public static Expression eq(@NonNull Expression compareOne, @NonNull String compareTwo, @NonNull Expression collator) Returns true if the input values are equal, false otherwise. The inputs must be numbers, strings, or booleans, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( eq(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second Stringcollator- the collator expression- Returns:
- expression
-
eq
Returns true if the input values are equal, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( eq(get("keyToValue"), 2.0f) );- Parameters:
compareOne- the first expressioncompareTwo- the second number- Returns:
- expression
-
neq
Returns true if the input values are not equal, false otherwise. The inputs must be numbers, strings, or booleans, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( neq(get("keyToValue"), get("keyToOtherValue")) );- Parameters:
compareOne- the first expressioncompareTwo- the second expression- Returns:
- expression
-
neq
public static Expression neq(@NonNull Expression compareOne, @NonNull Expression compareTwo, @NonNull Expression collator) Returns true if the input values are not equal, false otherwise. The inputs must be numbers, strings, or booleans, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( neq(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second expressioncollator- the collator expression- Returns:
- expression
-
neq
Returns true if the input values are equal, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( neq(get("keyToValue"), true) );- Parameters:
compareOne- the first expressioncompareTwo- the second boolean- Returns:
- expression
-
neq
Returns `true` if the input values are not equal, `false` otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( neq(get("keyToValue"), "value") );- Parameters:
compareOne- the first expressioncompareTwo- the second string- Returns:
- expression
-
neq
public static Expression neq(@NonNull Expression compareOne, @NonNull String compareTwo, @NonNull Expression collator) Returns true if the input values are not equal, false otherwise. The inputs must be numbers, strings, or booleans, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( neq(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second Stringcollator- the collator expression- Returns:
- expression
-
neq
Returns `true` if the input values are not equal, `false` otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( neq(get("keyToValue"), 2.0f) );- Parameters:
compareOne- the first expressioncompareTwo- the second number- Returns:
- expression
-
gt
Returns true if the first input is strictly greater than the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gt(get("keyToValue"), get("keyToOtherValue")) );- Parameters:
compareOne- the first expressioncompareTwo- the second expression- Returns:
- expression
-
gt
public static Expression gt(@NonNull Expression compareOne, @NonNull Expression compareTwo, @NonNull Expression collator) Returns true if the first input is strictly greater than the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gt(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second expressioncollator- the collator expression- Returns:
- expression
-
gt
Returns true if the first input is strictly greater than the second, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gt(get("keyToValue"), 2.0f) );- Parameters:
compareOne- the first expressioncompareTwo- the second number- Returns:
- expression
-
gt
Returns true if the first input is strictly greater than the second, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gt(get("keyToValue"), "value") );- Parameters:
compareOne- the first expressioncompareTwo- the second string- Returns:
- expression
-
gt
public static Expression gt(@NonNull Expression compareOne, @NonNull String compareTwo, @NonNull Expression collator) Returns true if the first input is strictly greater than the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gt(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second Stringcollator- the collator expression- Returns:
- expression
-
lt
Returns true if the first input is strictly less than the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lt(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second expression- Returns:
- expression
-
lt
public static Expression lt(@NonNull Expression compareOne, @NonNull Expression compareTwo, @NonNull Expression collator) Returns true if the first input is strictly less than the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lt(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second numbercollator- the collator expression- Returns:
- expression
-
lt
Returns true if the first input is strictly less than the second, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lt(get("keyToValue"), 2.0f) );- Parameters:
compareOne- the first expressioncompareTwo- the second number- Returns:
- expression
-
lt
Returns true if the first input is strictly less than the second, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lt(get("keyToValue"), "value") );- Parameters:
compareOne- the first expressioncompareTwo- the second string- Returns:
- expression
-
lt
public static Expression lt(@NonNull Expression compareOne, @NonNull String compareTwo, @NonNull Expression collator) Returns true if the first input is strictly less than the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lt(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second Stringcollator- the collator expression- Returns:
- expression
-
gte
Returns true if the first input is greater than or equal to the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gte(get("keyToValue"), get("keyToOtherValue")) );- Parameters:
compareOne- the first expressioncompareTwo- the second expression- Returns:
- expression
-
gte
public static Expression gte(@NonNull Expression compareOne, @NonNull Expression compareTwo, @NonNull Expression collator) Returns true if the first input is greater than or equal to the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gte(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second expressioncollator- the collator expression- Returns:
- expression
-
gte
Returns true if the first input is greater than or equal to the second, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gte(get("keyToValue"), 2.0f) );- Parameters:
compareOne- the first expressioncompareTwo- the second number- Returns:
- expression
-
gte
Returns true if the first input is greater than or equal to the second, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( neq(get("keyToValue"), "value") );- Parameters:
compareOne- the first expressioncompareTwo- the second string- Returns:
- expression
-
gte
public static Expression gte(@NonNull Expression compareOne, @NonNull String compareTwo, @NonNull Expression collator) Returns true if the first input is greater than or equal to the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( gte(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second Stringcollator- the collator expression- Returns:
- expression
-
lte
Returns true if the first input is less than or equal to the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lte(get("keyToValue"), get("keyToOtherValue")) );- Parameters:
compareOne- the first expressioncompareTwo- the second expression- Returns:
- expression
-
lte
public static Expression lte(@NonNull Expression compareOne, @NonNull Expression compareTwo, @NonNull Expression collator) Returns true if the first input is less than or equal to the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lte(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second expressioncollator- the collator expression- Returns:
- expression
-
lte
Returns true if the first input is less than or equal to the second, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lte(get("keyToValue"), 2.0f) );- Parameters:
compareOne- the first expressioncompareTwo- the second number- Returns:
- expression
-
lte
Returns true if the first input is less than or equal to the second, false otherwise.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lte(get("keyToValue"), "value") );- Parameters:
compareOne- the first expressioncompareTwo- the second string- Returns:
- expression
-
lte
public static Expression lte(@NonNull Expression compareOne, @NonNull String compareTwo, @NonNull Expression collator) Returns true if the first input is less than or equal to the second, false otherwise. The inputs must be numbers or strings, and both of the same type.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( lte(get("keyToValue"), get("keyToOtherValue"), collator(true, false)) );- Parameters:
compareOne- the first expressioncompareTwo- the second Stringcollator- the collator expression- Returns:
- expression
-
all
Returns `true` if all the inputs are `true`, `false` otherwise.The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates to `false`, the result is `false` and no further input expressions are evaluated.
Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( all(get("keyToValue"), get("keyToOtherValue")) );- Parameters:
input- expression input- Returns:
- expression
-
any
Returns `true` if any of the inputs are `true`, `false` otherwise.The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates to `true`, the result is `true` and no further input expressions are evaluated.
Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( any(get("keyToValue"), get("keyToOtherValue")) );- Parameters:
input- expression input- Returns:
- expression
-
not
Logical negation. Returns `true` if the input is `false`, and `false` if the input is `true`.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( not(get("keyToValue")) );- Parameters:
input- expression input- Returns:
- expression
-
not
Logical negation. Returns `true` if the input is `false`, and `false` if the input is `true`.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( not(false) );- Parameters:
input- boolean input- Returns:
- expression
-
switchCase
Selects the first output whose corresponding test condition evaluates to true.For each case a condition and an output should be provided. The last parameter should provide the default output.
Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( iconSize( switchCase( get(KEY_TO_BOOLEAN), literal(3.0f), get(KEY_TO_OTHER_BOOLEAN), literal(5.0f), literal(1.0f) // default value ) ) );- Parameters:
input- expression input- Returns:
- expression
-
match
Selects the output whose label value matches the input value, or the fallback value if no match is found. The `input` can be any string or number expression. Each label can either be a single literal value or an array of values. If types of the input and keys don't match, or the input value doesn't exist, the expresion will fail without falling back to the default value.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textColor( match(get("keyToValue"), literal(1), rgba(255, 0, 0, 1.0f), literal(2), rgba(0, 0, 255.0f, 1.0f), rgba(0.0f, 255.0f, 0.0f, 1.0f) ) ) );- Parameters:
input- expression input- Returns:
- expression
-
match
public static Expression match(@NonNull Expression input, @NonNull Expression defaultOutput, @NonNull Expression.Stop... stops) Selects the output whose label value matches the input value, or the fallback value if no match is found. The `input` can be any string or number expression. Each label can either be a single literal value or an array of values. If types of the input and keys don't match, or the input value doesn't exist, the expresion will fail without falling back to the default value.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textColor( match(get("keyToValue"), rgba(0.0f, 255.0f, 0.0f, 1.0f), stop(1f, rgba(255, 0, 0, 1.0f)), stop(2f, rgba(0, 0, 255.0f, 1.0f)) ) ) );- Parameters:
input- expression input- Returns:
- expression
-
coalesce
Evaluates each expression in turn until the first non-null value is obtained, and returns that value.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textColor( coalesce( get("keyToNullValue"), get("keyToNonNullValue") ) ) );- Parameters:
input- expression input- Returns:
- expression
-
properties
Gets the feature properties object.Note that in some cases, it may be more efficient to use
get(Expression)} instead.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(get("key-to-value", properties())) );- Returns:
- expression
-
geometryType
Gets the feature's geometry type: Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(concat(get("key-to-value"), literal(" "), geometryType())) );- Returns:
- expression
-
id
Gets the feature's id, if it has one.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(id()) );- Returns:
- expression
-
accumulated
Gets the value of a cluster property accumulated so far. Can only be used in the clusterProperties option of a clustered GeoJSON source.Example usage:
GeoJsonOptions options = new GeoJsonOptions() .withCluster(true) .withClusterProperty("max", max(accumulated(), get("max")).toArray(), get("mag").toArray());- Returns:
- expression
-
heatmapDensity
Gets the kernel density estimation of a pixel in a heatmap layer, which is a relative measure of how many data points are crowded around a particular pixel. Can only be used in the `heatmap-color` property.Example usage:
HeatmapLayer layer = new HeatmapLayer("layer-id", "source-id"); layer.setProperties( heatmapColor(interpolate(linear(), heatmapDensity(), literal(0), rgba(33, 102, 172, 0), literal(0.2), rgb(103, 169, 207), literal(0.4), rgb(209, 229, 240), literal(0.6), rgb(253, 219, 199), literal(0.8), rgb(239, 138, 98), literal(1), rgb(178, 24, 43)) ) );- Returns:
- expression
-
lineProgress
Gets the progress along a gradient line. Can only be used in the line-gradient property.Example usage:
LineLayer layer = new LineLayer("layer-id", "source-id"); layer.setProperties( lineGradient(interpolate( linear(), lineProgress(), stop(0f, rgb(0, 0, 255)), stop(0.5f, rgb(0, 255, 0)), stop(1f, rgb(255, 0, 0))) ) );- Returns:
- expression
-
at
Retrieves an item from an array.- Parameters:
number- the index expressionexpression- the array expression- Returns:
- expression
-
at
Retrieves an item from an array.- Parameters:
number- the index expressionexpression- the array expression- Returns:
- expression
-
in
Retrieves whether an item exists in an array or a substring exists in a string.- Parameters:
needle- the item expressionhaystack- the array or string expression- Returns:
- true if exists.
-
indexOf
Returns the first position at which a `needle` can be found in a `haystack`.- Parameters:
keyword- the item expressioninput- the array or string expression- Returns:
- position in the array or string or -1 if not found.
-
indexOf
public static Expression indexOf(@NonNull Expression keyword, @NonNull Expression input, @NonNull Expression fromIndex) Returns the first position at which a `needle` can be found in a `haystack`.- Parameters:
keyword- the item expressioninput- the array or string expressionfromIndex- the index to start searching from- Returns:
- position in the array or string or -1 if not found.
-
slice
Returns items from an array or a substring from a string from a specified start index. The return value is inclusive of the start index.- Parameters:
input- the array or string expressionfromIndex- the index to start slice from- Returns:
- array or string
-
slice
public static Expression slice(@NonNull Expression input, @NonNull Expression fromIndex, @NonNull Expression toIndex) Returns items from an array or a substring from a string between a start index and an end index if set. The return value is inclusive of the start index, but not of the end index.- Parameters:
input- the array or string expressionfromIndex- the index to start slice fromtoIndex- the index to end slice at- Returns:
- array or string
-
in
Retrieves whether an item exists in an array or a substring exists in a string.- Parameters:
needle- the item expressionhaystack- the array or string expression- Returns:
- true if exists.
-
in
Retrieves whether an item exists in an array or a substring exists in a string.- Parameters:
needle- the item expressionhaystack- the array or string expression- Returns:
- true if exists.
-
distance
Retrieves the shortest distance between two geometries. The returned value can be consumed as an input into another expression for changing a paint or layout property or filtering features by distance.Currently supports `Point`, `MultiPoint`, `LineString`, `MultiLineString` geometry types.
- Parameters:
geoJson- the target feature geoJson. Currently supports `Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, `MultiPolygon` geometry types- Returns:
- the distance in the unit "meters".
-
within
-
get
Retrieves a property value from the current feature's properties, or from another object if a second argument is provided. Returns null if the requested property is missing.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(get("key-to-feature")) );- Parameters:
input- expression input- Returns:
- expression
-
get
Retrieves a property value from the current feature's properties, or from another object if a second argument is provided. Returns null if the requested property is missing.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(get("key-to-feature")) );- Parameters:
input- string input- Returns:
- expression
-
get
Retrieves a property value from another object. Returns null if the requested property is missing.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(get("key-to-property", get("key-to-object"))) );- Parameters:
key- a property value keyobject- an expression object- Returns:
- expression
-
get
Retrieves a property value from another object. Returns null if the requested property is missing.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(get("key-to-property", get("key-to-object"))) );- Parameters:
key- a property value keyobject- an expression object- Returns:
- expression
-
has
Tests for the presence of an property value in the current feature's properties.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( has(get("keyToValue")) );- Parameters:
key- the expression property value key- Returns:
- expression
-
has
Tests for the presence of an property value in the current feature's properties.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( has("keyToValue") );- Parameters:
key- the property value key- Returns:
- expression
-
has
Tests for the presence of an property value from another object.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( has(get("keyToValue"), get("keyToObject")) );- Parameters:
key- the expression property value keyobject- an expression object- Returns:
- expression
-
has
Tests for the presence of an property value from another object.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setFilter( has("keyToValue", get("keyToObject")) );- Parameters:
key- the property value keyobject- an expression object- Returns:
- expression
-
length
Gets the length of an array or string.- Parameters:
expression- an expression object or expression string- Returns:
- expression
-
length
Gets the length of an array or string.- Parameters:
input- a string- Returns:
- expression
-
ln2
Returns mathematical constant ln(2).Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(product(literal(10.0f), ln2())) );- Returns:
- expression
-
pi
Returns the mathematical constant pi.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(product(literal(10.0f), pi())) );- Returns:
- expression
-
e
Returns the mathematical constant e.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(product(literal(10.0f), e())) );- Returns:
- expression
-
sum
Returns the sum of the inputs.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(sum(literal(10.0f), ln2(), pi())) );- Parameters:
numbers- the numbers to calculate the sum for- Returns:
- expression
-
sum
Returns the sum of the inputs.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(sum(10.0f, 5.0f, 3.0f)) );- Parameters:
numbers- the numbers to calculate the sum for- Returns:
- expression
-
product
Returns the product of the inputs.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(product(literal(10.0f), ln2())) );- Parameters:
numbers- the numbers to calculate the product for- Returns:
- expression
-
product
Returns the product of the inputs.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(product(10.0f, 2.0f)) );- Parameters:
numbers- the numbers to calculate the product for- Returns:
- expression
-
subtract
Returns the result of subtracting a number from 0.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(subtract(pi())) );- Parameters:
number- the number subtract from 0- Returns:
- expression
-
subtract
Returns the result of subtracting a number from 0.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(subtract(10.0f)) );- Parameters:
number- the number subtract from 0- Returns:
- expression
-
subtract
Returns the result of subtracting the second input from the first.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(subtract(literal(10.0f), pi())) );- Parameters:
first- the first numbersecond- the second number- Returns:
- expression
-
subtract
Returns the result of subtracting the second input from the first.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(subtract(10.0f, 20.0f)) );- Parameters:
first- the first numbersecond- the second number- Returns:
- expression
-
division
Returns the result of floating point division of the first input by the second.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(division(literal(10.0f), pi())) );- Parameters:
first- the first numbersecond- the second number- Returns:
- expression
-
division
Returns the result of floating point division of the first input by the second.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(division(10.0f, 20.0f)) );- Parameters:
first- the first numbersecond- the second number- Returns:
- expression
-
mod
Returns the remainder after integer division of the first input by the second.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(mod(literal(10.0f), pi())) );- Parameters:
first- the first numbersecond- the second number- Returns:
- expression
-
mod
Returns the remainder after integer division of the first input by the second.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(mod(10.0f, 10.0f)) );- Parameters:
first- the first numbersecond- the second number- Returns:
- expression
-
pow
Returns the result of raising the first input to the power specified by the second.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(pow(pi(), literal(2.0f))) );- Parameters:
first- the first numbersecond- the second number- Returns:
- expression
-
pow
Returns the result of raising the first input to the power specified by the second.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(pow(5.0f, 2.0f)) );- Parameters:
first- the first numbersecond- the second number- Returns:
- expression
-
sqrt
Returns the square root of the inputExample usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(sqrt(pi())) );- Parameters:
number- the number to take the square root from- Returns:
- expression
-
sqrt
Returns the square root of the inputExample usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(sqrt(25.0f)) );- Parameters:
number- the number to take the square root from- Returns:
- expression
-
log10
Returns the base-ten logarithm of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(log10(pi())) );- Parameters:
number- the number to take base-ten logarithm from- Returns:
- expression
-
log10
Returns the base-ten logarithm of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(log10(10)) );- Parameters:
number- the number to take base-ten logarithm from- Returns:
- expression
-
ln
Returns the natural logarithm of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(ln(pi())) );- Parameters:
number- the number to take natural logarithm from- Returns:
- expression
-
ln
Returns the natural logarithm of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(ln(10)) );- Parameters:
number- the number to take natural logarithm from- Returns:
- expression
-
log2
Returns the base-two logarithm of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(log2(pi())) );- Parameters:
number- the number to take base-two logarithm from- Returns:
- expression
-
log2
Returns the base-two logarithm of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(log2(2)) );- Parameters:
number- the number to take base-two logarithm from- Returns:
- expression
-
sin
Returns the sine of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(sin(pi())) );- Parameters:
number- the number to calculate the sine for- Returns:
- expression
-
sin
Returns the sine of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(sin(90.0f)) );- Parameters:
number- the number to calculate the sine for- Returns:
- expression
-
cos
Returns the cosine of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(cos(pi())) );- Parameters:
number- the number to calculate the cosine for- Returns:
- expression
-
cos
Returns the cosine of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(cos(0)) );- Parameters:
number- the number to calculate the cosine for- Returns:
- expression
-
tan
Returns the tangent of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(tan(pi())) );- Parameters:
number- the number to calculate the tangent for- Returns:
- expression
-
tan
Returns the tangent of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(tan(45.0f)) );- Parameters:
number- the number to calculate the tangent for- Returns:
- expression
-
asin
Returns the arcsine of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(asin(pi())) );- Parameters:
number- the number to calculate the arcsine for- Returns:
- expression
-
asin
Returns the arcsine of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(asin(90)) );- Parameters:
number- the number to calculate the arcsine for- Returns:
- expression
-
acos
Returns the arccosine of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(acos(pi())) );- Parameters:
number- the number to calculate the arccosine for- Returns:
- expression
-
acos
Returns the arccosine of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(acos(0)) );- Parameters:
number- the number to calculate the arccosine for- Returns:
- expression
-
atan
Returns the arctangent of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(asin(pi())) );- Parameters:
number- the number to calculate the arctangent for- Returns:
- expression
-
atan
Returns the arctangent of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(atan(90)) );- Parameters:
number- the number to calculate the arctangent for- Returns:
- expression
-
min
Returns the minimum value of the inputs.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(min(pi(), literal(3.14f), literal(3.15f))) );- Parameters:
numbers- varargs of numbers to get the minimum from- Returns:
- expression
-
min
Returns the minimum value of the inputs.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(min(3.141, 3.14f, 3.15f)) );- Parameters:
numbers- varargs of numbers to get the minimum from- Returns:
- expression
-
max
Returns the maximum value of the inputs.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(max(pi(), product(pi(), pi()))) );- Parameters:
numbers- varargs of numbers to get the maximum from- Returns:
- expression
-
max
Returns the maximum value of the inputs.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(max(3.141, 3.14f, 3.15f)) );- Parameters:
numbers- varargs of numbers to get the maximum from- Returns:
- expression
-
round
Rounds the input to the nearest integer. Halfway values are rounded away from zero. For example `[\"round\", -1.5]` evaluates to -2.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(round(pi())) );- Parameters:
expression- number expression to round- Returns:
- expression
-
round
Rounds the input to the nearest integer. Halfway values are rounded away from zero. For example `[\"round\", -1.5]` evaluates to -2.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(round(3.14159265359f)) );- Parameters:
number- number to round- Returns:
- expression
-
abs
Returns the absolute value of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(abs(subtract(pi()))) );- Parameters:
expression- number expression to get absolute value from- Returns:
- expression
-
abs
Returns the absolute value of the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(abs(-3.14159265359f)) );- Parameters:
number- number to get absolute value from- Returns:
- expression
-
ceil
Returns the smallest integer that is greater than or equal to the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(ceil(pi())) );- Parameters:
expression- number expression to get value from- Returns:
- expression
-
ceil
Returns the smallest integer that is greater than or equal to the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(ceil(3.14159265359)) );- Parameters:
number- number to get value from- Returns:
- expression
-
floor
Returns the largest integer that is less than or equal to the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(floor(pi())) );- Parameters:
expression- number expression to get value from- Returns:
- expression
-
floor
Returns the largest integer that is less than or equal to the input.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(floor(pi())) );- Parameters:
number- number to get value from- Returns:
- expression
-
resolvedLocale
Returns the IETF language tag of the locale being used by the provided collator. This can be used to determine the default system locale, or to determine if a requested locale was successfully loaded.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleColor(switchCase( eq(literal("it"), resolvedLocale(collator(true, true, Locale.ITALY))), literal(ColorUtils.colorToRgbaString (Color.GREEN)), literal(ColorUtils.colorToRgbaString(Color.RED)))) );- Parameters:
collator- the collator expression- Returns:
- expression
-
isSupportedScript
Returns true if the input string is expected to render legibly. Returns false if the input string contains sections that cannot be rendered without potential loss of meaning (e.g. Indic scripts that require complex text shaping, or right-to-left scripts if the the mapbox-gl-rtl-text plugin is not in use in TrimbleMaps GL JS).Example usage:
trimbleMapsMap.getStyle().addLayer(new SymbolLayer("layer-id", "source-id") .withProperties( textField( switchCase( isSupportedScript(get("name_property")), get("name_property"), literal("not-compatible") ) ) ));- Parameters:
expression- the expression to evaluate- Returns:
- expression
-
isSupportedScript
Returns true if the input string is expected to render legibly. Returns false if the input string contains sections that cannot be rendered without potential loss of meaning (e.g. Indic scripts that require complex text shaping, or right-to-left scripts if the the mapbox-gl-rtl-text plugin is not in use in TrimbleMaps GL JS).Example usage:
trimbleMapsMap.getStyle().addLayer(new SymbolLayer("layer-id", "source-id") .withProperties( textField( switchCase( isSupportedScript("ಗೌರವಾರ್ಥವಾಗಿ"), literal("ಗೌರವಾರ್ಥವಾಗಿ"), literal("not-compatible")) ) ) );- Parameters:
string- the string to evaluate- Returns:
- expression
-
upcase
Returns the input string converted to uppercase.Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.
Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(upcase(get("key-to-string-value"))) );- Parameters:
string- the string to upcase- Returns:
- expression
-
upcase
Returns the input string converted to uppercase.Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.
Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(upcase("text")) );- Parameters:
string- string to upcase- Returns:
- expression
-
downcase
Returns the input string converted to lowercase.Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.
Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(downcase(get("key-to-string-value"))) );- Parameters:
input- expression input- Returns:
- expression
-
downcase
Returns the input string converted to lowercase.Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.
Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(upcase("key-to-string-value")) );- Parameters:
input- string to downcase- Returns:
- expression
-
concat
Returns a string consisting of the concatenation of the inputs.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(concat(get("key-to-string-value"), literal("other string"))) );- Parameters:
input- expression input- Returns:
- expression
-
concat
Returns a string consisting of the concatenation of the inputs.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(concat("foo", "bar")) );- Parameters:
input- expression input- Returns:
- expression
-
array
Asserts that the input is an array (optionally with a specific item type and length). If, when the input expression is evaluated, it is not of the asserted type, then this assertion will cause the whole expression to be aborted.- Parameters:
input- expression input- Returns:
- expression
-
typeOf
Returns a string describing the type of the given value.- Parameters:
input- expression input- Returns:
- expression
-
string
Asserts that the input value is a string. If multiple values are provided, each one is evaluated in order until a string value is obtained. If none of the inputs are strings, the expression is an error. The asserted input value is returned as result.- Parameters:
input- expression input- Returns:
- expression
-
number
Asserts that the input value is a number. If multiple values are provided, each one is evaluated in order until a number value is obtained. If none of the inputs are numbers, the expression is an error. The asserted input value is returned as result.- Parameters:
input- expression input- Returns:
- expression
-
numberFormat
public static Expression numberFormat(@NonNull Expression number, @NonNull Expression.NumberFormatOption... options) Converts the input number into a string representation using the providing formatting rules. If set, the locale argument specifies the locale to use, as a BCP 47 language tag. If set, the currency argument specifies an ISO 4217 code to use for currency-style formatting. If set, the min-fraction-digits and max-fraction-digits arguments specify the minimum and maximum number of fractional digits to include.- Parameters:
number- number expressionoptions- number formatting options- Returns:
- expression
-
numberFormat
public static Expression numberFormat(@NonNull Number number, @NonNull Expression.NumberFormatOption... options) Converts the input number into a string representation using the providing formatting rules. If set, the locale argument specifies the locale to use, as a BCP 47 language tag. If set, the currency argument specifies an ISO 4217 code to use for currency-style formatting. If set, the min-fraction-digits and max-fraction-digits arguments specify the minimum and maximum number of fractional digits to include.- Parameters:
number- number expressionoptions- number formatting options- Returns:
- expression
-
bool
Asserts that the input value is a boolean. If multiple values are provided, each one is evaluated in order until a boolean value is obtained. If none of the inputs are booleans, the expression is an error. The asserted input value is returned as result.- Parameters:
input- expression input- Returns:
- expression
-
collator
Returns a collator for use in locale-dependent comparison operations. The case-sensitive and diacritic-sensitive options default to false. The locale argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, the collator will use a system-defined fallback locale. Use resolved-locale to test the results of locale fallback behavior.- Parameters:
caseSensitive- case sensitive flagdiacriticSensitive- diacritic sensitive flaglocale- locale- Returns:
- expression
-
collator
Returns a collator for use in locale-dependent comparison operations. The case-sensitive and diacritic-sensitive options default to false. The locale argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, the collator will use a system-defined fallback locale. Use resolved-locale to test the results of locale fallback behavior.- Parameters:
caseSensitive- case sensitive flagdiacriticSensitive- diacritic sensitive flag- Returns:
- expression
-
collator
public static Expression collator(Expression caseSensitive, Expression diacriticSensitive, Expression locale) Returns a collator for use in locale-dependent comparison operations. The case-sensitive and diacritic-sensitive options default to false. The locale argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, the collator will use a system-defined fallback locale. Use resolved-locale to test the results of locale fallback behavior.- Parameters:
caseSensitive- case sensitive flagdiacriticSensitive- diacritic sensitive flaglocale- locale- Returns:
- expression
-
collator
Returns a collator for use in locale-dependent comparison operations. The case-sensitive and diacritic-sensitive options default to false. The locale argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, the collator will use a system-defined fallback locale. Use resolved-locale to test the results of locale fallback behavior.- Parameters:
caseSensitive- case sensitive flagdiacriticSensitive- diacritic sensitive flag- Returns:
- expression
-
format
Returns formatted text containing annotations for use in mixed-format text-field entries.To build the expression, use
formatEntry(Expression, FormatOption...)."format" expression can be used, for example, with the
PropertyFactory.textField(Expression)and accepts unlimited numbers of formatted sections.Each section consist of the input, the displayed text, and options, like font-scale and text-font.
Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField( format( formatEntry( get("header_property"), formatFontScale(2.0), formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}) ), formatEntry(concat(literal("\n"), get("description_property")), formatFontScale(1.5)) ) ) );- Parameters:
formatEntries- format entries- Returns:
- expression
-
formatEntry
public static Expression.FormatEntry formatEntry(@NonNull Expression text, @Nullable Expression.FormatOption... formatOptions) Returns a format entry that can be used informat(FormatEntry...)to create formatted text fields.Text is required to be of a resulting type string.
Text is required to be passed;
Expression.FormatOptions are optional and will default to the base values defined for the symbol.- Parameters:
text- displayed textformatOptions- format options- Returns:
- format entry
-
formatEntry
Returns a format entry that can be used informat(FormatEntry...)to create formatted text fields.Text is required to be of a resulting type string.
Text is required to be passed;
Expression.FormatOptions are optional and will default to the base values defined for the symbol.- Parameters:
text- displayed text- Returns:
- format entry
-
formatEntry
public static Expression.FormatEntry formatEntry(@NonNull String text, @Nullable Expression.FormatOption... formatOptions) Returns a format entry that can be used informat(FormatEntry...)to create formatted text fields.Text is required to be of a resulting type string.
Text is required to be passed;
Expression.FormatOptions are optional and will default to the base values defined for the symbol.- Parameters:
text- displayed textformatOptions- format options- Returns:
- format entry
-
formatEntry
Returns a format entry that can be used informat(FormatEntry...)to create formatted text fields.Text is required to be of a resulting type string.
Text is required to be passed;
Expression.FormatOptions are optional and will default to the base values defined for the symbol.- Parameters:
text- displayed text- Returns:
- format entry
-
image
Returns image expression for use in '*-pattern' and 'icon-image' layer properties. Compared to string literals that can be used to represent an image, image expression allows to determine an image's availability at runtime, thus, can be used in conditional coalesce operator.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( iconImage(image(get("key-to-feature"))) );Example usage with coalesce operator:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( iconImage( coalesce( image(literal("maki-11")), image(literal("bicycle-15")), image(literal("default-icon")) ) ) );- Parameters:
input- expression input- Returns:
- expression
- See Also:
-
object
Asserts that the input value is an object. If it is not, the expression is an error The asserted input value is returned as result.- Parameters:
input- expression input- Returns:
- expression
-
toString
Converts the input value to a string. If the input is null, the result is null. If the input is a boolean, the result is true or false. If the input is a number, it is converted to a string by NumberToString in the ECMAScript Language Specification. If the input is a color, it is converted to a string of the form "rgba(r,g,b,a)", where `r`, `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from 0 to 1. Otherwise, the input is converted to a string in the format specified by the JSON.stringify in the ECMAScript Language Specification.Example usage:
SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id"); symbolLayer.setProperties( textField(get("key-to-number-value")) );- Parameters:
input- expression input- Returns:
- expression
-
toNumber
Converts the input value to a number, if possible. If the input is null or false, the result is 0. If the input is true, the result is 1. If the input is a string, it is converted to a number as specified by the ECMAScript Language Specification. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(toNumber(get("key-to-string-value"))) );- Parameters:
input- expression input- Returns:
- expression
-
toBool
Converts the input value to a boolean. The result is `false` when then input is an empty string, 0, false, null, or NaN; otherwise it is true.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius(toBool(get("key-to-value"))) );- Parameters:
input- expression input- Returns:
- expression
-
toColor
Converts the input value to a color. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor(toColor(get("keyStringValue"))) );- Parameters:
input- expression input- Returns:
- expression
-
let
Binds input to named variables, which can then be referenced in the result expression usingvar(String)orvar(Expression).- Parameters:
input- expression input- Returns:
- expression
-
var
References variable bound using let.- Parameters:
expression- the variable naming expression that was bound with using let- Returns:
- expression
-
var
References variable bound using let.- Parameters:
variableName- the variable naming that was bound with using let- Returns:
- expression
-
zoom
Gets the current zoom level.Note that in style layout and paint properties, zoom may only appear as the input to a top-level step or interpolate expression.
Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( interpolate( exponential(0.5f), zoom(), stop(1.0f, color(Color.RED)), stop(5.0f, color(Color.BLUE)), stop(10.0f, color(Color.GREEN)) ) ) );- Returns:
- expression
-
stop
Produces a stop value.Can be used for
stop(Object, Object)as part of varargs parameter instep(Number, Expression, Stop...)orinterpolate(Interpolator, Expression, Stop...).Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(zoom(), literal(0.0f), stop(1.0f, 2.5f), stop(10.0f, 5.0f)) ) );- Parameters:
stop- the stop inputvalue- the stop output- Returns:
- the stop
-
step
public static Expression step(@NonNull Number input, @NonNull Expression defaultOutput, Expression... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first input if the input is less than the first stop.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(zoom(), literal(0.0f), literal(1.0f), literal(2.5f), literal(10.0f), literal(5.0f)) ) );- Parameters:
input- the input valuedefaultOutput- the default output expressionstops- pair of input and output values- Returns:
- expression
-
step
public static Expression step(@NonNull Expression input, @NonNull Expression defaultOutput, @NonNull Expression... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first input if the input is less than the first stop.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(zoom(), literal(0.0f), literal(1.0f), literal(2.5f), literal(10.0f), literal(5.0f)) ) );- Parameters:
input- the input expressiondefaultOutput- the default output expressionstops- pair of input and output values- Returns:
- expression
-
step
public static Expression step(@NonNull Number input, @NonNull Expression defaultOutput, Expression.Stop... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first input if the input is less than the first stop.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(zoom(), literal(0.0f), stop(1, 2.5f), stop(10, 5.0f)) ) );- Parameters:
input- the input valuedefaultOutput- the default output expressionstops- pair of input and output values- Returns:
- expression
-
step
public static Expression step(@NonNull Expression input, @NonNull Expression defaultOutput, Expression.Stop... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first input if the input is less than the first stop.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(zoom(), literal(0.0f), stop(1, 2.5f), stop(10, 5.0f)) ) );- Parameters:
input- the input valuedefaultOutput- the default output expressionstops- pair of input and output values- Returns:
- expression
-
step
public static Expression step(@NonNull Number input, @NonNull Number defaultOutput, Expression... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first input if the input is less than the first stop.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(1.0f, 0.0f, literal(1.0f), literal(2.5f), literal(10.0f), literal(5.0f)) ) );- Parameters:
input- the input valuedefaultOutput- the default output expressionstops- pair of input and output values- Returns:
- expression
-
step
public static Expression step(@NonNull Expression input, @NonNull Number defaultOutput, Expression... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first input if the input is less than the first stop.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(zoom(), 0.0f, literal(1.0f), literal(2.5f), literal(10.0f), literal(5.0f)) ) );- Parameters:
input- the input expressiondefaultOutput- the default output expressionstops- pair of input and output values- Returns:
- expression
-
step
public static Expression step(@NonNull Number input, @NonNull Number defaultOutput, Expression.Stop... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first input if the input is less than the first stop.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(zoom(), 0.0f, stop(1, 2.5f), stop(10, 5.0f)) ) );- Parameters:
input- the input valuedefaultOutput- the default output expressionstops- pair of input and output values- Returns:
- expression
-
step
public static Expression step(@NonNull Expression input, @NonNull Number defaultOutput, Expression.Stop... stops) Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first input if the input is less than the first stop.Example usage:
CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); circleLayer.setProperties( circleRadius( step(zoom(), 0.0f, stop(1, 2.5f), stop(10, 5.0f)) ) );- Parameters:
input- the input valuedefaultOutput- the default output expressionstops- pair of input and output values- Returns:
- expression
-
interpolate
public static Expression interpolate(@NonNull Expression.Interpolator interpolation, @NonNull Expression number, @NonNull Expression... stops) Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. The output type must be `number`, `array<number>`, or `color`.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( interpolate(exponential(0.5f), zoom(), stop(1.0f, color(Color.RED)), stop(5.0f, color(Color.BLUE)), stop(10.0f, color(Color.GREEN) ) ) ) );- Parameters:
interpolation- type of interpolationnumber- the input expressionstops- pair of input and output values- Returns:
- expression
-
interpolate
public static Expression interpolate(@NonNull Expression.Interpolator interpolation, @NonNull Expression number, Expression.Stop... stops) Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. The output type must be `number`, `array<number>`, or `color`.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( interpolate( exponential(0.5f), zoom(), stop(1.0f, color(Color.RED)), stop(5.0f, color(Color.BLUE)), stop(10.0f, color(Color.GREEN)) ) ) );- Parameters:
interpolation- type of interpolationnumber- the input expressionstops- pair of input and output values- Returns:
- expression
-
linear
interpolates linearly between the pair of stops just less than and just greater than the input.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( interpolate( linear(), zoom(), stop(1.0f, color(Color.RED)), stop(5.0f, color(Color.BLUE)), stop(10.0f, color(Color.GREEN)) ) ) );- Returns:
- expression
-
exponential
Interpolates exponentially between the stops just less than and just greater than the input. `base` controls the rate at which the output increases: higher values make the output increase more towards the high end of the range. With values close to 1 the output increases linearly.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( interpolate( exponential(0.5f), zoom(), stop(1.0f, color(Color.RED)), stop(5.0f, color(Color.BLUE)), stop(10.0f, color(Color.GREEN)) ) ) );- Parameters:
base- value controlling the route at which the output increases- Returns:
- expression
-
exponential
Interpolates exponentially between the stops just less than and just greater than the input. The parameter controls the rate at which the output increases: higher values make the output increase more towards the high end of the range. With values close to 1 the output increases linearly.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( interpolate( exponential(get("keyToValue")), zoom(), stop(1.0f, color(Color.RED)), stop(5.0f, color(Color.BLUE)), stop(10.0f, color(Color.GREEN)) ) ) );- Parameters:
expression- base number expression- Returns:
- expression
-
cubicBezier
public static Expression.Interpolator cubicBezier(@NonNull Expression x1, @NonNull Expression y1, @NonNull Expression x2, @NonNull Expression y2) Interpolates using the cubic bezier curve defined by the given control points.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( interpolate( cubicBezier(0.42f, 0.0f, 1.0f, 1.0f), zoom(), stop(1.0f, color(Color.RED)), stop(5.0f, color(Color.BLUE)), stop(10.0f, color(Color.GREEN)) ) ) );- Parameters:
x1- x value of the first point of a cubic bezier, ranges from 0 to 1y1- y value of the first point of a cubic bezier, ranges from 0 to 1x2- x value of the second point of a cubic bezier, ranges from 0 to 1y2- y value fo the second point of a cubic bezier, ranges from 0 to 1- Returns:
- expression
-
cubicBezier
public static Expression.Interpolator cubicBezier(@NonNull Number x1, @NonNull Number y1, @NonNull Number x2, @NonNull Number y2) Interpolates using the cubic bezier curve defined by the given control points.Example usage:
FillLayer fillLayer = new FillLayer("layer-id", "source-id"); fillLayer.setProperties( fillColor( interpolate( cubicBezier(0.42f, 0.0f, 1.0f, 1.0f), zoom(), stop(1.0f, color(Color.RED)), stop(5.0f, color(Color.BLUE)), stop(10.0f, color(Color.GREEN)) ) ) );- Parameters:
x1- x value of the first point of a cubic bezier, ranges from 0 to 1y1- y value of the first point of a cubic bezier, ranges from 0 to 1x2- x value of the second point of a cubic bezier, ranges from 0 to 1y2- y value fo the second point of a cubic bezier, ranges from 0 to 1- Returns:
- expression
-
toArray
Converts the expression to Object array representation.The output will later be converted to a JSON Object array.
- Returns:
- the converted object array expression
-
toString
Returns a string representation of the object that matches the definition set in the style specification.If this expression contains a coma (,) delimited literal, like 'rgba(r, g, b, a)`, it will be enclosed with double quotes (").
-
raw
Returns a DSL equivalent of a raw expression.If your raw expression contains a coma (,) delimited literal it has to be enclosed with double quotes ("), for example
["to-color", "rgba(255, 0, 0, 255)"]- Parameters:
rawExpression- the raw expression- Returns:
- the resulting expression
-
equals
Indicates whether some other object is "equal to" this one. -
hashCode
public int hashCode()Returns a hash code value for the expression.
-