Package org.geotools.mbstyle.layer
Class FillMBLayer
-
public class FillMBLayer extends MBLayer
MBLayer wrapper for "Fill" layers.Example of line JSON:
{ "type": "line", "source": "http://localhost:8080/geoserver/ne/roads", "source-layer": "road" "id": "roads", "paint": { "fill-anitalias": true, "fill-opacity": 1 "fill-color": "#6655ae", "fill-outline-color": "#000000", "fill-translate": [0,0], "fill-translate-anchor": "map", "fill-pattern": "triangle" // Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). }, },
- Author:
- Reggie Beckwith (Boundless)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FillMBLayer.FillTranslateAnchor
Controls the translation reference point.-
Nested classes/interfaces inherited from class MBLayer
MBLayer.Visibility
-
-
Constructor Summary
Constructors Constructor Description FillMBLayer(JSONObject json)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SemanticType
defaultSemanticType()
Expression
fillColor()
Access fill-color as literal or function expression, defaults to black.Expression
fillOpacity()
Access fill-opacity, defaults to 1.Expression
fillOutlineColor()
Access fill-outline-color as literal or function expression, defaults to black.Expression
fillPattern()
(Optional) Name of image in a sprite to use for drawing image fills.Point
fillTranslate()
Access fill-translate as Point.Displacement
fillTranslateDisplacement()
Processes the filter-translate into a Displacement.Expression
getFillAntialias()
(Optional) Whether or not the fill should be antialiased.Color
getFillColor()
(Optional).Number
getFillOpacity()
(Optional) The opacity of the entire fill layer.Color
getFillOutlineColor()
(Optional).int[]
getFillTranslate()
(Optional) The geometry's offset.FillMBLayer.FillTranslateAnchor
getFillTranslateAnchor()
(Optional) Controls the translation reference point.String
getType()
Rendering type of this layer.boolean
hasFillPattern()
List<FeatureTypeStyle>
transformInternal(MBStyle styleContext)
Transform MBFillLayer to GeoTools FeatureTypeStyle.-
Methods inherited from class MBLayer
create, equals, filter, getFilter, getId, getJson, getLayout, getMaxZoom, getMetadata, getMinZoom, getPaint, getRef, getSource, getSourceLayer, getVisibility, hashCode, layout, paint, toString, transform, transform, visibility
-
-
-
-
Method Detail
-
defaultSemanticType
protected SemanticType defaultSemanticType()
-
getFillAntialias
public Expression getFillAntialias()
(Optional) Whether or not the fill should be antialiased.Defaults to true.
- Returns:
- Whether the fill should be antialiased.
-
getFillOpacity
public Number getFillOpacity() throws MBFormatException
(Optional) The opacity of the entire fill layer. In contrast to the fill-color, this value will also affect the 1px stroke around the fill, if the stroke is used.Defaults to 1.
- Returns:
- The opacity of the layer.
- Throws:
MBFormatException
- JSON provided inconsistent with specification
-
fillOpacity
public Expression fillOpacity() throws MBFormatException
Access fill-opacity, defaults to 1.- Returns:
- The opacity of the layer.
- Throws:
MBFormatException
- JSON provided inconsistent with specification
-
getFillColor
public Color getFillColor()
(Optional). The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used.Colors are written as JSON strings in a variety of permitted formats.
Defaults to #000000. Disabled by fill-pattern.
- Returns:
- The fill color.
-
fillColor
public Expression fillColor()
Access fill-color as literal or function expression, defaults to black.- Returns:
- The fill color.
-
getFillOutlineColor
public Color getFillOutlineColor()
(Optional). Requires fill-antialias = true. The outline color of the fill.Matches the value of fill-color if unspecified. Disabled by fill-pattern.
- Returns:
- The outline color of the fill.
-
fillOutlineColor
public Expression fillOutlineColor()
Access fill-outline-color as literal or function expression, defaults to black.- Returns:
- The outline color of the fill.
-
getFillTranslate
public int[] getFillTranslate()
(Optional) The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. Units in pixels. Defaults to 0, 0.- Returns:
- The geometry's offset
-
fillTranslate
public Point fillTranslate()
Access fill-translate as Point.- Returns:
- The geometry's offset, in pixels.
-
fillTranslateDisplacement
public Displacement fillTranslateDisplacement()
Processes the filter-translate into a Displacement.This should handle both literals and function stops:
filter-translate: [0,0] filter-translate: { property: "building-height", "stops": [[0,[0,0]],[5,[1,2]]] } filter-translate: [ 0, { property: "building-height", "TYPE":"exponential","stops": [[0,0],[30, 5]] }
- Returns:
- The geometry displacement
-
getFillTranslateAnchor
public FillMBLayer.FillTranslateAnchor getFillTranslateAnchor()
(Optional) Controls the translation reference point.FillMBLayer.FillTranslateAnchor.MAP
: The fill is translated relative to the map.FillMBLayer.FillTranslateAnchor.VIEWPORT
: The fill is translated relative to the viewport.
- Returns:
- One of 'map','viewport', defaults to 'map'.
-
fillPattern
public Expression fillPattern()
(Optional) Name of image in a sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).- Returns:
- name of the sprite for the fill pattern, or null if not defined.
-
hasFillPattern
public boolean hasFillPattern()
- Returns:
- True if the layer has a fill-pattern explicitly provided.
-
transformInternal
public List<FeatureTypeStyle> transformInternal(MBStyle styleContext)
Transform MBFillLayer to GeoTools FeatureTypeStyle.Notes:
- stroke-width is assumed to be 1 (not specified by MapBox style)
- Specified by:
transformInternal
in classMBLayer
- 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:
- FeatureTypeStyle
-
-