Constructs a new instance of the VersaTiles class.
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.
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.
A promise that resolves once the reader has been closed.
ProtectedgetProtected
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.
A promise that resolves with the block index map.
Asynchronously retrieves the header information from the .versatiles container.
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.
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.
The zoom level of the tile.
The x coordinate of the tile within its zoom level.
The y coordinate of the tile within its zoom level.
A promise that resolves with the tile data as a Buffer, or null if the tile cannot be found.
ProtectedgetAsynchronously 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.
The zoom level of the tile.
The x coordinate of the tile within its zoom level.
The y coordinate of the tile within its zoom level.
A promise that resolves with the uncompressed tile data as a Buffer, or null if the tile cannot be found.
ProtectedreadProtected
A protected method to read a chunk of data from the source based on the specified offset and length.
The offset from the start of the source data to begin reading.
The number of bytes to read from the source.
A promise that resolves with the read data as a Buffer.
The
VersaTilesclass is a wrapper around a.versatilescontainer file. It provides methods to access tile data, metadata, and other properties within the container.