s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
82 lines (81 loc) • 2.77 kB
TypeScript
import type Session from './session.js';
import type { Glyph } from 'workers/process/glyph/familySource.js';
import type TexturePack from './texturePack.js';
/** Unparsed state of glyph metadata, letting Tile Workers know of what glyphs are available */
export interface GlyphMetadataUnparsed {
name: string;
metadata: undefined | ArrayBuffer;
}
/** Actual glyph metadata for the Tile Worker to know how to shape and prepare glyphs for rendering */
export interface GlyphMetadata {
name: string;
metadata: ArrayBuffer;
}
/** An incoming lost of icon requests. Each string is the name of an icon */
export type IconRequest = Set<string>;
/** Glyph Image shape stored for future requests from Tile Workers */
export interface GlyphImage {
posX: number;
posY: number;
width: number;
height: number;
data: ArrayBuffer;
}
/** Collection of Glyph Images */
export type GlyphImages = GlyphImage[];
/**
* # Glyph Source
*
* A glyph source manager to request metadata, glyphs, and images
*/
export default class GlyphSource {
#private;
active: boolean;
extent: number;
name: string;
path: string;
size: number;
defaultAdvance: number;
maxHeight: number;
range: number;
texturePack: TexturePack;
session: Session;
glyphWaitlist: Map<string, Promise<void>>;
glyphCache: Map<string, Glyph>;
isIcon: boolean;
/**
* @param name - the name of the source
* @param path - the path to the source
* @param texturePack - the texture pack to help define where the glyphs/images are stored
* @param session - the session
*/
constructor(name: string, path: string, texturePack: TexturePack, session: Session);
/**
* Build the source data
* @param mapID - the id of the map
* @returns the metadata, yet to be parsed
*/
build(mapID: string): Promise<GlyphMetadataUnparsed>;
/**
* Build metadata from a buffer
* @param metadata - the metadata buffer
* @returns the metadata
*/
_buildMetadata(metadata: ArrayBuffer): GlyphMetadataUnparsed;
/**
* Given a collection of unicodes, request the glyphs from the server
* @param request - array of unicodes
* @param mapID - the id of the map we are fetching data for
* @param reqID - the id of the request
* @param worker - the worker port
*/
glyphRequest(request: string[], // array of codes
mapID: string, reqID: string, worker: MessageChannel['port2']): Promise<void>;
/**
* Fetch glyph data and or metadata
* @param path - the url to fetch the data
* @param mapID - the id of the map
* @returns the raw data if found
*/
_fetch(path: string, mapID: string): Promise<undefined | ArrayBuffer>;
}