gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
184 lines • 8.72 kB
TypeScript
import type { MValue, Properties, VectorFeatures, VectorGeometry } from '../geometry/index.js';
export * from './csv/index.js';
export * from './gbfs/index.js';
export * from './geotiff/index.js';
export * from './gpx/index.js';
export * from './grib2/index.js';
export * from './gtfs/index.js';
export * from './image/index.js';
export * from './json/index.js';
export * from './las/index.js';
export * from './netcdf/index.js';
export * from './osm/index.js';
export * from './pmtiles/index.js';
export * from './s2tiles/index.js';
export * from 'pbf-ts';
export * from './shapefile/index.js';
export * from './svg/index.js';
export * from './wkt/index.js';
export * from './xml/index.js';
export * from './fetch.js';
export * from './nadgrid.js';
export * from './tile/index.js';
/** 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: 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>;
}
/**
* Given a file and a file type, return a reader
* @param urlPath - The URL path to the file
* @param type - The file type if specified, otherwise it will be inferred
* @returns - The reader with {@link FeatureIterator} implemented
*/
export declare function fileTypeToReader(urlPath: string, type?: string): Promise<FeatureIterator>;
//# sourceMappingURL=index.d.ts.map