UNPKG

s2-tools

Version:

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

146 lines 5.11 kB
import type { Metadata } from './primitive'; import type { OSMHeader } from './headerBlock'; import type { FeatureIterator, Reader, ReaderInputs } from '..'; import type { IntermediateNodeMember, IntermediateRelation } from './relation'; import type { IntermediateWay, WayNodes } from './way'; import type { KVStore, KVStoreConstructor } from '../../dataStore'; import type { VectorFeature, VectorPoint } from '../../geometry'; export type * from './blob'; export type * from './headerBlock'; export type * from './info'; export type * from './node'; export type * from './primitive'; export type * from './relation'; export type * from './way'; /** * Filter types * Options are: * - All * - Node * - Way * - Relation */ export type FilterType = 'All' | 'Node' | 'Way' | 'Relation'; /** Filter map. Used internally by TagFilter */ export type FilterMap = Map<string, string | undefined>; /** * TagFilter Class * Builds a filter for the tags when parsing data. * Can parse tags from nodes, ways and relations. * Also allows the ability to add tags that apply to all object types. * Can filter by key, but also both key and value. */ export declare class TagFilter { #private; /** * Add a filter * @param filterType - The filter type to apply the filter * @param key - The key to apply the filter * @param value - The value to apply the filter (optional) */ addFilter(filterType: FilterType, key: string, value?: string): void; /** * Check if a filter has been found * @param filterType - The filter type * @param key - The key * @param value - The value (optional) * @returns - True if the filter has been found */ matchFound(filterType: FilterType, key: string, value?: string): boolean; } /** OSM Reader options */ export interface OsmReaderOptions { /** if true, remove nodes that have no tags [Default = true] */ removeEmptyNodes?: boolean; /** If provided, filters of the */ tagFilter?: TagFilter; /** If set to true, nodes will be skipped. [Default = false] */ skipNodes?: boolean; /** If set to true, ways will be skipped. [Default = false] */ skipWays?: boolean; /** If set to true, relations will be skipped. [Default = false] */ skipRelations?: boolean; /** * If set to true, ways will be converted to areas if they are closed. * NOTE: They are upgraded anyways if the tag "area" is set to "yes". * [Default = false] */ upgradeWaysToAreas?: boolean; /** If set to true, add a bbox property to each feature */ addBBox?: boolean; /** TODO: If defined, replace the stores with the provided class */ store?: KVStoreConstructor; } /** * # OSM Reader * * ## Description * Parses OSM PBF files * Implements the {@link FeatureIterator} interface * * ## Usage * ```ts * import { OSMReader } from 's2-tools'; * import { FileReader } from 's2-tools/file'; * * const reader = new OSMReader(new FileReader('./data.osm.pbf')); * // pull out the header * const header = reader.getHeader(); * // read the features * for (const feature of reader) { * console.log(feature); * } * // close the reader when done * reader.close(); * ``` * * ## Links * - https://wiki.openstreetmap.org/wiki/PBF_Format * - https://github.com/openstreetmap/pbf/blob/master/OSM-binary.md */ export declare class OSMReader implements FeatureIterator<Metadata> { #private; options?: OsmReaderOptions | undefined; reader: Reader; /** if true, remove nodes that have no tags [Default = true] */ removeEmptyNodes: boolean; /** If provided, filters of the */ tagFilter?: TagFilter; /** If set to true, nodes will be skipped */ skipNodes: boolean; /** If set to true, ways will be skipped */ skipWays: boolean; /** If set to true, relations will be skipped */ skipRelations: boolean; /** * If set to true, ways will be converted to areas if they are closed. * NOTE: They are upgraded anyways if the tag "area" is set to "yes". * [Default = false] */ upgradeWaysToAreas: boolean; /** If set to true, add a bbox property to each feature */ addBBox: boolean; nodeGeometry: KVStore<VectorPoint>; nodes: KVStore<VectorFeature<Metadata>>; wayGeometry: KVStore<WayNodes>; ways: KVStore<IntermediateWay>; relations: KVStore<IntermediateRelation>; nodeRelationPairs: KVStore<IntermediateNodeMember>; /** * @param input - The input (may be a local memory filter or file reader) * @param options - User defined options to apply when reading the OSM file */ constructor(input: ReaderInputs, options?: OsmReaderOptions | undefined); /** * An async iterator to read in each feature * @yields {VectorFeature} */ [Symbol.asyncIterator](): AsyncGenerator<VectorFeature<Metadata>>; /** * @returns - The header of the OSM file */ getHeader(): OSMHeader; /** Close out the data which will cleanup any temporary files if they exist */ close(): void; } //# sourceMappingURL=index.d.ts.map