Skip to main content

Crate mln_style

Crate mln_style 

Source
Expand description

The map style: Style, the style JSON parser, layers and sources, the property system (property), the expression language (expression), what expressions read of a feature (feature), the spec’s value types (types) and the conversions from JSON-like values to style types (conversion).

It also holds the vocabulary that the style shares with the engine: errors, colors, padding, sizes, ranges, interpolation and easing (unitbezier), images’ pixels (bitmap), coordinates (geo), tilesets, feature types (geometry), canonical tile ids (tile_id), the spec’s constants, math, number formatting (string), hash maps, clocks (time), the Unicode script checks (i18n) and the projection’s subdivision granularity.

A style parses against a StyleRegistry: the expression functions, layer types and source types its JSON, property values and filters may name, the extension members (member) that give the style’s and its layers’ <namespace>:<name> members a type, and the projections (crs) its projection.type may name.

Versions:

  • A Style is a value: a version of a map’s style. Its parts sit behind Arcs, so versions share what they don’t change, and a part whose Arc is the same pointer in two versions is the same part.
  • Style::apply makes an Edit, the only way to change a style; the JSON entry points (add_layer_json, set_layer_property_json, …) parse and then apply one.
  • Style::is_same_version says in O(1) whether two versions are the same, and diff::StyleDiff::between what a renderer has to redo for each layer, source and image to go from one version to another.
  • Loading isn’t here: the map’s loader fetches documents, sprites and source descriptions, and Style::from_json parses a document. A style holds its sources as values (SourceList), and what their loads find, of a type that the source type’s engine half names, arrives as edits.

Layers:

  • layer::Layer is a layer of any type. Its style data is an Arc<dyn layer::ErasedLayerStyle>, a layer::LayerStyle<T> of its type T; layer::LayerBase holds the members every layer type has.
  • Each layer type is a marker type that implements layer::StyleLayerType, such as layers::Background, with property sets such as layers::BackgroundPaintProperties::{Transitionable, Unevaluated, PossiblyEvaluated, Evaluated}.
  • Each layer type, the light and the sky have a property table, which property::table reads to get, set and serialize properties by name. layers/<type>_layer_properties.rs, light_properties.rs and sky_properties.rs are generated by //tools/style-codegen from the style spec.

Re-exports§

pub use layer::Layer;
pub use layer::LayerList;
pub use layer::LayerTypeInfo;
pub use property::evaluation::CrossfadeParameters;
pub use property::evaluation::PropertyEvaluationParameters;
pub use property::transition::GlobalStateChange;
pub use property::transition::TransitionOptions;
pub use property::transition::TransitionParameters;
pub use property::value::PropertyValue;
pub use property::value::StyleValue;
pub use registry::StyleRegistry;
pub use source::Source;
pub use source::SourceInstance;
pub use source::SourceList;
pub use source::SourceTypeInfo;

Modules§

bitmap
collections
VecMap and VecSet: ordered maps and sets kept as sorted vectors, for small maps.
color
constants
The style spec’s constants: the tile size and extent, the bounds of longitude and latitude, and the defaults of sources, transitions and fonts.
conversion
Style conversion: Error, the type-erased Convertible view of a JSON-like value, its front ends over serde_json values, over serde_json_borrow values (the style parser’s) and over crate::feature::Value, json_type, and the converters of value types.
crs
Planar coordinate reference systems that a map can draw in: an app registers each with its registry, and a style’s projection.type names one. A WorldMapping maps lng/lat to and from the world square that a map draws in: Web Mercator’s, or a registered projection’s.
diff
What changed between two versions of a style, which the renderer reads to find what to redo: StyleDiff.
error
The error type of the library’s fallible calls.
expression
Style expressions: their types and values, parsing, and evaluation.
feature
Features and what expressions read of them.
filter
font_face
The font faces of a style’s font-faces, as the style describes them. A map’s text engine turns them into faces it can draw with.
geo
Geographic coordinates: LatLng and LatLngBounds.
geometry
Tile geometry’s Point and helpers over geo_types feature geometry.
hash
The hash maps and sets of mln-rs.
i18n
image
A style’s images: an icon or pattern with its pixels, pixel ratio, stretch areas and content box, from a sprite or added by the app.
interpolate
layer
Layers of any type: a style’s Layers and their list (LayerList), their conversion from style JSON (convert_layer), and the contract a layer type implements (StyleLayerType).
layers
The style layer types.
light
math
Math helpers: angle conversion, clamping, wrapping, and floating-point minimum and maximum.
member
Extension members: members of the style’s root or of a layer named <namespace>:<name>, which no style spec member is, and which the style spec leaves to extensions.
padding
projection
property
The property system: a property’s value as the style sets it (value, expression, color_ramp), its conversion from style JSON (convert, with legacy functions in function), how it transitions (transition) and evaluates for a frame (evaluation, evaluated), the property sets of a layer type, the light and the sky (set), and access to them by style-spec name ([table]).
range
registry
The registrations that a style parses against: its expression functions, its layer types, its source types and its extension members, and the projections that its projection.type can name.
size
sky
sort
Stable sorts that share one compiled sort algorithm.
source
Source types as values.
sources
The style halves of the specification’s source types: their marker types, options, style JSON and edits. How their sources load and what they supply the renderer is the engine’s half, in mln_builtins.
sprite
string
subdivision_granularity
terrain
tile_id
The canonical tile id: a tile of the tile pyramid, by zoom level and column and row.
tileset
time
types
The values of the style spec’s property types: the enums, positions, rotations, number and color arrays, variable anchor offsets and projection definitions.
unitbezier

Macros§

layer_properties
Declares a layer type’s property sets, as properties! does, and its property table: PROPERTIES, with the paint properties and then the layout properties in the order the sets list them, and visit, which calls a visitor with the field of a slot of the table. A type’s StyleLayerType impl names both:
properties
Declares a property set as mod $module, one named field per property, followed by the paths its types and defaults need:

Structs§

Parser
Reads a style’s JSON, against the expression functions and layer types of a StyleRegistry.
Style
A version of a map’s style: what a style document describes, after the edits made since.
StyleCamera
The camera that a style’s root properties set: center, centerAltitude, zoom, bearing, pitch and roll. A parsed style sets every member, to the style spec’s default where the document leaves it out; an empty style sets none.

Enums§

Edit
A change to a style, which Style::apply makes.
StyleLoadError
Why a style failed to load.

Functions§

parse_fallback_font_faces
Parses fallback font faces from json, an array of font files in the format of a font face in a style’s font-faces, without a font name. It fails with ErrorKind::InvalidArgument if json isn’t such an array.

Type Aliases§

SourceUpdate
What Edit::UpdateSource does to a source: it returns the source with new data, made by Source::with_data, or None if it changes nothing, or fails, as for a source of a type it doesn’t update.