gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
50 lines • 1.36 kB
JavaScript
import { OSMReader } from '.';
import { FileKV, FileReader } from '../../file';
/**
* # OSM File Reader
*
* ## Description
* Parses OSM PBF files
* Implements the {@link FeatureIterator} interface
*
* ## Usage
* ```ts
* import { OSMFileReader } from 'gis-tools-ts/file';
*
* const reader = new OSMFileReader('./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 class OSMFileReader extends OSMReader {
options;
/**
* @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, options) {
const fileReader = new FileReader(input);
super(fileReader, options);
this.options = options;
this.nodeGeometry = new FileKV();
this.nodes = new FileKV();
this.wayGeometry = new FileKV();
this.ways = new FileKV();
this.relations = new FileKV();
this.nodeRelationPairs = new FileKV();
}
}
//# sourceMappingURL=file.js.map