Class MBLayer
- Direct Known Subclasses:
BackgroundMBLayer
,CircleMBLayer
,FillExtrusionMBLayer
,FillMBLayer
,LineMBLayer
,RasterMBLayer
,SymbolMBLayer
All methods act as accessors on provided JSON layer, no other state is maintained. This allows modifications to be made cleanly with out chance of side-effect.
- get methods: access the json directly
- query methods: provide logic / transforms to GeoTools classes as required.
In the normal course of events MBLayer is constructed as a flyweight object by MBStyle to provide easy access to its layers list.
- Author:
- Torben Barsballe (Boundless)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FilterFactory
Shared filter factoryprotected final String
field access for "id" key (due to its use in error messages)protected final JSONObject
JSON layer being wrapped.protected final MBObjectParser
Helper class used to provide json access and expression / filter conversionsprotected final StyleFactory
Shared style factory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MBLayer
create
(JSONObject layer) Factory method creating the appropriate MBStyle based on the "type" indicated in the layer JSON.boolean
Equality based on wrappedjson
.filter()
The "filter" as a GeoToolsFilter
suitable for feature selection, as defined bygetFilter()
.A MBFilter wrapping optional json specifying conditions on source features.getId()
Unique layer name.JSONObject
getJson()
JSONObject
Layout properties for the layer.int
The maximum zoom level on which the layer gets parsed and appears on.JSONObject
Arbitrary properties useful to track with the layer, but do not influence rendering.int
The minimum zoom level on which the layer gets parsed and appears on.JSONObject
getPaint()
Default paint properties for this layer.getRef()
References another layer to copy type, source, source-layer, minzoom, maxzoom, filter, and layout properties from.Name of a source description to be used for this layer.Layer to use from a vector tile source.abstract String
getType()
Rendering type of this layer.Layout setting - whether this layer is displayed.int
hashCode()
Hashcode based on wrappedjson
.JSONObject
layout()
Query for layout information (making use ofgetRef()
if available).JSONObject
paint()
Query for paint information (making use ofgetRef()
if available).toString()
final List<FeatureTypeStyle>
Transforms a givenMBLayer
to a GeoToolsFeatureTypeStyle
.Transforms a givenMBLayer
to a GeoToolsFeatureTypeStyle
.abstract List<FeatureTypeStyle>
transformInternal
(MBStyle styleContext) boolean
Whether this layer is displayed.
-
Field Details
-
parse
Helper class used to provide json access and expression / filter conversions -
ff
Shared filter factory -
sf
Shared style factory -
json
protected final JSONObject jsonJSON layer being wrapped. -
id
field access for "id" key (due to its use in error messages)
-
-
Constructor Details
-
MBLayer
-
-
Method Details
-
create
Factory method creating the appropriate MBStyle based on the "type" indicated in the layer JSON.- Parameters:
layer
- JSON Layer definition- Returns:
- Generated MBLayer subclass
-
getType
Rendering type of this layer.One of:
- fill:A filled polygon with an optional stroked border.
- line: A stroked line.
- symbol: An icon or a text label.
- circle:A filled circle.
- fill-extrusion: An extruded (3D) polygon.
- raster: Raster map textures such as satellite imagery.
- background: The background color or pattern of the map.
- Returns:
- One of fill, line, symbol, circle, fill-extrusion, raster, background.
-
getMetadata
public JSONObject getMetadata()Arbitrary properties useful to track with the layer, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'mapbox:' and 'gt:`.- Returns:
- Arbitrary properties useful to track with the layer.
-
getRef
References another layer to copy type, source, source-layer, minzoom, maxzoom, filter, and layout properties from. This allows the layers to share processing and be more efficient.- Returns:
- References another layer to copy type, source, source-layer, minzoom, maxzoom, filter, and layout properties from.
-
getJson
public JSONObject getJson() -
getId
Unique layer name.- Returns:
- layer name, required field
-
getSource
Name of a source description to be used for this layer.While this value is optional, it may be obtained via
getRef()
if needed.- Returns:
- name of source description to be used for this layer, or null if the style has no source.
-
getSourceLayer
Layer to use from a vector tile source. Required if the source supports multiple layers.While this value is optional, it may be obtained via
getRef()
if needed.- Returns:
- layer to use from a vector tile source, or null if the style has no source-layer.
-
getMinZoom
public int getMinZoom()The minimum zoom level on which the layer gets parsed and appears on.- Returns:
- minimum zoom level, or Integer.MIN_VALUE if the style has no minzoom.
-
getMaxZoom
public int getMaxZoom()The maximum zoom level on which the layer gets parsed and appears on.- Returns:
- maximum zoom level, or Integer.MAX_VALUE if the style has no maxzoom.
-
getFilter
A MBFilter wrapping optional json specifying conditions on source features. Only features that match the filter are displayed. This is available as a GeoToolsFilter
viafilter()
.- Returns:
- MBFilter expression specifying conditions on source features.
-
filter
The "filter" as a GeoToolsFilter
suitable for feature selection, as defined bygetFilter()
.- Returns:
- Filter, or Filter.INCLUDE if the style has no filter.
-
getLayout
public JSONObject getLayout()Layout properties for the layer.Layout properties appear in the layer's "layout" object. They are applied early in the rendering process and define how data for that layer is passed to the renderer. For efficiency, a layer can share layout properties with another layer via the "ref" layer property, and should do so where possible. This will decrease processing time and allow the two layers will share GPU memory and other resources associated with the layer.
- Returns:
- Layout properties defined for layer, or an empty
JSONObject
if no layout properties are defined for the style.
-
layout
public JSONObject layout()Query for layout information (making use ofgetRef()
if available).- Returns:
- Layout properties to use for this layer.
-
getPaint
public JSONObject getPaint()Default paint properties for this layer.Paint properties are applied later in the rendering process. A layer that shares layout properties with another layer can have independent paint properties. Paint properties appear in the layer's "paint" object.
- Returns:
- Default paint properties for this layer, or an empty
JSONObject
if no paint properties are defined for the style.
-
getVisibility
Layout setting - whether this layer is displayed.- Returns:
- One of visible, none. Defaults to visible if not defined in the style.
-
visibility
public boolean visibility()Whether this layer is displayed.- Returns:
- Whether the layout is visible. Defaults to true.
-
paint
public JSONObject paint()Query for paint information (making use ofgetRef()
if available).- Returns:
- Paint properties to use for this layer.
-
transform
public List<FeatureTypeStyle> transform(MBStyle styleContext, Double minScaleDenominator, Double maxScaleDenominator) Transforms a givenMBLayer
to a GeoToolsFeatureTypeStyle
.- Parameters:
styleContext
- The MBStyle to which this layer belongs, used to resolving sprite and glyph names to full urls.minScaleDenominator
- Used to determine zoom level restrictions for generated rulesmaxScaleDenominator
- Used to determine zoom level restrictions for generated rules- Returns:
- A feature type style from the provided layer, or null if the visibility of that layer is false.
-
transform
Transforms a givenMBLayer
to a GeoToolsFeatureTypeStyle
.- Parameters:
styleContext
- The MBStyle to which this layer belongs, used as a context for things like resolving sprite and glyph names to full urls.- Returns:
- A feature type style from the provided layer, or null if the visibility of that layer is false.
-
transformInternal
-
hashCode
public int hashCode()Hashcode based on wrappedjson
. -
equals
Equality based on wrappedjson
. -
toString
-