Class MBFilter
- Object
-
- 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
-
-
Field Summary
Fields Modifier and Type Field Description protected FilterFactory
ff
protected JSONArray
json
Wrapped jsonprotected MBObjectParser
parse
Parser context.protected SemanticType
semanticType
Default semanticType (or null for "geometry").static String
TYPE_LINE
static String
TYPE_POINT
static String
TYPE_POLYGON
-
Constructor Summary
Constructors Constructor Description MBFilter(JSONArray json)
MBFilter(JSONArray json, MBObjectParser parse)
MBFilter(JSONArray json, MBObjectParser parse, SemanticType semanticType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Filter
filter()
Generate GeoToolsFilter
from json definition.Set<SemanticType>
semanticTypeIdentifiers()
Translate "$type": the feature type we need This key may be used with the "==", "!
-
-
-
Field Detail
-
TYPE_POINT
public static final String TYPE_POINT
- See Also:
- Constant Field Values
-
TYPE_LINE
public static final String TYPE_LINE
- See Also:
- Constant Field Values
-
TYPE_POLYGON
public static final String TYPE_POLYGON
- See Also:
- Constant Field Values
-
semanticType
protected final SemanticType semanticType
Default semanticType (or null for "geometry").
-
parse
protected final MBObjectParser parse
Parser context.
-
ff
protected final FilterFactory ff
-
json
protected final JSONArray json
Wrapped json
-
-
Constructor Detail
-
MBFilter
public MBFilter(JSONArray json)
-
MBFilter
public MBFilter(JSONArray json, MBObjectParser parse)
-
MBFilter
public MBFilter(JSONArray json, MBObjectParser parse, SemanticType semanticType)
-
-
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).
-
-