Class MBFilter


  • public class MBFilter
    extends Object
    MBFilter json wrapper, allowing conversion to a GeoTools Filter.

    This wrapper class is used by MBObjectParser to generate rule filters when transforming MBStyle.

    This wrapper and MBFunction are a matched set handling data expression.

    Data expression: Decision

    Implementation Note: The value for any filter may be specified as an data expression. The result type of an data expression in the filter property must be boolean. See MBExpression for details.

    The expressions in this section can be used to add conditional logic to your styles. For example, the 'case' expression provides "if/then/else" logic, and 'match' allows you to map specific values of an input expression to different output expressions.

    • ["!", boolean]: boolean
    • ["!=", value, value]: boolean
    • </code>
    • <=
    • ==
    • >
    • >=
    • all
    • any
    • case
    • coalesce
    • match
    • within

    Filter Other

    Implementation Note: GeoTools also supports the depreciated syntax documented here (provided by a previous versions of the Mapbox style specification).

    A filter selects specific features from a layer. A filter is an array of one of the following forms:

    Existential Filters

    • ["has", key] - feature[key] exists
    • ["!has", key] - feature[key] does not exist

    Comparison Filters:

    • ["==", key, value] equality: feature[key] = value
    • ["!=", key, value] inequality: feature[key] ≠ value
    • [">", key, value] greater than: feature[key] > value
    • [">=", key, value] greater than or equal: feature[key] ≥ value
    • ["<", key, value] less than: feature[key] < value
    • ["<=", key, value] less than or equal: feature[key] ≤ value

    Set Membership Filters:

    • ["in", key, v0, ..., vn] set inclusion: feature[key] ∈ {v0, ..., vn}
    • ["!in", key, v0, ..., vn] set exclusion: feature[key] ∉ {v0, ..., vn}

    Combining Filters:

    • ["all", f0, ..., fn] logical AND: f0 ∧ ... ∧ fn
    • ["any", f0, ..., fn] logical OR: f0 ∨ ... ∨ fn
    • ["none", f0, ..., fn] logical NOR: ¬f0 ∧ ... ∧ ¬fn

    A key must be a string that identifies a feature property, or one of the following special keys:

    • "$type": the feature type. This key may be used with the "==", "!=", "in", and "!in" operators. Possible values are "Point", "LineString", and "Polygon".
    • "$id": the feature identifier. This key may be used with the "==", "!=", "has", "!has", "in", and "!in" operators.
    See Also:
    Filter, MBFunction, MBExpression
    • Constructor Detail

      • MBFilter

        public MBFilter​(JSONArray json)
      • MBFilter

        public MBFilter​(JSONArray json,
                        MBObjectParser parse)
    • Method Detail

      • semanticTypeIdentifiers

        public Set<SemanticType> semanticTypeIdentifiers()
        Translate "$type": the feature type we need This key may be used with the "==", "!=", "in", and "!in" operators. Possible values are "Point", "LineString", and "Polygon".
        Returns:
        Set of GeoTools SemanticType (Point, LineString, Polygon).
      • filter

        public Filter filter()
        Generate GeoTools Filter from json definition.

        This filter specifying conditions on source features. Only features that match the filter are displayed.

        Returns:
        GeoTools Filter specifying conditions on source features.