fgb-vt - v1.0.4
    Preparing search index...

    Class TileServer

    Stateful tile server with lazy header caching and multi-connector support.

    All connectors and sources are bound at construction. Tile requests take only coordinates. FGB headers and spatial indices are cached per source path on first access, amortizing I/O overhead across the lifetime of the instance.

    Use case: long-running tile server process with a fixed set of FGB sources. Maximum throughput -- all per-source overhead is amortized after the first request.

    const server = new TileServer({
    connector: new LocalConnector(),
    sources: [
    { name: 'buildings', path: './data/buildings.fgb' },
    { name: 'roads', path: './data/roads.fgb', options: { maxZoom: 16 } },
    ],
    });

    const pbf = await server.tile(14, 8192, 5461);
    await server.close();
    const server = new TileServer([
    {
    connector: new LocalConnector(),
    sources: { name: 'boundaries', path: './data/boundaries.fgb' },
    },
    {
    connector: new HttpConnector(),
    sources: { name: 'imagery-grid', path: 'https://tiles.example.com/grid.fgb' },
    },
    ]);

    const metadata = await server.tileJSON();
    const pbf = await server.tile(10, 512, 341);
    await server.close();
    Index

    Constructors

    Methods

    Constructors

    • Create a new tile server with the given layer configuration.

      Accepts a single layer or an array of layers. Each layer binds a connector to one or more sources. Sources across layers may use different connectors (e.g. local files + HTTP endpoints).

      Parameters

      • layers: TileServerLayer | TileServerLayer[]

        One or more layer configurations binding connectors to sources. A single TileServerLayer is accepted for convenience.

      • Optionaloptions: TileOptions

        Tile-level tiling option defaults applied to all sources unless overridden by per-source options.

      Returns TileServer

    Methods

    • Release all connector resources and cached state.

      Clears FGB header caches, resets initialization state, and closes every unique connector. After calling close(), this server instance must not be used again.

      Returns Promise<void>

      Resolves when all connectors have been closed.

    • Render a vector tile as a PBF-encoded MVT.

      Layers appear in the output in the order defined at construction time. FGB headers and spatial indices are lazily cached on the first request for each source and reused on subsequent calls.

      Parameters

      • z: number

        Tile zoom level.

      • x: number

        Tile column.

      • y: number

        Tile row.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      PBF-encoded Mapbox Vector Tile. Returns an empty tile if no features intersect the requested tile bounds.

    • Generate TileJSON 3.0.0 metadata derived from all configured sources.

      Returns aggregated bounds, zoom range, and a vector_layers array listing each source's layer name, field schema, and zoom range. FGB headers are read lazily if not already cached.

      Returns Promise<TileJSON>

      TileJSON metadata object conforming to the 3.0.0 specification.