open-vector-tile
Version:
This library reads/writes Open Vector Tiles
203 lines • 7.64 kB
TypeScript
import type { ColumnCacheWriter } from '../open/columnCache.js';
import type MapboxVectorFeature from '../mapbox/vectorFeature.js';
import type { VectorFeatures as S2JSONFeature } from 's2json-spec';
import type { Shape } from '../open/shape.js';
import type { BBOX, BBox, BBox3D, Properties as OProperties } from 's2json-spec';
import type { Point, VectorLine, VectorLine3D, VectorPoints, VectorPoints3D } from '../vectorTile.spec.js';
/**
* Base Vector Feature
* Common variables and methods shared by all vector features
*/
export declare class VectorFeatureBase<G, B = BBOX> {
geometry: G;
properties: OProperties;
id?: number | undefined;
bbox?: B | undefined;
type: number;
/**
* @param geometry - the geometry of the feature
* @param properties - the properties of the feature
* @param id - the id of the feature if there is one
* @param bbox - the BBox of the feature
*/
constructor(geometry: G, properties?: OProperties, id?: number | undefined, bbox?: B | undefined);
/** @returns - true if the feature has BBox */
get hasBBox(): boolean;
}
/** Base Vector Points Feature */
export declare class VectorFeaturePointsBase<G = VectorPoints | VectorPoints3D, B = BBOX> extends VectorFeatureBase<G, B> {
/**
* Points do not have this feature, so return false
* @returns false always
*/
get hasOffsets(): boolean;
/**
* Points do not have this feature, so return false
* @returns false always
*/
get hasMValues(): boolean;
/** @returns the geometry */
loadGeometry(): G;
/** @returns the M-Values */
getMValues(): undefined | OProperties[];
/**
* @param cache - the column cache to store the geometry
* @param mShape - the shape of the M-values to encode the values as
* @returns the index in the points column where the geometry is stored
*/
addGeometryToCache(cache: ColumnCacheWriter, mShape?: Shape): number;
}
/**
* Base Vector Points Feature
* Type 1
* Extends from @see {@link VectorFeaturePointsBase}.
* Store either a single point or a list of points
*/
export declare class BaseVectorPointsFeature extends VectorFeaturePointsBase<VectorPoints, BBox> {
type: number;
}
/**
* Base Vector Points 3D Feature
* Type 4
* Extends from @see {@link VectorFeaturePointsBase}.
* Store either a single point or a list of points
*/
export declare class BaseVectorPoints3DFeature extends VectorFeaturePointsBase<VectorPoints3D, BBox3D> {
type: number;
}
/**
* Base Vector Lines Feature
* Common variables and methods shared by all vector lines and/or polygons features
*/
export declare class BaseVectorLine<L = VectorLine | VectorLine3D> {
geometry: L;
offset: number;
/**
* @param geometry - the geometry of the feature
* @param offset - the offset of the feature
*/
constructor(geometry: L, offset?: number);
}
/** Base Vector Lines Feature */
export declare class VectorFeatureLinesBase<G = VectorLine | VectorLine3D, B = BBOX> extends VectorFeatureBase<BaseVectorLine<G>[], B> {
/** @returns - true if the feature has offsets */
get hasOffsets(): boolean;
/**
* @returns - true if the feature has M values
*/
get hasMValues(): boolean;
/** @returns the flattened geometry */
loadGeometry(): G[];
/** @returns the flattened M values */
getMValues(): undefined | OProperties[];
/**
* @param cache - the column cache to store the geometry
* @param mShape - the shape of the M-values to encode the values as
* @returns the indexes in the points column where the geometry is stored
*/
addGeometryToCache(cache: ColumnCacheWriter, mShape?: Shape): number;
}
/**
* Base Vector Lines Feature
* Type 2
* Extends from @see {@link VectorFeatureBase}.
* Store either a single line or a list of lines.
*/
export declare class BaseVectorLinesFeature extends VectorFeatureLinesBase<VectorLine, BBox> {
type: number;
}
/**
* Base Vector Lines 3D Feature
* Type 5
* Extends from @see {@link VectorFeatureBase}.
* Store either a single 3D line or a list of 3D lines
*/
export declare class BaseVectorLines3DFeature extends VectorFeatureLinesBase<VectorLine3D, BBox3D> {
type: number;
}
/** Base Vector Polys Feature */
export declare class VectorFeaturePolysBase<G = VectorLine | VectorLine3D, B = BBOX> extends VectorFeatureBase<BaseVectorLine<G>[][], B> {
#private;
geometry: BaseVectorLine<G>[][];
indices: number[];
bbox?: B | undefined;
tessellation: Point[];
/**
* @param geometry - the geometry of the feature
* @param indices - the indices of the geometry
* @param tessellation - the tessellation of the geometry
* @param properties - the properties of the feature
* @param id - the id of the feature
* @param bbox - the bbox of the feature
*/
constructor(geometry: BaseVectorLine<G>[][], indices?: number[], tessellation?: number[], properties?: OProperties, id?: number, bbox?: B | undefined);
/**
* @returns true if the feature has offsets
*/
get hasOffsets(): boolean;
/**
* @returns - true if the feature has M values
*/
get hasMValues(): boolean;
/**
* @returns the flattened geometry
*/
loadGeometry(): G[][];
/**
* @returns the flattened M-values
*/
getMValues(): undefined | OProperties[];
/**
* @param cache - the column cache to store the geometry
* @param mShape - the shape of the M-values to encode the values as
* @returns the indexes in the points column where the geometry is stored
*/
addGeometryToCache(cache: ColumnCacheWriter, mShape?: Shape): number;
}
/**
* Base Vector Polys Feature
* Type 3
* Extends from @see {@link VectorFeatureBase}.
* Store either a single polygon or a list of polygons
*/
export declare class BaseVectorPolysFeature extends VectorFeaturePolysBase<VectorLine, BBox> {
type: number;
}
/**
* Base Vector Polys 3D Feature
* Type 6
* Extends from @see {@link VectorFeatureBase}.
* Store either a single 3D poly or a list of 3D polys
*/
export declare class BaseVectorPolys3DFeature extends VectorFeaturePolysBase<VectorLine3D, BBox3D> {
type: number;
}
/**
* A type that encompasses all vector tile feature types
*/
export type BaseVectorFeature = BaseVectorPointsFeature | BaseVectorLinesFeature | BaseVectorPolysFeature | BaseVectorPoints3DFeature | BaseVectorLines3DFeature | BaseVectorPolys3DFeature;
/**
* @param feature - A mapbox vector feature that's been parsed from protobuf data
* @returns - A base feature to help build a vector tile
*/
export declare function fromMapboxVectorFeature(feature: MapboxVectorFeature): BaseVectorFeature;
/**
* Convert an S2JSON feature to a base feature
* @param feature - An S2JSON feature
* @param extent - the extent of the vector layer
* @returns - A base feature to help build a vector tile
*/
export declare function fromS2JSONFeature(feature: S2JSONFeature, extent: number): BaseVectorFeature;
/**
* Encode offset values into a signed integer to reduce byte cost without too much loss
* @param offset - float or double value to be compressed
* @returns - a signed integer that saves 3 decimal places
*/
export declare function encodeOffset(offset: number): number;
/**
* Decode offset from a signed integer into a float or double
* @param offset - the signed integer to be decompressed
* @returns - a float or double that restores 3 decimal places
*/
export declare function decodeOffset(offset: number): number;
//# sourceMappingURL=vectorFeature.d.ts.map