MvtFilter

sealed class MvtFilter

Predicate over an MVT feature's inflated property map. Sealed so the matching set is known up front. Filters are pure data evaluated once per feature off the render thread (in MvtVectorLayer.toRenderables); construct via the companion factory methods or the DSL infix helpers ("kind" eq "motorway").

Supported: literal equality, set membership, numeric comparison, has, boolean combinators. Not supported: expression operators (case, match, arithmetic), geometry-type filters.

Property values arrive as Any? because MVT's wire format types them per value: string → String, bool → Boolean, int64/uint64 → Long, sint64 → Long (zigzagged), float → Float, double → Double, absent → null. Numeric comparisons go through Number.toDouble so int/float/double mix correctly.

Inheritors

Types

Link copied to clipboard
class AllOf(val children: List<MvtFilter>) : MvtFilter

Short-circuit conjunction. Empty children = always true.

Link copied to clipboard
object Always : MvtFilter

Always-true filter. Useful as a placeholder when a rule needs no filter.

Link copied to clipboard
class AnyOf(val children: List<MvtFilter>) : MvtFilter

Short-circuit disjunction. Empty = always false. Named AnyOf because plain Any shadows kotlin.Any inside the class body and breaks every Any? reference. AllOf mirrors the naming.

Link copied to clipboard
object Companion
Link copied to clipboard
class Eq(val key: String, val value: Any?) : MvtFilter

True when properties[key] == value (Mapbox loose-equality: number-vs-number by primitive).

Link copied to clipboard

True when the feature's geometry type equals expected.

Link copied to clipboard
class Has(val key: String) : MvtFilter

True when key is present in the map (regardless of value, including null).

Link copied to clipboard
class In(val key: String, val values: Set<Any?>) : MvtFilter

True when properties[key] is in values. The membership test is a Set hash lookup — both the property value and the members are already boxed references, so this allocates nothing; numeric members are compared by their existing identity/equality (unchanged).

Link copied to clipboard
class Not(val child: MvtFilter) : MvtFilter

Negation.

Link copied to clipboard
class NotEq(val key: String, val value: Any?) : MvtFilter

Negation of Eq.

Link copied to clipboard
class NumericGt(val key: String, val threshold: Double) : MvtFilter

True when properties[key].toDouble()>threshold. Non-numeric / null = false.

Link copied to clipboard
class NumericGte(val key: String, val threshold: Double) : MvtFilter

True when properties[key].toDouble() ≥ threshold. Non-numeric / null = false.

Link copied to clipboard
class NumericLt(val key: String, val threshold: Double) : MvtFilter

True when properties[key].toDouble()<threshold. Non-numeric / null = false.

Link copied to clipboard
class NumericLte(val key: String, val threshold: Double) : MvtFilter

True when properties[key].toDouble() ≤ threshold. Non-numeric / null = false.

Functions

Link copied to clipboard
abstract fun matches(properties: Map<String, Any?>, geomType: MvtGeometryType? = null): Boolean

Evaluate this filter against a feature's inflated property map. geomType surfaces the feature's geometry kind so GeometryTypeEq can compare against it; other filters ignore it.