UNPKG

open-vector-tile

Version:

This library reads/writes Open Vector Tiles

182 lines 6.34 kB
import type { BBOX, BBox, BBox3D } from 's2json-spec'; import type { Point, Point3D } from './vectorTile.spec.js'; /** * Encode a command with the given length of the data that follows. * @param cmd - the command * @param len - the length * @returns - the encoded command and length into a single number */ export declare function commandEncode(cmd: number, len: number): number; /** Object shape for a command and its length */ export interface Command { /** The command */ cmd: number; /** The length */ len: number; } /** * Decode a command with the given length of the data that follows. * @param cmd - the encoded command * @returns - the command and length */ export declare function commandDecode(cmd: number): Command; /** * Perform zigzag encoding on the input number. * @param num - the input * @returns - the incoded unsigned output */ export declare function zigzag(num: number): number; /** * Perform zigzag decoding on the input number. * @param num - the input * @returns - the decoded signed output */ export declare function zagzig(num: number): number; /** * Interweave two 16-bit numbers into a 32-bit number. * In theory two small numbers can end up varint encoded to use less space. * @param a - the first number * @param b - the second number * @returns - the interwoven number */ export declare function weave2D(a: number, b: number): number; /** Object shape for two 16-bit numbers */ export interface Weave2D { a: number; b: number; } /** * Deweave a 32-bit number into two 16-bit numbers. * @param num - the input * @returns - the two numbers */ export declare function unweave2D(num: number): Weave2D; /** * Interweave three 16-bit numbers into a 48-bit number. * In theory three small numbers can end up varint encoded to use less space. * @param a - the first number * @param b - the second number * @param c - the third number * @returns - the interwoven number */ export declare function weave3D(a: number, b: number, c: number): number; /** Object shape for three 16-bit numbers */ export interface Weave3D { a: number; b: number; c: number; } /** * Deweave a 48-bit number into three 16-bit numbers. * @param num - the input * @returns - the three numbers */ export declare function unweave3D(num: number): Weave3D; /** * Encode an array of points using interweaving and delta encoding * @param array - the array of points * @returns - the encoded array as interwoven numbers */ export declare function weaveAndDeltaEncodeArray(array: Point[]): number[]; /** * Decode an array of points that were encoded using interweaving and delta encoding * @param array - the encoded array * @returns - the decoded array of points */ export declare function unweaveAndDeltaDecodeArray(array: number[]): Point[]; /** * Encode an array of 3D points using interweaving and delta encoding * @param array - the array of 3D points * @returns - the encoded array as interwoven numbers */ export declare function weaveAndDeltaEncode3DArray(array: Point3D[]): number[]; /** * Decode an array of 3D points that were encoded using interweaving and delta encoding * @param array - the encoded array * @returns - the decoded array of 3D points */ export declare function unweaveAndDeltaDecode3DArray(array: number[]): Point3D[]; /** * Encode an array using delta encoding * @param array - the array * @returns - the encoded array */ export declare function deltaEncodeArray(array: number[]): number[]; /** * Decode an array that was encoded using delta encoding * @param array - the encoded array * @returns - the decoded array */ export declare function deltaDecodeArray(array: number[]): number[]; /** * Encode a sorted array using delta encoding (doesn't require zigzag) * @param array - the array * @returns - the encoded array */ export declare function deltaEncodeSortedArray(array: number[]): number[]; /** * Decode a sorted array that was encoded using delta encoding * @param array - the encoded array * @returns - the decoded array */ export declare function deltaDecodeSortedArray(array: number[]): number[]; /** * 24-bit quantization * ~0.000021457672119140625 degrees precision * ~2.388 meters precision * @param lon - the longitude * @returns - the quantized longitude */ export declare function quantizeLon(lon: number): number; /** * 24-bit quantization * ~0.000010728836059570312 degrees precision * ~1.194 meters precision * @param lat - the latitude * @returns - the quantized latitude */ export declare function quantizeLat(lat: number): number; /** * @param qLon - the quantized longitude * @returns - the longitude */ export declare function dequantizeLon(qLon: number): number; /** * @param qLat - the quantized latitude * @returns - the latitude */ export declare function dequantizeLat(qLat: number): number; /** * | Decimal Places | Approximate Accuracy in Distance | * |----------------|----------------------------------------| * | 0 | 111 km (69 miles) | * | 1 | 11.1 km (6.9 miles) | * | 2 | 1.11 km (0.69 miles) | * | 3 | 111 meters (364 feet) | * | 4 | 11.1 meters (36.4 feet) | * | 5 | 1.11 meters (3.64 feet) | * | 6 | 0.111 meters (11.1 cm or 4.39 inches) | * | 7 | 1.11 cm (0.44 inches) | * | 8 | 1.11 mm (0.044 inches) | * 24-bit quantization for longitude and latitude * LONGITUDE: * - ~0.000021457672119140625 degrees precision * - ~2.388 meters precision * LATITUDE: * - ~0.000010728836059570312 degrees precision * - ~1.194 meters precision * @param bbox - either 2D or 3D. * @returns - the quantized bounding box */ export declare function quantizeBBox(bbox: BBOX): Uint8Array; /** * @param buffer - The buffer containing the quantized bounding box * @returns - The decoded bounding box */ export declare function dequantizeBBox(buffer: Uint8Array): BBox; /** * @param buffer - The buffer containing the quantized 3D bounding box * @returns - The decoded 3D bounding box */ export declare function dequantizeBBox3D(buffer: Uint8Array): BBox3D; //# sourceMappingURL=util.d.ts.map