dump-tile 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +7 -7
- package/index.js +14 -15
- package/package.json +14 -10
- package/History.md +0 -5
package/Readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[![NPM version][npm-image]][npm-url]
|
|
2
|
-
[![Build Status][
|
|
3
|
-
[![Dependency Status][
|
|
2
|
+
[![Build Status][build-image]][build-url]
|
|
3
|
+
[![Dependency Status][deps-image]][deps-url]
|
|
4
4
|
|
|
5
5
|
# dump-tile
|
|
6
6
|
|
|
@@ -26,11 +26,11 @@ cat tile.pbf | dump-tile > tile.json
|
|
|
26
26
|
|
|
27
27
|
MIT © [Damian Krzeminski](https://furkot.com)
|
|
28
28
|
|
|
29
|
-
[npm-image]: https://img.shields.io/npm/v/dump-tile
|
|
29
|
+
[npm-image]: https://img.shields.io/npm/v/dump-tile
|
|
30
30
|
[npm-url]: https://npmjs.org/package/dump-tile
|
|
31
31
|
|
|
32
|
-
[
|
|
33
|
-
[
|
|
32
|
+
[build-url]: https://github.com/pirxpilot/dump-tile/actions/workflows/check.yaml
|
|
33
|
+
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/dump-tile/check.yaml?branch=main
|
|
34
34
|
|
|
35
|
-
[
|
|
36
|
-
[
|
|
35
|
+
[deps-image]: https://img.shields.io/librariesio/release/npm/dump-tile
|
|
36
|
+
[deps-url]: https://libraries.io/npm/dump-tile
|
package/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { buffer } from 'node:stream/consumers';
|
|
4
|
+
import Pbf from '@mapwhit/pbf';
|
|
5
|
+
import { VectorTile } from '@mapwhit/vector-tile';
|
|
6
6
|
|
|
7
|
-
function dump(input, output) {
|
|
8
|
-
input.
|
|
7
|
+
export default function dump(input, output) {
|
|
8
|
+
return buffer(input).then(buffer => dumpBuffer(buffer, output));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function dumpBuffer(buffer, output) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const vt = new VectorTile(new Pbf(buffer));
|
|
13
|
+
const tile = dumpTile(vt);
|
|
14
14
|
output.write(JSON.stringify(tile, null, 2));
|
|
15
15
|
output.write('\n');
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function dumpTile({ layers }) {
|
|
19
|
-
|
|
19
|
+
const tile = {};
|
|
20
20
|
tile.layers = Object.values(layers).map(dumpLayer);
|
|
21
21
|
return tile;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function dumpLayer(vl) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const { version, name, extent, length } = vl;
|
|
26
|
+
const layer = { version, name, extent, features: [] };
|
|
27
27
|
for (let i = 0; i < length; i++) {
|
|
28
28
|
layer.features.push(dumpFeature(vl.feature(i)));
|
|
29
29
|
}
|
|
@@ -31,14 +31,14 @@ function dumpLayer(vl) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function dumpFeature(vf) {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const { type, extent, id, properties } = vf;
|
|
35
|
+
const geometry = dumpGeometry(vf.loadGeometry());
|
|
36
36
|
return { type, extent, id, properties, geometry };
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function dumpGeometry(vg) {
|
|
40
40
|
function convertRing(ring) {
|
|
41
|
-
return ring.reduce(
|
|
41
|
+
return ring.reduce((r, { x, y }) => {
|
|
42
42
|
r.push(x, y);
|
|
43
43
|
return r;
|
|
44
44
|
}, []);
|
|
@@ -46,7 +46,6 @@ function dumpGeometry(vg) {
|
|
|
46
46
|
return vg.map(convertRing);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
if (
|
|
49
|
+
if (import.meta.main) {
|
|
50
50
|
dump(process.stdin, process.stdout);
|
|
51
51
|
}
|
|
52
|
-
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dump-tile",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Dumps MVT tiles encoded in .pbf to JSON",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Damian Krzeminski",
|
|
7
7
|
"email": "pirxpilot@furkot.com",
|
|
8
8
|
"url": "https://furkot.com"
|
|
9
9
|
},
|
|
10
|
-
"repository":
|
|
11
|
-
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/pirxpilot/dump-tile.git"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"bin": {
|
|
16
|
+
"dump-tile": "index.js"
|
|
17
|
+
},
|
|
18
|
+
"exports": "./index.js",
|
|
12
19
|
"license": "MIT",
|
|
13
20
|
"keywords": [
|
|
14
21
|
"dump-tile",
|
|
@@ -17,14 +24,11 @@
|
|
|
17
24
|
"MVT"
|
|
18
25
|
],
|
|
19
26
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"
|
|
22
|
-
"pbf": "^3.1.0"
|
|
27
|
+
"@mapwhit/vector-tile": "^4.0.0",
|
|
28
|
+
"@mapwhit/pbf": "^2.0.0"
|
|
23
29
|
},
|
|
24
30
|
"devDependencies": {
|
|
25
|
-
"
|
|
26
|
-
"mocha": "^5.0.4",
|
|
27
|
-
"should": "^13.2.1"
|
|
31
|
+
"@biomejs/biome": "2.3.11"
|
|
28
32
|
},
|
|
29
33
|
"scripts": {
|
|
30
34
|
"test": "make check"
|
|
@@ -32,4 +36,4 @@
|
|
|
32
36
|
"files": [
|
|
33
37
|
"index.js"
|
|
34
38
|
]
|
|
35
|
-
}
|
|
39
|
+
}
|