gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
175 lines • 8.17 kB
TypeScript
import type { MValue, Properties, VectorFeatures, VectorGeometry } from '../geometry';
export * from './csv';
export * from './gbfs';
export * from './geotiff';
export * from './gpx';
export * from './grib2';
export * from './gtfs';
export * from './image';
export * from './json';
export * from './las';
export * from './netcdf';
export * from './osm';
export * from './pmtiles';
export * from 'pbf-ts';
export * from './shapefile';
export * from './wkt';
export * from './xml';
export * from './fetch';
export * from './nadgrid';
export * from './tile';
/** Reader interface. Implemented to read data from either a buffer or a filesystem */
export interface Reader {
byteLength: number;
byteOffset: number;
getBigInt64: (byteOffset?: number, littleEndian?: boolean) => bigint;
getBigUint64: (byteOffset?: number, littleEndian?: boolean) => bigint;
getFloat32: (byteOffset?: number, littleEndian?: boolean) => number;
getFloat64: (byteOffset?: number, littleEndian?: boolean) => number;
getInt16: (byteOffset?: number, littleEndian?: boolean) => number;
getInt32: (byteOffset?: number, littleEndian?: boolean) => number;
getInt8: (byteOffset?: number) => number;
getUint16: (byteOffset?: number, littleEndian?: boolean) => number;
getUint32: (byteOffset?: number, littleEndian?: boolean) => number;
getUint8: (byteOffset?: number) => number;
tell(): number;
seek(pos?: number): void;
slice: (begin?: number, end?: number) => DataView;
seekSlice: (size: number) => DataView;
setStringEncoding: (encoding: string) => void;
parseString: (byteOffset?: number, byteLength?: number) => string;
getRange: (offset: number, length: number) => Promise<Uint8Array>;
}
/** Feature iteration interface. Implemented by readers to iterate over features */
export interface FeatureIterator<M = Record<string, unknown>, D extends MValue = MValue, P extends Properties = Properties, G extends VectorGeometry<D> = VectorGeometry<D>> {
[Symbol.asyncIterator]: () => AsyncGenerator<VectorFeatures<M, D, P, G>>;
}
/** All input types that can be placed into a reader */
export type ReaderInputs = Reader | BufferReader | Buffer | ArrayBufferLike | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | DataView;
/**
* Convenience function that ensures the input is a usable reader
* @param input - the input data
* @returns - a BufferReader
*/
export declare function toReader(input: ReaderInputs): Reader;
/** A buffer reader is an extension of a DataView with some extra methods */
export declare class BufferReader extends DataView<ArrayBufferLike> implements Reader {
private cursor;
textDecoder: import("util").TextDecoder;
/**
* @param buffer - the input buffer
* @param byteOffset - offset in the buffer
* @param byteLength - length of the buffer
*/
constructor(buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number);
/**
* @returns - the current position of the cursor
*/
tell(): number;
/**
* Set the current position of the cursor
* @param pos - where to adjust the current cursor
*/
seek(pos?: number): void;
/**
* Reads a 64-bit unsigned integer (biguint64) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @param littleEndian - Optional, specifies if the value is stored in little-endian format. Defaults to false (big-endian).
* @returns The 64-bit unsigned integer as a bigint
*/
getBigInt64(byteOffset?: number, littleEndian?: boolean): bigint;
/**
* Reads a 64-bit unsigned integer (biguint64) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @param littleEndian - Optional, specifies if the value is stored in little-endian format. Defaults to false (big-endian).
* @returns The 64-bit unsigned integer as a bigint
*/
getBigUint64(byteOffset?: number, littleEndian?: boolean): bigint;
/**
* Reads a 32-bit floating-point number (float32) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @param littleEndian - Optional, specifies if the value is stored in little-endian format. Defaults to false (big-endian).
* @returns The 32-bit floating-point number as a number
*/
getFloat32(byteOffset?: number, littleEndian?: boolean): number;
/**
* Reads a 64-bit floating-point number (float64) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @param littleEndian - Optional, specifies if the value is stored in little-endian format. Defaults to false (big-endian).
* @returns The 64-bit floating-point number as a number
*/
getFloat64(byteOffset?: number, littleEndian?: boolean): number;
/**
* Reads a signed 16-bit integer (int16) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @param littleEndian - Optional, specifies if the value is stored in little-endian format. Defaults to false (big-endian).
* @returns The 16-bit signed integer value as a number
*/
getInt16(byteOffset?: number, littleEndian?: boolean): number;
/**
* Reads a signed 32-bit integer (int32) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @param littleEndian - Optional, specifies if the value is stored in little-endian format. Defaults to false (big-endian).
* @returns The 32-bit signed integer value as a number
*/
getInt32(byteOffset?: number, littleEndian?: boolean): number;
/**
* Reads a signed byte (int8) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @returns The byte value as a signed number
*/
getInt8(byteOffset?: number): number;
/**
* Reads an unsigned 16-bit integer (uint16) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @param littleEndian - Optional, specifies if the value is stored in little-endian format. Defaults to false (big-endian).
* @returns The 16-bit unsigned integer value as a number
*/
getUint16(byteOffset?: number, littleEndian?: boolean): number;
/**
* Reads an unsigned 32-bit integer (uint32) at the given byteOffset
* @param byteOffset - The position in the file to read from
* @param littleEndian - Optional, specifies if the value is stored in little-endian format. Defaults to false (big-endian).
* @returns The 32-bit unsigned integer value as a number
*/
getUint32(byteOffset?: number, littleEndian?: boolean): number;
/**
* Reads a single byte at the given byteOffset
* @param byteOffset - The position in the file to read from
* @returns The byte value as a number
*/
getUint8(byteOffset?: number): number;
/**
* Get a slice of the buffer
* @param begin - beginning of the slice
* @param end - end of the slice. If not provided, the end of the data is used
* @returns - a DataView of the slice
*/
slice(begin?: number, end?: number): DataView;
/**
* Fetch a slice at the current cursor position. The cursor is updated
* @param size - size of the slice
* @returns - a DataView of the slice
*/
seekSlice(size: number): DataView;
/**
* Set the text decoder's encoding
* @param encoding - update the text decoder's encoding
*/
setStringEncoding(encoding: string): void;
/**
* Reads a string from the buffer
* @param byteOffset - Start of the string
* @param byteLength - Length of the string
* @returns - The string
*/
parseString(byteOffset?: number, byteLength?: number): string;
/**
* Reads a range from the buffer
* @param offset - the offset of the range
* @param length - the length of the range
* @returns - the ranged buffer
*/
getRange(offset: number, length: number): Promise<Uint8Array>;
}
//# sourceMappingURL=index.d.ts.map