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

    Class S2TilesReader

    S2 Tiles Reader

    An S2 Tile Reader to store tile and metadata in a cloud optimized format. Similar to PMTiles but simplified to have as few features as possible.

    Reads either a Web Mercator tile or an S2 tile to the folder location given its (zoom, x, y) or (face, zoom, x, y) coordinates.

    Reads data via the S2Tiles specification.

    import { S2TilesReader } 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 S2TilesReader(new FileReader('./data.s2tiles'));

    // 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.hasTileWM(0, 0, 0);
    const tile = await reader.getTileWM(0, 0, 0);
    Index

    Constructors

    • Parameters

      • path: string | ReaderInputs

        the location of the S2Tiles 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 S2TilesReader

    Properties

    path: string | ReaderInputs

    the location of the S2Tiles data

    Methods

    • Get the metadata of the archive

      Returns Promise<Metadata>

      • the metadata of 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.
    • 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.
    • 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
    • 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
    • Setup the reader

      Returns Promise<void>