Skip to main content

Crate ezu_style

Crate ezu_style 

Source
Expand description

Ezu Style Spec — declarative style specification for painterly map rendering.

Parsing this crate produces a Document — a pure data structure, not an evaluator. To execute it, feed the document to ezu-graph::build_graph with a NodeRegistry.

let json = std::fs::read_to_string("watercolor.json").unwrap();
let doc = ezu_style::Document::from_json(&json).unwrap();
println!("{} ({} nodes)", doc.name, doc.nodes.len());

Structs§

CommentError
A block comment that never closed. Reported on its own rather than left to the JSON parser, which would blame whatever the runaway comment swallowed.
DemSource
Raster-DEM source. Tiles encode elevation in the RGB channels using either the Mapzen / Terrarium scheme (h = (R*256 + G + B/256) - 32768) or the Mapbox / MapLibre Terrain-RGB scheme (h = -10000 + (R*65536 + G*256 + B) * 0.1).
Document
A parsed style document. Order of nodes is preserved (for deterministic error messages) but does not imply evaluation order — that is derived by topological sort of the DAG.
Expanded
Result of expanding a document’s functions.
FileSource
A document-scoped, file-based source. src is a path the host resolves (relative to --assets-dir) or an http(s):// URL.
FontSource
A document-scoped font face (TTF / OTF / TTC bytes) consumed by the text node’s font fallback stack. The url doubles as the font’s asset key, like a sprite source’s image.
FuncDecl
A user-defined function: a reusable node subgraph with declared input ports and output kind. Shaped like a mini-document — inputs play the role of params, nodes is the body, output names the body node whose value the call produces.
FuncInput
One declared function input.
GeoJsonSource
Inline (or URL) GeoJSON in WGS84 lon/lat. The host projects it into each tile’s local coordinate frame and binds it under <source>.<source>.
GlyphsSource
A MapLibre-compatible glyph endpoint: pre-rendered SDF glyphs served in 256-codepoint ranges from a URL template. The text node’s font stack may name a glyphs source wherever it may name a font source — lower fidelity (fixed 24 px SDF bitmaps) but zero font files, matching what MapLibre GL itself renders from.
IconRect
One entry of a sprite index — a sub-rectangle of the atlas. Mirrors the MapLibre sprite-JSON entry shape (extra keys like sdf are ignored) so a fetched index deserializes into the same type.
KindCheck
A declared-kind check the host should verify once the graph is built and port kinds are resolved. Produced per call site so kind errors can name the call instead of an expanded internal port.
LegendDecl
A declared legend: what the map’s symbols mean, in the order they should be read.
LegendEntry
One row of a legend: a label, and the symbol it explains identified by where that symbol comes from.
MvtSource
Templated XYZ MVT tile source.
NodeRef
A reference to a node id, optionally prefixed with @. The prefix is stripped on parse.
NodeSpec
One node entry. op selects the implementation; remaining fields are op-specific and are validated by the NodeFactory registered for op.
ParamDecl
Declaration of a document-level parameter (overridable at render time).
PmtilesSource
PMTiles archive source — local path or http(s):// URL.
RasterSource
RGBA raster tile pyramid (satellite imagery, pre-rendered basemaps, …) consumed by the raster node as a canvas-sized Raster. The host fetches the 3×3 neighbourhood per render and stitches it onto the padded canvas, so downstream filters see seamless pixels across tile borders.
SpriteSource
A sprite sheet: one atlas image plus a name → sub-rect index, so icon nodes can crop named icons out of it (icons, fill-pattern). The runtime shape is [ezu_graph::SpriteSheet]; the host builds it.

Enums§

DemEncoding
ExpandError
FieldRef
Classify a string field on a node: a node reference, a param reference, or a literal string. The classification is by prefix:
FuncKind
Port-kind vocabulary for function signatures. Mirrors the graph’s PortKind names.
LegendGeometry
The geometry a legend swatch’s stand-in feature is given.
OnMissing
What a tile-pyramid source does when a tile request 404s within the source’s zoom range. (Other HTTP failures are always errors; requests past max-zoom always upsample from the ancestor at max-zoom.)
ParamKind
SourceDecl
Declaration of one external data source. Mixes document-scoped resources (brush, image, sprite, font) — resolved once per style from a file path or http(s):// URL — and tile-scoped pyramids (mvt, pmtiles, dem) — fetched per tile via a URL template.
SpriteIndex
A sprite index, inline or by reference.
StyleError

Constants§

MAX_EXPANDED_NODES
Hard ceiling on the number of nodes an expanded document may contain. Functions calling functions multiply node counts; this converts a runaway composition into a clear error.

Functions§

blank_comments
Blank every comment in src, leaving all other bytes at their original offsets. Returns the input untouched when it holds no comments.
expand_functions
Expand every op: "func" call in doc into inline body copies. Returns None when the document declares no functions (no work to do — callers keep using the original document).
parse_hex_color
Like parse_hex_color_u8 but with components scaled to [0, 1] (still sRGB-encoded, not linearized).
parse_hex_color_u8
Parse #rrggbb / #rrggbbaa into straight (non-premultiplied) sRGB components in [0, 255]. Returns None on malformed input.