Class CompositeVectorTileLayer


public class CompositeVectorTileLayer extends VectorTileLayer
A VectorTileLayer that can weave named external data sources (raster, hillshade,
merged vector / contour) into the master CartoCSS style's layer order.

Each external source is placed at the position of a matching layer name in the style
project's "layers" array, and configured by a matching '#name { ... }' block in the
CartoCSS (e.g. raster-opacity, hillshade-exaggeration), including zoom- and style-parameter-
parameter-dependent expressions. Raster and hillshade sources are rendered as their
own draped child layers interleaved between the master style layers; merged vector
sources are folded into the master source and styled normally.

Sources can be added and removed at runtime.
  • Constructor Details

    • CompositeVectorTileLayer

      public CompositeVectorTileLayer(TileDataSource dataSource, VectorTileDecoder decoder)
      Constructs a CompositeVectorTileLayer from a master vector data source and decoder.
      Parameters:
      dataSource - The master vector tile data source.
      decoder - The tile decoder (must be an MBVectorTileDecoder for external source
      configuration and placement to work).
  • Method Details

    • addExternalDataSource

      public void addExternalDataSource(String name, TileDataSource dataSource, int type, ElevationDecoder elevationDecoder)
      Adds a named external data source. For raster and hillshade types the source is
      drawn as its own child layer at the style slot named 'name'. For the vector type
      the source is merged into the master source (see addVectorDataSource).
      Parameters:
      name - The source name; must match a layer name in the style "layers" array.
      dataSource - The external data source.
      type - The source type.
      elevationDecoder - Optional elevation decoder for hillshade sources. If null,
      it is resolved from the data source 'encoding' metadata ("terrarium"/"mapbox").
    • addExternalDataSource

      public void addExternalDataSource(String name, TileDataSource dataSource, int type)
      Adds a named external data source. For raster and hillshade types the source is
      drawn as its own child layer at the style slot named 'name'. For the vector type
      the source is merged into the master source (see addVectorDataSource).
      Parameters:
      name - The source name; must match a layer name in the style "layers" array.
      dataSource - The external data source.
      type - The source type.
    • addVectorDataSource

      public void addVectorDataSource(String name, TileDataSource dataSource)
      Adds a named MBVT/protobuf source (including ContourTileDataSource) merged into the
      master source and styled by the master CartoCSS. Equivalent to addExternalDataSource
      with COMPOSITE_SOURCE_TYPE_VECTOR.
      Parameters:
      name - The source name; its layers must be declared in the master style.
      dataSource - The vector data source to merge.
    • removeExternalDataSource

      public boolean removeExternalDataSource(String name)
      Removes the named external data source (of any type). Returns true if removed.
      Parameters:
      name - The source name.
      Returns:
      True if a source was removed.
    • getExternalDataSourceNames

      public StringVector getExternalDataSourceNames()
      Returns the names of all registered external data sources.
      Returns:
      The registered external source names.
    • getExternalChildLayer

      public Layer getExternalChildLayer(String name)
      Returns the child layer a slot is drawn by - a RasterTileLayer, a HillshadeRasterTileLayer
      or a VectorTileLayer, depending on the source type. This is the way to reach a setting the
      config symbolizer does not carry: a HillshadeRasterTileLayer's NormalMapLightingShader is
      generated GLSL rather than a style property, and applyConfig never writes it, so a shader
      set through this survives the per-frame config pass.

      The child is owned by this layer - do not add it to a map.
      Parameters:
      name - The source name.
      Returns:
      The child layer, or null if no source is registered under that name.
    • isSinglePassRenderingEnabled

      public boolean isSinglePassRenderingEnabled()
      Returns whether single-pass segmented rendering is enabled (Milestone 6, optional).
      Returns:
      True if single-pass rendering is enabled. The default is false.
    • setSinglePassRenderingEnabled

      public void setSinglePassRenderingEnabled(boolean enabled)
      Sets whether to use the optional single-pass segmented renderer instead of the
      default one-vt-pass-per-segment path. Intended for A/B comparison; currently a
      no-op placeholder until the single-pass renderer lands.
      Parameters:
      enabled - True to enable single-pass rendering.
    • setZoomLevelBias

      public void setZoomLevelBias(float bias)
      Sets the zoom level bias for this layer and for every child layer it owns (external
      raster/hillshade/vector sources and the internal style-group layers). Sources with a
      per-source bias set via setExternalDataSourceZoomLevelBias keep their own value.
      Overrides:
      setZoomLevelBias in class TileLayer
      Parameters:
      bias - The new bias value, both positive and negative fractional values are supported.
    • setPreloading

      public void setPreloading(boolean preloading)
      Sets the preloading state for this layer and for every child layer it owns.
      Overrides:
      setPreloading in class TileLayer
      Parameters:
      preloading - The new preloading state of the layer.
    • setExternalDataSourceZoomLevelBias

      public void setExternalDataSourceZoomLevelBias(String name, float bias)
      Sets the zoom level bias of a single external data source, overriding the layer-wide value.
      Use this to fetch a source at a different resolution from the base map - e.g. a bias of 1.0
      on a high-resolution DEM source makes the hillshade use one zoom level more detail.
      Note that if the style defines a 'zoom-level-bias' value for this source, the style value
      wins - the same precedence the other per-source config values have.
      Parameters:
      name - The source name.
      bias - The new bias value, both positive and negative fractional values are supported.
      Throws:
      IllegalArgumentException - If the source does not exist.
    • getExternalDataSourceZoomLevelBias

      public float getExternalDataSourceZoomLevelBias(String name)
      Returns the effective zoom level bias of the given external data source.
      Parameters:
      name - The source name.
      Returns:
      The zoom level bias of the source.
      Throws:
      IllegalArgumentException - If the source does not exist.
    • clearExternalDataSourceZoomLevelBias

      public void clearExternalDataSourceZoomLevelBias(String name)
      Clears the per-source zoom level bias, so the source follows the layer-wide value again.
      Parameters:
      name - The source name.
      Throws:
      IllegalArgumentException - If the source does not exist.
    • setExternalDataSourceMaxOverzoomLevel

      public void setExternalDataSourceMaxOverzoomLevel(String name, int level)
      Sets the maximum overzoom level of a single external data source. Overzooming reuses a
      coarser parent tile when the source has no tile at the target zoom level, which is how a
      low-resolution DEM keeps covering the map above its own max zoom.
      Parameters:
      name - The source name.
      level - The new maximum overzoom level.
      Throws:
      IllegalArgumentException - If the source does not exist.
    • getExternalDataSourceMaxOverzoomLevel

      public int getExternalDataSourceMaxOverzoomLevel(String name)
      Returns the maximum overzoom level of the given external data source.
      Parameters:
      name - The source name.
      Returns:
      The maximum overzoom level of the source.
      Throws:
      IllegalArgumentException - If the source does not exist.