s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
120 lines • 5.97 kB
TypeScript
import type { ClusterOptions } from '../../dataStructures/pointCluster';
import type { Extents } from 'open-vector-tile';
import type { FeatureIterator } from '../../readers';
import type { Features } from '../../geometry';
import type { TileStoreOptions } from '../../dataStructures/tile';
import type { TileWriter } from '../../writers';
import type { Attribution, Encoding, LayerMetaData, Scheme } from 's2-tilejson';
/**
* Before tiling the data, you can mutate it here. It can also act as a filter if you return undefined
*/
export type OnFeature = (feature: Features) => Features | undefined;
/** No matter the type of layer you want to build, these are default properties to include */
export interface BaseLayer {
/** Name of the source */
sourceName: string;
/** Name of the layer */
layerName: string;
/** Components of how the layer is built and stored */
metadata: LayerMetaData;
/** Stringified version of the onFeature used by the source so it can be shipped to a worker. */
onFeature?: OnFeature;
}
/** Guide to building Raster layer data */
export interface RasterLayer extends BaseLayer {
/** describes how the image will be stored */
outputType: 'webp' | 'png' | 'jpeg' | 'avif';
}
/** Guide to building Raster layer data where the onFeature & filter is stringified to ship to workers */
export interface StringifiedRasterLayer extends Omit<RasterLayer, 'onFeature' | 'filter'> {
/** Stringified version of the onFeature used by the source so it can be shipped to a worker. */
onFeature?: string;
}
/** Guide to building Cluster layer data */
export interface ClusterLayer extends BaseLayer {
/** If options are provided, the assumption is the point data is clustered */
clusterGuide: ClusterOptions;
/** Extent at which the layer is storing its data */
extent: Extents;
}
/** Guide to building Cluster layer data where the onFeature & filter is stringified to ship to workers */
export interface StringifiedClusterLayer extends Omit<ClusterLayer, 'onFeature' | 'filter'> {
/** Stringified version of the onFeature used by the source so it can be shipped to a worker. */
onFeature?: string;
}
/** Guide to building Vector layer data */
export interface VectorLayer extends BaseLayer {
/** Guide on how to splice the data into vector tiles */
tileGuide: TileStoreOptions;
/** Extent at which the layer is storing its data */
extent: Extents;
}
/** Guide to building Vector layer data where the onFeature & filter is stringified to ship to workers */
export interface StringifiedVectorLayer extends Omit<VectorLayer, 'onFeature' | 'filter'> {
/** Stringified version of the onFeature used by the source so it can be shipped to a worker. */
onFeature?: string;
}
/** List of user defined guides to build layers */
export type LayerGuide = RasterLayer | ClusterLayer | VectorLayer;
/** List of user defined guides to build layers where the onFeature is stringified to ship to workers */
export type StringifiedLayerGuide = StringifiedRasterLayer | StringifiedClusterLayer | StringifiedVectorLayer;
/** A user defined guide on building the vector tiles */
export interface BuildGuide {
/** The name of the data */
name: string;
/** The description of the data */
description?: string;
/** User defined versioning for their data */
version?: string;
/**
* What kind of output format should be used. Used for describing either S2 or WM
* projections [Default: 'fzxy']
*/
scheme?: Scheme;
/** The encoding format. Can be either 'gz', 'br', 'zstd' or 'none' [Default: 'gz'] */
encoding?: Encoding;
/** The attribution of the data. Store as { 'presentation name': 'href' }. */
attribution?: Attribution;
/**
* The vector format if applicable helps define how the vector data is stored.
* - The more modern vector format is the 'open-v2' which supports things like m-values
* and 3D geometries.
* - The new vector format is the 'open-v2' which only supports 2D & 3D geometries, supports M-Values,
* properties and M-Values can have nested properties and/or arrays, and is decently fast to parse.
* - The legacy vector format is the 'open-v1' which only supports 2D geometries and works on
* older map engines like Mapbox-gl-js, is faster to parse and often lighter in size.
* - The older vector format is the 'mapbox' which is the legacy format used by Mapbox and slow to parse.
* [Default: 'open-v2']
*/
vectorFormat?: 'mapbox' | 'open-v1' | 'open-v2';
/**
* The vector sources that the tile is built from and how the layers are to be stored.
* Created using `{ [sourceName: string]: FeatureIterator }`
*/
vectorSources?: Record<string, FeatureIterator>;
/** The raster sources that will be conjoined into a single rgba pixel index for tile extraction */
rasterSources?: Record<string, FeatureIterator>;
/** The elevation sources that will be conjoined into a single elevation index for tile extraction */
elevationSources?: Record<string, FeatureIterator>;
/** The guides on how to build the various data */
layerGuides: LayerGuide[];
/**
* The data created will be stored in either a folder structure or a pmtiles file
* Folder structure is either '{face}/{zoom}/{x}/{y}.pbf' or '{zoom}/{x}/{y}.pbf'.
* PMTiles store all data in a single data file.
*/
tileWriter: TileWriter;
/** Set the number of threads to use. [Default: 1] */
threads?: number;
}
/**
* Build vector tiles give a guide on what sources to parse data from and how to store it
* @param buildGuide - the user defined guide on building the vector tiles
*/
export declare function toVectorTiles(buildGuide: BuildGuide): Promise<void>;
/** A result of a feature iterator */
export interface FeatureIterateResult {
sourceName: string;
feature: Features;
}
//# sourceMappingURL=index.d.ts.map