@versatiles/container
    Preparing search index...

    Class Container

    The VersaTiles class is a wrapper around a .versatiles container file. It provides methods to access tile data, metadata, and other properties within the container.

    Index
    • Constructs a new instance of the VersaTiles class.

      Parameters

      • source: string | Reader

        The data source for the tiles. This can be a URL starting with http:// or https://, a path to a local file, or a custom Reader function that reads data chunks based on offset and length.

      • Optionaloptions: OpenOptions

        Optional settings that configure tile handling. See OpenOptions; timeout only applies when source is an HTTP(S) URL.

      Returns Container

      Will throw an error if the provided source is neither a string nor a Reader function.

      Will throw an error if source is a path to a file that cannot be opened.

    • Releases any resources held by the underlying reader: the open file descriptor when reading from a local file, or the pooled keep-alive sockets when reading over HTTP(S). A custom Reader function without a close method is left untouched. After calling close, no further methods should be called on this container.

      Returns Promise<void>

      A promise that resolves once the reader has been closed.

    • Protected

      Asynchronously retrieves a mapping of tile block indices. The map's keys are formatted as "{z},{x},{y}". This method is for internal use to manage tile lookup within the container.

      Returns Promise<Map<string, Block>>

      A promise that resolves with the block index map.

    • Asynchronously retrieves the header information from the .versatiles container.

      Returns Promise<Header>

      A promise that resolves with the header object.

      Will throw an error if the container does not start with expected magic bytes indicating a valid format.

      Will throw an error if the container is a versatiles_v01 file. That format is obsolete and no longer readable by this library; convert such containers to v02 first.

      Will throw an error if tile_format or precompression holds a value this library does not support. Such a container is rejected rather than read with a substituted default, as required by the container spec.

    • Asynchronously retrieves the metadata associated with the .versatiles container. Metadata is stored as a string, usually TileJSON, and typically includes information about vector_layers for vector tiles. If the container does not include metadata, this method returns undefined.

      Returns Promise<string | undefined>

      A promise that resolves with the metadata string, or undefined if the container holds no metadata.

    • Asynchronously retrieves a specific tile's data as a Buffer. If the tile data is compressed as defined in the container header, the returned Buffer will contain the compressed data. To obtain uncompressed data, use the getTileUncompressed method. If the specified tile does not exist, the method returns null.

      Parameters

      • z: number

        The zoom level of the tile.

      • x: number

        The x coordinate of the tile within its zoom level.

      • y: number

        The y coordinate of the tile within its zoom level.

      Returns Promise<Buffer<ArrayBufferLike> | null>

      A promise that resolves with the tile data as a Buffer, or null if the tile cannot be found.

    • Protected

      Asynchronously retrieves the tile index for a specified block. This is an internal method used to maintain a lookup for every tile within a block.

      Parameters

      • block: Block

        The block for which to retrieve the tile index.

      Returns Promise<TileIndex>

      A promise that resolves with the tile index.

    • Asynchronously retrieves a specific tile's uncompressed data as a Buffer. This method first retrieves the compressed tile data using getTile and then decompresses it based on the compression setting in the container header. If the specified tile does not exist, the method returns null.

      Parameters

      • z: number

        The zoom level of the tile.

      • x: number

        The x coordinate of the tile within its zoom level.

      • y: number

        The y coordinate of the tile within its zoom level.

      Returns Promise<Buffer<ArrayBufferLike> | null>

      A promise that resolves with the uncompressed tile data as a Buffer, or null if the tile cannot be found.

    • Protected

      A protected method to read a chunk of data from the source based on the specified offset and length.

      Parameters

      • offset: number

        The offset from the start of the source data to begin reading.

      • length: number

        The number of bytes to read from the source.

      Returns Promise<Buffer<ArrayBufferLike>>

      A promise that resolves with the read data as a Buffer.