Generator Reference
The generator package provides the core rendering engine for Elzar.
Modules
render
Style rendering functions.
elzar.generator.render
Render map style layers to MapLibre GL style format.
This module provides functionality to convert internal layer representations to MapLibre GL JSON style format, including icon resolution from templates.
LayerRenderer
LayerRenderer(children)
Source code in elzar/generator/render.py
47 48 | |
render_mapbox_style
render_mapbox_style(data_layers, style_tree, sources, style_name='{style_name}')
Source code in elzar/generator/render.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
get_used_icons
get_used_icons(layer, resolved_layout)
Source code in elzar/generator/render.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
styler
Style tree implementation.
elzar.generator.styler
Style tree for hierarchical style resolution.
This module provides a tree structure for organizing and resolving styles based on dot-separated selector paths (e.g., 'road.highway.motorway').
StyleElement
StyleElement(paint=None, layout=None, min_zoom=None, max_zoom=None, metadata=None)
Source code in elzar/generator/styler.py
36 37 38 39 40 41 42 43 44 45 46 47 48 | |
__or__
__or__(other)
Merge two StyleElements. other fields override self where explicitly set.
Source code in elzar/generator/styler.py
50 51 52 53 54 55 56 57 58 59 60 | |
StyleNode
StyleNode(name)
Source code in elzar/generator/styler.py
77 78 79 80 | |
StyleTree
StyleTree(style)
Source code in elzar/generator/styler.py
84 85 86 87 88 89 90 | |
data
Layer and data definitions.
elzar.generator.data
Data structures for map style layer definitions.
This module defines the core data types for representing map layers, including geometry types, render groups, and specialized road/rail nodes.
Layer
dataclass
Layer(id, geometry_type, filter=None, feature_type=None, element_types=None, style_layer=None)
GeometryType
Bases: Enum
InjectionsNames
Bases: Enum
DataNode
DataNode(id, filter=None, geometry_type=BACKGROUND, render_group=TOP, feature_type=_FEATURE_TYPE_DEFAULT, element_types=None)
Bases: Node
Source code in elzar/generator/data.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
render
render(stack)
Renders the layer in the stack
Source code in elzar/generator/data.py
315 316 317 318 319 320 321 322 323 324 325 326 | |
Stack
Stack(render_groups)
Bases: Node, Generic[T]
Source code in elzar/generator/data.py
275 276 | |
get_layers
get_layers()
Returns only renderable layers
Source code in elzar/generator/data.py
288 289 290 | |
render
render(stack)
Render this node to the layer stack. Override in subclasses.
Source code in elzar/generator/data.py
22 23 24 | |
multiclass_fill
Multiclass fill layer builder.
elzar.generator.multiclass_fill
Builder for multiclass fill layers (e.g. landcover).
Produces a single FillLayer where multiple feature classes share one GL layer. The JS runtime reads classMetadata from the layer's metadata to build interpolate+case paint expressions that branch on the feature's class property.
FillClass
dataclass
FillClass(fill_color, fill_outline_color=None, visible=True)
Definition of one class within a multiclass fill layer.
MulticlassFillNode
MulticlassFillNode(id, classes, source, source_layer, feature_type, *, fill_opacity=None, max_zoom=None, min_zoom=None, render_group=LANDCOVER)
Bases: Node
A Node that produces a multiclass fill layer through the standard rendering pipeline.
Source code in elzar/generator/multiclass_fill.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
build_multiclass_fill_layer
build_multiclass_fill_layer(identifier, classes, source, source_layer, feature_type, *, fill_opacity=None, max_zoom=None, min_zoom=None)
Build a single FillLayer with classMetadata for multiple feature classes.
The returned layer has: - Paint with interpolate+case expressions for fill-color (and fill-outline-color if any class defines it) - Metadata with classMetadata and classBaseFilter for JS runtime styling - Filter combining classBaseFilter with all visible class filters
Source code in elzar/generator/multiclass_fill.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
poi
POI layer builder.
elzar.generator.poi
POIClass
dataclass
POIClass(filter, icon=None, symbol_color='#fff', color=None, min_size=0.7, min_zoom=14)
POINode
POINode(id, pois, base_filter, *, visible=False, bold=False, all_label_color=None, all_halo_color=None, all_symbol_color=None, default_icon=None, raster=False, category_halo=False, source='openmaptiles', source_layer='poi', render_group=POI_AFTER_LABELS)
Bases: Node
A Node that produces a POI symbol layer through the standard rendering pipeline.
Source code in elzar/generator/poi.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
build_poi_layer
build_poi_layer(name, pois, base_filter, visible, bold, all_label_color=None, all_halo_color=None, all_symbol_color=None, default_icon=None, raster=False, category_halo=False, source='openmaptiles', source_layer='poi')
:returns required icons by poi layer and the symbol layer
Source code in elzar/generator/poi.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
filters
Filter expression handling.
elzar.generator.filters
Convert Q filter expressions to MapLibre GL filter format.
This module transforms Django-style Q expressions into MapLibre GL JSON filter expressions for use in map style layer definitions.
ExpressionSet
ExpressionSet(q=None)
Source code in elzar/generator/filters.py
15 16 | |