Class MVTTile

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

public class MVTTile extends Object
Represents a Mapbox Vector Tile and provides methods to download, parse, and render it.
Author:
fdiaz
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Data structure to hold a collection of features for a specific source layer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    MVTTile(org.geotools.api.referencing.crs.CoordinateReferenceSystem tileCRS, org.geotools.api.referencing.crs.CoordinateReferenceSystem mapCRS)
    Constructor with CRS information.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    download(InputStream is, org.locationtech.jts.geom.Envelope envelope, Map<String,Set<String>> fieldsByLayer)
    Parses a tile from an input stream.
    void
    download(URL url, int z, int y, int x, org.locationtech.jts.geom.Envelope envelope, Map<String,Set<String>> fieldsByLayer)
    Downloads and parses a tile from a template URL by replacing {z}, {x}, and {y} placeholders.
    void
    download(URL url, org.locationtech.jts.geom.Envelope envelope, Map<String,Set<String>> fieldsByLayer)
    Downloads and parses a tile from the given URL.
    Returns the folder path where tile data is stored.
    render(MVTStyles mvtStyle, int widthInPixels, int heightInPixels)
    Renders the tile to a BufferedImage using the provided style.

    Methods inherited from class java.lang.Object

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

    • debugMode

      public boolean debugMode
  • Constructor Details

    • MVTTile

      public MVTTile()
      Default constructor. Only for test.
    • MVTTile

      public MVTTile(org.geotools.api.referencing.crs.CoordinateReferenceSystem tileCRS, org.geotools.api.referencing.crs.CoordinateReferenceSystem mapCRS)
      Constructor with CRS information.
      Parameters:
      tileCRS - The coordinate reference system of the tile.
      mapCRS - The coordinate reference system of the map.
  • Method Details

    • download

      public void download(URL url, org.locationtech.jts.geom.Envelope envelope, Map<String,Set<String>> fieldsByLayer) throws IOException
      Downloads and parses a tile from the given URL.
      Parameters:
      url - The URL to download the tile from.
      envelope - The envelope of the tile.
      fieldsByLayer - A map of field names to add for each layer.
      Throws:
      IOException - If an I/O error occurs.
    • download

      public void download(URL url, int z, int y, int x, org.locationtech.jts.geom.Envelope envelope, Map<String,Set<String>> fieldsByLayer) throws IOException
      Downloads and parses a tile from a template URL by replacing {z}, {x}, and {y} placeholders.
      Parameters:
      url - The template URL.
      z - The zoom level.
      y - The tile Y coordinate.
      x - The tile X coordinate.
      envelope - The envelope of the tile.
      fieldsByLayer - A map of field names to add for each layer.
      Throws:
      IOException - If an I/O error occurs.
    • download

      public void download(InputStream is, org.locationtech.jts.geom.Envelope envelope, Map<String,Set<String>> fieldsByLayer) throws IOException
      Parses a tile from an input stream. Handles GZIP compression automatically.
      Parameters:
      is - The input stream containing the tile data.
      envelope - The envelope of the tile.
      fieldsByLayer - A map of field names to add for each layer.
      Throws:
      IOException - If an I/O error occurs.
    • render

      public BufferedImage render(MVTStyles mvtStyle, int widthInPixels, int heightInPixels)
      Renders the tile to a BufferedImage using the provided style.
      Parameters:
      mvtStyle - The MVT style definition.
      widthInPixels - The width of the output image in pixels.
      heightInPixels - The height of the output image in pixels.
      Returns:
      A BufferedImage containing the rendered tile.
    • getFolder

      public String getFolder()
      Returns the folder path where tile data is stored. Creates the folder if it doesn't exist. Only for test (see main).
      Returns:
      The folder path string.