public abstract class MBLayer extends Object
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.
In the normal course of events MBLayer is constructed as a flyweight object by MBStyle to provide easy access to its layers list.
Modifier and Type | Class and Description |
---|---|
static class |
MBLayer.Visibility
Whether this layer is displayed.
|
Modifier and Type | Field and Description |
---|---|
protected FilterFactory2 |
ff
Shared filter factory
|
protected String |
id
field access for "id" key (due to its use in error messages)
|
protected JSONObject |
json
JSON layer being wrapped.
|
protected MBObjectParser |
parse
Helper class used to provide json access and expression / filter conversions
|
protected StyleFactory2 |
sf
Shared style factory
|
Constructor and Description |
---|
MBLayer(JSONObject json,
MBObjectParser parse) |
Modifier and Type | Method and Description |
---|---|
static MBLayer |
create(JSONObject layer)
Factory method creating the appropriate MBStyle based on the "type" indicated in the layer
JSON.
|
boolean |
equals(Object obj)
Equality based on wrapped
json . |
Filter |
filter()
The "filter" as a GeoTools
Filter suitable for feature selection, as defined by
getFilter() . |
MBFilter |
getFilter()
A MBFilter wrapping optional json specifying conditions on source features.
|
String |
getId()
Unique layer name.
|
JSONObject |
getJson() |
JSONObject |
getLayout()
Layout properties for the layer.
|
int |
getMaxZoom()
The maximum zoom level on which the layer gets parsed and appears on.
|
JSONObject |
getMetadata()
Arbitrary properties useful to track with the layer, but do not influence rendering.
|
int |
getMinZoom()
The minimum zoom level on which the layer gets parsed and appears on.
|
JSONObject |
getPaint()
Default paint properties for this layer.
|
String |
getRef()
References another layer to copy type, source, source-layer, minzoom, maxzoom, filter, and
layout properties from.
|
String |
getSource()
Name of a source description to be used for this layer.
|
String |
getSourceLayer()
Layer to use from a vector tile source.
|
abstract String |
getType()
Rendering type of this layer.
|
MBLayer.Visibility |
getVisibility()
Layout setting - whether this layer is displayed.
|
int |
hashCode()
Hashcode based on wrapped
json . |
JSONObject |
layout()
Query for layout information (making use of
getRef() if available). |
JSONObject |
paint()
Query for paint information (making use of
getRef() if available). |
String |
toString() |
List<FeatureTypeStyle> |
transform(MBStyle styleContext)
Transforms a given
MBLayer to a GeoTools FeatureTypeStyle . |
List<FeatureTypeStyle> |
transform(MBStyle styleContext,
Double minScaleDenominator,
Double maxScaleDenominator)
Transforms a given
MBLayer to a GeoTools FeatureTypeStyle . |
abstract List<FeatureTypeStyle> |
transformInternal(MBStyle styleContext) |
boolean |
visibility()
Whether this layer is displayed.
|
protected final MBObjectParser parse
protected final FilterFactory2 ff
protected final StyleFactory2 sf
protected final JSONObject json
protected final String id
public MBLayer(JSONObject json, MBObjectParser parse)
public static MBLayer create(JSONObject layer)
layer
- JSON Layer definitionpublic abstract String getType()
One of:
public JSONObject getMetadata()
public String getRef()
public JSONObject getJson()
public String getId()
public String getSource()
While this value is optional, it may be obtained via getRef()
if needed.
public String getSourceLayer()
While this value is optional, it may be obtained via getRef()
if needed.
public int getMinZoom()
public int getMaxZoom()
public MBFilter getFilter()
Filter
via
filter()
.public Filter filter()
Filter
suitable for feature selection, as defined by
getFilter()
.public JSONObject getLayout()
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.
JSONObject
if no layout
properties are defined for the style.public JSONObject layout()
getRef()
if available).public JSONObject getPaint()
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.
JSONObject
if no paint
properties are defined for the style.public MBLayer.Visibility getVisibility()
public boolean visibility()
public JSONObject paint()
getRef()
if available).public List<FeatureTypeStyle> transform(MBStyle styleContext, Double minScaleDenominator, Double maxScaleDenominator)
MBLayer
to a GeoTools FeatureTypeStyle
.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 rulespublic final List<FeatureTypeStyle> transform(MBStyle styleContext)
MBLayer
to a GeoTools FeatureTypeStyle
.styleContext
- The MBStyle to which this layer belongs, used as a context for things
like resolving sprite and glyph names to full urls.public abstract List<FeatureTypeStyle> transformInternal(MBStyle styleContext)
Copyright © 1996–2022 Geotools. All rights reserved.