UNPKG

s2maps-gpu

Version:

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

122 lines (121 loc) 4.91 kB
import FamilySource from './glyph/familySource.js'; import type { Glyph } from './glyph/familySource.js'; import type { GlyphMetadata } from 'workers/source/glyphSource.js'; import type { IDGen } from './process.spec.js'; import type { ImageSourceMetadata } from 'workers/source/imageSource.js'; import type { S2CellId } from 'gis-tools/index.js'; /** Glyph Request Tracker */ export interface GlyphRequestTracker { glyphFamilyCount: number; processed: number; self: { promise?: Promise<void>; }; resolve: () => void; } /** Map of Glyph/Icon Sources, their requests and their resolves */ export declare class MapGlyphSource extends Map<string, FamilySource> { /** resolve mechanic to ensure the glyph/icon source is built */ resolve: (value: void | PromiseLike<void>) => void; ready: Promise<void>; glyphRequestTracker: Map<string, GlyphRequestTracker>; /** * Get a glyph/icon family or list of glyph/icon families * @param family - the name(s) of the glyph/icon family * @returns the glyph/icon family(ies) */ getFamily(family: string | string[]): undefined | FamilySource | FamilySource[]; } /** * Image Store * * Manages the Glyph/Icon sources, Sprites, and Images (like fill pattern images) */ export default class ImageStore { glyphSources: Map<string, MapGlyphSource>; idGen: IDGen; sourceWorker: MessagePort; /** * Setup the image store * @param idGen - id generator * @param sourceWorker - the source worker to send requests to */ setup(idGen: IDGen, sourceWorker: MessagePort): void; /** * Setup a glyph/icon source * @param mapID - the id of the map to setup the glyph/icon source for */ setupMap(mapID: string): void; /** * Wait for the glyph/icon source to be ready * @param mapID - the id of the map to await the glyph/icon source for */ getReady(mapID: string): Promise<void>; /** * Get the glyph/icon source * @param mapID - the id of the map to get the glyph/icon source for * @returns the glyph/icon source */ getGlyphSource(mapID: string): MapGlyphSource; /** * Get a glyph/icon family * @param mapID - the id of the map to get the glyph/icon source for * @param family - the name of the glyph/icon family * @returns the glyph/icon family */ getFamilyMap(mapID: string, family: string): FamilySource; /** * Parse specific ligatures * @param mapID - the id of the map * @param families - the name(s) of the glyph/icon family * @param glyphs - the ligature codes */ parseLigatures(mapID: string, families: string[], glyphs: string[]): void; /** * Add missing glyphs * @param mapID - the id of the map * @param tileID - the id of the tile * @param glyphCodes - the codes of the glyphs * @param families - the name(s) of the glyph/icon family * @returns true if there are missing glyphs */ addMissingGlyph(mapID: string, tileID: S2CellId, glyphCodes: string[], families: string[]): boolean; /** * Process metadata for a collection of glyph/icon/sprite/image metadatas * NOTE: This function is called from the source thread ONLY ONCE per mapID before anything is processed * @param mapID - the id of the map to process the metadatas for * @param glyphMetadata - the glyph/icon metadatas * @param imageMetadata - the sprite/image metadatas */ processMetadata(mapID: string, glyphMetadata: GlyphMetadata[], imageMetadata: ImageSourceMetadata[]): void; /** * Process missing data * @param mapID - the id of the map to process the missing data for * @param tileID - the id of the tile that has missing data * @param sourceName - the name of the source that has missing data */ processMissingData(mapID: string, tileID: S2CellId, sourceName: string): Promise<void>; /** * Process a response from the source thread * @param mapID - the id of the map * @param reqID - the id of the request * @param glyphMetadata - the glyph metadata * @param familyName - the name of the family */ processGlyphResponse(mapID: string, reqID: string, glyphMetadata: Glyph[], familyName: string): void; /** * a response from the sourceThread for glyph data * @param mapID - the id of the map to process the response for * @param familyName - the name of the family * @param glyphs - the glyphs to import */ importGlyphs(mapID: string, familyName: string, glyphs: Glyph[]): void; /** * Get an image pattern (used by fills) * @param mapID - the id of the map * @param familyName - the name of the family * @param name - the name of the pattern * @returns the pattern guide */ getPattern(mapID: string, familyName: string, name?: string): Glyph; }