@loaders.gl/mvt 4.0.0-alpha.4 → 4.0.0-alpha.6
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/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +3124 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/helpers/binary-util-functions.js +82 -0
- package/dist/es5/helpers/binary-util-functions.js.map +1 -0
- package/dist/es5/helpers/mapbox-util-functions.js +50 -0
- package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/es5/index.js +26 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +168 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +62 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile.js +28 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/LICENSE +19 -0
- package/dist/es5/lib/geojson-tiler/clip.js +237 -0
- package/dist/es5/lib/geojson-tiler/clip.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/convert.js +161 -0
- package/dist/es5/lib/geojson-tiler/convert.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/feature.js +62 -0
- package/dist/es5/lib/geojson-tiler/feature.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js +186 -0
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/simplify.js +52 -0
- package/dist/es5/lib/geojson-tiler/simplify.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/tile.js +121 -0
- package/dist/es5/lib/geojson-tiler/tile.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/transform.js +50 -0
- package/dist/es5/lib/geojson-tiler/transform.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/wrap.js +122 -0
- package/dist/es5/lib/geojson-tiler/wrap.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +184 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +62 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +28 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/es5/lib/parse-mvt.js +143 -0
- package/dist/es5/lib/parse-mvt.js.map +1 -0
- package/dist/es5/lib/types.js +2 -0
- package/dist/es5/lib/types.js.map +1 -0
- package/dist/es5/mvt-loader.js +58 -0
- package/dist/es5/mvt-loader.js.map +1 -0
- package/dist/es5/workers/mvt-worker.js +6 -0
- package/dist/es5/workers/mvt-worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/helpers/binary-util-functions.js +73 -0
- package/dist/esm/helpers/binary-util-functions.js.map +1 -0
- package/dist/esm/helpers/mapbox-util-functions.js +41 -0
- package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +136 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +47 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile.js +19 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/LICENSE +19 -0
- package/dist/esm/lib/geojson-tiler/clip.js +173 -0
- package/dist/esm/lib/geojson-tiler/clip.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/convert.js +116 -0
- package/dist/esm/lib/geojson-tiler/convert.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/feature.js +35 -0
- package/dist/esm/lib/geojson-tiler/feature.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/geojson-tiler.js +171 -0
- package/dist/esm/lib/geojson-tiler/geojson-tiler.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/simplify.js +46 -0
- package/dist/esm/lib/geojson-tiler/simplify.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/tile.js +103 -0
- package/dist/esm/lib/geojson-tiler/tile.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/transform.js +32 -0
- package/dist/esm/lib/geojson-tiler/transform.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/wrap.js +67 -0
- package/dist/esm/lib/geojson-tiler/wrap.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +163 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +47 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +19 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/esm/lib/parse-mvt.js +138 -0
- package/dist/esm/lib/parse-mvt.js.map +1 -0
- package/dist/esm/lib/types.js +2 -0
- package/dist/esm/lib/types.js.map +1 -0
- package/dist/esm/mvt-loader.js +29 -0
- package/dist/esm/mvt-loader.js.map +1 -0
- package/dist/esm/workers/mvt-worker.js +4 -0
- package/dist/esm/workers/mvt-worker.js.map +1 -0
- package/dist/helpers/binary-util-functions.d.ts +35 -0
- package/dist/helpers/binary-util-functions.d.ts.map +1 -0
- package/dist/helpers/binary-util-functions.js +111 -74
- package/dist/helpers/mapbox-util-functions.d.ts +29 -0
- package/dist/helpers/mapbox-util-functions.d.ts.map +1 -0
- package/dist/helpers/mapbox-util-functions.js +78 -45
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -2
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +41 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +142 -142
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +23 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
- package/dist/lib/binary-vector-tile/vector-tile.d.ts +9 -0
- package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
- package/dist/lib/geojson-tiler/clip.d.ts +16 -0
- package/dist/lib/geojson-tiler/clip.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/clip.js +209 -0
- package/dist/lib/geojson-tiler/convert.d.ts +10 -0
- package/dist/lib/geojson-tiler/convert.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/convert.js +134 -0
- package/dist/lib/geojson-tiler/feature.d.ts +3 -0
- package/dist/lib/geojson-tiler/feature.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/feature.js +46 -0
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts +44 -0
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/geojson-tiler.js +210 -0
- package/dist/lib/geojson-tiler/simplify.d.ts +10 -0
- package/dist/lib/geojson-tiler/simplify.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/simplify.js +68 -0
- package/dist/lib/geojson-tiler/tile.d.ts +38 -0
- package/dist/lib/geojson-tiler/tile.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/tile.js +125 -0
- package/dist/lib/geojson-tiler/transform.d.ts +7 -0
- package/dist/lib/geojson-tiler/transform.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/transform.js +43 -0
- package/dist/lib/geojson-tiler/wrap.d.ts +17 -0
- package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/wrap.js +86 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +27 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +20 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +9 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
- package/dist/lib/parse-mvt.d.ts +14 -0
- package/dist/lib/parse-mvt.d.ts.map +1 -0
- package/dist/lib/parse-mvt.js +149 -98
- package/dist/lib/types.d.ts +69 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -2
- package/dist/mvt-loader.d.ts +10 -0
- package/dist/mvt-loader.d.ts.map +1 -0
- package/dist/mvt-loader.js +43 -22
- package/dist/mvt-worker.js +845 -766
- package/dist/workers/mvt-worker.d.ts +2 -0
- package/dist/workers/mvt-worker.d.ts.map +1 -0
- package/dist/workers/mvt-worker.js +5 -4
- package/package.json +10 -9
- package/src/helpers/binary-util-functions.ts +9 -7
- package/src/helpers/mapbox-util-functions.ts +2 -2
- package/src/index.ts +7 -0
- package/src/lib/binary-vector-tile/vector-tile-feature.ts +42 -45
- package/src/lib/binary-vector-tile/vector-tile-layer.ts +4 -4
- package/src/lib/geojson-tiler/LICENSE +19 -0
- package/src/lib/geojson-tiler/clip.ts +248 -0
- package/src/lib/geojson-tiler/convert.ts +158 -0
- package/src/lib/geojson-tiler/feature.ts +45 -0
- package/src/lib/geojson-tiler/geojson-tiler.ts +281 -0
- package/src/lib/geojson-tiler/simplify.ts +77 -0
- package/src/lib/geojson-tiler/tile.ts +185 -0
- package/src/lib/geojson-tiler/transform.ts +55 -0
- package/src/lib/geojson-tiler/wrap.ts +108 -0
- package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +4 -4
- package/src/lib/parse-mvt.ts +138 -93
- package/src/lib/types.ts +49 -72
- package/src/mvt-loader.ts +13 -9
- package/dist/bundle.js.map +0 -1
- package/dist/helpers/binary-util-functions.js.map +0 -1
- package/dist/helpers/mapbox-util-functions.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/binary-vector-tile/features-to-binary.js +0 -327
- package/dist/lib/binary-vector-tile/features-to-binary.js.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
- package/dist/lib/parse-mvt.js.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/mvt-loader.js.map +0 -1
- package/dist/workers/mvt-worker.js.map +0 -1
- package/src/lib/binary-vector-tile/features-to-binary.ts +0 -518
- /package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
- /package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
|
@@ -1,202 +1,170 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (cmd === 1) {
|
|
61
|
-
if (line) lines.push(line);
|
|
62
|
-
line = [];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (line) line.push([x, y]);
|
|
66
|
-
} else if (cmd === 7) {
|
|
67
|
-
if (line) {
|
|
68
|
-
line.push(line[0].slice());
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mapbox_util_functions_1 = require("../../helpers/mapbox-util-functions");
|
|
4
|
+
class VectorTileFeature {
|
|
5
|
+
static get types() {
|
|
6
|
+
return ['Unknown', 'Point', 'LineString', 'Polygon'];
|
|
7
|
+
}
|
|
8
|
+
constructor(pbf, end, extent, keys, values) {
|
|
9
|
+
// Public
|
|
10
|
+
this.properties = {};
|
|
11
|
+
this.extent = extent;
|
|
12
|
+
this.type = 0;
|
|
13
|
+
this.id = null;
|
|
14
|
+
// Private
|
|
15
|
+
this._pbf = pbf;
|
|
16
|
+
this._geometry = -1;
|
|
17
|
+
this._keys = keys;
|
|
18
|
+
this._values = values;
|
|
19
|
+
pbf.readFields(mapbox_util_functions_1.readFeature, this, end);
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line complexity, max-statements
|
|
22
|
+
loadGeometry() {
|
|
23
|
+
const pbf = this._pbf;
|
|
24
|
+
pbf.pos = this._geometry;
|
|
25
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
26
|
+
let cmd = 1;
|
|
27
|
+
let length = 0;
|
|
28
|
+
let x = 0;
|
|
29
|
+
let y = 0;
|
|
30
|
+
const lines = [];
|
|
31
|
+
let line;
|
|
32
|
+
while (pbf.pos < end) {
|
|
33
|
+
if (length <= 0) {
|
|
34
|
+
const cmdLen = pbf.readVarint();
|
|
35
|
+
cmd = cmdLen & 0x7;
|
|
36
|
+
length = cmdLen >> 3;
|
|
37
|
+
}
|
|
38
|
+
length--;
|
|
39
|
+
if (cmd === 1 || cmd === 2) {
|
|
40
|
+
x += pbf.readSVarint();
|
|
41
|
+
y += pbf.readSVarint();
|
|
42
|
+
if (cmd === 1) {
|
|
43
|
+
// moveTo
|
|
44
|
+
if (line)
|
|
45
|
+
lines.push(line);
|
|
46
|
+
line = [];
|
|
47
|
+
}
|
|
48
|
+
if (line)
|
|
49
|
+
line.push([x, y]);
|
|
50
|
+
}
|
|
51
|
+
else if (cmd === 7) {
|
|
52
|
+
// Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
|
|
53
|
+
if (line) {
|
|
54
|
+
line.push(line[0].slice()); // closePolygon
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw new Error(`unknown command ${cmd}`);
|
|
59
|
+
}
|
|
69
60
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
if (line)
|
|
62
|
+
lines.push(line);
|
|
63
|
+
return lines;
|
|
73
64
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
65
|
+
// eslint-disable-next-line max-statements
|
|
66
|
+
bbox() {
|
|
67
|
+
const pbf = this._pbf;
|
|
68
|
+
pbf.pos = this._geometry;
|
|
69
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
70
|
+
let cmd = 1;
|
|
71
|
+
let length = 0;
|
|
72
|
+
let x = 0;
|
|
73
|
+
let y = 0;
|
|
74
|
+
let x1 = Infinity;
|
|
75
|
+
let x2 = -Infinity;
|
|
76
|
+
let y1 = Infinity;
|
|
77
|
+
let y2 = -Infinity;
|
|
78
|
+
while (pbf.pos < end) {
|
|
79
|
+
if (length <= 0) {
|
|
80
|
+
const cmdLen = pbf.readVarint();
|
|
81
|
+
cmd = cmdLen & 0x7;
|
|
82
|
+
length = cmdLen >> 3;
|
|
83
|
+
}
|
|
84
|
+
length--;
|
|
85
|
+
if (cmd === 1 || cmd === 2) {
|
|
86
|
+
x += pbf.readSVarint();
|
|
87
|
+
y += pbf.readSVarint();
|
|
88
|
+
if (x < x1)
|
|
89
|
+
x1 = x;
|
|
90
|
+
if (x > x2)
|
|
91
|
+
x2 = x;
|
|
92
|
+
if (y < y1)
|
|
93
|
+
y1 = y;
|
|
94
|
+
if (y > y2)
|
|
95
|
+
y2 = y;
|
|
96
|
+
}
|
|
97
|
+
else if (cmd !== 7) {
|
|
98
|
+
throw new Error(`unknown command ${cmd}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return [x1, y1, x2, y2];
|
|
111
102
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
103
|
+
_toGeoJSON(transform) {
|
|
104
|
+
let coords = this.loadGeometry();
|
|
105
|
+
let type = VectorTileFeature.types[this.type];
|
|
106
|
+
let i;
|
|
107
|
+
let j;
|
|
108
|
+
// eslint-disable-next-line default-case
|
|
109
|
+
switch (this.type) {
|
|
110
|
+
case 1:
|
|
111
|
+
const points = [];
|
|
112
|
+
for (i = 0; i < coords.length; i++) {
|
|
113
|
+
points[i] = coords[i][0];
|
|
114
|
+
}
|
|
115
|
+
coords = points;
|
|
116
|
+
transform(coords, this);
|
|
117
|
+
break;
|
|
118
|
+
case 2:
|
|
119
|
+
for (i = 0; i < coords.length; i++) {
|
|
120
|
+
transform(coords[i], this);
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
case 3:
|
|
124
|
+
coords = (0, mapbox_util_functions_1.classifyRings)(coords);
|
|
125
|
+
for (i = 0; i < coords.length; i++) {
|
|
126
|
+
for (j = 0; j < coords[i].length; j++) {
|
|
127
|
+
transform(coords[i][j], this);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
128
131
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
transform(coords, this);
|
|
132
|
-
break;
|
|
133
|
-
|
|
134
|
-
case 2:
|
|
135
|
-
for (i = 0; i < coords.length; i++) {
|
|
136
|
-
transform(coords[i], this);
|
|
132
|
+
if (coords.length === 1) {
|
|
133
|
+
coords = coords[0];
|
|
137
134
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
case 3:
|
|
142
|
-
coords = classifyRings(coords);
|
|
143
|
-
|
|
144
|
-
for (i = 0; i < coords.length; i++) {
|
|
145
|
-
for (j = 0; j < coords[i].length; j++) {
|
|
146
|
-
transform(coords[i][j], this);
|
|
147
|
-
}
|
|
135
|
+
else {
|
|
136
|
+
type = `Multi${type}`;
|
|
148
137
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
geometry: {
|
|
162
|
-
type,
|
|
163
|
-
coordinates: coords
|
|
164
|
-
},
|
|
165
|
-
properties: this.properties
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
if (this.id !== null) {
|
|
169
|
-
result.id = this.id;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return result;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
toGeoJSON(options) {
|
|
176
|
-
if (typeof options === 'function') {
|
|
177
|
-
return this._toGeoJSON(options);
|
|
138
|
+
const result = {
|
|
139
|
+
type: 'Feature',
|
|
140
|
+
geometry: {
|
|
141
|
+
type,
|
|
142
|
+
coordinates: coords
|
|
143
|
+
},
|
|
144
|
+
properties: this.properties
|
|
145
|
+
};
|
|
146
|
+
if (this.id !== null) {
|
|
147
|
+
result.id = this.id;
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
178
150
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
151
|
+
toGeoJSON(options) {
|
|
152
|
+
if (typeof options === 'function') {
|
|
153
|
+
return this._toGeoJSON(options);
|
|
154
|
+
}
|
|
155
|
+
const { x, y, z } = options;
|
|
156
|
+
const size = this.extent * Math.pow(2, z);
|
|
157
|
+
const x0 = this.extent * x;
|
|
158
|
+
const y0 = this.extent * y;
|
|
159
|
+
function project(line) {
|
|
160
|
+
for (let j = 0; j < line.length; j++) {
|
|
161
|
+
const p = line[j];
|
|
162
|
+
p[0] = ((p[0] + x0) * 360) / size - 180;
|
|
163
|
+
const y2 = 180 - ((p[1] + y0) * 360) / size;
|
|
164
|
+
p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return this._toGeoJSON(project);
|
|
196
168
|
}
|
|
197
|
-
|
|
198
|
-
return this._toGeoJSON(project);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
169
|
}
|
|
202
|
-
|
|
170
|
+
exports.default = VectorTileFeature;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Protobuf from 'pbf';
|
|
2
|
+
import VectorTileFeature from './vector-tile-feature';
|
|
3
|
+
export default class VectorTileLayer {
|
|
4
|
+
version: number;
|
|
5
|
+
name: string;
|
|
6
|
+
extent: number;
|
|
7
|
+
length: number;
|
|
8
|
+
_pbf: Protobuf;
|
|
9
|
+
_keys: string[];
|
|
10
|
+
_values: (string | number | boolean | null)[];
|
|
11
|
+
_features: number[];
|
|
12
|
+
constructor(pbf: Protobuf, end: number);
|
|
13
|
+
/**
|
|
14
|
+
* return feature `i` from this layer as a `VectorTileFeature`
|
|
15
|
+
* @param index
|
|
16
|
+
* @returns feature
|
|
17
|
+
*/
|
|
18
|
+
feature(i: number): VectorTileFeature;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=vector-tile-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-tile-layer.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile-layer.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;IAC9C,SAAS,EAAE,MAAM,EAAE,CAAC;gBACR,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM;IAkBtC;;;;OAIG;IAEH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,iBAAiB;CAUtC"}
|
|
@@ -1,64 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable indent */
|
|
3
|
+
// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const vector_tile_feature_1 = __importDefault(require("./vector-tile-feature"));
|
|
9
|
+
class VectorTileLayer {
|
|
10
|
+
constructor(pbf, end) {
|
|
11
|
+
// Public
|
|
12
|
+
this.version = 1;
|
|
13
|
+
this.name = '';
|
|
14
|
+
this.extent = 4096;
|
|
15
|
+
this.length = 0;
|
|
16
|
+
// Private
|
|
17
|
+
this._pbf = pbf;
|
|
18
|
+
this._keys = [];
|
|
19
|
+
this._values = [];
|
|
20
|
+
this._features = [];
|
|
21
|
+
pbf.readFields(readLayer, this, end);
|
|
22
|
+
this.length = this._features.length;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* return feature `i` from this layer as a `VectorTileFeature`
|
|
26
|
+
* @param index
|
|
27
|
+
* @returns feature
|
|
28
|
+
*/
|
|
29
|
+
feature(i) {
|
|
30
|
+
if (i < 0 || i >= this._features.length) {
|
|
31
|
+
throw new Error('feature index out of bounds');
|
|
32
|
+
}
|
|
33
|
+
this._pbf.pos = this._features[i];
|
|
34
|
+
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
35
|
+
return new vector_tile_feature_1.default(this._pbf, end, this.extent, this._keys, this._values);
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
this._pbf.pos = this._features[i];
|
|
39
|
-
|
|
40
|
-
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
41
|
-
|
|
42
|
-
return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
37
|
}
|
|
46
|
-
|
|
38
|
+
exports.default = VectorTileLayer;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param tag
|
|
42
|
+
* @param layer
|
|
43
|
+
* @param pbf
|
|
44
|
+
*/
|
|
47
45
|
function readLayer(tag, layer, pbf) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
if (layer && pbf) {
|
|
47
|
+
if (tag === 15)
|
|
48
|
+
layer.version = pbf.readVarint();
|
|
49
|
+
else if (tag === 1)
|
|
50
|
+
layer.name = pbf.readString();
|
|
51
|
+
else if (tag === 5)
|
|
52
|
+
layer.extent = pbf.readVarint();
|
|
53
|
+
else if (tag === 2)
|
|
54
|
+
layer._features.push(pbf.pos);
|
|
55
|
+
else if (tag === 3)
|
|
56
|
+
layer._keys.push(pbf.readString());
|
|
57
|
+
else if (tag === 4)
|
|
58
|
+
layer._values.push(readValueMessage(pbf));
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
|
-
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param pbf
|
|
64
|
+
* @returns value
|
|
65
|
+
*/
|
|
53
66
|
function readValueMessage(pbf) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
let value = null;
|
|
68
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
69
|
+
while (pbf.pos < end) {
|
|
70
|
+
const tag = pbf.readVarint() >> 3;
|
|
71
|
+
value =
|
|
72
|
+
tag === 1
|
|
73
|
+
? pbf.readString()
|
|
74
|
+
: tag === 2
|
|
75
|
+
? pbf.readFloat()
|
|
76
|
+
: tag === 3
|
|
77
|
+
? pbf.readDouble()
|
|
78
|
+
: tag === 4
|
|
79
|
+
? pbf.readVarint64()
|
|
80
|
+
: tag === 5
|
|
81
|
+
? pbf.readVarint()
|
|
82
|
+
: tag === 6
|
|
83
|
+
? pbf.readSVarint()
|
|
84
|
+
: tag === 7
|
|
85
|
+
? pbf.readBoolean()
|
|
86
|
+
: null;
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
63
89
|
}
|
|
64
|
-
//# sourceMappingURL=vector-tile-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAClD,OAAO,QAAQ,MAAM,KAAK,CAAC;AAE3B,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,MAAM,EAAE;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,eAAe,CAAA;KAAC,CAAC;gBAC3B,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,MAAM;CAGxC"}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const vector_tile_layer_1 = __importDefault(require("./vector-tile-layer"));
|
|
8
|
+
class VectorTile {
|
|
9
|
+
constructor(pbf, end) {
|
|
10
|
+
this.layers = pbf.readFields(readTile, {}, end);
|
|
11
|
+
}
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
exports.default = VectorTile;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param tag
|
|
17
|
+
* @param layers
|
|
18
|
+
* @param pbf
|
|
19
|
+
*/
|
|
12
20
|
function readTile(tag, layers, pbf) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
if (tag === 3) {
|
|
22
|
+
if (pbf) {
|
|
23
|
+
const layer = new vector_tile_layer_1.default(pbf, pbf.readVarint() + pbf.pos);
|
|
24
|
+
if (layer.length && layers) {
|
|
25
|
+
layers[layer.name] = layer;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
|
-
}
|
|
22
29
|
}
|
|
23
|
-
//# sourceMappingURL=vector-tile.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Feature, BinaryFeatures, GeoJSONRowTable } from '@loaders.gl/schema';
|
|
2
|
+
import type { MVTLoaderOptions } from '../lib/types';
|
|
3
|
+
/**
|
|
4
|
+
* Parse MVT arrayBuffer and return GeoJSON.
|
|
5
|
+
*
|
|
6
|
+
* @param arrayBuffer A MVT arrayBuffer
|
|
7
|
+
* @param options
|
|
8
|
+
* @returns A GeoJSON geometry object or a binary representation
|
|
9
|
+
*/
|
|
10
|
+
export default function parseMVT(arrayBuffer: ArrayBuffer, options?: MVTLoaderOptions): BinaryFeatures | GeoJSONRowTable | Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>[] | {
|
|
11
|
+
shape: string;
|
|
12
|
+
data: BinaryFeatures;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=parse-mvt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EAEP,cAAc,EACd,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAmC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAOrF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,gBAAgB;;;EAuBpF"}
|