Package org.geotools.mbstyle
Class MBStyle
- Object
- 
- MBStyle
 
- 
 public class MBStyle extends Object MapBox Style implemented as wrapper around parsed JSON file.This class is responsible for presenting the wrapped JSON in an easy to use / navigate form for Java developers: - get methods: access the json directly
- query methods: provide logic / transforms to GeoTools classes as required.
 Access methods should return Java Objects, rather than generic maps. Additional access methods to perform common queries are expected and encouraged. This class works closely with MBLayerhierarchy used to represent the fill, line, symbol, raster, circle layers. Additional support will be required to work with sprites and glyphs.- Author:
- Jody Garnett (Boundless)
 
- 
- 
Field SummaryFields Modifier and Type Field Description JSONObjectjsonJSON document being wrapped by this class.
 - 
Constructor SummaryConstructors Constructor Description MBStyle(JSONObject json)MBStyle wrapper on the provided json
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MBStylecreate(Object json)Parse MBStyle for the provided json.NumbergetBearing()(Optional) Default bearing, in degrees clockwise from true north.Point2DgetCenter()(Optional) Default map center in longitude and latitude.StringgetGlyphs()(Optional) A URL template for loading signed-distance-field glyph sets in PBF format.JSONObjectgetMetadata()(Optional) Arbitrary properties useful to track with the stylesheet, but do not influence rendering.StringgetName()A human-readable name for the styleNumbergetPitch()(Optional) Default pitch, in degrees.Map<String,MBSource>getSources()Data source specifications.StringgetSprite()A base URL for retrieving the sprite image and metadata.NumbergetZoom()(Optional) Default zoom level.MBLayerlayer(String id)Access the layer with the provided id.List<MBLayer>layers()Access all layers.List<MBLayer>layers(String source)Access layers matching provided source.StyledLayerDescriptortransform()Transform MBStyle to a GeoTools StyledLayerDescriptor.
 
- 
- 
- 
Method Detail- 
createpublic static MBStyle create(Object json) throws MBFormatException Parse MBStyle for the provided json.- Parameters:
- json- Required to be a JSONObject
- Returns:
- MBStyle wrapping the provided json
- Throws:
- MBFormatException- JSON content inconsistent with specification
 
 - 
layerpublic MBLayer layer(String id) Access the layer with the provided id.- Parameters:
- id- Id of layer to access
- Returns:
- layer with the provided id, or null if not found.
 
 - 
layerspublic List<MBLayer> layers(String source) throws MBFormatException Access layers matching provided source.- Parameters:
- source- Data source
- Returns:
- list of layers matching provided source
- Throws:
- MBFormatException
 
 - 
getNamepublic String getName() A human-readable name for the style- Returns:
- human-readable name, or "name" if the style has no name.
 
 - 
getMetadatapublic JSONObject getMetadata() (Optional) Arbitrary properties useful to track with the stylesheet, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'mapbox:'.- Returns:
- JSONObjectcontaining the metadata, or an empty JSON object the style has no metadata.
 
 - 
getCenterpublic Point2D getCenter() (Optional) Default map center in longitude and latitude. The style center will be used only if the map has not been positioned by other means (e.g. map options or user interaction).- Returns:
- A Pointfor the map center, or null if the style contains no center.
 
 - 
getZoompublic Number getZoom() (Optional) Default zoom level. The style zoom will be used only if the map has not been positioned by other means (e.g. map options or user interaction).- Returns:
- Number for the zoom level, or null if the style has no default zoom level.
 
 - 
getBearingpublic Number getBearing() (Optional) Default bearing, in degrees clockwise from true north. The style bearing will be used only if the map has not been positioned by other means (e.g. map options or user interaction).- Returns:
- The bearing in degrees. Defaults to 0 if the style has no bearing.
 
 - 
getPitchpublic Number getPitch() (Optional) Default pitch, in degrees. Zero is perpendicular to the surface, for a look straight down at the map, while a greater value like 60 looks ahead towards the horizon. The style pitch will be used only if the map has not been positioned by other means (e.g. map options or user interaction).- Returns:
- The pitch in degrees. Defaults to 0 if the style has no pitch.
 
 - 
getSpritepublic String getSprite() A base URL for retrieving the sprite image and metadata. The extensions .png, .json and scale factor @2x.png will be automatically appended. This property is required if any layer uses the background-pattern, fill-pattern, line-pattern, fill-extrusion-pattern, or icon-image properties.- Returns:
- The sprite URL, or null if the style has no sprite URL.
 
 - 
getGlyphspublic String getGlyphs() (Optional) A URL template for loading signed-distance-field glyph sets in PBF format. The URL must include {fontstack} and {range} tokens. This property is required if any layer uses the text-field layout property.
 Example:
 "glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf"- Returns:
- The glyphs URL template, or null if the style has no glyphs URL template.
 
 - 
transformpublic StyledLayerDescriptor transform() Transform MBStyle to a GeoTools StyledLayerDescriptor.- Returns:
- StyledLayerDescriptor
 
 
- 
 
-