Class MBVectorTileDecoder

java.lang.Object
com.massifmaps.vectortiles.VectorTileDecoder
com.massifmaps.vectortiles.MBVectorTileDecoder

public class MBVectorTileDecoder extends VectorTileDecoder
Decoder for vector tiles in MapBox format.
  • Constructor Details

    • MBVectorTileDecoder

      public MBVectorTileDecoder(CompiledStyleSet compiledStyleSet)
      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

      public MBVectorTileDecoder(CartoCSSStyleSet cartoCSSStyleSet)
      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

      public CompiledStyleSet 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

      public void setCompiledStyleSet(CompiledStyleSet styleSet)
      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

      public CartoCSSStyleSet 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

      public void setCartoCSSStyleSet(CartoCSSStyleSet styleSet)
      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

      public StringVector getStyleParameters()
      Returns the list of all available style parameters.
      Returns:
      The list of all available style parameters.
    • getStyleParameter

      public String getStyleParameter(String param)
      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

      public boolean setStyleParameter(String param, String value)
      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

      public void setStyleParameters(StringMap params)
      Sets the values of the specified parameters.
      The style parameters must be declared in the current style.
      Parameters:
      params - The getStyleParameters to set.
    • setJSONStyleParameters

      public void setJSONStyleParameters(String params)
      Sets the values of the specified parameters.
      The style parameters must be declared in the current style.
      Parameters:
      params - The getStyleParameters to set.
    • getStyleLayerNames

      public StringVector 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

      public static int parseTileFormat(String format)
      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

      public void addFallbackFont(BinaryData fontData)
      Description copied from class: VectorTileDecoder
      Adds a fallback font. The font should be TTF or OTF font. It is used for glyphs not found in style defined fonts.
      Overrides:
      addFallbackFont in class VectorTileDecoder
      Parameters:
      fontData - The font binary.
    • getMinZoom

      public int getMinZoom()
      Description copied from class: VectorTileDecoder
      Returns minimum zoom level supported for by the decoder (or style).
      Overrides:
      getMinZoom in class VectorTileDecoder
      Returns:
      Minimum supported zoom level.
    • getMaxZoom

      public int getMaxZoom()
      Description copied from class: VectorTileDecoder
      Returns maximum zoom level supported for by the decoder (or style).
      Overrides:
      getMaxZoom in class VectorTileDecoder
      Returns:
      Maximum supported zoom level.