s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
87 lines (86 loc) • 2.88 kB
TypeScript
import type { Session } from './index.js';
import type { Face, Properties, VectorPoint } from 'gis-tools/index.js';
import type { LayerDefinition, Projection, SourceMetadata } from 'style/style.spec.js';
import type { SourceFlushMessage, TileRequest } from '../worker.spec.js';
/** Marker metadata */
export interface MarkerMetadata {
html?: string;
}
/** Marker definition tracking lon/lat, html, and properties associated with it */
export interface MarkerDefinition {
id?: number;
face?: Face;
properties: Properties;
point: VectorPoint;
metadata?: MarkerMetadata;
}
/** Properties associated with markers */
interface MarkerProperties extends Properties {
__markerID: number;
}
/** A storage container for Marker */
export interface Marker {
id: number;
metadata?: MarkerMetadata;
properties: MarkerProperties;
geometry: VectorPoint;
}
/**
* # Marker Source
*
* Store, process, and render markers. Handles both WM and S2 projections
*/
export default class MarkerSource {
#private;
name: string;
projection: Projection;
isTimeFormat: boolean;
styleLayers: LayerDefinition[];
idGen: number;
0: Map<number, Marker>;
1: Map<number, Marker>;
2: Map<number, Marker>;
3: Map<number, Marker>;
4: Map<number, Marker>;
5: Map<number, Marker>;
session: Session;
textEncoder: TextEncoder;
/**
* @param name - name of the source
* @param session - the session associated with the source data
* @param projection - the projection to use (WM or S2)
* @param layers - the style layers associated with this source
*/
constructor(name: string, session: Session, projection: Projection, layers: LayerDefinition[]);
/**
* Build the source
* @param _mapID - the id of the map (unused)
* @param metadata - the metadata associated with the source
*/
build(_mapID: string, metadata?: SourceMetadata): void;
/**
* Add marker to the source
* @param marker - the marker to add
*/
addMarker(marker: MarkerDefinition): void;
/**
* Delete marker(s)
* @param ids - the id(s) of the marker(s) to delete
*/
deleteMarkers(ids: number[]): void;
/**
* Process a tile request
* @param mapID - the id of the map that is requesting data
* @param tile - the tile request
* @param flushMessage - the flush message function to call on completion
*/
tileRequest(mapID: string, tile: TileRequest, flushMessage: SourceFlushMessage): void;
/**
* If no data, we still have to let the tile worker know so it can prepare a proper flush
* as well as manage cases like "invert" type data.
* @param mapID - the id of the map that is requesting data
* @param tile - the tile request
*/
_flush(mapID: string, tile: TileRequest): void;
}
export {};