MvtRuleBasedStyle

class MvtRuleBasedStyle(val rules: List<MvtStyleRule>, val backgroundColor: Color? = null) : MvtStyle

Style backed by an ordered list of MvtStyleRules. For each feature, iterates rules in order and returns the first match's resolved attributes. The same first match's MvtStyleRule.zOrder is reported from zOrderFor.

Rule order = paint order = z-order tiebreak. Put earlier rules where you want them under later rules. Within a tile, this layer relies on the rule list itself for cross-feature ordering; the per-rule MvtStyleRule.zOrder is used by MvtVectorLayer to coordinate cross-tile compositing (water-tile under road-tile etc.).

Use the mvtStyle DSL to author one of these declaratively, or pass a pre-built list of rules to the constructor.

Constructors

Link copied to clipboard
constructor(rules: List<MvtStyleRule>, backgroundColor: Color? = null)

Types

Link copied to clipboard

Mutable holder for firstShapeAndText results; reused across features to avoid allocation.

Properties

Link copied to clipboard
open override val backgroundColor: Color?

Solid base under every fill — the Mapbox background layer. Fills gaps MVT has no polygon for (bare rock, street interiors, highway corridors); null (default) shows whatever is beneath the layer. See Z_BACKGROUND.

Link copied to clipboard

Functions

Link copied to clipboard
fun firstMatching(layerName: String, geometryType: MvtGeometryType, zoom: Int, properties: Map<String, Any?>): MvtStyleRule?
Link copied to clipboard
fun firstShapeAndText(layerName: String, geometryType: MvtGeometryType, zoom: Int, properties: Map<String, Any?>, out: MvtRuleBasedStyle.ShapeTextRules)

Single-pass shape+text resolution for one feature. Walks rules ONCE by index (no iterator allocation), evaluating each rule's MvtStyleRule.matches at most once, and captures into out the FIRST matching rule whose paint hasShape and (independently) the FIRST whose paint hasText. Early-exits once both are found. Byte-identical to two separate firstMatching(...) { it.paint.hasShape } / { it.paint.hasText } calls, but without re-walking the list or re-running matches twice per rule.

Link copied to clipboard
open override fun styleFor(layerName: String, geometryType: MvtGeometryType, properties: Map<String, Any?>): ShapeAttributes?

Zoom-blind callers resolve at zoom 0; use the zoom-aware overload for proper interpolation.

fun styleFor(layerName: String, geometryType: MvtGeometryType, zoom: Int, properties: Map<String, Any?>): ShapeAttributes?

Zoom-aware overload — MvtVectorLayer passes the tile's z.

Link copied to clipboard
open override fun zOrderFor(layerName: String, geometryType: MvtGeometryType, properties: Map<String, Any?>): Int

Optional paint order within a tile. Features with smaller zOrderFor paint first, features with larger values paint over them. Default 0 — every feature shares the same z-layer, and the order falls through to MVT-server-determined layer iteration order (good enough for OpenMapTiles-schema servers that already order water → landuse → roads → buildings sensibly).