open-vector-tile
Version:
This library reads/writes Open Vector Tiles
234 lines • 10.6 kB
TypeScript
import type { BaseVectorFeature } from '../base/index.js';
import type { Extents } from './vectorLayer.js';
import type { Shape } from './shape.js';
import type { BBox, BBox3D, Properties as OProperties, VectorGeometryType, VectorMultiLineOffset, VectorMultiLineString, VectorMultiPoint, VectorMultiPolygon, VectorMultiPolygonOffset } from 's2json-spec';
import type { ColumnCacheReader, ColumnCacheWriter } from './columnCache.js';
import type { VectorFeatureType, VectorLines, VectorLines3D, VectorMultiPoly, VectorMultiPoly3D, VectorPoints, VectorPoints3D } from '../vectorTile.spec.js';
/**
* Vector Feature Base
* Common variables and functions shared by all vector features
*/
export declare class OVectorFeatureBase {
readonly cache: ColumnCacheReader;
readonly id: number | undefined;
readonly properties: OProperties;
readonly mShape: Shape;
readonly extent: Extents;
readonly geometryIndices: number[];
readonly single: boolean;
readonly bboxIndex: number;
readonly hasOffsets: boolean;
readonly hasMValues: boolean;
readonly indicesIndex: number;
readonly tessellationIndex: number;
type: number;
/**
* @param cache - the column cache for future retrieval
* @param id - the id of the feature
* @param properties - the properties of the feature
* @param mShape - the shape of the feature's mValues if they exist
* @param extent - the extent of the feature
* @param geometryIndices - the indices of the geometry in the cache
* @param single - if true, you know the initial length is 1
* @param bboxIndex - index to the values column where the BBox is stored
* @param hasOffsets - if true, the geometryIndices has offsets encoded into it
* @param hasMValues - if true, the feature has M values
* @param indicesIndex - if greater than 0, the feature has indices to parse
* @param tessellationIndex - if greater than 0, the feature has tessellation
*/
constructor(cache: ColumnCacheReader, id: number | undefined, properties: OProperties, mShape: Shape, extent: Extents, geometryIndices: number[], single: boolean, bboxIndex: number, // -1 if there is no bbox
hasOffsets: boolean, hasMValues: boolean, indicesIndex: number, // -1 if there are no indices
tessellationIndex: number);
/** @returns - the geometry type of the feature */
geoType(): VectorGeometryType;
/** @returns - true if the type of the feature is points */
isPoints(): boolean;
/** @returns - true if the type of the feature is lines */
isLines(): boolean;
/** @returns - true if the type of the feature is polygons */
isPolygons(): boolean;
/** @returns - true if the type of the feature is points 3D */
isPoints3D(): boolean;
/** @returns - true if the type of the feature is lines 3D */
isLines3D(): boolean;
/** @returns - true if the type of the feature is polygons 3D */
isPolygons3D(): boolean;
/**
* adds the tessellation to the geometry
* @param geometry - the input geometry to add to
* @param multiplier - the multiplier to multiply the geometry by
*/
addTessellation(geometry: number[], multiplier: number): void;
/** @returns the geometry as an array of lines */
loadLines(): [VectorMultiLineString, VectorMultiLineOffset] | undefined;
/** @returns the geometry as an array of lines objects that include offsets */
loadPolys(): [VectorMultiPolygon, VectorMultiPolygonOffset] | undefined;
/** @returns an empty geometry */
loadGeometryFlat(): [geometry: number[], indices: number[]];
/** @returns the indices for the feature */
readIndices(): number[];
}
/**
* Vector Feature Base 2D.
* Extends from @see {@link OVectorFeatureBase}.
*/
export declare class OVectorFeatureBase2D extends OVectorFeatureBase {
/** @returns the BBox of the feature (in lon-lat space) */
bbox(): BBox;
}
/**
* Vector Feature Base 3D.
* Extends from @see {@link OVectorFeatureBase}.
*/
export declare class OVectorFeatureBase3D extends OVectorFeatureBase {
/** @returns the BBox3D of the feature (in lon-lat space) */
bbox(): BBox3D;
}
/**
* Points Vector Feature
* Type 1
* Extends from @see {@link OVectorFeatureBase}.
* store either a single point or a list of points
*/
export declare class OVectorPointsFeature extends OVectorFeatureBase2D {
type: VectorFeatureType;
geometry?: VectorPoints;
/** @returns the geometry as an array of points */
loadPoints(): VectorMultiPoint;
/** @returns the geometry as an array of points */
loadGeometry(): VectorPoints;
}
/**
* Lines Vector Feature
* Type 2
* Extends from @see {@link OVectorFeatureBase2D}.
* Store either a single line or a list of lines
*/
export declare class OVectorLinesFeature extends OVectorFeatureBase2D {
type: VectorFeatureType;
geometry?: [VectorLines, VectorMultiLineOffset];
/** @returns the geometry as a flattened array of points */
loadPoints(): VectorMultiPoint;
/** @returns the geometry as an array of lines objects that include offsets */
loadLines(): [VectorLines, VectorMultiLineOffset];
/** @returns the geometry as an array of flattened line geometry */
loadGeometry(): VectorLines;
}
/**
* Polys Vector Feature
* Type 3
* Extends from @see {@link OVectorFeatureBase2D}.
* Stores either one or multiple polygons. Polygons are an abstraction to polylines, and
* each polyline can contain an offset.
*/
export declare class OVectorPolysFeature extends OVectorFeatureBase2D {
#private;
type: VectorFeatureType;
geometry?: [VectorMultiPoly, VectorMultiPolygonOffset];
/** @returns the geometry as a flattened array of points */
loadPoints(): VectorMultiPoint;
/** @returns the geometry flattened into an array with offsets */
loadLines(): [VectorLines, VectorMultiLineOffset];
/** @returns the geometry as an array of lines objects that include offsets */
loadPolys(): [VectorMultiPolygon, VectorMultiPolygonOffset];
/** @returns the geometry as an array of raw poly geometry */
loadGeometry(): VectorMultiPoly;
/**
* Automatically adds the tessellation to the geometry if the tessellationIndex exists
* @returns the geometry as an array of totally flattend poly geometry with indices
*/
loadGeometryFlat(): [geometry: number[], indices: number[]];
/** @returns the indices of the geometry */
readIndices(): number[];
/**
* adds the tessellation to the geometry
* @param geometry - the geometry of the feature
* @param multiplier - the multiplier to apply the extent shift
*/
addTessellation(geometry: number[], multiplier: number): void;
}
/**
* 3D Point Vector Feature
* Type 4.
* Extends from @see {@link OVectorFeatureBase3D}.
* Store either a single 3D point or a list of 3D points.
*/
export declare class OVectorPoints3DFeature extends OVectorFeatureBase3D {
type: VectorFeatureType;
geometry?: VectorPoints3D;
/** @returns the geometry as a flattened array of points */
loadPoints(): VectorPoints3D;
/**
* Read in the 3D Point Geometry. Can be more than one point.
* @returns the 3D Point Geometry
*/
loadGeometry(): VectorPoints3D;
}
/**
* 3D Lines Vector Feature
* Type 5
* Extends from @see {@link OVectorFeatureBase3D}.
* Store either a single 3D line or a list of 3D lines.
*/
export declare class OVectorLines3DFeature extends OVectorFeatureBase3D {
type: VectorFeatureType;
geometry?: [VectorLines3D, VectorMultiLineOffset];
/** @returns the geometry as a flattened array of points */
loadPoints(): VectorPoints3D;
/** @returns the geometry as an array of lines objects that include offsets */
loadLines(): [VectorLines3D, VectorMultiLineOffset];
/** @returns the geometry as an array of flattened line geometry */
loadGeometry(): VectorLines3D;
}
/**
* 3D Polygons Vector Feature
* Type 6
* Extends from @see {@link OVectorFeatureBase3D}.
* Store either a single 3D polygon or a list of 3D polygons.
*/
export declare class OVectorPolys3DFeature extends OVectorFeatureBase3D {
#private;
type: VectorFeatureType;
geometry?: [VectorMultiPoly3D, VectorMultiPolygonOffset];
/** @returns the geometry as a flattened array of points */
loadPoints(): VectorPoints3D;
/** @returns the geometry flattened into an array with offsets */
loadLines(): [VectorMultiLineString, VectorMultiLineOffset];
/** @returns the geometry as an array of lines objects that include offsets */
loadPolys(): [VectorMultiPolygon, VectorMultiPolygonOffset];
/** @returns the geometry as an array of raw poly geometry */
loadGeometry(): VectorMultiPoly3D;
/**
* Automatically adds the tessellation to the geometry if the tessellationIndex exists
* @returns the geometry as an array of totally flattend poly geometry with indices
*/
loadGeometryFlat(): [geometry: number[], indices: number[]];
/** @returns the indices of the geometry */
readIndices(): number[];
/**
* adds the tessellation to the geometry
* @param geometry - the geometry of the feature
* @param multiplier - the multiplier to apply the extent shift
*/
addTessellation(geometry: number[], multiplier: number): void;
}
/** All feature class types. Points, Lines, and Polys for both 2D and 3D */
export type OVectorFeature = OVectorPointsFeature | OVectorLinesFeature | OVectorPolysFeature | OVectorPoints3DFeature | OVectorLines3DFeature | OVectorPolys3DFeature;
/**
* @param bytes - the bytes to read from
* @param extent - the extent of the vector layer to help decode the geometry
* @param cache - the column cache to read from
* @param shape - the shape of the feature's properties data
* @param mShape - the shape of the feature's m-values if they exist
* @returns - the decoded feature
*/
export declare function readFeature(bytes: Uint8Array, extent: Extents, cache: ColumnCacheReader, shape: Shape, mShape?: Shape): OVectorFeature;
/**
* @param feature - BaseVectorFeature to build a buffer from
* @param shape - The shape of the feature's properties data
* @param mShape - The shape of the feature's m-values if they exist
* @param cache - where to store all feature data to in columns
* @returns - Compressed indexes for the feature
*/
export declare function writeOVFeature(feature: BaseVectorFeature, shape: Shape, mShape: Shape | undefined, cache: ColumnCacheWriter): Uint8Array;
//# sourceMappingURL=vectorFeature.d.ts.map