gis-tools-ts - v0.6.0
    Preparing search index...

    Class S2PMTilesReader

    (S2) PMTiles Reader

    A V3.0 PMTiles reader for reading standard WebMercator Tile data and V1.0 S2 Tile data.

    A Modified implementation of the PMTiles library. It is backwards compatible but offers support for the S2 Projection.

    You can learn more about the S2PMTiles Specification here.

    import { S2PMTilesReader } from 'gis-tools-ts';
    import { FileReader } from 'gis-tools-ts/file';
    // or use the MMapReader if using Bun:
    // import { MMapReader } from 'gis-tools-ts/mmap';

    const reader = new S2PMTilesReader(new FileReader('./data.pmtiles'));

    // pull out the header
    const header = reader.getHeader();

    // get the metadata
    const metadata = await reader.getMetadata();

    // S2 specific functions
    const hasTile = await reader.hasTileS2(0, 0, 0, 0);
    const tile = await reader.getTileS2(0, 0, 0, 0);

    // WM functions
    const hasTile = await reader.hasTile(0, 0, 0);
    const tile = await reader.getTile(0, 0, 0);
    Index

    Constructors

    • Given an input path, read in the header and root directory

      Parameters

      • path: string | ReaderInputs

        the location of the PMTiles data

      • rangeRequests: boolean = false

        FetchReader specific; enable range requests or use urlParam "bytes"

      • maxSize: number = 20

        the max size of the cache before dumping old data. Defaults to 20.

      Returns S2PMTilesReader

    Properties

    path: string | ReaderInputs

    the location of the PMTiles data

    Methods

    • Get the header of the archive

      Returns Promise<Header>

      • the header of the archive
    • Get the metadata of the archive

      Returns Promise<Metadata>

      • the metadata of the archive
    • Get the bytes of the tile at the given (zoom, x, y) coordinates

      Parameters

      • zoom: number

        the zoom level of the tile

      • x: number

        the x coordinate of the tile

      • y: number

        the y coordinate of the tile

      Returns Promise<undefined | Uint8Array<ArrayBufferLike>>

      • the bytes of the tile at the given (z, x, y) coordinates, or undefined if the tile does not exist in the archive.
    • Get the bytes of the tile at the given (face, zoom, x, y) coordinates

      Parameters

      • face: Face

        the Open S2 projection face

      • zoom: number

        the zoom level of the tile

      • x: number

        the x coordinate of the tile

      • y: number

        the y coordinate of the tile

      Returns Promise<undefined | Uint8Array<ArrayBufferLike>>

      • the bytes of the tile at the given (face, zoom, x, y) coordinates, or undefined if the tile does not exist in the archive.
    • Check if a tile exists in the archive

      Parameters

      • zoom: number

        the zoom level of the tile

      • x: number

        the x coordinate of the tile

      • y: number

        the y coordinate of the tile

      Returns Promise<boolean>

      • true if the tile exists in the archive
    • Check if an S2 tile exists in the archive

      Parameters

      • face: Face

        the Open S2 projection face

      • zoom: number

        the zoom level of the tile

      • x: number

        the x coordinate of the tile

      • y: number

        the y coordinate of the tile

      Returns Promise<boolean>

      • true if the tile exists in the archive