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
Styleis a value: a version of a map’s style. Its parts sit behindArcs, so versions share what they don’t change, and a part whoseArcis the same pointer in two versions is the same part. Style::applymakes anEdit, 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_versionsays in O(1) whether two versions are the same, anddiff::StyleDiff::betweenwhat 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_jsonparses 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::Layeris a layer of any type. Its style data is anArc<dyn layer::ErasedLayerStyle>, alayer::LayerStyle<T>of its typeT;layer::LayerBaseholds the members every layer type has.- Each layer type is a marker type that implements
layer::StyleLayerType, such aslayers::Background, with property sets such aslayers::BackgroundPaintProperties::{Transitionable, Unevaluated, PossiblyEvaluated, Evaluated}. - Each layer type, the light and the sky have a property table, which
property::tablereads to get, set and serialize properties by name.layers/<type>_layer_properties.rs,light_properties.rsandsky_properties.rsare 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
VecMapandVecSet: 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-erasedConvertibleview of a JSON-like value, its front ends overserde_jsonvalues, overserde_json_borrowvalues (the style parser’s) and overcrate::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.typenames one. AWorldMappingmaps 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:
LatLngandLatLngBounds. - geometry
- Tile geometry’s
Pointand helpers overgeo_typesfeature 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 infunction), 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.typecan 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, andvisit, which calls a visitor with the field of a slot of the table. A type’sStyleLayerTypeimpl 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.
- Style
Camera - The camera that a style’s root properties set:
center,centerAltitude,zoom,bearing,pitchandroll. 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::applymakes. - Style
Load Error - 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’sfont-faces, without a font name. It fails withErrorKind::InvalidArgumentifjsonisn’t such an array.
Type Aliases§
- Source
Update - What
Edit::UpdateSourcedoes to a source: it returns the source with new data, made bySource::with_data, orNoneif it changes nothing, or fails, as for a source of a type it doesn’t update.