osm2geojson-lite 0.9.2 → 0.9.3
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/lib/index.js +11 -11
- package/lib/osmobjs.js +26 -26
- package/lib/utils.js +17 -15
- package/lib/xmlparser.js +13 -13
- package/osm2geojson-lite +0 -3
- 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/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++;
|
|
@@ -116,9 +116,9 @@ module.exports = (() => {
|
|
|
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
|
}
|
|
@@ -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
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
|
+
}
|