UNPKG

s2maps-gpu

Version:

S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.

59 lines (58 loc) 2.47 kB
import type { Projector, TileInView } from '../index.js'; /** type for temporary WMID. It handles a single quadtree supporting id's that fall outside the range of the tree */ export type TmpWMID = bigint; /** Track the face-i-j positions */ type ZoomXY = [zoom: number, x: number, y: number]; /** * Given a zoom, lon, lat, and projector, get the tiles in view * Due to the nature of the Web Mercator design, * it's easiest to store an MVP matrix for each tile * * NOTE: Real World Tiles must be created/cached BEFORE creating out of bounds tiles * as the out of bounds tiles will need to reference the real world tiles. * So we sort all out of bounds tiles to the end of the list. * @param zoom - the zoom leve * @param lon - the longitude * @param lat - the latitude * @param projector - the projection object * @returns a list of Tile IDs in view */ export declare function getTilesInViewWM(zoom: number, lon: number, lat: number, projector: Projector): TileInView[]; /** * grab the tiles next to the current tiles zoom-x-y * only include adjacent tiles, not diagonal. * If includeOutOfBounds set to true, it will include out of bounds tiles * on the x-axis * @param zoom - tile's zoom * @param x - tile's x-coordinate * @param y - tile's y-coordinate * @param includeOutOfBounds - flag to keep out of bounds tiles if true * @returns neighboring tiles, including out of bounds if flag set */ export declare function neighborsXY(zoom: number, x: number, y: number, includeOutOfBounds?: boolean): ZoomXY[]; /** * Convert zoom-x-y to a singular number * It may resolve to itself. This is useful for maps that have * `duplicateHorizontally` set to true. It forces the tile to be * within the bounds of the quad tree. * @param zoom - the zoom level * @param x - the x tile-coordinate * @param y - the y tile-coordinate * @param duplicateHorizontally - whether to duplicate horizontally * @returns the singular number */ export declare function toWMID(zoom: number, x: number, y: number, duplicateHorizontally: boolean): bigint | undefined; /** * encode a number as always positive interweaving negative and postive values * @param n - the number * @returns the encoded number */ export declare function zigzag(n: number): number; /** * a modulo function that works with negative numbers * @param x - the number * @param n - the modulus * @returns the result */ export declare function mod(x: number, n: number): number; export {};