open-vector-tile
Version:
This library reads/writes Open Vector Tiles
64 lines • 2.72 kB
TypeScript
import { OVectorFeature } from './vectorFeature.js';
import { PbfReader, Pbf as Protobuf } from 'pbf-ts';
import type { BaseVectorLayer } from '../base/index.js';
import type { Shape } from './shape.js';
import type { ColumnCacheReader, ColumnCacheWriter } from './columnCache.js';
/** Extents are the tile size limits of what a user can use to encode a geometry. */
export type Extents = 16_384 | 8_192 | 4_096 | 2_048 | 1_024 | 512;
/**
* The Open Vector Layer class represents a layer in an Open Vector Tile.
* Contains an extent, name, version, and features.
* The features will utilize the layer extent to decode geometry.
*/
export declare class OVectorLayer {
#private;
version: number;
name: string;
extent: Extents;
/**
* @param pbf - the pbf protocol we are reading from
* @param end - the position to stop at
* @param cache - the cache where all data is stored in a column format
*/
constructor(pbf: PbfReader, end: number, cache: ColumnCacheReader);
/** @returns - The number of features in the layer */
get length(): number;
/** @returns - The shape of the features properties */
get shape(): Shape;
/** @returns - The shape of the M-Values */
get mShape(): Shape | undefined;
/**
* should return OVectorFeature which is a type combining all 6 feature types
* @param i - The index of the feature
* @returns - A feature at the given index
*/
feature(i: number): OVectorFeature;
}
/**
* @param extent - number are in 512, 1024, 2048, 4096, 8192
* @returns - remap to smaller values: 0 -> 512, 1 -> 1024, 2 -> 2048, 3 -> 4096, 4 -> 8192
*/
export declare function encodeExtent(extent: Extents): number;
/**
* @param encExtent - number are in 0, 1, 2, 3, 4
* @returns - remap to smaller values: 0 -> 512, 1 -> 1024, 2 -> 2048, 3 -> 4096, 4 -> 8192
*/
export declare function decodeExtent(encExtent: number): Extents;
/**
* Because of the Column Cache, a layer will contain:
* - version 1 byte
* - extent (1 byte) - 1 -> 1024, 2 -> 2048, 3 -> 4096, 4 -> 8192
* - name (varint) - index into the string columns table
* - features (writeMessage) - for each feature
* @param layerCache - object containing the layer and the cache
* @param layerCache.layer - the layer to encode into the Protobuffer
* @param layerCache.cache - the cache where all column level data is stored
* @param layerCache.verbose - set to true to print out write information
* @param pbf - the pbf protocol we are writing to
*/
export declare function writeOVLayer(layerCache: {
layer: BaseVectorLayer;
cache: ColumnCacheWriter;
verbose: boolean;
}, pbf: Protobuf): void;
//# sourceMappingURL=vectorLayer.d.ts.map