Operator

struct Operator : RawRepresentable, Codable, Equatable

Undocumented

  • For two inputs, returns the result of subtracting the second input from the first. For a single input, returns the result of subtracting it from 0.

    Declaration

    Swift

    public static let subtract: Expression.Operator
  • not

    Logical negation. Returns true if the input is false, and false if the input is true.

    Declaration

    Swift

    public static let not: Expression.Operator
  • neq

    Returns true if the input values are not equal, false otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optional collator argument to control locale-dependent string comparisons.

    Declaration

    Swift

    public static let neq: Expression.Operator
  • Returns the product of the inputs.

    Declaration

    Swift

    public static let product: Expression.Operator
  • Returns the result of floating point division of the first input by the second.

    Declaration

    Swift

    public static let division: Expression.Operator
  • mod

    Returns the remainder after integer division of the first input by the second.

    Declaration

    Swift

    public static let mod: Expression.Operator
  • pow

    Returns the result of raising the first input to the power specified by the second.

    Declaration

    Swift

    public static let pow: Expression.Operator
  • sum

    Returns the sum of the inputs.

    Declaration

    Swift

    public static let sum: Expression.Operator
  • lt

    Returns true if the first input is strictly less than the second, false otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional collator argument to control locale-dependent string comparisons.

    Declaration

    Swift

    public static let lt: Expression.Operator
  • lte

    Returns true if the first input is less than or equal to the second, false otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional collator argument to control locale-dependent string comparisons.

    Declaration

    Swift

    public static let lte: Expression.Operator
  • eq

    Returns true if the input values are equal, false otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optional collator argument to control locale-dependent string comparisons.

    Declaration

    Swift

    public static let eq: Expression.Operator
  • gt

    Returns true if the first input is strictly greater than the second, false otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional collator argument to control locale-dependent string comparisons.

    Declaration

    Swift

    public static let gt: Expression.Operator
  • gte

    Returns true if the first input is greater than or equal to the second, false otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional collator argument to control locale-dependent string comparisons.

    Declaration

    Swift

    public static let gte: Expression.Operator
  • abs

    Returns the absolute value of the input.

    Declaration

    Swift

    public static let abs: Expression.Operator
  • Returns the value of a cluster property accumulated so far. Can only be used in the clusterProperties option of a clustered GeoJSON source.

    Declaration

    Swift

    public static let accumulated: Expression.Operator
  • Returns the arccosine of the input.

    Declaration

    Swift

    public static let acos: Expression.Operator
  • Returns a string which matches one of the values specified in the text-anchor layout property, depending on the best-fit anchor for the symbol during rendering. Using this expression the content of the layer can be dynamically configured for the specific anchor type.

    Declaration

    Swift

    @_spi(Experimental)
    public static let activeAnchor: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let all: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let any: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let array: Expression.Operator
  • Returns the arcsine of the input.

    Declaration

    Swift

    public static let asin: Expression.Operator
  • at

    Retrieves an item from an array.

    Declaration

    Swift

    public static let at: Expression.Operator
  • Returns the arctangent of the input.

    Declaration

    Swift

    public static let atan: Expression.Operator
  • Asserts that the input value is a boolean. If multiple values are provided, each one is evaluated in order until a boolean is obtained. If none of the inputs are booleans, the expression is an error.

    Declaration

    Swift

    public static let boolean: Expression.Operator
  • Selects the first output whose corresponding test condition evaluates to true, or the fallback value otherwise.

    Declaration

    Swift

    public static let switchCase: Expression.Operator
  • Returns the smallest integer that is greater than or equal to the input.

    Declaration

    Swift

    public static let ceil: Expression.Operator
  • Evaluates each expression in turn until the first valid value is obtained. Invalid values are null and 'image' expressions that are unavailable in the style. If all values are invalid, coalesce returns the first value listed.

    Declaration

    Swift

    public static let coalesce: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let collator: Expression.Operator
  • Returns a string consisting of the concatenation of the inputs. Each input is converted to a string as if by to-string.

    Declaration

    Swift

    public static let concat: Expression.Operator
  • Retrieves the configuration value for the given option.

    Declaration

    Swift

    public static let config: Expression.Operator
  • cos

    Returns the cosine of the input.

    Declaration

    Swift

    public static let cos: Expression.Operator
  • Returns the shortest distance in meters between the evaluated feature and the input geometry. The input value can be a valid GeoJSON of type Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, Feature, or FeatureCollection. Distance values returned may vary in precision due to loss in precision from encoding geometries, particularly below zoom level 13.

    Declaration

    Swift

    public static let distance: Expression.Operator
  • Returns the distance of a symbol instance from the center of the map. The distance is measured in pixels divided by the height of the map container. It measures 0 at the center, decreases towards the camera and increase away from the camera. For example, if the height of the map is 1000px, a value of -1 means 1000px away from the center towards the camera, and a value of 1 means a distance of 1000px away from the camera from the center. ["distance-from-center"] may only be used in the filter expression for a symbol layer.

    Declaration

    Swift

    public static let distanceFromCenter: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let downcase: Expression.Operator
  • e

    Returns the mathematical constant e.

    Declaration

    Swift

    public static let e: Expression.Operator
  • Retrieves a property value from the current feature’s state. Returns null if the requested property is not present on the feature’s state. A feature’s state is not part of the GeoJSON or vector tile data, and must be set programmatically on each feature. Features are identified by their id attribute, which must be an integer or a string that can be cast to an integer. Note that [“feature-state”] can only be used with paint properties that support data-driven styling.

    Declaration

    Swift

    public static let featureState: Expression.Operator
  • Returns the largest integer that is less than or equal to the input.

    Declaration

    Swift

    public static let floor: Expression.Operator
  • Returns a formatted string for displaying mixed-format text in the text-field property. The input may contain a string literal or expression, including an 'image' expression. Strings may be followed by a style override object that supports the following properties:

    • "text-font": Overrides the font stack specified by the root layout property.
    • "text-color": Overrides the color specified by the root paint property.
    • "font-scale": Applies a scaling factor on text-size as specified by the root layout property.

    Declaration

    Swift

    public static let format: Expression.Operator
  • Returns the feature’s geometry type: Point, LineString or Polygon. Multi* feature types return the singular forms.

    Declaration

    Swift

    public static let geometryType: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let get: Expression.Operator
  • has

    Tests for the presence of an property value in the current feature’s properties, or from another object if a second argument is provided.

    Declaration

    Swift

    public static let has: Expression.Operator
  • Returns 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.

    Declaration

    Swift

    public static let heatmapDensity: Expression.Operator
  • hsl

    Creates a color value from hue (range 0-360), saturation and lightness components (range 0-100), and an alpha component of 1. If any component is out of range, the expression is an error.

    Declaration

    Swift

    public static let hsl: Expression.Operator
  • Creates a color value from hue (range 0-360), saturation and lightness components (range 0-100), and an alpha component (range 0-1). If any component is out of range, the expression is an error.

    Declaration

    Swift

    public static let hsla: Expression.Operator
  • id

    Returns the feature’s id, if it has one.

    Declaration

    Swift

    public static let id: Expression.Operator
  • Returns a ResolvedImage for use in icon-image, *-pattern entries, and as a section in the 'format' expression. A 'coalesce' expression containing image expressions will evaluate to the first listed image that is currently in the style. This validation process is synchronous and requires the image to have been added to the style before requesting it in the 'image' argument.

    Declaration

    Swift

    public static let image: Expression.Operator
  • Determines whether an item exists in an array or a substring exists in a string. In the specific case when the second and third arguments are string literals, you must wrap at least one of them in a literal expression to hint correct interpretation to the type system.

    Declaration

    Swift

    public static let inExpression: Expression.Operator
  • Returns the first position at which an item can be found in an array or a substring can be found in a string, or -1 if the input cannot be found. Accepts an optional index from where to begin the search.

    Declaration

    Swift

    public static let indexOf: Expression.Operator
  • 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.

    Interpolation types:

    • ["linear"]: Interpolates linearly between the pair of stops just less than and just greater than the input.
    • ["exponential", base]: 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.
    • ["cubic-bezier", x1, y1, x2, y2]: Interpolates using the cubic bezier curve defined by the given control points.

    Declaration

    Swift

    public static let interpolate: Expression.Operator
  • 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 Mapbox GL JS).

    Declaration

    Swift

    public static let isSupportedScript: Expression.Operator
  • Returns the length of an array or string.

    Declaration

    Swift

    public static let length: Expression.Operator
  • Binds expressions to named variables, which can then be referenced in the result expression using [“var”, “variable_name”].

    Declaration

    Swift

    public static let letExpression: Expression.Operator
  • Returns the progress along a gradient line. Can only be used in the line-gradient property.

    Declaration

    Swift

    public static let lineProgress: Expression.Operator
  • Provides a literal array or object value.

    Declaration

    Swift

    public static let literal: Expression.Operator
  • ln

    Returns the natural logarithm of the input.

    Declaration

    Swift

    public static let ln: Expression.Operator
  • ln2

    Returns mathematical constant ln(2).

    Declaration

    Swift

    public static let ln2: Expression.Operator
  • Returns the base-ten logarithm of the input.

    Declaration

    Swift

    public static let log10: Expression.Operator
  • Returns the base-two logarithm of the input.

    Declaration

    Swift

    public static let log2: Expression.Operator
  • Selects the output for which the label value matches the input value, or the fallback value if no match is found. The input can be any expression (for example, ["get", "building_type"]). Each label must be unique, and must be either:

    • a single literal value; or
    • an array of literal values, the values of which must be all strings or all numbers (for example [100, 101] or ["c", "b"]).

    The input matches if any of the values in the array matches using strict equality, similar to the "in" operator. If the input type does not match the type of the labels, the result will be the fallback value.

    Declaration

    Swift

    public static let match: Expression.Operator
  • max

    Returns the maximum value of the inputs.

    Declaration

    Swift

    public static let max: Expression.Operator
  • Returns a requested property of the light configuration based on the supplied options. Currently the only supported option is brightness which returns the global brightness value of the lights on a scale of 0 to 1, where 0 means total darkness and 1 means full brightness. This expression works only with 3D light, i.e. when lights root property is defined.

    Declaration

    Swift

    public static let measureLight: Expression.Operator
  • min

    Returns the minimum value of the inputs.

    Declaration

    Swift

    public static let min: Expression.Operator
  • Asserts that the input value is a number. If multiple values are provided, each one is evaluated in order until a number is obtained. If none of the inputs are numbers, the expression is an error.

    Declaration

    Swift

    public static let number: Expression.Operator
  • 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 unit argument specifies a simple ECMAScript unit to use for unit-style formatting. If set, the min and max arguments specify the minimum and maximum number of fractional digits to include.

    Declaration

    Swift

    public static let numberFormat: Expression.Operator
  • Asserts that the input value is an object. If multiple values are provided, each one is evaluated in order until an object is obtained. If none of the inputs are objects, the expression is an error.

    Declaration

    Swift

    public static let objectExpression: Expression.Operator
  • pi

    Returns the mathematical constant pi.

    Declaration

    Swift

    public static let pi: Expression.Operator
  • Returns the current pitch in degrees. ["pitch"] may only be used in the filter expression for a symbol layer.

    Declaration

    Swift

    public static let pitch: Expression.Operator
  • Returns the feature properties object. Note that in some cases, it may be more efficient to use ["get", "property_name"] directly.

    Declaration

    Swift

    public static let properties: Expression.Operator
  • Returns a random value in the specified range (first two input numbers) based on a supplied seed (third input). The seed can be an expression or a constant number or string value.

    Declaration

    Swift

    public static let random: Expression.Operator
  • Returns the raster value of a pixel computed via raster-color-mix. Can only be used in the raster-color property.

    Declaration

    Swift

    public static let rasterValue: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let resolvedLocale: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let rgb: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let rgba: Expression.Operator
  • Rounds the input to the nearest integer. Halfway values are rounded away from zero. For example, ["round", -1.5] evaluates to -2.

    Declaration

    Swift

    public static let round: Expression.Operator
  • sin

    Returns the sine of the input.

    Declaration

    Swift

    public static let sin: Expression.Operator
  • Returns the distance of a point on the sky from the sun position. Returns 0 at sun position and 1 when the distance reaches sky-gradient-radius. Can only be used in the sky-gradient property.

    Declaration

    Swift

    public static let skyRadialProgress: Expression.Operator
  • Returns an item from an array or a substring from a string from a specified start index, or 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.

    Declaration

    Swift

    public static let slice: Expression.Operator
  • Returns the square root of the input.

    Declaration

    Swift

    public static let sqrt: Expression.Operator
  • 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 output if the input is less than the first stop.

    Declaration

    Swift

    public static let step: Expression.Operator
  • Asserts that the input value is a string. If multiple values are provided, each one is evaluated in order until a string is obtained. If none of the inputs are strings, the expression is an error.

    Declaration

    Swift

    public static let string: Expression.Operator
  • tan

    Returns the tangent of the input.

    Declaration

    Swift

    public static let tan: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let toBoolean: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let toColor: Expression.Operator
  • 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 “ToNumber Applied to the String Type” algorithm of 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.

    Declaration

    Swift

    public static let toNumber: Expression.Operator
  • Returns a four-element array containing the input color’s red, green, blue, and alpha components, in that order.

    Declaration

    Swift

    public static let toRgba: Expression.Operator
  • Converts the input value to a string. If the input is null, the result is "". If the input is a boolean, the result is "true" or "false". If the input is a number, it is converted to a string as specified by the “NumberToString” algorithm of 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. If the input is an 'image' expression, 'to-string' returns the image name. Otherwise, the input is converted to a string in the format specified by the JSON.stringify function of the ECMAScript Language Specification.

    Declaration

    Swift

    public static let toString: Expression.Operator
  • Returns a string describing the type of the given value.

    Declaration

    Swift

    public static let typeofExpression: Expression.Operator
  • 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.

    Declaration

    Swift

    public static let upcase: Expression.Operator
  • References variable bound using “let”.

    Declaration

    Swift

    public static let varExpression: Expression.Operator
  • Returns true if the evaluated feature is fully contained inside a boundary of the input geometry, false otherwise. The input value can be a valid GeoJSON of type Polygon, MultiPolygon, Feature, or FeatureCollection. Supported features for evaluation:

    • Point: Returns false if a point is on the boundary or falls outside the boundary.
    • LineString: Returns false if any part of a line falls outside the boundary, the line intersects the boundary, or a line’s endpoint is on the boundary.

    Declaration

    Swift

    public static let within: Expression.Operator
  • Returns 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.

    Declaration

    Swift

    public static let zoom: Expression.Operator
  • Interpolates linearly between the pair of stops just less than and just greater than the input

    Declaration

    Swift

    public static let linear: Expression.Operator
  • ["exponential", base] 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.

    Declaration

    Swift

    public static let exponential: Expression.Operator
  • ["cubic-bezier", x1, y1, x2, y2] Interpolates using the cubic bezier curve defined by the given control points.

    Declaration

    Swift

    public static let cubicBezier: Expression.Operator
  • Declaration

    Swift

    public let rawValue: String
  • Declaration

    Swift

    public init(rawValue: String)