s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
74 lines (73 loc) • 3.08 kB
TypeScript
import type { Callback } from 's2/style/parseFeature.js';
import type { ColorArray } from 'style/color/index.js';
import type { IDGen } from './process.spec.js';
import type { BuildCodeFunction, GPUType, InteractiveWorkerLayer, NotNullOrObject, Property, ValueType } from 'style/style.spec.js';
import type { InteractiveObject, TileRequest } from '../worker.spec.js';
import type { Properties, S2CellId } from 'gis-tools/index.js';
/** Code design input wrapper */
export type CodeDesignInput<T extends NotNullOrObject> = [T | Property<T>, Callback<T, ColorArray>] | [T | Property<T>];
/** Code design wrapper */
export type CodeDesign<T = any> = Array<CodeDesignInput<ValueType<T>>>;
/**
* Color function to convert a color to either RBG or LCH
* @param lch - flag to use lch if true
* @returns a color parsing function
*/
export declare const colorFunc: (lch: boolean) => Callback<string, ColorArray>;
/**
* Clamp tool to ensure the number is between -1 and 1
* @param i - input number
* @returns clamped number
*/
export declare const clamp: Callback<number, number>;
/**
* # Vector Worker
*
* Base class for all vector workers.
* Ensurses that all vector workers can reuse things like prepping and shipping interactive features,
* flusing, id-generation, etc.
*/
export default class VectorWorker {
idGen: IDGen;
gpuType: GPUType;
interactiveMap: Map<number, InteractiveObject>;
/**
* @param idGen - id generator to ensure features don't overlap
* @param gpuType - the GPU context of the map renderer (WebGL(1|2) | WebGPU)
*/
constructor(idGen: IDGen, gpuType: GPUType);
/**
* Add an interactive feature
* @param id - feature id
* @param properties - feature properties
* @param workerLayer - worker layer to pull the interactive-properties from
*/
_addInteractiveFeature(id: number, properties: Properties, workerLayer: InteractiveWorkerLayer): void;
/**
* Flush a tile-request to the render thread
* @param mapID - id of the map to ship the data back to
* @param tile - tile request
* @param sourceName - name of the source the data belongs to
* @param _wait - wait function. Not needed at this flush level.
*/
flush(mapID: string, tile: TileRequest, sourceName: string, _wait: Promise<void>): Promise<void>;
/**
* Build code for a vector layer
* @param design - the design to modify
* @returns the build function
*/
buildCode(design: CodeDesign<NotNullOrObject>): BuildCodeFunction;
/**
* Post an interactive feature set to the render thread
* @param mapID - id of the map to ship the data back to
* @param sourceName - name of the source the data belongs to
* @param tileID - tile id the features belong to
*/
postInteractive(mapID: string, sourceName: string, tileID: S2CellId): void;
}
/**
* A convenience function to convert an ID to an RGBA encoded color
* @param id - the id to convert
* @returns an RGBA encoded color
*/
export declare function idToRGB(id: number): ColorArray;