osm2geojson-lite 0.9.2 → 0.9.4
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/bench/o2gl-bench.js +4 -4
- package/bench/otg-bench.js +4 -4
- package/bench/package-lock.json +67 -300
- package/bench/package.json +1 -1
- package/dist/osm2geojson-lite.js +1 -1
- package/lib/index.js +11 -11
- package/lib/osmobjs.js +29 -29
- package/lib/utils.js +17 -15
- package/lib/xmlparser.js +13 -13
- package/osm2geojson-lite +2 -4
- package/package.json +1 -1
- package/test/osm2geojson +5 -7
- package/test/package.json +0 -4
package/bench/o2gl-bench.js
CHANGED
|
@@ -8,24 +8,24 @@ console.log('==========xml processing performance results==========');
|
|
|
8
8
|
const xmlFiles = ['zhucheng.osm', 'hebei.osm', 'tokyodo.osm', 'usa.osm'];
|
|
9
9
|
for (let file of xmlFiles) {
|
|
10
10
|
let osm = fs.readFileSync(`./data/${file}`, 'utf-8');
|
|
11
|
-
console.log(`---processing
|
|
11
|
+
console.log(`---processing ${file}---`);
|
|
12
12
|
let stime = new Date().getTime();
|
|
13
13
|
for (let i = 0; i < rounds; i++) {
|
|
14
14
|
osm2geojson(osm, {completeFeature: true});
|
|
15
15
|
}
|
|
16
16
|
let etime = new Date().getTime();
|
|
17
|
-
console.log(
|
|
17
|
+
console.log(`-> ${etime - stime}ms was taken for ${rounds} rounds`);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
console.log('==========json processing performance results==========');
|
|
21
21
|
const jsonFiles = ['zhucheng.json', 'hebei.json', 'tokyodo.json', 'usa.json'];
|
|
22
22
|
for (let file of jsonFiles) {
|
|
23
23
|
let osm = require(`./data/${file}`);
|
|
24
|
-
console.log(`---processing
|
|
24
|
+
console.log(`---processing ${file}---`);
|
|
25
25
|
let stime = new Date().getTime();
|
|
26
26
|
for (let i = 0; i < rounds; i++) {
|
|
27
27
|
osm2geojson(osm, {completeFeature: true});
|
|
28
28
|
}
|
|
29
29
|
etime = new Date().getTime();
|
|
30
|
-
console.log(
|
|
30
|
+
console.log(`-> ${etime - stime}ms was taken for ${rounds} rounds`);
|
|
31
31
|
}
|
package/bench/otg-bench.js
CHANGED
|
@@ -9,24 +9,24 @@ console.log('==========xml processing performance results==========');
|
|
|
9
9
|
const xmlFiles = ['zhucheng.osm', 'hebei.osm', 'tokyodo.osm', 'usa.osm'];
|
|
10
10
|
for (let file of xmlFiles) {
|
|
11
11
|
let osm = fs.readFileSync(`./data/${file}`, 'utf-8');
|
|
12
|
-
console.log(`---processing
|
|
12
|
+
console.log(`---processing ${file}---`);
|
|
13
13
|
let stime = new Date().getTime();
|
|
14
14
|
for (let i = 0; i < rounds; i++) {
|
|
15
15
|
const osmdom = new DOMParser().parseFromString(osm);
|
|
16
16
|
osmtogeojson(osmdom);
|
|
17
17
|
}
|
|
18
18
|
let etime = new Date().getTime();
|
|
19
|
-
console.log(
|
|
19
|
+
console.log(`-> ${etime - stime}ms was taken for ${rounds} rounds`);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
console.log('==========json processing performance results==========');
|
|
23
23
|
const jsonFiles = ['zhucheng.json', 'hebei.json', 'tokyodo.json', 'usa.json'];
|
|
24
24
|
for (let file of jsonFiles) {
|
|
25
25
|
let osm = require(`./data/${file}`);
|
|
26
|
-
console.log(`---processing
|
|
26
|
+
console.log(`---processing ${file}---`);
|
|
27
27
|
let stime = new Date().getTime();
|
|
28
28
|
for (let i = 0; i < rounds; i++)
|
|
29
29
|
osmtogeojson(osm);
|
|
30
30
|
etime = new Date().getTime();
|
|
31
|
-
console.log(
|
|
31
|
+
console.log(`-> ${etime - stime}ms was taken for ${rounds} rounds`);
|
|
32
32
|
}
|
package/bench/package-lock.json
CHANGED
|
@@ -9,101 +9,41 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"osmtogeojson": "^3.0.0-beta.
|
|
12
|
+
"osmtogeojson": "^3.0.0-beta.4",
|
|
13
13
|
"xmldom": "^0.6.0"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"node_modules/@mapbox/geojson-area": {
|
|
17
|
-
"version": "0.2.2",
|
|
18
|
-
"resolved": "https://registry.npmjs.org/@mapbox/geojson-area/-/geojson-area-0.2.2.tgz",
|
|
19
|
-
"integrity": "sha1-GNeBSqNr8j+7zDefjiaiKSfevxA=",
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"wgs84": "0.0.0"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
16
|
"node_modules/@mapbox/geojson-rewind": {
|
|
25
|
-
"version": "0.
|
|
26
|
-
"resolved": "https://registry.npmjs.org/@mapbox/geojson-rewind/-/geojson-rewind-0.
|
|
27
|
-
"integrity": "sha512-
|
|
17
|
+
"version": "0.5.2",
|
|
18
|
+
"resolved": "https://registry.npmjs.org/@mapbox/geojson-rewind/-/geojson-rewind-0.5.2.tgz",
|
|
19
|
+
"integrity": "sha512-tJaT+RbYGJYStt7wI3cq4Nl4SXxG8W7JDG5DMJu97V25RnbNg3QtQtf+KD+VLjNpWKYsRvXDNmNrBgEETr1ifA==",
|
|
28
20
|
"dependencies": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"minimist": "1.2.0",
|
|
32
|
-
"sharkdown": "^0.1.0"
|
|
21
|
+
"get-stream": "^6.0.1",
|
|
22
|
+
"minimist": "^1.2.6"
|
|
33
23
|
},
|
|
34
24
|
"bin": {
|
|
35
25
|
"geojson-rewind": "geojson-rewind"
|
|
36
26
|
}
|
|
37
27
|
},
|
|
38
|
-
"node_modules/@mapbox/geojson-rewind/node_modules/concat-stream": {
|
|
39
|
-
"version": "1.6.2",
|
|
40
|
-
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
|
41
|
-
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
|
42
|
-
"engines": [
|
|
43
|
-
"node >= 0.8"
|
|
44
|
-
],
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"buffer-from": "^1.0.0",
|
|
47
|
-
"inherits": "^2.0.3",
|
|
48
|
-
"readable-stream": "^2.2.2",
|
|
49
|
-
"typedarray": "^0.0.6"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"node_modules/@mapbox/geojson-rewind/node_modules/readable-stream": {
|
|
53
|
-
"version": "2.3.7",
|
|
54
|
-
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
|
|
55
|
-
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"core-util-is": "~1.0.0",
|
|
58
|
-
"inherits": "~2.0.3",
|
|
59
|
-
"isarray": "~1.0.0",
|
|
60
|
-
"process-nextick-args": "~2.0.0",
|
|
61
|
-
"safe-buffer": "~5.1.1",
|
|
62
|
-
"string_decoder": "~1.1.1",
|
|
63
|
-
"util-deprecate": "~1.0.1"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"node_modules/@mapbox/geojson-rewind/node_modules/safe-buffer": {
|
|
67
|
-
"version": "5.1.2",
|
|
68
|
-
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
|
69
|
-
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
|
70
|
-
},
|
|
71
|
-
"node_modules/@mapbox/geojson-rewind/node_modules/string_decoder": {
|
|
72
|
-
"version": "1.1.1",
|
|
73
|
-
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
|
74
|
-
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
|
75
|
-
"dependencies": {
|
|
76
|
-
"safe-buffer": "~5.1.0"
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
28
|
"node_modules/@types/geojson": {
|
|
80
|
-
"version": "
|
|
81
|
-
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-
|
|
82
|
-
"integrity": "sha512-
|
|
29
|
+
"version": "7946.0.10",
|
|
30
|
+
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.10.tgz",
|
|
31
|
+
"integrity": "sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==",
|
|
83
32
|
"optional": true
|
|
84
33
|
},
|
|
85
|
-
"node_modules/
|
|
86
|
-
"version": "0.
|
|
87
|
-
"resolved": "https://registry.npmjs.org/
|
|
88
|
-
"integrity": "
|
|
34
|
+
"node_modules/@xmldom/xmldom": {
|
|
35
|
+
"version": "0.8.3",
|
|
36
|
+
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.3.tgz",
|
|
37
|
+
"integrity": "sha512-Lv2vySXypg4nfa51LY1nU8yDAGo/5YwF+EY/rUZgIbfvwVARcd67ttCM8SMsTeJy51YhHYavEq+FS6R0hW9PFQ==",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=10.0.0"
|
|
40
|
+
}
|
|
89
41
|
},
|
|
90
42
|
"node_modules/buffer-from": {
|
|
91
43
|
"version": "1.1.2",
|
|
92
44
|
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
|
93
45
|
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
|
|
94
46
|
},
|
|
95
|
-
"node_modules/cardinal": {
|
|
96
|
-
"version": "0.4.4",
|
|
97
|
-
"resolved": "https://registry.npmjs.org/cardinal/-/cardinal-0.4.4.tgz",
|
|
98
|
-
"integrity": "sha1-ylu2iltRG5D+k7ms6km97lwyv+I=",
|
|
99
|
-
"dependencies": {
|
|
100
|
-
"ansicolors": "~0.2.1",
|
|
101
|
-
"redeyed": "~0.4.0"
|
|
102
|
-
},
|
|
103
|
-
"bin": {
|
|
104
|
-
"cdl": "bin/cdl.js"
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
47
|
"node_modules/concat-stream": {
|
|
108
48
|
"version": "2.0.0",
|
|
109
49
|
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
|
|
@@ -144,18 +84,6 @@
|
|
|
144
84
|
"domelementtype": "1"
|
|
145
85
|
}
|
|
146
86
|
},
|
|
147
|
-
"node_modules/esprima": {
|
|
148
|
-
"version": "1.0.4",
|
|
149
|
-
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz",
|
|
150
|
-
"integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=",
|
|
151
|
-
"bin": {
|
|
152
|
-
"esparse": "bin/esparse.js",
|
|
153
|
-
"esvalidate": "bin/esvalidate.js"
|
|
154
|
-
},
|
|
155
|
-
"engines": {
|
|
156
|
-
"node": ">=0.4.0"
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
87
|
"node_modules/geojson-numeric": {
|
|
160
88
|
"version": "0.2.1",
|
|
161
89
|
"resolved": "https://registry.npmjs.org/geojson-numeric/-/geojson-numeric-0.2.1.tgz",
|
|
@@ -168,6 +96,17 @@
|
|
|
168
96
|
"geojson-numeric": "geojson-numeric"
|
|
169
97
|
}
|
|
170
98
|
},
|
|
99
|
+
"node_modules/get-stream": {
|
|
100
|
+
"version": "6.0.1",
|
|
101
|
+
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
|
|
102
|
+
"integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==",
|
|
103
|
+
"engines": {
|
|
104
|
+
"node": ">=10"
|
|
105
|
+
},
|
|
106
|
+
"funding": {
|
|
107
|
+
"url": "https://github.com/sponsors/sindresorhus"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
171
110
|
"node_modules/htmlparser2": {
|
|
172
111
|
"version": "3.5.1",
|
|
173
112
|
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.5.1.tgz",
|
|
@@ -224,11 +163,6 @@
|
|
|
224
163
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
|
225
164
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
|
226
165
|
},
|
|
227
|
-
"node_modules/isarray": {
|
|
228
|
-
"version": "1.0.0",
|
|
229
|
-
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
|
230
|
-
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
|
231
|
-
},
|
|
232
166
|
"node_modules/jsonparse": {
|
|
233
167
|
"version": "0.0.5",
|
|
234
168
|
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz",
|
|
@@ -250,9 +184,12 @@
|
|
|
250
184
|
}
|
|
251
185
|
},
|
|
252
186
|
"node_modules/minimist": {
|
|
253
|
-
"version": "1.2.
|
|
254
|
-
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.
|
|
255
|
-
"integrity": "
|
|
187
|
+
"version": "1.2.8",
|
|
188
|
+
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
|
189
|
+
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
|
190
|
+
"funding": {
|
|
191
|
+
"url": "https://github.com/sponsors/ljharb"
|
|
192
|
+
}
|
|
256
193
|
},
|
|
257
194
|
"node_modules/optimist": {
|
|
258
195
|
"version": "0.3.7",
|
|
@@ -268,19 +205,19 @@
|
|
|
268
205
|
"integrity": "sha1-IK5BEwxIbkmjsqPCtYoUGcSYZ3g="
|
|
269
206
|
},
|
|
270
207
|
"node_modules/osmtogeojson": {
|
|
271
|
-
"version": "3.0.0-beta.
|
|
272
|
-
"resolved": "https://registry.npmjs.org/osmtogeojson/-/osmtogeojson-3.0.0-beta.
|
|
273
|
-
"integrity": "sha512-
|
|
208
|
+
"version": "3.0.0-beta.5",
|
|
209
|
+
"resolved": "https://registry.npmjs.org/osmtogeojson/-/osmtogeojson-3.0.0-beta.5.tgz",
|
|
210
|
+
"integrity": "sha512-izvaUWnunrYvMB4LB0ZN15O1+g90c628yHS4SeSR3daVSBF9vdTHL7iVHfg0wEr1uEYjQ+lMJHCiYFusL5yKVg==",
|
|
274
211
|
"dependencies": {
|
|
275
|
-
"@mapbox/geojson-rewind": "0.
|
|
212
|
+
"@mapbox/geojson-rewind": "0.5.2",
|
|
213
|
+
"@xmldom/xmldom": "0.8.3",
|
|
276
214
|
"concat-stream": "2.0.0",
|
|
277
215
|
"geojson-numeric": "0.2.1",
|
|
278
216
|
"htmlparser2": "3.5.1",
|
|
279
217
|
"JSONStream": "0.8.0",
|
|
280
218
|
"optimist": "~0.3.5",
|
|
281
219
|
"osm-polygon-features": "^0.9.1",
|
|
282
|
-
"tiny-osmpbf": "^0.1.0"
|
|
283
|
-
"xmldom": "~0.1.16"
|
|
220
|
+
"tiny-osmpbf": "^0.1.0"
|
|
284
221
|
},
|
|
285
222
|
"bin": {
|
|
286
223
|
"osmtogeojson": "osmtogeojson"
|
|
@@ -289,16 +226,7 @@
|
|
|
289
226
|
"node": ">=0.5"
|
|
290
227
|
},
|
|
291
228
|
"optionalDependencies": {
|
|
292
|
-
"@types/geojson": "^
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
"node_modules/osmtogeojson/node_modules/xmldom": {
|
|
296
|
-
"version": "0.1.31",
|
|
297
|
-
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz",
|
|
298
|
-
"integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==",
|
|
299
|
-
"deprecated": "Deprecated due to CVE-2021-21366 resolved in 0.5.0",
|
|
300
|
-
"engines": {
|
|
301
|
-
"node": ">=0.1"
|
|
229
|
+
"@types/geojson": "^7946.0"
|
|
302
230
|
}
|
|
303
231
|
},
|
|
304
232
|
"node_modules/pbf": {
|
|
@@ -313,11 +241,6 @@
|
|
|
313
241
|
"pbf": "bin/pbf"
|
|
314
242
|
}
|
|
315
243
|
},
|
|
316
|
-
"node_modules/process-nextick-args": {
|
|
317
|
-
"version": "2.0.1",
|
|
318
|
-
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
|
319
|
-
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
|
|
320
|
-
},
|
|
321
244
|
"node_modules/protocol-buffers-schema": {
|
|
322
245
|
"version": "3.6.0",
|
|
323
246
|
"resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz",
|
|
@@ -336,14 +259,6 @@
|
|
|
336
259
|
"node": ">= 6"
|
|
337
260
|
}
|
|
338
261
|
},
|
|
339
|
-
"node_modules/redeyed": {
|
|
340
|
-
"version": "0.4.4",
|
|
341
|
-
"resolved": "https://registry.npmjs.org/redeyed/-/redeyed-0.4.4.tgz",
|
|
342
|
-
"integrity": "sha1-N+mQpvKyGyoRwuakj9QTVpjLqX8=",
|
|
343
|
-
"dependencies": {
|
|
344
|
-
"esprima": "~1.0.4"
|
|
345
|
-
}
|
|
346
|
-
},
|
|
347
262
|
"node_modules/resolve-protobuf-schema": {
|
|
348
263
|
"version": "2.1.0",
|
|
349
264
|
"resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz",
|
|
@@ -371,35 +286,6 @@
|
|
|
371
286
|
}
|
|
372
287
|
]
|
|
373
288
|
},
|
|
374
|
-
"node_modules/sharkdown": {
|
|
375
|
-
"version": "0.1.1",
|
|
376
|
-
"resolved": "https://registry.npmjs.org/sharkdown/-/sharkdown-0.1.1.tgz",
|
|
377
|
-
"integrity": "sha512-exwooSpmo5s45lrexgz6Q0rFQM574wYIX3iDZ7RLLqOb7IAoQZu9nxlZODU972g19sR69OIpKP2cpHTzU+PHIg==",
|
|
378
|
-
"dependencies": {
|
|
379
|
-
"cardinal": "~0.4.2",
|
|
380
|
-
"minimist": "0.0.5",
|
|
381
|
-
"split": "~0.2.10"
|
|
382
|
-
},
|
|
383
|
-
"bin": {
|
|
384
|
-
"sharkdown": "sharkdown"
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
"node_modules/sharkdown/node_modules/minimist": {
|
|
388
|
-
"version": "0.0.5",
|
|
389
|
-
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz",
|
|
390
|
-
"integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY="
|
|
391
|
-
},
|
|
392
|
-
"node_modules/split": {
|
|
393
|
-
"version": "0.2.10",
|
|
394
|
-
"resolved": "https://registry.npmjs.org/split/-/split-0.2.10.tgz",
|
|
395
|
-
"integrity": "sha1-Zwl8YB1pfOE2j0GPBs0gHPBSGlc=",
|
|
396
|
-
"dependencies": {
|
|
397
|
-
"through": "2"
|
|
398
|
-
},
|
|
399
|
-
"engines": {
|
|
400
|
-
"node": "*"
|
|
401
|
-
}
|
|
402
|
-
},
|
|
403
289
|
"node_modules/string_decoder": {
|
|
404
290
|
"version": "1.3.0",
|
|
405
291
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
|
@@ -437,11 +323,6 @@
|
|
|
437
323
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
|
438
324
|
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
|
439
325
|
},
|
|
440
|
-
"node_modules/wgs84": {
|
|
441
|
-
"version": "0.0.0",
|
|
442
|
-
"resolved": "https://registry.npmjs.org/wgs84/-/wgs84-0.0.0.tgz",
|
|
443
|
-
"integrity": "sha1-NP3FVZF7blfPKigu0ENxDASc3HY="
|
|
444
|
-
},
|
|
445
326
|
"node_modules/wordwrap": {
|
|
446
327
|
"version": "0.0.3",
|
|
447
328
|
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",
|
|
@@ -460,90 +341,31 @@
|
|
|
460
341
|
}
|
|
461
342
|
},
|
|
462
343
|
"dependencies": {
|
|
463
|
-
"@mapbox/geojson-area": {
|
|
464
|
-
"version": "0.2.2",
|
|
465
|
-
"resolved": "https://registry.npmjs.org/@mapbox/geojson-area/-/geojson-area-0.2.2.tgz",
|
|
466
|
-
"integrity": "sha1-GNeBSqNr8j+7zDefjiaiKSfevxA=",
|
|
467
|
-
"requires": {
|
|
468
|
-
"wgs84": "0.0.0"
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
344
|
"@mapbox/geojson-rewind": {
|
|
472
|
-
"version": "0.
|
|
473
|
-
"resolved": "https://registry.npmjs.org/@mapbox/geojson-rewind/-/geojson-rewind-0.
|
|
474
|
-
"integrity": "sha512-
|
|
345
|
+
"version": "0.5.2",
|
|
346
|
+
"resolved": "https://registry.npmjs.org/@mapbox/geojson-rewind/-/geojson-rewind-0.5.2.tgz",
|
|
347
|
+
"integrity": "sha512-tJaT+RbYGJYStt7wI3cq4Nl4SXxG8W7JDG5DMJu97V25RnbNg3QtQtf+KD+VLjNpWKYsRvXDNmNrBgEETr1ifA==",
|
|
475
348
|
"requires": {
|
|
476
|
-
"
|
|
477
|
-
"
|
|
478
|
-
"minimist": "1.2.0",
|
|
479
|
-
"sharkdown": "^0.1.0"
|
|
480
|
-
},
|
|
481
|
-
"dependencies": {
|
|
482
|
-
"concat-stream": {
|
|
483
|
-
"version": "1.6.2",
|
|
484
|
-
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
|
485
|
-
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
|
486
|
-
"requires": {
|
|
487
|
-
"buffer-from": "^1.0.0",
|
|
488
|
-
"inherits": "^2.0.3",
|
|
489
|
-
"readable-stream": "^2.2.2",
|
|
490
|
-
"typedarray": "^0.0.6"
|
|
491
|
-
}
|
|
492
|
-
},
|
|
493
|
-
"readable-stream": {
|
|
494
|
-
"version": "2.3.7",
|
|
495
|
-
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
|
|
496
|
-
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
|
|
497
|
-
"requires": {
|
|
498
|
-
"core-util-is": "~1.0.0",
|
|
499
|
-
"inherits": "~2.0.3",
|
|
500
|
-
"isarray": "~1.0.0",
|
|
501
|
-
"process-nextick-args": "~2.0.0",
|
|
502
|
-
"safe-buffer": "~5.1.1",
|
|
503
|
-
"string_decoder": "~1.1.1",
|
|
504
|
-
"util-deprecate": "~1.0.1"
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
"safe-buffer": {
|
|
508
|
-
"version": "5.1.2",
|
|
509
|
-
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
|
510
|
-
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
|
511
|
-
},
|
|
512
|
-
"string_decoder": {
|
|
513
|
-
"version": "1.1.1",
|
|
514
|
-
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
|
515
|
-
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
|
516
|
-
"requires": {
|
|
517
|
-
"safe-buffer": "~5.1.0"
|
|
518
|
-
}
|
|
519
|
-
}
|
|
349
|
+
"get-stream": "^6.0.1",
|
|
350
|
+
"minimist": "^1.2.6"
|
|
520
351
|
}
|
|
521
352
|
},
|
|
522
353
|
"@types/geojson": {
|
|
523
|
-
"version": "
|
|
524
|
-
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-
|
|
525
|
-
"integrity": "sha512-
|
|
354
|
+
"version": "7946.0.10",
|
|
355
|
+
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.10.tgz",
|
|
356
|
+
"integrity": "sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==",
|
|
526
357
|
"optional": true
|
|
527
358
|
},
|
|
528
|
-
"
|
|
529
|
-
"version": "0.
|
|
530
|
-
"resolved": "https://registry.npmjs.org/
|
|
531
|
-
"integrity": "
|
|
359
|
+
"@xmldom/xmldom": {
|
|
360
|
+
"version": "0.8.3",
|
|
361
|
+
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.3.tgz",
|
|
362
|
+
"integrity": "sha512-Lv2vySXypg4nfa51LY1nU8yDAGo/5YwF+EY/rUZgIbfvwVARcd67ttCM8SMsTeJy51YhHYavEq+FS6R0hW9PFQ=="
|
|
532
363
|
},
|
|
533
364
|
"buffer-from": {
|
|
534
365
|
"version": "1.1.2",
|
|
535
366
|
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
|
536
367
|
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
|
|
537
368
|
},
|
|
538
|
-
"cardinal": {
|
|
539
|
-
"version": "0.4.4",
|
|
540
|
-
"resolved": "https://registry.npmjs.org/cardinal/-/cardinal-0.4.4.tgz",
|
|
541
|
-
"integrity": "sha1-ylu2iltRG5D+k7ms6km97lwyv+I=",
|
|
542
|
-
"requires": {
|
|
543
|
-
"ansicolors": "~0.2.1",
|
|
544
|
-
"redeyed": "~0.4.0"
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
369
|
"concat-stream": {
|
|
548
370
|
"version": "2.0.0",
|
|
549
371
|
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
|
|
@@ -581,11 +403,6 @@
|
|
|
581
403
|
"domelementtype": "1"
|
|
582
404
|
}
|
|
583
405
|
},
|
|
584
|
-
"esprima": {
|
|
585
|
-
"version": "1.0.4",
|
|
586
|
-
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz",
|
|
587
|
-
"integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0="
|
|
588
|
-
},
|
|
589
406
|
"geojson-numeric": {
|
|
590
407
|
"version": "0.2.1",
|
|
591
408
|
"resolved": "https://registry.npmjs.org/geojson-numeric/-/geojson-numeric-0.2.1.tgz",
|
|
@@ -595,6 +412,11 @@
|
|
|
595
412
|
"optimist": "~0.3.5"
|
|
596
413
|
}
|
|
597
414
|
},
|
|
415
|
+
"get-stream": {
|
|
416
|
+
"version": "6.0.1",
|
|
417
|
+
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
|
|
418
|
+
"integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg=="
|
|
419
|
+
},
|
|
598
420
|
"htmlparser2": {
|
|
599
421
|
"version": "3.5.1",
|
|
600
422
|
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.5.1.tgz",
|
|
@@ -639,11 +461,6 @@
|
|
|
639
461
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
|
640
462
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
|
641
463
|
},
|
|
642
|
-
"isarray": {
|
|
643
|
-
"version": "1.0.0",
|
|
644
|
-
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
|
645
|
-
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
|
646
|
-
},
|
|
647
464
|
"jsonparse": {
|
|
648
465
|
"version": "0.0.5",
|
|
649
466
|
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz",
|
|
@@ -659,9 +476,9 @@
|
|
|
659
476
|
}
|
|
660
477
|
},
|
|
661
478
|
"minimist": {
|
|
662
|
-
"version": "1.2.
|
|
663
|
-
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.
|
|
664
|
-
"integrity": "
|
|
479
|
+
"version": "1.2.8",
|
|
480
|
+
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
|
481
|
+
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
|
|
665
482
|
},
|
|
666
483
|
"optimist": {
|
|
667
484
|
"version": "0.3.7",
|
|
@@ -677,27 +494,20 @@
|
|
|
677
494
|
"integrity": "sha1-IK5BEwxIbkmjsqPCtYoUGcSYZ3g="
|
|
678
495
|
},
|
|
679
496
|
"osmtogeojson": {
|
|
680
|
-
"version": "3.0.0-beta.
|
|
681
|
-
"resolved": "https://registry.npmjs.org/osmtogeojson/-/osmtogeojson-3.0.0-beta.
|
|
682
|
-
"integrity": "sha512-
|
|
497
|
+
"version": "3.0.0-beta.5",
|
|
498
|
+
"resolved": "https://registry.npmjs.org/osmtogeojson/-/osmtogeojson-3.0.0-beta.5.tgz",
|
|
499
|
+
"integrity": "sha512-izvaUWnunrYvMB4LB0ZN15O1+g90c628yHS4SeSR3daVSBF9vdTHL7iVHfg0wEr1uEYjQ+lMJHCiYFusL5yKVg==",
|
|
683
500
|
"requires": {
|
|
684
|
-
"@mapbox/geojson-rewind": "0.
|
|
685
|
-
"@types/geojson": "^
|
|
501
|
+
"@mapbox/geojson-rewind": "0.5.2",
|
|
502
|
+
"@types/geojson": "^7946.0",
|
|
503
|
+
"@xmldom/xmldom": "0.8.3",
|
|
686
504
|
"concat-stream": "2.0.0",
|
|
687
505
|
"geojson-numeric": "0.2.1",
|
|
688
506
|
"htmlparser2": "3.5.1",
|
|
689
507
|
"JSONStream": "0.8.0",
|
|
690
508
|
"optimist": "~0.3.5",
|
|
691
509
|
"osm-polygon-features": "^0.9.1",
|
|
692
|
-
"tiny-osmpbf": "^0.1.0"
|
|
693
|
-
"xmldom": "~0.1.16"
|
|
694
|
-
},
|
|
695
|
-
"dependencies": {
|
|
696
|
-
"xmldom": {
|
|
697
|
-
"version": "0.1.31",
|
|
698
|
-
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz",
|
|
699
|
-
"integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ=="
|
|
700
|
-
}
|
|
510
|
+
"tiny-osmpbf": "^0.1.0"
|
|
701
511
|
}
|
|
702
512
|
},
|
|
703
513
|
"pbf": {
|
|
@@ -709,11 +519,6 @@
|
|
|
709
519
|
"resolve-protobuf-schema": "^2.1.0"
|
|
710
520
|
}
|
|
711
521
|
},
|
|
712
|
-
"process-nextick-args": {
|
|
713
|
-
"version": "2.0.1",
|
|
714
|
-
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
|
715
|
-
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
|
|
716
|
-
},
|
|
717
522
|
"protocol-buffers-schema": {
|
|
718
523
|
"version": "3.6.0",
|
|
719
524
|
"resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz",
|
|
@@ -729,14 +534,6 @@
|
|
|
729
534
|
"util-deprecate": "^1.0.1"
|
|
730
535
|
}
|
|
731
536
|
},
|
|
732
|
-
"redeyed": {
|
|
733
|
-
"version": "0.4.4",
|
|
734
|
-
"resolved": "https://registry.npmjs.org/redeyed/-/redeyed-0.4.4.tgz",
|
|
735
|
-
"integrity": "sha1-N+mQpvKyGyoRwuakj9QTVpjLqX8=",
|
|
736
|
-
"requires": {
|
|
737
|
-
"esprima": "~1.0.4"
|
|
738
|
-
}
|
|
739
|
-
},
|
|
740
537
|
"resolve-protobuf-schema": {
|
|
741
538
|
"version": "2.1.0",
|
|
742
539
|
"resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz",
|
|
@@ -750,31 +547,6 @@
|
|
|
750
547
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
|
751
548
|
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
|
|
752
549
|
},
|
|
753
|
-
"sharkdown": {
|
|
754
|
-
"version": "0.1.1",
|
|
755
|
-
"resolved": "https://registry.npmjs.org/sharkdown/-/sharkdown-0.1.1.tgz",
|
|
756
|
-
"integrity": "sha512-exwooSpmo5s45lrexgz6Q0rFQM574wYIX3iDZ7RLLqOb7IAoQZu9nxlZODU972g19sR69OIpKP2cpHTzU+PHIg==",
|
|
757
|
-
"requires": {
|
|
758
|
-
"cardinal": "~0.4.2",
|
|
759
|
-
"minimist": "0.0.5",
|
|
760
|
-
"split": "~0.2.10"
|
|
761
|
-
},
|
|
762
|
-
"dependencies": {
|
|
763
|
-
"minimist": {
|
|
764
|
-
"version": "0.0.5",
|
|
765
|
-
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz",
|
|
766
|
-
"integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY="
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
},
|
|
770
|
-
"split": {
|
|
771
|
-
"version": "0.2.10",
|
|
772
|
-
"resolved": "https://registry.npmjs.org/split/-/split-0.2.10.tgz",
|
|
773
|
-
"integrity": "sha1-Zwl8YB1pfOE2j0GPBs0gHPBSGlc=",
|
|
774
|
-
"requires": {
|
|
775
|
-
"through": "2"
|
|
776
|
-
}
|
|
777
|
-
},
|
|
778
550
|
"string_decoder": {
|
|
779
551
|
"version": "1.3.0",
|
|
780
552
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
|
@@ -812,11 +584,6 @@
|
|
|
812
584
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
|
813
585
|
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
|
814
586
|
},
|
|
815
|
-
"wgs84": {
|
|
816
|
-
"version": "0.0.0",
|
|
817
|
-
"resolved": "https://registry.npmjs.org/wgs84/-/wgs84-0.0.0.tgz",
|
|
818
|
-
"integrity": "sha1-NP3FVZF7blfPKigu0ENxDASc3HY="
|
|
819
|
-
},
|
|
820
587
|
"wordwrap": {
|
|
821
588
|
"version": "0.0.3",
|
|
822
589
|
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",
|
package/bench/package.json
CHANGED
package/dist/osm2geojson-lite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).osm2geojson=e()}(function(){return function r(n,i,o){function a(t,e){if(!i[t]){if(!n[t]){var s="function"==typeof require&&require;if(!e&&s)return s(t,!0);if(l)return l(t,!0);throw(s=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",s}s=i[t]={exports:{}},n[t][0].call(s.exports,function(e){return a(n[t][1][e]||e)},s,s.exports,r,n,i,o)}return i[t].exports}for(var l="function"==typeof require&&require,e=0;e<o.length;e++)a(o[e]);return a}({1:[function(e,t,s){const{Node:h,Way:u,Relation:f}=e("./osmobjs.js"),{purgeProps:p,RefElements:g}=e("./utils.js"),c=e("./xmlparser.js");t.exports=(e,t)=>{let s=!1,r=!1,n=!0;(t=t)&&(s=!(!t.completeFeature&&!t.allFeatures),r=!!t.renderTagged,void 0===(t=t.suppressWay||t.excludeWay)||t||(n=!1));let i=(t=e).elements?"json":0<=t.indexOf("<osm")?"xml":t.trim().startsWith("{")?"json-raw":"invalid",a=new g,o=[];var l;"json-raw"===i&&(e=JSON.parse(e),i=e.elements?"json":"invalid"),"json"===i?(e=>{for(var r of e.elements)switch(r.type){case"node":let e=new h(r.id,a);r.tags&&e.addTags(r.tags),e.addProps(p(r,["id","type","tags","lat","lon"])),e.setLatLng(r);break;case"way":let t=new u(r.id,a);if(r.tags&&t.addTags(r.tags),t.addProps(p(r,["id","type","tags","nodes","geometry"])),r.nodes)for(var n of r.nodes)t.addNodeRef(n);else r.geometry&&t.setLatLngArray(r.geometry);break;case"relation":let s=new f(r.id,a);if(r.bounds&&s.setBounds([parseFloat(r.bounds.minlon),parseFloat(r.bounds.minlat),parseFloat(r.bounds.maxlon),parseFloat(r.bounds.maxlat)]),r.tags&&s.addTags(r.tags),s.addProps(p(r,["id","type","tags","bounds","members"])),r.members)for(var i of r.members)s.addMember(i)}})(e):"xml"===i&&(e=>{const t=new c({progressive:!0});t.on("</osm.node>",e=>{let t=new h(e.id,a);for(var[s,r]of Object.entries(e))!s.startsWith("$")&&["id","lon","lat"].indexOf(s)<0&&t.addProp(s,r);if(t.setLatLng(e),e.$innerNodes)for(var n of e.$innerNodes)"tag"===n.$tag&&t.addTag(n.k,n.v)}),t.on("</osm.way>",e=>{let t=new u(e.id,a);for(var[s,r]of Object.entries(e))!s.startsWith("$")&&["id"].indexOf(s)<0&&t.addProp(s,r);if(e.$innerNodes)for(var n of e.$innerNodes)"nd"===n.$tag?n.lon&&n.lat?t.addLatLng(n):n.ref&&t.addNodeRef(n.ref):"tag"===n.$tag&&t.addTag(n.k,n.v)}),t.on("<osm.relation>",e=>{new f(e.id,a)}),t.on("</osm.relation.member>",(s,e)=>{let t=a.get("relation/"+e.id),r={type:s.type,role:s.role||"",ref:s.ref};if(s.lat&&s.lon){r.lat=s.lat,r.lon=s.lon,r.tags={};for(var[n,i]of Object.entries(s))!n.startsWith("$")&&["type","lat","lon"].indexOf(n)<0&&(r[n]=i)}if(s.$innerNodes){let e=[],t=[];for(var o of s.$innerNodes)o.lat&&o.lon?e.push(o):t.push(o.ref);0<e.length?r.geometry=e:0<t.length&&(r.nodes=t)}t.addMember(r)}),t.on("</osm.relation.bounds>",(e,t)=>{a.get("relation/"+t.id).setBounds([parseFloat(e.minlon),parseFloat(e.minlat),parseFloat(e.maxlon),parseFloat(e.maxlat)])}),t.on("</osm.relation.tag>",(e,t)=>{a.get("relation/"+t.id).addTag(e.k,e.v)}),t.parse(e)})(e),a.bindAll();for(l of a.values())if(l.refCount<=0||l.hasTag&&r&&!(l instanceof u&&n)){var d=l.toFeatureArray();if(l instanceof f&&!s&&0<d.length)return d[0].geometry;o=o.concat(d)}return{type:"FeatureCollection",features:o}}},{"./osmobjs.js":2,"./utils.js":4,"./xmlparser.js":5}],2:[function(t,e,s){e.exports=(()=>{"use strict";const{first:p,isRing:s,ringDirection:r,ptInsidePolygon:g,strToFloat:n,LateBinder:l,WayCollection:c}=t("./utils.js"),i=t("./polytags.json");class e{constructor(e,t,s){this.type=e,this.id=t,this.refElems=s,this.tags={},this.props={id:this.getCompositeId()},this.refCount=0,this.hasTag=!1,s&&s.add(this.getCompositeId(),this)}addTags(e){this.tags=Object.assign(this.tags,e),this.hasTag=!!e}addTag(e,t){this.tags[e]=t,this.hasTag=!!e}addProp(e,t){this.props[e]=t}addProps(e){this.props=Object.assign(this.props,e)}getCompositeId(){return this.type+"/"+this.id}getProps(){return Object.assign(this.props,this.tags)}toFeatureArray(){return[]}}class d extends e{constructor(e,t){super("node",e,t),this.latLng=null}setLatLng(e){this.latLng=e}toFeatureArray(){return this.latLng?[{type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"Point",coordinates:n([this.latLng.lon,this.latLng.lat])}}]:[]}getLatLng(){return this.latLng}}class h extends e{constructor(e,t){super("way",e,t),this.latLngArray=[],this.isPolygon=!1}addLatLng(e){this.latLngArray.push(e)}setLatLngArray(e){this.latLngArray=e}addNodeRef(e){e=new l(this.latLngArray,function(e){let t=this.refElems.get("node/"+e);if(t)return t.refCount++,t.getLatLng()},this,[e]);this.latLngArray.push(e),this.refElems.addBinder(e)}analyzeTag(e,t){let s=i[e];s&&(this.isPolygon=!0,s.whitelist?this.isPolygon=0<=s.whitelist.indexOf(t):s.blacklist&&(this.isPolygon=!(0<=s.blacklist.indexOf(t))))}addTags(e){super.addTags(e);for(var[t,s]of Object.entries(e))this.analyzeTag(t,s)}addTag(e,t){super.addTag(e,t),this.analyzeTag(e,t)}toCoordsArray(){return this.latLngArray.map(e=>[e.lon,e.lat])}toFeatureArray(){let t=this.toCoordsArray();if(1<t.length){t=n(t);let e={type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"LineString",coordinates:t}};return this.isPolygon&&s(t)?("counterclockwise"!==r(t)&&t.reverse(),e.geometry={type:"Polygon",coordinates:[t]},[e]):[e]}return[]}}return{Node:d,Way:h,Relation:class extends e{constructor(e,t){super("relation",e,t),this.relations=[],this.nodes=[],this.bounds=null}setBounds(e){this.bounds=e}addMember(s){switch(s.type){case"relation":var r=new l(this.relations,function(e){let t=this.refElems.get("relation/"+e);if(t)return t.refCount++,t},this,[s.ref]);this.relations.push(r),this.refElems.addBinder(r);break;case"way":s.role||(s.role="");let t=this[s.role];if(t=t||(this[s.role]=[]),s.geometry){let e=new h(s.ref,this.refElems);e.setLatLngArray(s.geometry),e.refCount++,t.push(e)}else if(s.nodes){let e=new h(s.ref,this.refElems);for(var n of s.nodes)e.addNodeRef(n);e.refCount++,t.push(e)}else{var i=new l(t,function(e){let t=this.refElems.get("way/"+e);if(t)return t.refCount++,t},this,[s.ref]);t.push(i),this.refElems.addBinder(i)}break;case"node":let e=null;if(s.lat&&s.lon){e=new d(s.ref,this.refElems),e.setLatLng({lon:s.lon,lat:s.lat}),s.tags&&e.addTags(s.tags);for(var[o,a]of Object.entries(s))["id","type","lat","lon"].indexOf(o)<0&&e.addProp(o,a);e.refCount++,this.nodes.push(e)}else{i=new l(this.nodes,function(e){let t=this.refElems.get("node/"+e);if(t)return t.refCount++,t},this,[s.ref]);this.nodes.push(i),this.refElems.addBinder(i)}}}toFeatureArray(){let e=[],t=[],s=[];var r,n,i,o=["outer","inner",""];for(r of this.relations)if(r)for(var a of o){var l=r[a];if(l){let e=this[a];e?[].splice.apply(e,[e.length,0].concat(l)):this[a]=l}}for(n of o){var d=this[n];if(d){this[n]=new c;for(var h of d)this[n].addWay(h)}}let u=null,f={type:"Feature",id:this.getCompositeId(),bbox:this.bounds,properties:this.getProps()};this.bounds||delete f.bbox,this.outer?(u=((e,t)=>{let s=e?e.toRings("counterclockwise"):[],r=t?t.toRings("clockwise"):[];if(0<s.length){let e=[],t=null;for(t of s)e.push([t]);for(;t=r.shift();)for(var n in s)if(g(p(t),s[n])){e[n].push(t);break}return 1===e.length?{type:"Polygon",coordinates:e[0]}:{type:"MultiPolygon",coordinates:e}}return null})(this.outer,this.inner),u&&(f.geometry=u,e.push(f))):this[""]&&(u=(e=>{e=e?e.toStrings():[];return 0<e.length?1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}:null})(this[""]),u&&(f.geometry=u,t.push(f)));for(i of this.nodes)s=s.concat(i.toFeatureArray());return e.concat(t).concat(s)}}}})()},{"./polytags.json":3,"./utils.js":4}],3:[function(e,t,s){t.exports={building:{},highway:{whitelist:["services","rest_area","escape","elevator"]},natural:{blacklist:["coastline","cliff","ridge","arete","tree_row"]},landuse:{},waterway:{whitelist:["riverbank","dock","boatyard","dam"]},amenity:{},leisure:{},barrier:{whitelist:["city_wall","ditch","hedge","retaining_wall","wall","spikes"]},railway:{whitelist:["station","turntable","roundhouse","platform"]},area:{},boundary:{},man_made:{blacklist:["cutline","embankment","pipeline"]},power:{whitelist:["plant","substation","generator","transformer"]},place:{},shop:{},aeroway:{blacklist:["taxiway"]},tourism:{},historic:{},public_transport:{},office:{},"building:part":{},military:{},ruins:{},"area:highway":{},craft:{},golf:{},indoor:{}}},{}],4:[function(e,t,s){t.exports=(()=>{"use strict";const e=e=>e[0],n=e=>e[e.length-1],i=e=>e.join(","),t=(e,t,s)=>{let r=e[t];r?r.push(s):e[t]=[s]},o=(e,t,s)=>{let r=e[t],n=null;r&&0<=(n=r.indexOf(s))&&r.splice(n,1)},a=(e,t)=>{t=e[t];return t&&0<t.length?t[0]:null},l=e=>3<e.length&&i(e[0])===i(n(e)),d=(r,n,e)=>{n=n||0,e=e||1;var t=r.reduce((e,t,s)=>r[e][n]>t[n]?e:s,0),s=t<=0?r.length-2:t-1,i=t>=r.length-1?1:t+1,o=r[s][n],a=r[t][n],l=r[i][n],s=r[s][e],t=r[t][e];return(a-o)*(r[i][e]-s)-(l-o)*(t-s)<0?"clockwise":"counterclockwise"};const h=e=>e instanceof Array?e.map(h):parseFloat(e);class s extends Map{constructor(){super(),this.binders=[]}add(e,t){this.has(e)||this.set(e,t)}addBinder(e){this.binders.push(e)}bindAll(){this.binders.forEach(e=>e.bind())}}class r extends Array{constructor(){super(),this.firstMap={},this.lastMap={}}addWay(e){0<(e=e.toCoordsArray()).length&&(this.push(e),t(this.firstMap,i(e[0]),e),t(this.lastMap,i(n(e)),e))}toStrings(){let e=[],t;for(;t=this.shift();){o(this.firstMap,i(t[0]),t),o(this.lastMap,i(n(t)),t);let s=t,r=null;do{let e=i(n(s)),t=!1;r=a(this.firstMap,e),r||(r=a(this.lastMap,e),t=!0),r&&(this.splice(this.indexOf(r),1),o(this.firstMap,i(r[0]),r),o(this.lastMap,i(n(r)),r),t&&(r.length>s.length&&([s,r]=[r,s]),r.reverse()),s=s.concat(r.slice(1)))}while(r);e.push(h(s))}return e}toRings(e){let t=this.toStrings(),s=[],r=null;for(;r=t.shift();)l(r)&&(d(r)!==e&&r.reverse(),s.push(r));return s}}return{purgeProps:(t,s)=>{if(t){let e=Object.assign({},t);if(s)for(var r of s)delete e[r];return e}return{}},mergeProps:(e,t)=>(e=e||{},t=t||{},Object.assign(e,t)),first:e,last:n,coordsToKey:i,addToMap:t,removeFromMap:o,getFirstFromMap:a,isRing:l,ringDirection:d,ptInsidePolygon:(s,r,n,i)=>{n=n||0,i=i||1;let o=!1;for(let e=0,t=r.length-1;e<r.length;t=e++)(r[e][n]<=s[n]&&s[n]<r[t][n]||r[t][n]<=s[n]&&s[n]<r[e][n])&&s[i]<(r[t][i]-r[e][i])*(s[n]-r[e][n])/(r[t][n]-r[e][n])+r[e][i]&&(o=!o);return o},strToFloat:h,RefElements:s,LateBinder:class{constructor(e,t,s,r){this.container=e,this.valueFunc=t,this.ctx=s,this.args=r}bind(){var t=this.valueFunc.apply(this.ctx,this.args);if(this.container instanceof Array){var s=this.container.indexOf(this);if(0<=s){let e=[s,1];t&&e.push(t),[].splice.apply(this.container,e)}}else"object"!=typeof this.container||(s=Object.keys(this.container).find(e=>this.container[e]===this))&&(t?this.container[s]=t:delete this.container[s])}},WayCollection:r}})()},{}],5:[function(e,t,s){t.exports=(()=>{"use strict";function r(e){return null!=e.match(/^(.+?)\[(.+?)\]>$/g)}function n(e){var t=/^(.+?)\[(.+?)\]>$/g.exec(e);return t?{evt:t[1]+">",exp:t[2]}:{evt:e}}return class{constructor(e){e&&(this.queryParent=!!e.queryParent,this.progressive=e.progressive,this.queryParent&&(this.parentMap=new WeakMap)),this.evtListeners={}}parse(d,h,u){u=u?u+".":"";let f=/<([^ >\/]+)(.*?)>/gm,p=null,g=[];for(;p=f.exec(d);){let t=p[1],s={$tag:t},r=u+t,e=p[2].trim(),n=!1;(e.endsWith("/")||t.startsWith("?")||t.startsWith("!"))&&(n=!0);let i=/([^ ]+?)="(.+?)"/g,o=/([^ ]+?)='(.+?)'/g,a=null,l=!1;for(;a=i.exec(e);)l=!0,s[a[1]]=a[2];if(!l)for(;a=o.exec(e);)l=!0,s[a[1]]=a[2];if(l||""===e||(s.text=e),this.progressive&&this.emit(`<${r}>`,s,h),!n){let e=new RegExp(`([^]+?)</${t}>`,"g");e.lastIndex=f.lastIndex;var c,y=e.exec(d);y&&y[1]&&(f.lastIndex=e.lastIndex,0<(c=this.parse(y[1],s,r)).length?s.$innerNodes=c:s.$innerText=y[1])}this.queryParent&&h&&this.parentMap.set(s,h),this.progressive&&this.emit(`</${r}>`,s,h),g.push(s)}return g}getParent(e){return this.queryParent?this.parentMap.get(e):null}$addListener(e,t){let s=this.evtListeners[e];s?s.push(t):this.evtListeners[e]=[t]}addListener(e,t){var s;r(e)&&(e=n(e),t.condition=(s="return "+(s=e.exp).replace(/(\$.+?)(?=[=!.])/g,"node.$&")+";",new Function("node",s)),e=e.evt),this.$addListener(e,t)}$removeListener(e,t){let s=this.evtListeners[e],r=null;s&&0<=(r=s.indexOf(t))&&s.splice(r,1)}removeListener(e,t){r(e)&&(e=(e=n(e)).evt),this.$removeListener(e,t)}emit(e,...t){e=this.evtListeners[e];if(e)for(var s of e)(!s.condition||!0===s.condition.apply(null,t))&&s.apply(null,t)}on(e,t){this.addListener(e,t)}off(e,t){this.removeListener(e,t)}}})()},{}]},{},[1])(1)});
|
|
1
|
+
!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).osm2geojson=e()}(function(){return function r(n,i,o){function a(t,e){if(!i[t]){if(!n[t]){var s="function"==typeof require&&require;if(!e&&s)return s(t,!0);if(l)return l(t,!0);throw(s=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",s}s=i[t]={exports:{}},n[t][0].call(s.exports,function(e){return a(n[t][1][e]||e)},s,s.exports,r,n,i,o)}return i[t].exports}for(var l="function"==typeof require&&require,e=0;e<o.length;e++)a(o[e]);return a}({1:[function(e,t,s){const{Node:h,Way:u,Relation:f}=e("./osmobjs.js"),{purgeProps:p,RefElements:g}=e("./utils.js"),c=e("./xmlparser.js");t.exports=(e,t)=>{let s=!1,r=!1,n=!0;(t=t)&&(s=!(!t.completeFeature&&!t.allFeatures),r=!!t.renderTagged,void 0===(t=t.suppressWay||t.excludeWay)||t||(n=!1));let i=(t=e).elements?"json":0<=t.indexOf("<osm")?"xml":t.trim().startsWith("{")?"json-raw":"invalid",a=new g,o=[];var l;"json-raw"===i&&(e=JSON.parse(e),i=e.elements?"json":"invalid"),"json"===i?(e=>{for(var r of e.elements)switch(r.type){case"node":let e=new h(r.id,a);r.tags&&e.addTags(r.tags),e.addProps(p(r,["id","type","tags","lat","lon"])),e.setLatLng(r);break;case"way":let t=new u(r.id,a);if(r.tags&&t.addTags(r.tags),t.addProps(p(r,["id","type","tags","nodes","geometry"])),r.nodes)for(var n of r.nodes)t.addNodeRef(n);else r.geometry&&t.setLatLngArray(r.geometry);break;case"relation":let s=new f(r.id,a);if(r.bounds&&s.setBounds([parseFloat(r.bounds.minlon),parseFloat(r.bounds.minlat),parseFloat(r.bounds.maxlon),parseFloat(r.bounds.maxlat)]),r.tags&&s.addTags(r.tags),s.addProps(p(r,["id","type","tags","bounds","members"])),r.members)for(var i of r.members)s.addMember(i)}})(e):"xml"===i&&(e=>{const t=new c({progressive:!0});t.on("</osm.node>",e=>{let t=new h(e.id,a);for(var[s,r]of Object.entries(e))!s.startsWith("$")&&["id","lon","lat"].indexOf(s)<0&&t.addProp(s,r);if(t.setLatLng(e),e.$innerNodes)for(var n of e.$innerNodes)"tag"===n.$tag&&t.addTag(n.k,n.v)}),t.on("</osm.way>",e=>{let t=new u(e.id,a);for(var[s,r]of Object.entries(e))!s.startsWith("$")&&["id"].indexOf(s)<0&&t.addProp(s,r);if(e.$innerNodes)for(var n of e.$innerNodes)"nd"===n.$tag?n.lon&&n.lat?t.addLatLng(n):n.ref&&t.addNodeRef(n.ref):"tag"===n.$tag&&t.addTag(n.k,n.v)}),t.on("<osm.relation>",e=>{new f(e.id,a)}),t.on("</osm.relation.member>",(s,e)=>{let t=a.get("relation/"+e.id),r={type:s.type,role:s.role||"",ref:s.ref};if(s.lat&&s.lon){r.lat=s.lat,r.lon=s.lon,r.tags={};for(var[n,i]of Object.entries(s))!n.startsWith("$")&&["type","lat","lon"].indexOf(n)<0&&(r[n]=i)}if(s.$innerNodes){let e=[],t=[];for(var o of s.$innerNodes)o.lat&&o.lon?e.push(o):t.push(o.ref);0<e.length?r.geometry=e:0<t.length&&(r.nodes=t)}t.addMember(r)}),t.on("</osm.relation.bounds>",(e,t)=>{a.get("relation/"+t.id).setBounds([parseFloat(e.minlon),parseFloat(e.minlat),parseFloat(e.maxlon),parseFloat(e.maxlat)])}),t.on("</osm.relation.tag>",(e,t)=>{a.get("relation/"+t.id).addTag(e.k,e.v)}),t.parse(e)})(e),a.bindAll();for(l of a.values())if(l.refCount<=0||l.hasTag&&r&&!(l instanceof u&&n)){var d=l.toFeatureArray();if(l instanceof f&&!s&&0<d.length)return d[0].geometry;o=o.concat(d)}return{type:"FeatureCollection",features:o}}},{"./osmobjs.js":2,"./utils.js":4,"./xmlparser.js":5}],2:[function(t,e,s){e.exports=(()=>{"use strict";const{first:p,isRing:s,ringDirection:r,ptInsidePolygon:g,strToFloat:n,LateBinder:l,WayCollection:c}=t("./utils.js"),i=t("./polytags.json");class e{constructor(e,t,s){this.type=e,this.id=t,this.refElems=s,this.tags={},this.props={id:this.getCompositeId()},this.refCount=0,this.hasTag=!1,s&&s.add(this.getCompositeId(),this)}addTags(e){this.tags=Object.assign(this.tags,e),this.hasTag=!!e}addTag(e,t){this.tags[e]=t,this.hasTag=!!e}addProp(e,t){this.props[e]=t}addProps(e){this.props=Object.assign(this.props,e)}getCompositeId(){return this.type+"/"+this.id}getProps(){return Object.assign(this.props,this.tags)}toFeatureArray(){return[]}}class d extends e{constructor(e,t){super("node",e,t),this.latLng=null}setLatLng(e){this.latLng=e}toFeatureArray(){return this.latLng?[{type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"Point",coordinates:n([this.latLng.lon,this.latLng.lat])}}]:[]}getLatLng(){return this.latLng}}class h extends e{constructor(e,t){super("way",e,t),this.latLngArray=[],this.isPolygon=!1}addLatLng(e){this.latLngArray.push(e)}setLatLngArray(e){this.latLngArray=e}addNodeRef(e){e=new l(this.latLngArray,function(e){let t=this.refElems.get("node/"+e);if(t)return t.refCount++,t.getLatLng()},this,[e]);this.latLngArray.push(e),this.refElems.addBinder(e)}analyzeGeometryType(e,t){let s=i[e];s&&(this.isPolygon=!0,s.whitelist?this.isPolygon=0<=s.whitelist.indexOf(t):s.blacklist&&(this.isPolygon=!(0<=s.blacklist.indexOf(t))))}addTags(e){super.addTags(e);for(var[t,s]of Object.entries(e))this.analyzeGeometryType(t,s)}addTag(e,t){super.addTag(e,t),this.analyzeGeometryType(e,t)}toCoordsArray(){return this.latLngArray.map(e=>[e.lon,e.lat])}toFeatureArray(){let t=this.toCoordsArray();if(1<t.length){t=n(t);let e={type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"LineString",coordinates:t}};return this.isPolygon&&s(t)?("counterclockwise"!==r(t)&&t.reverse(),e.geometry={type:"Polygon",coordinates:[t]},[e]):[e]}return[]}}return{Node:d,Way:h,Relation:class extends e{constructor(e,t){super("relation",e,t),this.relations=[],this.nodes=[],this.bounds=null}setBounds(e){this.bounds=e}addMember(s){switch(s.type){case"relation":var r=new l(this.relations,function(e){let t=this.refElems.get("relation/"+e);if(t)return t.refCount++,t},this,[s.ref]);this.relations.push(r),this.refElems.addBinder(r);break;case"way":s.role||(s.role="");let t=this[s.role];if(t=t||(this[s.role]=[]),s.geometry){let e=new h(s.ref,this.refElems);e.setLatLngArray(s.geometry),e.refCount++,t.push(e)}else if(s.nodes){let e=new h(s.ref,this.refElems);for(var n of s.nodes)e.addNodeRef(n);e.refCount++,t.push(e)}else{var i=new l(t,function(e){let t=this.refElems.get("way/"+e);if(t)return t.refCount++,t},this,[s.ref]);t.push(i),this.refElems.addBinder(i)}break;case"node":let e=null;if(s.lat&&s.lon){e=new d(s.ref,this.refElems),e.setLatLng({lon:s.lon,lat:s.lat}),s.tags&&e.addTags(s.tags);for(var[o,a]of Object.entries(s))["id","type","lat","lon"].indexOf(o)<0&&e.addProp(o,a);e.refCount++,this.nodes.push(e)}else{i=new l(this.nodes,function(e){let t=this.refElems.get("node/"+e);if(t)return t.refCount++,t},this,[s.ref]);this.nodes.push(i),this.refElems.addBinder(i)}}}toFeatureArray(){let e=[],t=[],s=[];var r,n,i,o=["outer","inner",""];for(r of this.relations)if(r)for(var a of o){var l=r[a];if(l){let e=this[a];e?[].splice.apply(e,[e.length,0].concat(l)):this[a]=l}}for(n of o){var d=this[n];if(d){this[n]=new c;for(var h of d)this[n].addWay(h)}}let u=null,f={type:"Feature",id:this.getCompositeId(),bbox:this.bounds,properties:this.getProps()};this.bounds||delete f.bbox,this.outer?(u=((e,t)=>{let s=e?e.toRings("counterclockwise"):[],r=t?t.toRings("clockwise"):[];if(0<s.length){let e=[],t=null;for(t of s)e.push([t]);for(;t=r.shift();)for(var n in s)if(g(p(t),s[n])){e[n].push(t);break}return 1===e.length?{type:"Polygon",coordinates:e[0]}:{type:"MultiPolygon",coordinates:e}}return null})(this.outer,this.inner),u&&(f.geometry=u,e.push(f))):this[""]&&(u=(e=>{e=e?e.toStrings():[];return 0<e.length?1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}:null})(this[""]),u&&(f.geometry=u,t.push(f)));for(i of this.nodes)s=s.concat(i.toFeatureArray());return e.concat(t).concat(s)}}}})()},{"./polytags.json":3,"./utils.js":4}],3:[function(e,t,s){t.exports={building:{},highway:{whitelist:["services","rest_area","escape","elevator"]},natural:{blacklist:["coastline","cliff","ridge","arete","tree_row"]},landuse:{},waterway:{whitelist:["riverbank","dock","boatyard","dam"]},amenity:{},leisure:{},barrier:{whitelist:["city_wall","ditch","hedge","retaining_wall","wall","spikes"]},railway:{whitelist:["station","turntable","roundhouse","platform"]},area:{},boundary:{},man_made:{blacklist:["cutline","embankment","pipeline"]},power:{whitelist:["plant","substation","generator","transformer"]},place:{},shop:{},aeroway:{blacklist:["taxiway"]},tourism:{},historic:{},public_transport:{},office:{},"building:part":{},military:{},ruins:{},"area:highway":{},craft:{},golf:{},indoor:{}}},{}],4:[function(e,t,s){t.exports=(()=>{"use strict";const e=e=>e[0],n=e=>e[e.length-1],i=e=>e.join(","),t=(e,t,s)=>{let r=e[t];r?r.push(s):e[t]=[s]},o=(e,t,s)=>{let r=e[t],n=null;r&&0<=(n=r.indexOf(s))&&r.splice(n,1)},a=(e,t)=>{t=e[t];return t&&0<t.length?t[0]:null},l=e=>3<e.length&&i(e[0])===i(n(e)),d=(r,n,e)=>{n=n||0,e=e||1;var t=r.reduce((e,t,s)=>r[e][n]>t[n]?e:s,0),s=t<=0?r.length-2:t-1,i=t>=r.length-1?1:t+1,o=r[s][n],a=r[t][n],l=r[i][n],s=r[s][e],t=r[t][e];return(a-o)*(r[i][e]-s)-(l-o)*(t-s)<0?"clockwise":"counterclockwise"};const h=e=>e instanceof Array?e.map(h):parseFloat(e);class s extends Map{constructor(){super(),this.binders=[]}add(e,t){this.has(e)||this.set(e,t)}addBinder(e){this.binders.push(e)}bindAll(){this.binders.forEach(e=>e.bind())}}class r extends Array{constructor(){super(),this.firstMap={},this.lastMap={}}addWay(e){0<(e=e.toCoordsArray()).length&&(this.push(e),t(this.firstMap,i(e[0]),e),t(this.lastMap,i(n(e)),e))}toStrings(){let e=[],t;for(;t=this.shift();){o(this.firstMap,i(t[0]),t),o(this.lastMap,i(n(t)),t);let s=t,r=null;do{let e=i(n(s)),t=!1;r=a(this.firstMap,e),r||(r=a(this.lastMap,e),t=!0),r&&(this.splice(this.indexOf(r),1),o(this.firstMap,i(r[0]),r),o(this.lastMap,i(n(r)),r),t&&(r.length>s.length&&([s,r]=[r,s]),r.reverse()),s=s.concat(r.slice(1)))}while(r);e.push(h(s))}return e}toRings(e){let t=this.toStrings(),s=[],r=null;for(;r=t.shift();)l(r)&&(d(r)!==e&&r.reverse(),s.push(r));return s}}return{purgeProps:(t,s)=>{if(t){let e=Object.assign({},t);if(s)for(var r of s)delete e[r];return e}return{}},mergeProps:(e,t)=>(e=e||{},t=t||{},Object.assign(e,t)),first:e,last:n,coordsToKey:i,addToMap:t,removeFromMap:o,getFirstFromMap:a,isRing:l,ringDirection:d,ptInsidePolygon:(s,r,n,i)=>{n=n||0,i=i||1;let o=!1;for(let e=0,t=r.length-1;e<r.length;t=e++)(r[e][n]<=s[n]&&s[n]<r[t][n]||r[t][n]<=s[n]&&s[n]<r[e][n])&&s[i]<(r[t][i]-r[e][i])*(s[n]-r[e][n])/(r[t][n]-r[e][n])+r[e][i]&&(o=!o);return o},strToFloat:h,RefElements:s,LateBinder:class{constructor(e,t,s,r){this.container=e,this.valueFunc=t,this.ctx=s,this.args=r}bind(){var t=this.valueFunc.apply(this.ctx,this.args);if(this.container instanceof Array){var s=this.container.indexOf(this);if(0<=s){let e=[s,1];t&&e.push(t),[].splice.apply(this.container,e)}}else"object"!=typeof this.container||(s=Object.keys(this.container).find(e=>this.container[e]===this))&&(t?this.container[s]=t:delete this.container[s])}},WayCollection:r}})()},{}],5:[function(e,t,s){t.exports=(()=>{"use strict";function r(e){return null!=e.match(/^(.+?)\[(.+?)\]>$/g)}function n(e){var t=/^(.+?)\[(.+?)\]>$/g.exec(e);return t?{evt:t[1]+">",exp:t[2]}:{evt:e}}return class{constructor(e){e&&(this.queryParent=!!e.queryParent,this.progressive=e.progressive,this.queryParent&&(this.parentMap=new WeakMap)),this.evtListeners={}}parse(d,h,u){u=u?u+".":"";let f=/<([^ >\/]+)(.*?)>/gm,p=null,g=[];for(;p=f.exec(d);){let t=p[1],s={$tag:t},r=u+t,e=p[2].trim(),n=!1;(e.endsWith("/")||t.startsWith("?")||t.startsWith("!"))&&(n=!0);let i=/([^ ]+?)="(.+?)"/g,o=/([^ ]+?)='(.+?)'/g,a=null,l=!1;for(;a=i.exec(e);)l=!0,s[a[1]]=a[2];if(!l)for(;a=o.exec(e);)l=!0,s[a[1]]=a[2];if(l||""===e||(s.text=e),this.progressive&&this.emit(`<${r}>`,s,h),!n){let e=new RegExp(`([^]+?)</${t}>`,"g");e.lastIndex=f.lastIndex;var c,y=e.exec(d);y&&y[1]&&(f.lastIndex=e.lastIndex,0<(c=this.parse(y[1],s,r)).length?s.$innerNodes=c:s.$innerText=y[1])}this.queryParent&&h&&this.parentMap.set(s,h),this.progressive&&this.emit(`</${r}>`,s,h),g.push(s)}return g}getParent(e){return this.queryParent?this.parentMap.get(e):null}#addListener(e,t){let s=this.evtListeners[e];s?s.push(t):this.evtListeners[e]=[t]}addListener(e,t){var s;r(e)&&(e=n(e),t.condition=(s="return "+(s=e.exp).replace(/(\$.+?)(?=[=!.])/g,"node.$&")+";",new Function("node",s)),e=e.evt),this.#addListener(e,t)}#removeListener(e,t){let s=this.evtListeners[e],r=null;s&&0<=(r=s.indexOf(t))&&s.splice(r,1)}removeListener(e,t){r(e)&&(e=(e=n(e)).evt),this.#removeListener(e,t)}emit(e,...t){e=this.evtListeners[e];if(e)for(var s of e)(!s.condition||!0===s.condition.apply(null,t))&&s.apply(null,t)}on(e,t){this.addListener(e,t)}off(e,t){this.removeListener(e,t)}}})()},{}]},{},[1])(1)});
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const {Node, Way, Relation} = require('./osmobjs.js'),
|
|
2
|
-
{purgeProps, RefElements} = require('./utils.js'),
|
|
1
|
+
const { Node, Way, Relation } = require('./osmobjs.js'),
|
|
2
|
+
{ purgeProps, RefElements } = require('./utils.js'),
|
|
3
3
|
XmlParser = require('./xmlparser.js');
|
|
4
4
|
|
|
5
5
|
module.exports = (osm, opts) => {
|
|
@@ -7,8 +7,8 @@ module.exports = (osm, opts) => {
|
|
|
7
7
|
|
|
8
8
|
const parseOpts = opts => {
|
|
9
9
|
if (opts) {
|
|
10
|
-
completeFeature = opts.completeFeature || opts.allFeatures? true : false;
|
|
11
|
-
renderTagged = opts.renderTagged? true : false;
|
|
10
|
+
completeFeature = opts.completeFeature || opts.allFeatures ? true : false;
|
|
11
|
+
renderTagged = opts.renderTagged ? true : false;
|
|
12
12
|
let wayOpt = opts.suppressWay || opts.excludeWay;
|
|
13
13
|
if (wayOpt !== undefined && !wayOpt) {
|
|
14
14
|
excludeWay = false;
|
|
@@ -37,7 +37,7 @@ module.exports = (osm, opts) => {
|
|
|
37
37
|
|
|
38
38
|
const analyzeFeaturesFromJson = osm => {
|
|
39
39
|
for (let elem of osm.elements) {
|
|
40
|
-
switch(elem.type) {
|
|
40
|
+
switch (elem.type) {
|
|
41
41
|
case 'node':
|
|
42
42
|
let node = new Node(elem.id, refElements);
|
|
43
43
|
if (elem.tags) {
|
|
@@ -64,7 +64,7 @@ module.exports = (osm, opts) => {
|
|
|
64
64
|
|
|
65
65
|
case 'relation':
|
|
66
66
|
let relation = new Relation(elem.id, refElements);
|
|
67
|
-
|
|
67
|
+
if (elem.bounds) {
|
|
68
68
|
relation.setBounds([parseFloat(elem.bounds.minlon), parseFloat(elem.bounds.minlat), parseFloat(elem.bounds.maxlon), parseFloat(elem.bounds.maxlat)]);
|
|
69
69
|
}
|
|
70
70
|
if (elem.tags) {
|
|
@@ -85,7 +85,7 @@ module.exports = (osm, opts) => {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
const analyzeFeaturesFromXml = osm => {
|
|
88
|
-
const xmlParser = new XmlParser({progressive: true});
|
|
88
|
+
const xmlParser = new XmlParser({ progressive: true });
|
|
89
89
|
|
|
90
90
|
xmlParser.on('</osm.node>', node => {
|
|
91
91
|
let nd = new Node(node.id, refElements);
|
|
@@ -96,7 +96,7 @@ module.exports = (osm, opts) => {
|
|
|
96
96
|
nd.setLatLng(node);
|
|
97
97
|
if (node.$innerNodes) {
|
|
98
98
|
for (let ind of node.$innerNodes) {
|
|
99
|
-
if(ind.$tag === 'tag') {
|
|
99
|
+
if (ind.$tag === 'tag') {
|
|
100
100
|
nd.addTag(ind.k, ind.v);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -132,7 +132,7 @@ module.exports = (osm, opts) => {
|
|
|
132
132
|
let relation = refElements.get(`relation/${parent.id}`);
|
|
133
133
|
let member = {
|
|
134
134
|
type: node.type,
|
|
135
|
-
role: node.role? node.role : '',
|
|
135
|
+
role: node.role ? node.role : '',
|
|
136
136
|
ref: node.ref
|
|
137
137
|
};
|
|
138
138
|
if (node.lat && node.lon) {
|
|
@@ -169,7 +169,7 @@ module.exports = (osm, opts) => {
|
|
|
169
169
|
xmlParser.on('</osm.relation.tag>', (node, parent) => {
|
|
170
170
|
refElements.get(`relation/${parent.id}`).addTag(node.k, node.v);
|
|
171
171
|
});
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
xmlParser.parse(osm);
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -201,5 +201,5 @@ module.exports = (osm, opts) => {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
return {type: 'FeatureCollection', features: featureArray};
|
|
204
|
+
return { type: 'FeatureCollection', features: featureArray };
|
|
205
205
|
}
|
package/lib/osmobjs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module.exports = (() => {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const {first, last, coordsToKey,
|
|
5
|
-
addToMap, removeFromMap, getFirstFromMap,
|
|
6
|
-
isRing, ringDirection, ptInsidePolygon, strToFloat,
|
|
7
|
-
LateBinder, WayCollection} = require('./utils.js'),
|
|
4
|
+
const { first, last, coordsToKey,
|
|
5
|
+
addToMap, removeFromMap, getFirstFromMap,
|
|
6
|
+
isRing, ringDirection, ptInsidePolygon, strToFloat,
|
|
7
|
+
LateBinder, WayCollection } = require('./utils.js'),
|
|
8
8
|
polygonTags = require('./polytags.json');
|
|
9
9
|
|
|
10
10
|
class OsmObject {
|
|
@@ -13,7 +13,7 @@ module.exports = (() => {
|
|
|
13
13
|
this.id = id;
|
|
14
14
|
this.refElems = refElems;
|
|
15
15
|
this.tags = {};
|
|
16
|
-
this.props = {id: this.getCompositeId()};
|
|
16
|
+
this.props = { id: this.getCompositeId() };
|
|
17
17
|
this.refCount = 0;
|
|
18
18
|
this.hasTag = false;
|
|
19
19
|
if (refElems) {
|
|
@@ -23,12 +23,12 @@ module.exports = (() => {
|
|
|
23
23
|
|
|
24
24
|
addTags(tags) {
|
|
25
25
|
this.tags = Object.assign(this.tags, tags);
|
|
26
|
-
this.hasTag = tags? true : false;
|
|
26
|
+
this.hasTag = tags ? true : false;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
addTag(k, v) {
|
|
30
30
|
this.tags[k] = v;
|
|
31
|
-
this.hasTag = k? true : false;
|
|
31
|
+
this.hasTag = k ? true : false;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
addProp(k, v) {
|
|
@@ -36,7 +36,7 @@ module.exports = (() => {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
addProps(props) {
|
|
39
|
-
this.props = Object.assign(this.props, props);
|
|
39
|
+
this.props = Object.assign(this.props, props);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
getCompositeId() {
|
|
@@ -45,7 +45,7 @@ module.exports = (() => {
|
|
|
45
45
|
|
|
46
46
|
getProps() {
|
|
47
47
|
return Object.assign(this.props, this.tags);
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
|
|
50
50
|
toFeatureArray() {
|
|
51
51
|
return [];
|
|
@@ -99,7 +99,7 @@ module.exports = (() => {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
addNodeRef(ref) {
|
|
102
|
-
let binder = new LateBinder(this.latLngArray, function(id) {
|
|
102
|
+
let binder = new LateBinder(this.latLngArray, function (id) {
|
|
103
103
|
let node = this.refElems.get(`node/${id}`);
|
|
104
104
|
if (node) {
|
|
105
105
|
node.refCount++;
|
|
@@ -111,14 +111,14 @@ module.exports = (() => {
|
|
|
111
111
|
this.refElems.addBinder(binder);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
analyzeGeometryType(k, v) {
|
|
115
115
|
let o = polygonTags[k];
|
|
116
116
|
if (o) {
|
|
117
117
|
this.isPolygon = true;
|
|
118
118
|
if (o.whitelist) {
|
|
119
|
-
this.isPolygon = o.whitelist.indexOf(v) >= 0? true : false;
|
|
120
|
-
} else if(o.blacklist) {
|
|
121
|
-
this.isPolygon = o.blacklist.indexOf(v) >= 0? false : true;
|
|
119
|
+
this.isPolygon = o.whitelist.indexOf(v) >= 0 ? true : false;
|
|
120
|
+
} else if (o.blacklist) {
|
|
121
|
+
this.isPolygon = o.blacklist.indexOf(v) >= 0 ? false : true;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -126,13 +126,13 @@ module.exports = (() => {
|
|
|
126
126
|
addTags(tags) {
|
|
127
127
|
super.addTags(tags);
|
|
128
128
|
for (let [k, v] of Object.entries(tags)) {
|
|
129
|
-
this.
|
|
129
|
+
this.analyzeGeometryType(k, v);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
addTag(k, v) {
|
|
134
134
|
super.addTag(k, v);
|
|
135
|
-
this.
|
|
135
|
+
this.analyzeGeometryType(k, v);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
toCoordsArray() {
|
|
@@ -189,7 +189,7 @@ module.exports = (() => {
|
|
|
189
189
|
switch (member.type) {
|
|
190
190
|
// super relation, need to do combination
|
|
191
191
|
case 'relation':
|
|
192
|
-
let binder = new LateBinder(this.relations, function(id) {
|
|
192
|
+
let binder = new LateBinder(this.relations, function (id) {
|
|
193
193
|
let relation = this.refElems.get(`relation/${id}`);
|
|
194
194
|
if (relation) {
|
|
195
195
|
relation.refCount++;
|
|
@@ -221,7 +221,7 @@ module.exports = (() => {
|
|
|
221
221
|
way.refCount++;
|
|
222
222
|
ways.push(way);
|
|
223
223
|
} else {
|
|
224
|
-
let binder = new LateBinder(ways, function(id) {
|
|
224
|
+
let binder = new LateBinder(ways, function (id) {
|
|
225
225
|
let way = this.refElems.get(`way/${id}`);
|
|
226
226
|
if (way) {
|
|
227
227
|
way.refCount++;
|
|
@@ -237,7 +237,7 @@ module.exports = (() => {
|
|
|
237
237
|
let node = null;
|
|
238
238
|
if (member.lat && member.lon) {
|
|
239
239
|
node = new Node(member.ref, this.refElems);
|
|
240
|
-
node.setLatLng({lon: member.lon, lat: member.lat});
|
|
240
|
+
node.setLatLng({ lon: member.lon, lat: member.lat });
|
|
241
241
|
if (member.tags) {
|
|
242
242
|
node.addTags(member.tags);
|
|
243
243
|
}
|
|
@@ -250,7 +250,7 @@ module.exports = (() => {
|
|
|
250
250
|
node.refCount++;
|
|
251
251
|
this.nodes.push(node);
|
|
252
252
|
} else {
|
|
253
|
-
let binder = new LateBinder(this.nodes, function(id) {
|
|
253
|
+
let binder = new LateBinder(this.nodes, function (id) {
|
|
254
254
|
let node = this.refElems.get(`node/${id}`);
|
|
255
255
|
if (node) {
|
|
256
256
|
node.refCount++;
|
|
@@ -261,15 +261,15 @@ module.exports = (() => {
|
|
|
261
261
|
this.refElems.addBinder(binder);
|
|
262
262
|
}
|
|
263
263
|
break;
|
|
264
|
-
|
|
265
|
-
default:
|
|
264
|
+
|
|
265
|
+
default:
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
toFeatureArray() {
|
|
271
271
|
const constructStringGeometry = (ws) => {
|
|
272
|
-
let strings = ws? ws.toStrings() : [];
|
|
272
|
+
let strings = ws ? ws.toStrings() : [];
|
|
273
273
|
if (strings.length > 0) {
|
|
274
274
|
if (strings.length === 1) return {
|
|
275
275
|
type: 'LineString',
|
|
@@ -285,16 +285,16 @@ module.exports = (() => {
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
const constructPolygonGeometry = (ows, iws) => {
|
|
288
|
-
let outerRings = ows? ows.toRings('counterclockwise') : [],
|
|
289
|
-
innerRings = iws? iws.toRings('clockwise') : [];
|
|
290
|
-
|
|
288
|
+
let outerRings = ows ? ows.toRings('counterclockwise') : [],
|
|
289
|
+
innerRings = iws ? iws.toRings('clockwise') : [];
|
|
290
|
+
|
|
291
291
|
if (outerRings.length > 0) {
|
|
292
292
|
let compositPolyons = [];
|
|
293
293
|
|
|
294
294
|
let ring = null;
|
|
295
295
|
for (ring of outerRings)
|
|
296
296
|
compositPolyons.push([ring]);
|
|
297
|
-
|
|
297
|
+
|
|
298
298
|
// link inner polygons to outer containers
|
|
299
299
|
while (ring = innerRings.shift()) {
|
|
300
300
|
for (let idx in outerRings) {
|
|
@@ -352,7 +352,7 @@ module.exports = (() => {
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
let geometry = null;
|
|
355
|
-
|
|
355
|
+
|
|
356
356
|
let feature = {
|
|
357
357
|
type: 'Feature',
|
|
358
358
|
id: this.getCompositeId(),
|
|
@@ -387,5 +387,5 @@ module.exports = (() => {
|
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
-
return {Node, Way, Relation};
|
|
390
|
+
return { Node, Way, Relation };
|
|
391
391
|
})();
|
package/lib/utils.js
CHANGED
|
@@ -15,8 +15,8 @@ module.exports = (() => {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const mergeProps = (obj1, obj2) => {
|
|
18
|
-
obj1 = obj1? obj1 : {};
|
|
19
|
-
obj2 = obj2? obj2 : {};
|
|
18
|
+
obj1 = obj1 ? obj1 : {};
|
|
19
|
+
obj2 = obj2 ? obj2 : {};
|
|
20
20
|
return Object.assign(obj1, obj2);
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -44,7 +44,7 @@ module.exports = (() => {
|
|
|
44
44
|
m[k] = [v];
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
const removeFromMap = (m, k, v) => {
|
|
49
49
|
let a = m[k];
|
|
50
50
|
let idx = null;
|
|
@@ -52,7 +52,7 @@ module.exports = (() => {
|
|
|
52
52
|
a.splice(idx, 1);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
const getFirstFromMap = (m, k) => {
|
|
57
57
|
let a = m[k];
|
|
58
58
|
if (a && a.length > 0) {
|
|
@@ -71,7 +71,7 @@ module.exports = (() => {
|
|
|
71
71
|
// 'coz the first point is virtually the same one as the last point,
|
|
72
72
|
// we need to skip a.length - 1 for left when m = 0,
|
|
73
73
|
// and skip 0 for right when m = a.length - 1;
|
|
74
|
-
let l = m <= 0? a.length - 2 : m - 1, r = m >= a.length - 1? 1 : m + 1;
|
|
74
|
+
let l = m <= 0 ? a.length - 2 : m - 1, r = m >= a.length - 1 ? 1 : m + 1;
|
|
75
75
|
let xa = a[l][xIdx], xb = a[m][xIdx], xc = a[r][xIdx];
|
|
76
76
|
let ya = a[l][yIdx], yb = a[m][yIdx], yc = a[r][yIdx];
|
|
77
77
|
let det = (xb - xa) * (yc - ya) - (xc - xa) * (yb - ya);
|
|
@@ -85,15 +85,15 @@ module.exports = (() => {
|
|
|
85
85
|
if ((polygon[i][xIdx] <= pt[xIdx] && pt[xIdx] < polygon[j][xIdx] ||
|
|
86
86
|
polygon[j][xIdx] <= pt[xIdx] && pt[xIdx] < polygon[i][xIdx]) &&
|
|
87
87
|
pt[yIdx] < (polygon[j][yIdx] - polygon[i][yIdx]) * (pt[xIdx] - polygon[i][xIdx]) / (polygon[j][xIdx] - polygon[i][xIdx]) + polygon[i][yIdx]) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
result = !result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
91
|
}
|
|
92
92
|
return result;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const strToFloat = el => el instanceof Array? el.map(strToFloat) : parseFloat(el);
|
|
96
|
-
|
|
95
|
+
const strToFloat = el => el instanceof Array ? el.map(strToFloat) : parseFloat(el);
|
|
96
|
+
|
|
97
97
|
class RefElements extends Map {
|
|
98
98
|
constructor() {
|
|
99
99
|
super();
|
|
@@ -175,12 +175,12 @@ module.exports = (() => {
|
|
|
175
175
|
do {
|
|
176
176
|
let key = coordsToKey(last(current)), shouldReverse = false;
|
|
177
177
|
|
|
178
|
-
next = getFirstFromMap(this.firstMap, key);
|
|
178
|
+
next = getFirstFromMap(this.firstMap, key);
|
|
179
179
|
if (!next) {
|
|
180
180
|
next = getFirstFromMap(this.lastMap, key);
|
|
181
181
|
shouldReverse = true;
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
|
|
184
184
|
if (next) {
|
|
185
185
|
this.splice(this.indexOf(next), 1);
|
|
186
186
|
removeFromMap(this.firstMap, coordsToKey(first(next)), next);
|
|
@@ -211,15 +211,17 @@ module.exports = (() => {
|
|
|
211
211
|
string.reverse();
|
|
212
212
|
}
|
|
213
213
|
rings.push(string);
|
|
214
|
-
}
|
|
214
|
+
}
|
|
215
215
|
}
|
|
216
216
|
return rings;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
return {
|
|
220
|
+
return {
|
|
221
|
+
purgeProps, mergeProps,
|
|
221
222
|
first, last, coordsToKey,
|
|
222
223
|
addToMap, removeFromMap, getFirstFromMap,
|
|
223
224
|
isRing, ringDirection, ptInsidePolygon, strToFloat,
|
|
224
|
-
RefElements, LateBinder, WayCollection
|
|
225
|
+
RefElements, LateBinder, WayCollection
|
|
226
|
+
};
|
|
225
227
|
})();
|
package/lib/xmlparser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = (() => {
|
|
2
2
|
'use strict';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
function conditioned(evt) {
|
|
5
5
|
return evt.match(/^(.+?)\[(.+?)\]>$/g) != null;
|
|
6
6
|
}
|
|
@@ -8,9 +8,9 @@ module.exports = (() => {
|
|
|
8
8
|
function parseEvent(evt) {
|
|
9
9
|
let match = /^(.+?)\[(.+?)\]>$/g.exec(evt);
|
|
10
10
|
if (match) {
|
|
11
|
-
return {evt: match[1] + '>', exp: match[2]};
|
|
11
|
+
return { evt: match[1] + '>', exp: match[2] };
|
|
12
12
|
}
|
|
13
|
-
return {evt: evt};
|
|
13
|
+
return { evt: evt };
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function genConditionFunc(cond) {
|
|
@@ -21,7 +21,7 @@ module.exports = (() => {
|
|
|
21
21
|
return class {
|
|
22
22
|
constructor(opts) {
|
|
23
23
|
if (opts) {
|
|
24
|
-
this.queryParent = opts.queryParent? true : false;
|
|
24
|
+
this.queryParent = opts.queryParent ? true : false;
|
|
25
25
|
this.progressive = opts.progressive;
|
|
26
26
|
if (this.queryParent) {
|
|
27
27
|
this.parentMap = new WeakMap();
|
|
@@ -31,10 +31,10 @@ module.exports = (() => {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
parse(xml, parent, dir) {
|
|
34
|
-
dir = dir? dir + '.' : '';
|
|
34
|
+
dir = dir ? dir + '.' : '';
|
|
35
35
|
let nodeRegEx = /<([^ >\/]+)(.*?)>/mg, nodeMatch = null, nodes = [];
|
|
36
36
|
while (nodeMatch = nodeRegEx.exec(xml)) {
|
|
37
|
-
let tag = nodeMatch[1], node = {$tag: tag}, fullTag = dir + tag;
|
|
37
|
+
let tag = nodeMatch[1], node = { $tag: tag }, fullTag = dir + tag;
|
|
38
38
|
|
|
39
39
|
let attrText = nodeMatch[2].trim(), closed = false;
|
|
40
40
|
if (attrText.endsWith('/') || tag.startsWith('?') || tag.startsWith('!')) {
|
|
@@ -95,7 +95,7 @@ module.exports = (() => {
|
|
|
95
95
|
return null;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
#addListener(evt, func) {
|
|
99
99
|
let funcs = this.evtListeners[evt];
|
|
100
100
|
if (funcs) {
|
|
101
101
|
funcs.push(func);
|
|
@@ -108,14 +108,14 @@ module.exports = (() => {
|
|
|
108
108
|
addListener(evt, func) {
|
|
109
109
|
if (conditioned(evt)) {
|
|
110
110
|
// func.prototype = evt;
|
|
111
|
-
evt = parseEvent(evt);
|
|
111
|
+
evt = parseEvent(evt);
|
|
112
112
|
func.condition = genConditionFunc(evt.exp);
|
|
113
113
|
evt = evt.evt;
|
|
114
114
|
}
|
|
115
|
-
this
|
|
115
|
+
this.#addListener(evt, func);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
#removeListener(evt, func) {
|
|
119
119
|
let funcs = this.evtListeners[evt];
|
|
120
120
|
let idx = null;
|
|
121
121
|
if (funcs && (idx = funcs.indexOf(func)) >= 0) {
|
|
@@ -125,10 +125,10 @@ module.exports = (() => {
|
|
|
125
125
|
|
|
126
126
|
removeListener(evt, func) {
|
|
127
127
|
if (conditioned(evt)) {
|
|
128
|
-
evt = parseEvent(evt);
|
|
128
|
+
evt = parseEvent(evt);
|
|
129
129
|
evt = evt.evt;
|
|
130
130
|
}
|
|
131
|
-
this
|
|
131
|
+
this.#removeListener(evt, func);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
emit(evt, ...args) {
|
|
@@ -154,4 +154,4 @@ module.exports = (() => {
|
|
|
154
154
|
this.removeListener(evt, func);
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
|
-
})();
|
|
157
|
+
})();
|
package/osm2geojson-lite
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const fs = require("fs");
|
|
4
3
|
const osm2geojson = require('./lib/index.js');
|
|
4
|
+
const fs = require('fs');
|
|
5
5
|
|
|
6
6
|
const data = fs.readFileSync("/dev/stdin", "utf-8");
|
|
7
|
-
|
|
8
|
-
const geojson = osm2geojson(data, {});
|
|
9
|
-
|
|
7
|
+
const geojson = osm2geojson(data, {completeFeature: true, renderTagged: true});
|
|
10
8
|
console.log(JSON.stringify(geojson));
|
package/package.json
CHANGED
package/test/osm2geojson
CHANGED
|
@@ -30,16 +30,14 @@ if (fileName) {
|
|
|
30
30
|
if (profile) {
|
|
31
31
|
let stime = new Date().getTime();
|
|
32
32
|
for (let i = 0; i < rounds; i++)
|
|
33
|
-
osm2geojson(osm, {completeFeature: true});
|
|
33
|
+
osm2geojson(osm, {completeFeature: true, suppressWay: false});
|
|
34
34
|
let etime = new Date().getTime();
|
|
35
35
|
console.log(`${etime - stime}ms cost by ${rounds} rounds of conversion`);
|
|
36
36
|
} else {
|
|
37
|
-
let featureCollection = osm2geojson(osm, {completeFeature: true});
|
|
37
|
+
let featureCollection = osm2geojson(osm, {completeFeature: true, suppressWay: false});
|
|
38
38
|
if (!shouldBeSilent)
|
|
39
39
|
console.log(JSON.stringify(featureCollection, null, 2));
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
console.log(`Usage: osm2geojson <xml/json file> <rounds to profile> [-s|--silent] [-p|--profile]`);
|
|
41
|
+
} else {
|
|
42
|
+
console.log(`Usage: osm2geojson <xml/json file> <rounds to profile> [-s|--silent] [-p|--profile]`);
|
|
43
|
+
}
|