s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
115 lines (114 loc) • 4.8 kB
TypeScript
import type { MarkerDefinition } from './source/markerSource.js';
import type S2Map from '../s2Map.js';
import type { UrlMap } from 'util/index.js';
import type { TileRequest } from './worker.spec.js';
import type { Analytics, LayerDefinition, Source, StylePackage } from 'style/style.spec.js';
/**
* # Worker Pool
*
* Manages the tile workers and the source worker
*
* The Source worker manages sources, builds/fetches requests, and sends them to the tile workers to be processed
*
* The Tile Workers process the raw data into renderable / interactive data for the GPU or end user.
*
* Communications channels are created for:
* - SourceWorker<->TileWorker
* - TileWorker->Worker Pool->Map Object
* - SourceWorker->Worker Pool->Map Object
*
* There is a two way channel for SourceWorker<->TileWorker mostly because of glyphs,images, etc.
*/
export declare class WorkerPool {
#private;
workerCount: number;
workers: Worker[];
sourceWorker: Worker;
maps: Record<string, S2Map>;
/** setup workers and channels between all */
constructor();
/**
* Add a map to the worker pool for communication
* @param map - the s2map
*/
addMap(map: S2Map): void;
/**
* Request the source worker load a style
* @param mapID - the id of the map
* @param style - the style url to fetch
* @param analytics - basic analytics
* @param apiKey - the api key if needed
* @param urlMap - the url map
*/
requestStyle(mapID: string, style: string, analytics: Analytics, apiKey?: string, urlMap?: UrlMap): void;
/**
* Inject a style. The style is already built, so just send it to the workers
* @param mapID - the id of the map
* @param style - the style data
*/
injectStyle(mapID: string, style: StylePackage): void;
/** delete the worker pool. This is a temporary solution as the worker pool should be a singleton. */
delete(): void;
/**
* Request tiles
* @param mapID - the id of the map
* @param tiles - the tiles to fetch data for
* @param sources - the sources to fetch data for. If empty request data for all sources
*/
tileRequest(mapID: string, tiles: TileRequest[], sources?: Array<[sourceName: string, href: string | undefined]>): void;
/**
* Request temporal tile data
* @param mapID - the id of the map
* @param tiles - the tiles to fetch data for
* @param sourceNames - the sources to fetch data for. If empty request data for all sources
*/
timeRequest(mapID: string, tiles: TileRequest[], sourceNames?: string[]): void;
/**
* Add marker(s) to the map
* @param mapID - the id of the map to add marker(s) to
* @param markers - the marker(s) to add
* @param sourceName - the name of the source to add the marker(s) to
*/
addMarkers(mapID: string, markers: MarkerDefinition[], sourceName: string): void;
/**
* Delete marker(s) from the map
* @param mapID - the id of the map to delete marker(s) from
* @param ids - the id(s) of the marker(s) to delete
* @param sourceName - the name of the source to delete the marker(s) from
*/
deleteMarkers(mapID: string, ids: number[], sourceName: string): void;
/**
* Add a source to the map
* @param mapID - the id of the map to add the source to
* @param sourceName - the name of the source to add the source to
* @param source - the source
* @param tileRequest - the list of tiles of all existing tiles in the map already to build this source data for
*/
addSource(mapID: string, sourceName: string, source: Source, tileRequest: TileRequest[]): void;
/**
* Delete a source from the map
* @param mapID - the id of the map to delete the source from
* @param sourceNames - the name(s) of the source(s) to delete
*/
deleteSource(mapID: string, sourceNames: string[]): void;
/**
* Add a style layer to the map
* @param mapID - the id of the map to add the layer to
* @param layer - the style layer
* @param index - the index to add the layer at
* @param tileRequest - the list of tiles of all existing tiles in the map already to adjust
*/
addLayer(mapID: string, layer: LayerDefinition, index: number, tileRequest: TileRequest[]): void;
/**
* Delete a style layer from the map
* @param mapID - the id of the map to delete the layer from
* @param index - the index of the style layer to delete
*/
deleteLayer(mapID: string, index: number): void;
/**
* Reorder style layers
* @param mapID - the id of the map
* @param layerChanges - the layer changes to make
*/
reorderLayers(mapID: string, layerChanges: Record<string | number, number>): void;
}