geopackage-ts
    Preparing search index...

    Class TileDao

    Data Access Object for querying, inserting, and deleting tiles in a GeoPackage tile pyramid user data table.

    The TileDao provides methods for accessing individual tiles by their grid coordinates and zoom level, iterating over tiles, retrieving zoom level metadata, and managing tile data.

    const tileDao = new TileDao(conn, 'my_tiles', tileMatrixSet);

    // Query a specific tile
    const tile = tileDao.queryForTile(0, 0, 0);
    if (tile) {
    fs.writeFileSync('tile.png', tile.tile_data);
    }

    // Get available zoom levels
    const zooms = tileDao.getZoomLevels();
    console.log('Available zoom levels:', zooms);
    Index

    Constructors

    Accessors

    Methods

    • Counts the total number of tiles across all zoom levels.

      Returns number

      The total tile count.

    • Counts the number of tiles at a specific zoom level.

      Parameters

      • zoomLevel: number

        The zoom level to count tiles for.

      Returns number

      The number of tiles at the given zoom level.

    • Deletes a tile by its unique row ID.

      Parameters

      • id: number

        The primary key of the tile row to delete.

      Returns number

      The number of rows deleted (0 or 1).

    • Deletes a tile at the specified grid position and zoom level.

      Parameters

      • column: number

        The tile column index.

      • row: number

        The tile row index.

      • zoomLevel: number

        The zoom level.

      Returns number

      The number of rows deleted (0 or 1).

    • Returns the maximum zoom level containing tiles.

      Returns number | null

      The maximum zoom level, or null if the table contains no tiles.

    • Returns the minimum zoom level containing tiles.

      Returns number | null

      The minimum zoom level, or null if the table contains no tiles.

    • Retrieves the tile matrix definition for a specific zoom level.

      Parameters

      • zoomLevel: number

        The zoom level to query.

      Returns TileMatrix | undefined

      The TileMatrix for the specified zoom level, or undefined if not defined.

    • Returns all distinct zoom levels that contain tiles, sorted in ascending order.

      Returns number[]

      An array of zoom level numbers.

      const levels = tileDao.getZoomLevels();
      // e.g., [0, 1, 2, 3, 4]
    • Inserts a new tile into the table.

      Parameters

      • row: { tile_column: number; tile_data: Buffer; tile_row: number; zoom_level: number }

        The tile data to insert, including the zoom level, column, row, and binary tile data.

      Returns number

      The row ID of the newly inserted tile.

      const tileData = fs.readFileSync('tile.png');
      const id = tileDao.insert({
      zoom_level: 5,
      tile_column: 10,
      tile_row: 20,
      tile_data: tileData,
      });
      console.log(`Inserted tile with ID: ${id}`);
    • Queries for a single tile at the specified grid position and zoom level.

      Parameters

      • column: number

        The tile column index.

      • row: number

        The tile row index.

      • zoomLevel: number

        The zoom level.

      Returns TileRow | undefined

      The tile row if found, or undefined if no tile exists at the specified position.

      const tile = tileDao.queryForTile(10, 20, 5);
      if (tile) {
      console.log(`Tile size: ${tile.tile_data.length} bytes`);
      }
    • Returns an iterator over all tiles at the specified zoom level.

      Parameters

      • zoomLevel: number

        The zoom level to query.

      Returns IterableIterator<TileRow>

      An iterable iterator of TileRow records at the given zoom level.

      for (const tile of tileDao.queryForTilesAtZoom(3)) {
      console.log(`Tile at column=${tile.tile_column}, row=${tile.tile_row}`);
      }