s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
122 lines • 5.35 kB
TypeScript
import type { Reader } from '.';
export * from './tile/file';
/**
* # File Reader
*
* ## Description
* Reads data from a file implementing the {@link Reader} interface
*
* ## Usage
* ```ts
* import { FileReader } from 's2-tools/file';
*
* const reader = new FileReader('./BETA2007.gsb');
*
* const data = await reader.getRange(0, 100);
* ```
*/
export declare class FileReader implements Reader {
#private;
byteOffset: number;
byteLength: number;
textDecoder: import("util").TextDecoder;
/** @param file - The path to the file */
constructor(file: string);
/**
* 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 file data as DataView
* @param begin - Beginning of the slice
* @param end - End of the slice. If not provided, the end of the data is used
* @returns - The data as a DataView
*/
slice(begin?: number, end?: 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 file
* @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 file
* @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>;
/** Closes the file */
close(): void;
}
//# sourceMappingURL=file.d.ts.map