UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

85 lines 3.37 kB
import type { IntermediateNodeMember } from './relation.js'; import type { PbfReader } from 'pbf-ts'; import type { InfoBlock, OSMProperties, OSMReader } from './index.js'; /** The expected metadata in the VectorFeature for all types (node, way, relation) */ export interface OSMMetadata { type: 'node' | 'way' | 'relation'; info: InfoBlock; nodes?: IntermediateNodeMember[]; relation?: { role: string; properties: OSMProperties; }; } /** * NOTE: currently relations are stored, but we don't wait for the Block to store all relations * before we start testing primtiveHandle against the data. This is a problem because * relations reference eachother at times, and we need to be able to resolve those references * before we can run relationHandle against the data. This isn't an important issue since * in practice, all relations that reference eachother often produce garbage or unusable data. * But it would be *nice* to fix this. Morbidly enough, the "BEST" solution is to treat relations * like we do nodes and ways since relations could possibly reference eachother outside their own block. * From a practical standpoint, I can't see this being worth the effort or memory/time cost. */ export declare class PrimitiveBlock { #private; pbf: PbfReader; reader: OSMReader; stringtable: StringTable; primitiveGroups: PrimitiveGroup[]; granularity: number; latOffset: number; lonOffset: number; dateGranularity: number; /** * @param pbf - the Protobuf object to read from * @param reader - the OSMReader to modify */ constructor(pbf: PbfReader, reader: OSMReader); /** * Get a string from the string table at the given index * @param index - the index of the string in the string table * @returns - the string */ getString(index: number): string; /** * Get a record of strings from the string table * @param keys - list of indices for the keys * @param values - list of indices for the values * @returns - the record or object containing the key-value pairs */ tags(keys: number[], values: number[]): OSMProperties; } /** Group of OSMPrimitives. All primitives in a group must be the same type. */ export declare class PrimitiveGroup { #private; primitiveBlock: PrimitiveBlock; pbf: PbfReader; /** * @param primitiveBlock - the parent PrimitiveBlock * @param pbf - the Protobuf object to read from */ constructor(primitiveBlock: PrimitiveBlock, pbf: PbfReader); } /** * String table, contains the common strings in each block. * Note that we reserve index '0' as a delimiter, so the entry at that * index in the table is ALWAYS blank and unused. * NOTE: OSM isn't safe and allows " inside of strings, so we have to replace them with ' * NOTE: OSM isn't safe and allows \ at the end of strings, so we have to remove them so it can be properly parsed. */ export declare class StringTable { #private; strings: string[]; /** * @param pbf - the Protobuf object to read from */ constructor(pbf: PbfReader); /** * @param index - the index of the string * @returns - the string */ get(index: number): string; } /** This is kept for backwards compatibility but not used anywhere. */ //# sourceMappingURL=primitive.d.ts.map