MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
Loading...
Searching...
No Matches
style_expression.h File Reference

Go to the source code of this file.

Data Structures

struct  mln_style_expression_type
struct  mln_style_expression_options
struct  mln_style_expression_inputs
struct  mln_style_expression_info

Typedefs

typedef enum mln_style_expression_type_kind mln_style_expression_type_kind
typedef struct mln_style_expression_type mln_style_expression_type
typedef enum mln_style_expression_option_field mln_style_expression_option_field
typedef uint32_t mln_style_expression_option_fields
typedef struct mln_style_expression_options mln_style_expression_options
typedef enum mln_style_expression_input_field mln_style_expression_input_field
typedef uint32_t mln_style_expression_input_fields
typedef struct mln_style_expression_inputs mln_style_expression_inputs
typedef struct mln_style_expression_info mln_style_expression_info

Enumerations

enum  mln_style_expression_type_kind : uint32_t {
  MLN_STYLE_EXPRESSION_TYPE_VALUE = 0 , MLN_STYLE_EXPRESSION_TYPE_NUMBER = 1 , MLN_STYLE_EXPRESSION_TYPE_STRING = 2 , MLN_STYLE_EXPRESSION_TYPE_BOOLEAN = 3 ,
  MLN_STYLE_EXPRESSION_TYPE_COLOR = 4 , MLN_STYLE_EXPRESSION_TYPE_OBJECT = 5 , MLN_STYLE_EXPRESSION_TYPE_FORMATTED = 6 , MLN_STYLE_EXPRESSION_TYPE_IMAGE = 7 ,
  MLN_STYLE_EXPRESSION_TYPE_PADDING = 8 , MLN_STYLE_EXPRESSION_TYPE_VARIABLE_ANCHOR_OFFSET_COLLECTION = 9 , MLN_STYLE_EXPRESSION_TYPE_ARRAY = 10
}
enum  mln_style_expression_option_field : uint32_t { MLN_STYLE_EXPRESSION_OPTION_EXPECTED_TYPE = 1U << 0U }
enum  mln_style_expression_input_field : uint32_t { MLN_STYLE_EXPRESSION_INPUT_ZOOM = 1U << 0U , MLN_STYLE_EXPRESSION_INPUT_COLOR_RAMP_PARAMETER = 1U << 1U , MLN_STYLE_EXPRESSION_INPUT_CANONICAL_TILE_ID = 1U << 3U }

Functions

mln_status mln_style_expression_create (mln_buffer_view expression, const mln_style_expression_options *options, mln_style_expression *out_expression, mln_diagnostic *out_diagnostic)
void mln_style_expression_release (mln_style_expression expression)
mln_status mln_style_expression_get_info (mln_style_expression expression, mln_style_expression_info *out_info, mln_diagnostic *out_diagnostic)
mln_status mln_style_expression_evaluate (mln_style_expression expression, const mln_style_expression_inputs *inputs, char *out_json, size_t json_capacity, size_t *out_json_length, mln_diagnostic *out_diagnostic)

Detailed Description

Parse and evaluate style expressions without a map.

Typedef Documentation

◆ mln_style_expression_info

typedef struct mln_style_expression_info mln_style_expression_info

What a style expression's result depends on.

◆ mln_style_expression_input_field

◆ mln_style_expression_input_fields

◆ mln_style_expression_inputs

typedef struct mln_style_expression_inputs mln_style_expression_inputs

The inputs that a style expression reads while it evaluates.

◆ mln_style_expression_option_field

◆ mln_style_expression_option_fields

◆ mln_style_expression_options

typedef struct mln_style_expression_options mln_style_expression_options

Options for parsing a style expression.

◆ mln_style_expression_type

typedef struct mln_style_expression_type mln_style_expression_type

The type of a style expression's result.

◆ mln_style_expression_type_kind

The type of a style expression's result, or of the items of an array result.

Enumeration Type Documentation

◆ mln_style_expression_input_field

The fields that mln_style_expression_inputs sets.

Enumerator
MLN_STYLE_EXPRESSION_INPUT_ZOOM 
MLN_STYLE_EXPRESSION_INPUT_COLOR_RAMP_PARAMETER 
MLN_STYLE_EXPRESSION_INPUT_CANONICAL_TILE_ID 

◆ mln_style_expression_option_field

The fields that mln_style_expression_options sets.

Enumerator
MLN_STYLE_EXPRESSION_OPTION_EXPECTED_TYPE 

◆ mln_style_expression_type_kind

The type of a style expression's result, or of the items of an array result.

Enumerator
MLN_STYLE_EXPRESSION_TYPE_VALUE 

Any type.

MLN_STYLE_EXPRESSION_TYPE_NUMBER 
MLN_STYLE_EXPRESSION_TYPE_STRING 
MLN_STYLE_EXPRESSION_TYPE_BOOLEAN 
MLN_STYLE_EXPRESSION_TYPE_COLOR 
MLN_STYLE_EXPRESSION_TYPE_OBJECT 
MLN_STYLE_EXPRESSION_TYPE_FORMATTED 
MLN_STYLE_EXPRESSION_TYPE_IMAGE 
MLN_STYLE_EXPRESSION_TYPE_PADDING 
MLN_STYLE_EXPRESSION_TYPE_VARIABLE_ANCHOR_OFFSET_COLLECTION 
MLN_STYLE_EXPRESSION_TYPE_ARRAY 

Function Documentation

◆ mln_style_expression_create()

mln_status mln_style_expression_create ( mln_buffer_view expression,
const mln_style_expression_options * options,
mln_style_expression * out_expression,
mln_diagnostic * out_diagnostic )

Parses a style expression to evaluate without a map.

Returns:

  • MLN_STATUS_INVALID_ARGUMENT when expression isn't a valid expression, or its result can't have the expected type.

◆ mln_style_expression_evaluate()

mln_status mln_style_expression_evaluate ( mln_style_expression expression,
const mln_style_expression_inputs * inputs,
char * out_json,
size_t json_capacity,
size_t * out_json_length,
mln_diagnostic * out_diagnostic )

Evaluates a style expression and writes its result as JSON.

A number in the result that isn't finite becomes null. A color is ["rgba", r, g, b, a], with red, green, and blue from 0 to 255 and alpha from 0 to 1, each exact only to single precision. Formatted text is a ["format", …] expression, an image is {"name": …, "available": …}, padding is [top, right, bottom, left], and a variable anchor offset is [anchor, [x, y], …].

Returns:

  • MLN_STATUS_INVALID_ARGUMENT when the expression fails to evaluate, such as when it reads an input that inputs doesn't set.

Lifetimes: The function writes the result and a terminating NUL to out_json only when json_capacity is greater than the result's length. It always sets out_json_length to the length without the NUL.

◆ mln_style_expression_get_info()

mln_status mln_style_expression_get_info ( mln_style_expression expression,
mln_style_expression_info * out_info,
mln_diagnostic * out_diagnostic )

Reads what a style expression's result depends on.

◆ mln_style_expression_release()

void mln_style_expression_release ( mln_style_expression expression)

Releases a parsed style expression.