Package com.massifmaps.vectortiles
Class MBVectorTileDecoder
java.lang.Object
com.massifmaps.vectortiles.VectorTileDecoder
com.massifmaps.vectortiles.MBVectorTileDecoder
Decoder for vector tiles in MapBox format.
-
Constructor Summary
ConstructorsConstructorDescriptionMBVectorTileDecoder(CartoCSSStyleSet cartoCSSStyleSet) Constructs a decoder for MapBox vector tiles based on specified CartoCSS style set.MBVectorTileDecoder(CompiledStyleSet compiledStyleSet) Constructs a decoder for MapBox vector tiles based on specified compiled style set. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFallbackFont(BinaryData fontData) Adds a fallback font.Returns the current CartoCSS style set used by the decoder.
If decoder uses non-CartoCSS style set, null is returned.Returns the current compiled style set used by the decoder.
If decoder uses non-compiled style set, null is returned.intReturns maximum zoom level supported for by the decoder (or style).intReturns minimum zoom level supported for by the decoder (or style).Returns the ordered list of style layer names as declared by the style (the project
JSON "layers" array, or the Layer elements of a Mapnik XML style).getStyleParameter(String param) Returns the value of the specified style parameter.
The style parameter must be declared in the current style.Returns the list of all available style parameters.intReturns the binary format the tiles are decoded as.booleanReturns the value of feature id override flag.static intparseTileFormat(String format) Maps a container's declared format or encoding - an MBTiles or PMTiles metadata value, a
TileJSON media type - onto a tile format.voidsetCartoCSSStyleSet(CartoCSSStyleSet styleSet) Sets the current CartoCSS style set used by the decoder.voidsetCompiledStyleSet(CompiledStyleSet styleSet) Sets the current compiled style set used by the decoder.voidsetFeatureIdOverride(boolean idOverride) Sets the value of feature id override flag.voidsetJSONStyleParameters(String params) Sets the values of the specified parameters.
The style parameters must be declared in the current style.booleansetStyleParameter(String param, String value) Sets the value of the specified parameter.
The style parameter must be declared in the current style.voidsetStyleParameters(StringMap params) Sets the values of the specified parameters.
The style parameters must be declared in the current style.voidsetTileFormat(int format) Sets the binary format the tiles are decoded as.Methods inherited from class com.massifmaps.vectortiles.VectorTileDecoder
equals, hashCode, notifyDecoderChanged, notifyDecoderRefreshed
-
Constructor Details
-
MBVectorTileDecoder
Constructs a decoder for MapBox vector tiles based on specified compiled style set.- Parameters:
compiledStyleSet- The compiled style set for the tiles.- Throws:
Exception- If the decoder could not be created or there are issues with the style set.
-
MBVectorTileDecoder
Constructs a decoder for MapBox vector tiles based on specified CartoCSS style set.- Parameters:
cartoCSSStyleSet- The CartoCSS style set for the tiles.- Throws:
Exception- If the decoder could not be created or there are issues with the style set.
-
-
Method Details
-
getCompiledStyleSet
Returns the current compiled style set used by the decoder.
If decoder uses non-compiled style set, null is returned.- Returns:
- The current style set.
-
setCompiledStyleSet
Sets the current compiled style set used by the decoder.- Parameters:
styleSet- The new style set to use.- Throws:
Exception- If the decoder could not be updated or there are issues with the style set.
-
getCartoCSSStyleSet
Returns the current CartoCSS style set used by the decoder.
If decoder uses non-CartoCSS style set, null is returned.- Returns:
- The current style set.
-
setCartoCSSStyleSet
Sets the current CartoCSS style set used by the decoder.- Parameters:
styleSet- The new style set to use.- Throws:
Exception- If the decoder could not be updated or there are issues with the style set.
-
getStyleParameters
Returns the list of all available style parameters.- Returns:
- The list of all available style parameters.
-
getStyleParameter
Returns the value of the specified style parameter.
The style parameter must be declared in the current style.- Parameters:
param- The parameter to return.- Returns:
- The value of the parameter. If parameter does not exists, empty string is returned.
- Throws:
IllegalArgumentException- If the style parameter does not exist.
-
setStyleParameter
Sets the value of the specified parameter.
The style parameter must be declared in the current style.- Parameters:
param- The parameter to set.value- The value for the parameter.- Returns:
- True if the parameter was set. False if the style parameter does not exist or could not be set.
-
setStyleParameters
Sets the values of the specified parameters.
The style parameters must be declared in the current style.- Parameters:
params- The getStyleParameters to set.
-
setJSONStyleParameters
Sets the values of the specified parameters.
The style parameters must be declared in the current style.- Parameters:
params- The getStyleParameters to set.
-
getStyleLayerNames
Returns the ordered list of style layer names as declared by the style (the project
JSON "layers" array, or the Layer elements of a Mapnik XML style). This defines both
the draw order and which layers exist. CompositeVectorTileLayer uses it to place
external data sources in the layer order: a source whose name is not in this list has
no slot in the style and is not drawn, so this is the way to check a style before
wiring sources into it.- Returns:
- The ordered style layer names.
-
isFeatureIdOverride
public boolean isFeatureIdOverride()Returns the value of feature id override flag. This is intended for cases when feature ids in tile are not globally unique.- Returns:
- The value of feature id override flag.
-
setFeatureIdOverride
public void setFeatureIdOverride(boolean idOverride) Sets the value of feature id override flag. This is intended for cases when feature ids in tile are not globally unique.- Parameters:
idOverride- The value of the flag.
-
getTileFormat
public int getTileFormat()Returns the binary format the tiles are decoded as.- Returns:
- The tile format. Default is MVT.
-
setTileFormat
public void setTileFormat(int format) Sets the binary format the tiles are decoded as. The two formats are not distinguishable
from the tile data, so the source has to say which it serves.- Parameters:
format- The tile format.
-
parseTileFormat
Maps a container's declared format or encoding - an MBTiles or PMTiles metadata value, a
TileJSON media type - onto a tile format. Matching is case-insensitive and by substring,
because generators spell this differently ('mvt',
'application/vnd.maplibre-vector-tile'). 'pbf' is inconclusive rather than MVT, since
MapLibre's tilesets keep format at 'pbf' and declare MLT through encoding instead.- Parameters:
format- The declared format or encoding string.- Returns:
- The tile format, or TILE_FORMAT_AUTO when the string says nothing conclusive.
-
addFallbackFont
Description copied from class:VectorTileDecoderAdds a fallback font. The font should be TTF or OTF font. It is used for glyphs not found in style defined fonts.- Overrides:
addFallbackFontin classVectorTileDecoder- Parameters:
fontData- The font binary.
-
getMinZoom
public int getMinZoom()Description copied from class:VectorTileDecoderReturns minimum zoom level supported for by the decoder (or style).- Overrides:
getMinZoomin classVectorTileDecoder- Returns:
- Minimum supported zoom level.
-
getMaxZoom
public int getMaxZoom()Description copied from class:VectorTileDecoderReturns maximum zoom level supported for by the decoder (or style).- Overrides:
getMaxZoomin classVectorTileDecoder- Returns:
- Maximum supported zoom level.
-