UNPKG

@mapbox/tilebelt

Version:
94 lines (93 loc) 2.32 kB
import type { BBox, Geometry } from 'geojson'; export type Tile = [number, number, number]; /** * Get the bbox of a tile * * const bbox = tileToBBOX([5, 10, 10]) * //=bbox */ export declare function tileToBBOX(tile: Tile): BBox; /** * Get a geojson representation of a tile * * const poly = tileToGeoJSON([5, 10, 10]) * //=poly */ export declare function tileToGeoJSON(tile: Tile): Geometry; /** * Get the tile for a point at a specified zoom level * * const tile = pointToTile(1, 1, 20) * //=tile */ export declare function pointToTile(lon: number, lat: number, z: number): Tile; /** * Get the precise fractional tile location for a point at a zoom level * * const tile = pointToTileFraction(30.5, 50.5, 15) * //=tile */ export declare function pointToTileFraction(lon: number, lat: number, z: number): Tile; /** * Get the 4 tiles one zoom level higher * * const tiles = getChildren([5, 10, 10]) * //=tiles */ export declare function getChildren(tile: Tile): Tile[]; /** * Get the tile one zoom level lower * * const tile = getParent([5, 10, 10]) * //=tile */ export declare function getParent(tile: Tile): Tile; export declare function getSiblings(tile: Tile): Tile[]; /** * Get the 3 sibling tiles for a tile * * const tiles = getSiblings([5, 10, 10]) * //=boolean */ export declare function hasSiblings(tile: Tile, tiles: Tile[]): boolean; /** * Check to see if an array of tiles contains a particular tile * * const tiles = [ * [0, 0, 5], * [0, 1, 5], * [1, 1, 5], * [1, 0, 5] * ] * hasTile(tiles, [0, 0, 5]) * //=boolean */ export declare function hasTile(tiles: Tile[], tile: Tile): boolean; /** * Check to see if two tiles are the same * * tilesEqual([0, 1, 5], [0, 0, 5]) * //=boolean */ export declare function tilesEqual(tile1: Tile, tile2: Tile): boolean; /** * Get the quadkey for a tile * * const quadkey = tileToQuadkey([0, 1, 5]) * //=quadkey */ export declare function tileToQuadkey(tile: Tile): string; /** * Get the tile for a quadkey * * const tile = quadkeyToTile('00001033') * //=tile */ export declare function quadkeyToTile(quadkey: string): Tile; /** * Get the smallest tile to cover a bbox * * const tile = bboxToTile([ -178, 84, -177, 85 ]) * //=tile */ export declare function bboxToTile(bboxCoords: BBox): Tile;