osm2geojson-lite 1.2.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/cli.mjs +36 -0
- package/dist/index.d.ts +203 -0
- package/dist/index.js +924 -0
- package/dist/index.mjs +924 -0
- package/package.json +43 -56
- package/dist/node/index.d.ts +0 -25
- package/dist/node/index.js +0 -196
- package/dist/node/late-binder.d.ts +0 -8
- package/dist/node/late-binder.js +0 -24
- package/dist/node/node.d.ts +0 -14
- package/dist/node/node.js +0 -31
- package/dist/node/osm-object.d.ts +0 -25
- package/dist/node/osm-object.js +0 -38
- package/dist/node/ref-elements.d.ts +0 -9
- package/dist/node/ref-elements.js +0 -19
- package/dist/node/relation.d.ts +0 -21
- package/dist/node/relation.js +0 -220
- package/dist/node/utils.d.ts +0 -22
- package/dist/node/utils.js +0 -97
- package/dist/node/way-collection.d.ts +0 -14
- package/dist/node/way-collection.js +0 -109
- package/dist/node/way.d.ts +0 -21
- package/dist/node/way.js +0 -87
- package/dist/node/xmlparser.d.ts +0 -32
- package/dist/node/xmlparser.js +0 -161
- package/dist/web/osm2geojson-lite.js +0 -1
- /package/dist/{node/polytags.json → polytags.json} +0 -0
package/package.json
CHANGED
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
"name": "osm2geojson-lite",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "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",
|
|
5
|
+
"author": "tibetty",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/**/*.js",
|
|
19
|
+
"dist/**/*.mjs",
|
|
20
|
+
"dist/**/*.d.ts",
|
|
21
|
+
"dist/**/*.json"
|
|
20
22
|
],
|
|
21
|
-
"
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "rolldown -c && cp src/polytags.json dist/",
|
|
25
|
+
"test": "vitest test/e2e.test.ts --coverage"
|
|
26
|
+
},
|
|
27
|
+
"optionalDependencies": {
|
|
28
|
+
"@types/geojson": "^7946.0.16"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^24.12.2",
|
|
32
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
33
|
+
"rolldown": "^1.0.0-rc.18",
|
|
34
|
+
"rolldown-plugin-dts": "^0.24.1",
|
|
35
|
+
"typescript": "^6.0.3",
|
|
36
|
+
"vitest": "^4.1.5"
|
|
37
|
+
},
|
|
22
38
|
"bin": {
|
|
23
|
-
"osm2geojson-lite": "
|
|
39
|
+
"osm2geojson-lite": "dist/cli.mjs"
|
|
40
|
+
},
|
|
41
|
+
"directories": {
|
|
42
|
+
"lib": "lib",
|
|
43
|
+
"test": "test"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/tibetty/osm2geojson-lite.git"
|
|
24
48
|
},
|
|
25
49
|
"bugs": {
|
|
26
50
|
"url": "https://github.com/tibetty/osm2geojson-lite/issues"
|
|
27
51
|
},
|
|
28
|
-
"bundleDependencies": [],
|
|
29
|
-
"deprecated": false,
|
|
30
|
-
"description": "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",
|
|
31
52
|
"homepage": "https://github.com/tibetty/osm2geojson-lite#readme",
|
|
32
53
|
"keywords": [
|
|
33
54
|
"openstreetmap",
|
|
@@ -43,39 +64,5 @@
|
|
|
43
64
|
"multilinestring",
|
|
44
65
|
"polygon",
|
|
45
66
|
"multipolygon"
|
|
46
|
-
],
|
|
47
|
-
"license": "MIT",
|
|
48
|
-
"main": "dist/node/index.js",
|
|
49
|
-
"types": "dist/node/index.d.ts",
|
|
50
|
-
"name": "osm2geojson-lite",
|
|
51
|
-
"repository": {
|
|
52
|
-
"type": "git",
|
|
53
|
-
"url": "git+https://github.com/tibetty/osm2geojson-lite.git"
|
|
54
|
-
},
|
|
55
|
-
"scripts": {
|
|
56
|
-
"build-node": "tsc --declaration && cp src/polytags.json dist/node",
|
|
57
|
-
"build-web": "mkdir -p dist/web && browserify -s osm2geojson dist/node/index.js | uglifyjs -c -m -o dist/web/osm2geojson-lite.js",
|
|
58
|
-
"build": "npm run build-node && npm run build-web",
|
|
59
|
-
"test": "vitest test/e2e.test.ts --coverage"
|
|
60
|
-
},
|
|
61
|
-
"optionalDependencies": {
|
|
62
|
-
"@types/geojson": "^7946.0.16"
|
|
63
|
-
},
|
|
64
|
-
"version": "1.2.0",
|
|
65
|
-
"directories": {
|
|
66
|
-
"lib": "lib",
|
|
67
|
-
"test": "test"
|
|
68
|
-
},
|
|
69
|
-
"devDependencies": {
|
|
70
|
-
"@vitest/coverage-v8": "^3.1.3",
|
|
71
|
-
"browserify": "^17.0.1",
|
|
72
|
-
"typescript": "^5.8.3",
|
|
73
|
-
"uglify-js": "^3.19.3",
|
|
74
|
-
"vitest": "^3.1.3"
|
|
75
|
-
},
|
|
76
|
-
"files": [
|
|
77
|
-
"dist/**/*.js",
|
|
78
|
-
"dist/**/*.ts",
|
|
79
|
-
"dist/**/*.json"
|
|
80
67
|
]
|
|
81
68
|
}
|
package/dist/node/index.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { FeatureCollection, GeometryObject } from 'geojson';
|
|
2
|
-
interface IOptions {
|
|
3
|
-
/**
|
|
4
|
-
* When it's set to `true`, the returned geojson will include all elements that meet the specified conditions in `FeatureCollection` format;
|
|
5
|
-
* otherwise, only the bare geometry of the first `relation` element will be returned.
|
|
6
|
-
* @default false
|
|
7
|
-
*/
|
|
8
|
-
completeFeature?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* When it's set to `true`, the returned geojson will include all elements with tags (i.e., tagged)
|
|
11
|
-
* until `suppressWay` changes its behavior a bit; otherwise only the unreferenced ones get returned.
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
renderTagged?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* When it's set to `true`, the returned `FeatureCollection` will exclude all referenced `way`s even though they are tagged;
|
|
17
|
-
* otherwise the features of those `way`s will be included in the resulted result as well.
|
|
18
|
-
* @default true
|
|
19
|
-
*/
|
|
20
|
-
excludeWay?: boolean;
|
|
21
|
-
}
|
|
22
|
-
declare function osm2geojson(osm: string | {
|
|
23
|
-
[k: string]: any;
|
|
24
|
-
}, opts?: IOptions): FeatureCollection<GeometryObject>;
|
|
25
|
-
export = osm2geojson;
|
package/dist/node/index.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const utils_1 = require("./utils");
|
|
3
|
-
const xmlparser_1 = require("./xmlparser");
|
|
4
|
-
const node_1 = require("./node");
|
|
5
|
-
const way_1 = require("./way");
|
|
6
|
-
const relation_1 = require("./relation");
|
|
7
|
-
const ref_elements_1 = require("./ref-elements");
|
|
8
|
-
function parseOptions(options) {
|
|
9
|
-
if (!options) {
|
|
10
|
-
return { completeFeature: false, renderTagged: false, excludeWay: true };
|
|
11
|
-
}
|
|
12
|
-
let excludeWay = options.excludeWay === undefined || options.excludeWay;
|
|
13
|
-
let completeFeature = options.completeFeature ? true : false;
|
|
14
|
-
let renderTagged = options.renderTagged ? true : false;
|
|
15
|
-
return { completeFeature, renderTagged, excludeWay };
|
|
16
|
-
}
|
|
17
|
-
function detectFormat(o) {
|
|
18
|
-
if (o.elements) {
|
|
19
|
-
return 'json';
|
|
20
|
-
}
|
|
21
|
-
if (o.indexOf('<osm') >= 0) {
|
|
22
|
-
return 'xml';
|
|
23
|
-
}
|
|
24
|
-
if (o.trim().startsWith('{')) {
|
|
25
|
-
return 'json-raw';
|
|
26
|
-
}
|
|
27
|
-
return 'invalid';
|
|
28
|
-
}
|
|
29
|
-
;
|
|
30
|
-
function analyzeFeaturesFromJson(osm, refElements) {
|
|
31
|
-
for (const elem of osm.elements) {
|
|
32
|
-
switch (elem.type) {
|
|
33
|
-
case 'node':
|
|
34
|
-
const node = new node_1.Node(elem.id, refElements);
|
|
35
|
-
if (elem.tags) {
|
|
36
|
-
node.addTags(elem.tags);
|
|
37
|
-
}
|
|
38
|
-
node.addProps((0, utils_1.purgeProps)(elem, ['id', 'type', 'tags', 'lat', 'lon']));
|
|
39
|
-
node.setLatLng(elem);
|
|
40
|
-
break;
|
|
41
|
-
case 'way':
|
|
42
|
-
const way = new way_1.Way(elem.id, refElements);
|
|
43
|
-
if (elem.tags) {
|
|
44
|
-
way.addTags(elem.tags);
|
|
45
|
-
}
|
|
46
|
-
way.addProps((0, utils_1.purgeProps)(elem, ['id', 'type', 'tags', 'nodes', 'geometry']));
|
|
47
|
-
if (elem.geometry) {
|
|
48
|
-
way.setLatLngArray(elem.geometry);
|
|
49
|
-
}
|
|
50
|
-
else if (elem.nodes) {
|
|
51
|
-
for (const n of elem.nodes) {
|
|
52
|
-
way.addNodeRef(n);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
break;
|
|
56
|
-
case 'relation':
|
|
57
|
-
const relation = new relation_1.Relation(elem.id, refElements);
|
|
58
|
-
if (elem.bounds) {
|
|
59
|
-
relation.setBounds([parseFloat(elem.bounds.minlon), parseFloat(elem.bounds.minlat), parseFloat(elem.bounds.maxlon), parseFloat(elem.bounds.maxlat)]);
|
|
60
|
-
}
|
|
61
|
-
if (elem.tags) {
|
|
62
|
-
relation.addTags(elem.tags);
|
|
63
|
-
}
|
|
64
|
-
relation.addProps((0, utils_1.purgeProps)(elem, ['id', 'type', 'tags', 'bounds', 'members']));
|
|
65
|
-
if (elem.members) {
|
|
66
|
-
for (const member of elem.members) {
|
|
67
|
-
relation.addMember(member);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
default:
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function analyzeFeaturesFromXml(osm, refElements) {
|
|
76
|
-
const xmlParser = new xmlparser_1.XmlParser({ progressive: true });
|
|
77
|
-
xmlParser.on('</osm.node>', (node) => {
|
|
78
|
-
const nd = new node_1.Node(node.id, refElements);
|
|
79
|
-
for (const [k, v] of Object.entries(node)) {
|
|
80
|
-
if (!k.startsWith('$') && ['id', 'lon', 'lat'].indexOf(k) < 0) {
|
|
81
|
-
nd.addProp(k, v);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
nd.setLatLng(node);
|
|
85
|
-
if (node.$innerNodes) {
|
|
86
|
-
for (const ind of node.$innerNodes) {
|
|
87
|
-
if (ind.$tag === 'tag') {
|
|
88
|
-
nd.addTag(ind.k, ind.v);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
xmlParser.on('</osm.way>', (node) => {
|
|
94
|
-
const way = new way_1.Way(node.id, refElements);
|
|
95
|
-
for (const [k, v] of Object.entries(node)) {
|
|
96
|
-
if (!k.startsWith('$') && ['id'].indexOf(k) < 0) {
|
|
97
|
-
way.addProp(k, v);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (node.$innerNodes) {
|
|
101
|
-
for (const ind of node.$innerNodes) {
|
|
102
|
-
if (ind.$tag === 'nd') {
|
|
103
|
-
if (ind.lon && ind.lat) {
|
|
104
|
-
way.addLatLng(ind);
|
|
105
|
-
}
|
|
106
|
-
else if (ind.ref) {
|
|
107
|
-
way.addNodeRef(ind.ref);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (ind.$tag === 'tag') {
|
|
111
|
-
way.addTag(ind.k, ind.v);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
xmlParser.on('<osm.relation>', (node) => new relation_1.Relation(node.id, refElements));
|
|
117
|
-
xmlParser.on('</osm.relation.member>', (node, parent) => {
|
|
118
|
-
const relation = refElements.get(`relation/${parent === null || parent === void 0 ? void 0 : parent.id}`);
|
|
119
|
-
const member = {
|
|
120
|
-
type: node.type,
|
|
121
|
-
role: node.role ? node.role : '',
|
|
122
|
-
ref: node.ref,
|
|
123
|
-
};
|
|
124
|
-
if (node.lat && node.lon) {
|
|
125
|
-
member.lat = node.lat, member.lon = node.lon, member.tags = {};
|
|
126
|
-
for (const [k, v] of Object.entries(node)) {
|
|
127
|
-
if (!k.startsWith('$') && ['type', 'lat', 'lon'].indexOf(k) < 0) {
|
|
128
|
-
member[k] = v;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (node.$innerNodes) {
|
|
133
|
-
const geometry = [];
|
|
134
|
-
const nodes = [];
|
|
135
|
-
for (const ind of node.$innerNodes) {
|
|
136
|
-
if (ind.lat && ind.lon) {
|
|
137
|
-
geometry.push(ind);
|
|
138
|
-
}
|
|
139
|
-
else if (ind.ref) {
|
|
140
|
-
nodes.push(ind.ref);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (geometry.length > 0) {
|
|
144
|
-
member.geometry = geometry;
|
|
145
|
-
}
|
|
146
|
-
else if (nodes.length > 0) {
|
|
147
|
-
member.nodes = nodes;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
relation.addMember(member);
|
|
151
|
-
});
|
|
152
|
-
xmlParser.on('</osm.relation.bounds>', (node, parent) => {
|
|
153
|
-
refElements.get(`relation/${parent === null || parent === void 0 ? void 0 : parent.id}`).setBounds([parseFloat(node.minlon), parseFloat(node.minlat), parseFloat(node.maxlon), parseFloat(node.maxlat)]);
|
|
154
|
-
});
|
|
155
|
-
xmlParser.on('</osm.relation.tag>', (node, parent) => {
|
|
156
|
-
refElements.get(`relation/${parent === null || parent === void 0 ? void 0 : parent.id}`).addTag(node.k, node.v);
|
|
157
|
-
});
|
|
158
|
-
xmlParser.parse(osm);
|
|
159
|
-
}
|
|
160
|
-
;
|
|
161
|
-
function osm2geojson(osm, opts) {
|
|
162
|
-
let { completeFeature, renderTagged, excludeWay } = parseOptions(opts);
|
|
163
|
-
let format = detectFormat(osm);
|
|
164
|
-
const refElements = new ref_elements_1.RefElements();
|
|
165
|
-
let featureArray = [];
|
|
166
|
-
if (format === 'json-raw') {
|
|
167
|
-
osm = JSON.parse(osm);
|
|
168
|
-
if (osm.elements) {
|
|
169
|
-
format = 'json';
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
format = 'invalid';
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (format === 'json') {
|
|
176
|
-
analyzeFeaturesFromJson(osm, refElements);
|
|
177
|
-
}
|
|
178
|
-
else if (format === 'xml') {
|
|
179
|
-
analyzeFeaturesFromXml(osm, refElements);
|
|
180
|
-
}
|
|
181
|
-
refElements.bindAll();
|
|
182
|
-
for (const v of refElements.values()) {
|
|
183
|
-
if (v.refCount > 0 && (!v.hasTag || !renderTagged || (v instanceof way_1.Way && excludeWay))) {
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
const features = v.toFeatureArray();
|
|
187
|
-
// return the first geometry of the first relation element
|
|
188
|
-
if (v instanceof relation_1.Relation && !completeFeature && features.length > 0) {
|
|
189
|
-
return features[0].geometry;
|
|
190
|
-
}
|
|
191
|
-
featureArray = featureArray.concat(features);
|
|
192
|
-
}
|
|
193
|
-
return { type: 'FeatureCollection', features: featureArray };
|
|
194
|
-
}
|
|
195
|
-
;
|
|
196
|
-
module.exports = osm2geojson;
|
package/dist/node/late-binder.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LateBinder = void 0;
|
|
4
|
-
class LateBinder {
|
|
5
|
-
constructor(container, valueFunc, ctx, args) {
|
|
6
|
-
this.container = container;
|
|
7
|
-
this.valueFunc = valueFunc;
|
|
8
|
-
this.ctx = ctx;
|
|
9
|
-
this.args = args;
|
|
10
|
-
}
|
|
11
|
-
bind() {
|
|
12
|
-
const v = this.valueFunc.apply(this.ctx, this.args);
|
|
13
|
-
const idx = this.container.indexOf(this);
|
|
14
|
-
if (idx < 0) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const args = [idx, 1];
|
|
18
|
-
if (v) {
|
|
19
|
-
args.push(v);
|
|
20
|
-
}
|
|
21
|
-
Array.prototype.splice.apply(this.container, args);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.LateBinder = LateBinder;
|
package/dist/node/node.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { OsmObject } from "./osm-object";
|
|
2
|
-
import type { RefElements } from "./ref-elements";
|
|
3
|
-
import type { Feature } from "geojson";
|
|
4
|
-
export type LatLon = {
|
|
5
|
-
lat: string;
|
|
6
|
-
lon: string;
|
|
7
|
-
};
|
|
8
|
-
export declare class Node extends OsmObject {
|
|
9
|
-
private latLng;
|
|
10
|
-
constructor(id: string, refElems: RefElements);
|
|
11
|
-
setLatLng(latLng: LatLon): void;
|
|
12
|
-
toFeatureArray(): Array<Feature<any, any>>;
|
|
13
|
-
getLatLng(): LatLon | undefined;
|
|
14
|
-
}
|
package/dist/node/node.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Node = void 0;
|
|
4
|
-
const osm_object_1 = require("./osm-object");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
class Node extends osm_object_1.OsmObject {
|
|
7
|
-
constructor(id, refElems) {
|
|
8
|
-
super('node', id, refElems);
|
|
9
|
-
}
|
|
10
|
-
setLatLng(latLng) {
|
|
11
|
-
this.latLng = latLng;
|
|
12
|
-
}
|
|
13
|
-
toFeatureArray() {
|
|
14
|
-
if (this.latLng) {
|
|
15
|
-
return [{
|
|
16
|
-
type: 'Feature',
|
|
17
|
-
id: this.getCompositeId(),
|
|
18
|
-
properties: this.getProps(),
|
|
19
|
-
geometry: {
|
|
20
|
-
type: 'Point',
|
|
21
|
-
coordinates: (0, utils_1.strArrayToFloat)([this.latLng.lon, this.latLng.lat]),
|
|
22
|
-
},
|
|
23
|
-
}];
|
|
24
|
-
}
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
getLatLng() {
|
|
28
|
-
return this.latLng;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.Node = Node;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { RefElements } from './ref-elements';
|
|
2
|
-
import type { Feature } from 'geojson';
|
|
3
|
-
export declare abstract class OsmObject {
|
|
4
|
-
refCount: number;
|
|
5
|
-
hasTag: boolean;
|
|
6
|
-
id: string;
|
|
7
|
-
protected refElems: RefElements;
|
|
8
|
-
private type;
|
|
9
|
-
private tags;
|
|
10
|
-
private props;
|
|
11
|
-
constructor(type: string, id: string, refElems: RefElements);
|
|
12
|
-
addTags(tags: {
|
|
13
|
-
[k: string]: string;
|
|
14
|
-
}): void;
|
|
15
|
-
addTag(k: string, v: string): void;
|
|
16
|
-
addProp(k: string, v: any): void;
|
|
17
|
-
addProps(props: {
|
|
18
|
-
[k: string]: string;
|
|
19
|
-
}): void;
|
|
20
|
-
getCompositeId(): string;
|
|
21
|
-
getProps(): {
|
|
22
|
-
[k: string]: string;
|
|
23
|
-
};
|
|
24
|
-
abstract toFeatureArray(): Array<Feature<any, any>>;
|
|
25
|
-
}
|
package/dist/node/osm-object.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OsmObject = void 0;
|
|
4
|
-
class OsmObject {
|
|
5
|
-
constructor(type, id, refElems) {
|
|
6
|
-
this.type = type;
|
|
7
|
-
this.id = id;
|
|
8
|
-
this.refElems = refElems;
|
|
9
|
-
this.tags = {};
|
|
10
|
-
this.props = { id: this.getCompositeId() };
|
|
11
|
-
this.refCount = 0;
|
|
12
|
-
this.hasTag = false;
|
|
13
|
-
if (refElems) {
|
|
14
|
-
refElems.add(this.getCompositeId(), this);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
addTags(tags) {
|
|
18
|
-
this.tags = Object.assign(this.tags, tags);
|
|
19
|
-
this.hasTag = true;
|
|
20
|
-
}
|
|
21
|
-
addTag(k, v) {
|
|
22
|
-
this.tags[k] = v;
|
|
23
|
-
this.hasTag = true;
|
|
24
|
-
}
|
|
25
|
-
addProp(k, v) {
|
|
26
|
-
this.props[k] = v;
|
|
27
|
-
}
|
|
28
|
-
addProps(props) {
|
|
29
|
-
this.props = Object.assign(this.props, props);
|
|
30
|
-
}
|
|
31
|
-
getCompositeId() {
|
|
32
|
-
return `${this.type}/${this.id}`;
|
|
33
|
-
}
|
|
34
|
-
getProps() {
|
|
35
|
-
return Object.assign(this.props, this.tags);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.OsmObject = OsmObject;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { LateBinder } from "./late-binder";
|
|
2
|
-
import type { OsmObject } from "./osm-object";
|
|
3
|
-
export declare class RefElements extends Map<string, OsmObject> {
|
|
4
|
-
private binders;
|
|
5
|
-
constructor();
|
|
6
|
-
add(k: string, v: OsmObject): void;
|
|
7
|
-
addBinder(binder: LateBinder<any>): void;
|
|
8
|
-
bindAll(): void;
|
|
9
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RefElements = void 0;
|
|
4
|
-
class RefElements extends Map {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.binders = [];
|
|
8
|
-
}
|
|
9
|
-
add(k, v) {
|
|
10
|
-
this.set(k, v);
|
|
11
|
-
}
|
|
12
|
-
addBinder(binder) {
|
|
13
|
-
this.binders.push(binder);
|
|
14
|
-
}
|
|
15
|
-
bindAll() {
|
|
16
|
-
this.binders.forEach((binder) => binder.bind());
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.RefElements = RefElements;
|
package/dist/node/relation.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { OsmObject } from "./osm-object";
|
|
2
|
-
import { Way } from "./way";
|
|
3
|
-
import { LateBinder } from "./late-binder";
|
|
4
|
-
import type { RefElements } from "./ref-elements";
|
|
5
|
-
import type { Feature } from "geojson";
|
|
6
|
-
export declare class Relation extends OsmObject {
|
|
7
|
-
private relations;
|
|
8
|
-
private nodes;
|
|
9
|
-
private bounds;
|
|
10
|
-
ways: (LateBinder<Way> | Way)[];
|
|
11
|
-
roles: string[];
|
|
12
|
-
constructor(id: string, refElems: RefElements);
|
|
13
|
-
setBounds(bounds: any[]): void;
|
|
14
|
-
addMember(member: {
|
|
15
|
-
[k: string]: any;
|
|
16
|
-
}): void;
|
|
17
|
-
private constructStringGeometry;
|
|
18
|
-
private constructPolygonGeometry;
|
|
19
|
-
private collectAllWaysForRelation;
|
|
20
|
-
toFeatureArray(): Array<Feature<any, any>>;
|
|
21
|
-
}
|