osm2geojson-lite
Version:
a lightweight yet faster osm (either in xml or in json formats) to geojson convertor - 4x faster than xmldom + osmtogeojson in most situations - implemented in pure JavaScript without any 3rd party dependency
39 lines (38 loc) • 971 B
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OsmObject = void 0;
class OsmObject {
constructor(type, id, refElems) {
this.type = type;
this.id = id;
this.refElems = refElems;
this.tags = {};
this.props = { id: this.getCompositeId() };
this.refCount = 0;
this.hasTag = false;
if (refElems) {
refElems.add(this.getCompositeId(), this);
}
}
addTags(tags) {
this.tags = Object.assign(this.tags, tags);
this.hasTag = true;
}
addTag(k, v) {
this.tags[k] = v;
this.hasTag = true;
}
addProp(k, v) {
this.props[k] = v;
}
addProps(props) {
this.props = Object.assign(this.props, props);
}
getCompositeId() {
return `${this.type}/${this.id}`;
}
getProps() {
return Object.assign(this.props, this.tags);
}
}
exports.OsmObject = OsmObject;