UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

99 lines 3.62 kB
import { PointCluster, PointGrid } from '../../../dataStructures/index.js'; import type { Encoding } from 's2-tilejson'; import type { MultiMapStore } from '../../../dataStore/index.js'; import type { RGBA } from '../../../index.js'; import type { Face, Projection, Properties, VectorFeatures } from '../../../geometry/index.js'; import type { FormatOutput, LayerGuide, StringifiedLayerGuide } from '../types.js'; /** Take in options that will be used to create a tiled data correctly */ export interface InitMessage { /** Message type */ type: 'init'; /** id of the worker */ id: number; /** The sources that will be used to create the tile */ layerGuides: StringifiedLayerGuide[]; /** The scheme that will be used to decide the projection and store method */ projection?: Projection; /** The encoding that will be used to compress the tile */ encoding?: Encoding; /** The output format */ format?: FormatOutput; /** If we should build indices into the tile or not */ buildIndices?: boolean; } /** Take in a feature that will be added to the tile */ export interface FeatureMessage { /** Message type */ type: 'feature'; /** The name of the source that the feature is from */ sourceName: string; /** The feature to add to the tile */ feature: VectorFeatures; } /** We want to track the associated layer for each feature */ export interface FeatureMetadata extends Properties { layerName: string; } /** A built tile that is ready to be written to the filesystem */ export interface BuiltTile { face: Face; zoom: number; x: number; y: number; data: Uint8Array; } /** Convert a vector feature to a collection of tiles and store each tile feature */ export default class TileWorker { #private; id: number; layerGuides: LayerGuide[]; projection: Projection; encoding: Encoding; format: FormatOutput; buildIndices: boolean; vectorStore: MultiMapStore<VectorFeatures<FeatureMetadata>>; clusterStores: { [layerName: string]: PointCluster; }; rasterStores: { [layerName: string]: PointGrid<RGBA>; }; gridStores: { [layerName: string]: PointGrid; }; /** * Tile-ize input vector features and store them * @param event - the init message or a feature message */ onmessage(event: MessageEvent<InitMessage | FeatureMessage>): void; /** * Tile-ize input vector features and store them * @param message - the init message or a feature message */ handleMessage(message: InitMessage | FeatureMessage): void; /** Iterate through all the stores and sort/cluster as needed */ sort(): Promise<void>; /** * Iterate through the stores and build tiles, compressing as we go if required * @yields {BuiltTile} - a built tile */ buildTiles(): AsyncGenerator<BuiltTile>; /** * Store a feature across all appropriate zooms * @param message - the message to pull the feature and source info from */ storeFeature(message: FeatureMessage): void; } /** * Get the absolute minzoom from the layer guides * @param layerGuides - the user defined guide on building the vector tiles * @returns the absolute minzoom */ export declare function getMinzoom(layerGuides: LayerGuide[]): number; /** * Get the absolute maxzoom from the layer guides * @param layerGuides - the user defined guide on building the vector tiles * @returns the absolute maxzoom */ export declare function getMaxzoom(layerGuides: LayerGuide[]): number; //# sourceMappingURL=tileWorker.d.ts.map