Class MVTStyles

java.lang.Object
org.gvsig.mvtrenderer.lib.impl.MVTStyles

public class MVTStyles extends Object
Manages Mapbox Vector Tile styles and their conversion to GeoTools styles.
Author:
fdiaz
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    org.geotools.mbstyle.MBStyle
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes a new instance of MVTStyles and creates the background polygon.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Downloads the style JSON and parses it with MBStyleParser to verify correctness.
    Extracts the field names used in the style layers for each source layer.
    getLayersToDraw(Map<String,MVTTile.MVTDataSource> dataSources, org.locationtech.jts.geom.Envelope tileEnvelope, org.geotools.api.referencing.crs.CoordinateReferenceSystem tileCRS)
    Builds and returns the list of layers (MVTLayer) ready to be painted, in the correct order (Z-order) defined by the Mapbox style.
    org.geotools.api.style.Style
    getStyle(String styleLayerId)
    Calculates and caches the GeoTools Style associated with the indicated styleLayerId and returns it.
    Returns the collection of font names used in the style.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • mbStyle

      public org.geotools.mbstyle.MBStyle mbStyle
  • Constructor Details

    • MVTStyles

      public MVTStyles()
      Initializes a new instance of MVTStyles and creates the background polygon.
  • Method Details

    • download

      public void download(URL url) throws IOException
      Downloads the style JSON and parses it with MBStyleParser to verify correctness. Stores the result in memory (MBStyle) for later use.
      Parameters:
      url - The style.json file URL.
      Throws:
      IOException - If there is a network or parsing error.
    • getLayersToDraw

      public List<MVTLayer> getLayersToDraw(Map<String,MVTTile.MVTDataSource> dataSources, org.locationtech.jts.geom.Envelope tileEnvelope, org.geotools.api.referencing.crs.CoordinateReferenceSystem tileCRS)
      Builds and returns the list of layers (MVTLayer) ready to be painted, in the correct order (Z-order) defined by the Mapbox style.
      Parameters:
      dataSources - Map of available data layers.
      tileEnvelope - The envelope of the tile.
      tileCRS - The coordinate reference system of the tile.
      Returns:
      Ordered list of MVTLayer objects.
    • getStyle

      public org.geotools.api.style.Style getStyle(String styleLayerId)
      Calculates and caches the GeoTools Style associated with the indicated styleLayerId and returns it.
      Parameters:
      styleLayerId - The style layer ID (Mapbox layer id).
      Returns:
      The GeoTools Style object ready for rendering, or null if the ID doesn't exist.
    • getUsedFontNames

      public Collection<String> getUsedFontNames()
      Returns the collection of font names used in the style.
      Returns:
      Collection of font names.
    • extractFieldsFromStyles

      public Map<String,Set<String>> extractFieldsFromStyles()
      Extracts the field names used in the style layers for each source layer.
      Returns:
      A map of source layer names to sets of field names.