@loaders.gl/mvt 4.2.0-alpha.3 → 4.2.0-alpha.5
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/dist.dev.js +274 -252
- package/dist/dist.min.js +14 -0
- package/dist/helpers/binary-util-functions.d.ts +1 -1
- package/dist/helpers/binary-util-functions.d.ts.map +1 -1
- package/dist/helpers/binary-util-functions.js +99 -61
- package/dist/helpers/mapbox-util-functions.d.ts +2 -2
- package/dist/helpers/mapbox-util-functions.d.ts.map +1 -1
- package/dist/helpers/mapbox-util-functions.js +67 -33
- package/dist/index.cjs +37 -61
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +135 -118
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +77 -38
- package/dist/lib/binary-vector-tile/vector-tile.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile.js +17 -12
- package/dist/lib/geojson-tiler/clip.d.ts +1 -1
- package/dist/lib/geojson-tiler/clip.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/clip.js +177 -142
- package/dist/lib/geojson-tiler/convert.d.ts +1 -1
- package/dist/lib/geojson-tiler/convert.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/convert.js +116 -100
- package/dist/lib/geojson-tiler/feature.d.ts +1 -1
- package/dist/lib/geojson-tiler/feature.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/feature.js +38 -29
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts +1 -1
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/geojson-tiler.js +197 -159
- package/dist/lib/geojson-tiler/simplify.js +60 -40
- package/dist/lib/geojson-tiler/tile.js +108 -88
- package/dist/lib/geojson-tiler/transform.d.ts +1 -1
- package/dist/lib/geojson-tiler/transform.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/transform.js +35 -26
- package/dist/lib/geojson-tiler/wrap.d.ts +1 -1
- package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/wrap.js +71 -53
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +156 -151
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +75 -38
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.js +17 -12
- package/dist/lib/parse-mvt.d.ts +1 -1
- package/dist/lib/parse-mvt.d.ts.map +1 -1
- package/dist/lib/parse-mvt.js +142 -115
- package/dist/lib/parse-tilejson.js +234 -176
- package/dist/lib/types.js +0 -1
- package/dist/mvt-loader.d.ts +1 -1
- package/dist/mvt-loader.d.ts.map +1 -1
- package/dist/mvt-loader.js +42 -22
- package/dist/mvt-source.js +148 -139
- package/dist/mvt-worker.js +1 -1
- package/dist/tilejson-loader.d.ts +1 -1
- package/dist/tilejson-loader.d.ts.map +1 -1
- package/dist/tilejson-loader.js +32 -31
- package/dist/workers/mvt-worker.js +0 -1
- package/package.json +12 -8
- 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/LICENSE.txt +0 -31
- 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/geojson-tiler/LICENSE +0 -19
- package/dist/lib/geojson-tiler/clip.js.map +0 -1
- package/dist/lib/geojson-tiler/convert.js.map +0 -1
- package/dist/lib/geojson-tiler/feature.js.map +0 -1
- package/dist/lib/geojson-tiler/geojson-tiler.js.map +0 -1
- package/dist/lib/geojson-tiler/simplify.js.map +0 -1
- package/dist/lib/geojson-tiler/tile.js.map +0 -1
- package/dist/lib/geojson-tiler/transform.js.map +0 -1
- package/dist/lib/geojson-tiler/wrap.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/LICENSE.txt +0 -31
- 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/parse-tilejson.js.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/mvt-loader.js.map +0 -1
- package/dist/mvt-source.js.map +0 -1
- package/dist/tilejson-loader.js.map +0 -1
- package/dist/workers/mvt-worker.js.map +0 -1
|
@@ -1,162 +1,167 @@
|
|
|
1
1
|
import { readFeature, classifyRings } from "../../helpers/mapbox-util-functions.js";
|
|
2
2
|
export default class VectorTileFeature {
|
|
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
|
-
|
|
3
|
+
static get types() {
|
|
4
|
+
return ['Unknown', 'Point', 'LineString', 'Polygon'];
|
|
5
|
+
}
|
|
6
|
+
constructor(pbf, end, extent, keys, values) {
|
|
7
|
+
// Public
|
|
8
|
+
this.properties = {};
|
|
9
|
+
this.extent = extent;
|
|
10
|
+
this.type = 0;
|
|
11
|
+
this.id = null;
|
|
12
|
+
// Private
|
|
13
|
+
this._pbf = pbf;
|
|
14
|
+
this._geometry = -1;
|
|
15
|
+
this._keys = keys;
|
|
16
|
+
this._values = values;
|
|
17
|
+
pbf.readFields(readFeature, this, end);
|
|
18
|
+
}
|
|
19
|
+
// eslint-disable-next-line complexity, max-statements
|
|
20
|
+
loadGeometry() {
|
|
21
|
+
const pbf = this._pbf;
|
|
22
|
+
pbf.pos = this._geometry;
|
|
23
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
24
|
+
let cmd = 1;
|
|
25
|
+
let length = 0;
|
|
26
|
+
let x = 0;
|
|
27
|
+
let y = 0;
|
|
28
|
+
const lines = [];
|
|
29
|
+
let line;
|
|
30
|
+
while (pbf.pos < end) {
|
|
31
|
+
if (length <= 0) {
|
|
32
|
+
const cmdLen = pbf.readVarint();
|
|
33
|
+
cmd = cmdLen & 0x7;
|
|
34
|
+
length = cmdLen >> 3;
|
|
35
|
+
}
|
|
36
|
+
length--;
|
|
37
|
+
if (cmd === 1 || cmd === 2) {
|
|
38
|
+
x += pbf.readSVarint();
|
|
39
|
+
y += pbf.readSVarint();
|
|
40
|
+
if (cmd === 1) {
|
|
41
|
+
// moveTo
|
|
42
|
+
if (line)
|
|
43
|
+
lines.push(line);
|
|
44
|
+
line = [];
|
|
45
|
+
}
|
|
46
|
+
if (line)
|
|
47
|
+
line.push([x, y]);
|
|
48
|
+
}
|
|
49
|
+
else if (cmd === 7) {
|
|
50
|
+
// Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
|
|
51
|
+
if (line) {
|
|
52
|
+
line.push(line[0].slice()); // closePolygon
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new Error(`unknown command ${cmd}`);
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (line)
|
|
60
|
+
lines.push(line);
|
|
61
|
+
return lines;
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
63
|
+
// eslint-disable-next-line max-statements
|
|
64
|
+
bbox() {
|
|
65
|
+
const pbf = this._pbf;
|
|
66
|
+
pbf.pos = this._geometry;
|
|
67
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
68
|
+
let cmd = 1;
|
|
69
|
+
let length = 0;
|
|
70
|
+
let x = 0;
|
|
71
|
+
let y = 0;
|
|
72
|
+
let x1 = Infinity;
|
|
73
|
+
let x2 = -Infinity;
|
|
74
|
+
let y1 = Infinity;
|
|
75
|
+
let y2 = -Infinity;
|
|
76
|
+
while (pbf.pos < end) {
|
|
77
|
+
if (length <= 0) {
|
|
78
|
+
const cmdLen = pbf.readVarint();
|
|
79
|
+
cmd = cmdLen & 0x7;
|
|
80
|
+
length = cmdLen >> 3;
|
|
81
|
+
}
|
|
82
|
+
length--;
|
|
83
|
+
if (cmd === 1 || cmd === 2) {
|
|
84
|
+
x += pbf.readSVarint();
|
|
85
|
+
y += pbf.readSVarint();
|
|
86
|
+
if (x < x1)
|
|
87
|
+
x1 = x;
|
|
88
|
+
if (x > x2)
|
|
89
|
+
x2 = x;
|
|
90
|
+
if (y < y1)
|
|
91
|
+
y1 = y;
|
|
92
|
+
if (y > y2)
|
|
93
|
+
y2 = y;
|
|
94
|
+
}
|
|
95
|
+
else if (cmd !== 7) {
|
|
96
|
+
throw new Error(`unknown command ${cmd}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return [x1, y1, x2, y2];
|
|
90
100
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
_toGeoJSON(transform) {
|
|
102
|
+
let coords = this.loadGeometry();
|
|
103
|
+
let type = VectorTileFeature.types[this.type];
|
|
104
|
+
let i;
|
|
105
|
+
let j;
|
|
106
|
+
// eslint-disable-next-line default-case
|
|
107
|
+
switch (this.type) {
|
|
108
|
+
case 1:
|
|
109
|
+
const points = [];
|
|
110
|
+
for (i = 0; i < coords.length; i++) {
|
|
111
|
+
points[i] = coords[i][0];
|
|
112
|
+
}
|
|
113
|
+
coords = points;
|
|
114
|
+
transform(coords, this);
|
|
115
|
+
break;
|
|
116
|
+
case 2:
|
|
117
|
+
for (i = 0; i < coords.length; i++) {
|
|
118
|
+
transform(coords[i], this);
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case 3:
|
|
122
|
+
coords = classifyRings(coords);
|
|
123
|
+
for (i = 0; i < coords.length; i++) {
|
|
124
|
+
for (j = 0; j < coords[i].length; j++) {
|
|
125
|
+
transform(coords[i][j], this);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
103
129
|
}
|
|
104
|
-
coords
|
|
105
|
-
|
|
106
|
-
break;
|
|
107
|
-
case 2:
|
|
108
|
-
for (i = 0; i < coords.length; i++) {
|
|
109
|
-
transform(coords[i], this);
|
|
130
|
+
if (coords.length === 1) {
|
|
131
|
+
coords = coords[0];
|
|
110
132
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
coords = classifyRings(coords);
|
|
114
|
-
for (i = 0; i < coords.length; i++) {
|
|
115
|
-
for (j = 0; j < coords[i].length; j++) {
|
|
116
|
-
transform(coords[i][j], this);
|
|
117
|
-
}
|
|
133
|
+
else {
|
|
134
|
+
type = `Multi${type}`;
|
|
118
135
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
properties: this.properties
|
|
133
|
-
};
|
|
134
|
-
if (this.id !== null) {
|
|
135
|
-
result.id = this.id;
|
|
136
|
-
}
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
toGeoJSON(options) {
|
|
140
|
-
if (typeof options === 'function') {
|
|
141
|
-
return this._toGeoJSON(options);
|
|
136
|
+
const result = {
|
|
137
|
+
type: 'Feature',
|
|
138
|
+
geometry: {
|
|
139
|
+
type,
|
|
140
|
+
coordinates: coords
|
|
141
|
+
},
|
|
142
|
+
properties: this.properties
|
|
143
|
+
};
|
|
144
|
+
if (this.id !== null) {
|
|
145
|
+
result.id = this.id;
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
142
148
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
toGeoJSON(options) {
|
|
150
|
+
if (typeof options === 'function') {
|
|
151
|
+
return this._toGeoJSON(options);
|
|
152
|
+
}
|
|
153
|
+
const { x, y, z } = options;
|
|
154
|
+
const size = this.extent * Math.pow(2, z);
|
|
155
|
+
const x0 = this.extent * x;
|
|
156
|
+
const y0 = this.extent * y;
|
|
157
|
+
function project(line) {
|
|
158
|
+
for (let j = 0; j < line.length; j++) {
|
|
159
|
+
const p = line[j];
|
|
160
|
+
p[0] = ((p[0] + x0) * 360) / size - 180;
|
|
161
|
+
const y2 = 180 - ((p[1] + y0) * 360) / size;
|
|
162
|
+
p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return this._toGeoJSON(project);
|
|
158
166
|
}
|
|
159
|
-
return this._toGeoJSON(project);
|
|
160
|
-
}
|
|
161
167
|
}
|
|
162
|
-
//# sourceMappingURL=vector-tile-feature.js.map
|
|
@@ -1 +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,
|
|
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,iCAA8B;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,46 +1,83 @@
|
|
|
1
|
+
/* eslint-disable indent */
|
|
2
|
+
// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
|
|
1
3
|
import VectorTileFeature from "./vector-tile-feature.js";
|
|
2
4
|
export default class VectorTileLayer {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
constructor(pbf, end) {
|
|
6
|
+
// Public
|
|
7
|
+
this.version = 1;
|
|
8
|
+
this.name = '';
|
|
9
|
+
this.extent = 4096;
|
|
10
|
+
this.length = 0;
|
|
11
|
+
// Private
|
|
12
|
+
this._pbf = pbf;
|
|
13
|
+
this._keys = [];
|
|
14
|
+
this._values = [];
|
|
15
|
+
this._features = [];
|
|
16
|
+
pbf.readFields(readLayer, this, end);
|
|
17
|
+
this.length = this._features.length;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* return feature `i` from this layer as a `VectorTileFeature`
|
|
21
|
+
* @param index
|
|
22
|
+
* @returns feature
|
|
23
|
+
*/
|
|
24
|
+
feature(i) {
|
|
25
|
+
if (i < 0 || i >= this._features.length) {
|
|
26
|
+
throw new Error('feature index out of bounds');
|
|
27
|
+
}
|
|
28
|
+
this._pbf.pos = this._features[i];
|
|
29
|
+
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
30
|
+
return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
|
|
26
31
|
}
|
|
27
|
-
this._pbf.pos = this._features[i];
|
|
28
|
-
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
29
|
-
return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
|
|
30
|
-
}
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param tag
|
|
36
|
+
* @param layer
|
|
37
|
+
* @param pbf
|
|
38
|
+
*/
|
|
32
39
|
function readLayer(tag, layer, pbf) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
if (layer && pbf) {
|
|
41
|
+
if (tag === 15)
|
|
42
|
+
layer.version = pbf.readVarint();
|
|
43
|
+
else if (tag === 1)
|
|
44
|
+
layer.name = pbf.readString();
|
|
45
|
+
else if (tag === 5)
|
|
46
|
+
layer.extent = pbf.readVarint();
|
|
47
|
+
else if (tag === 2)
|
|
48
|
+
layer._features.push(pbf.pos);
|
|
49
|
+
else if (tag === 3)
|
|
50
|
+
layer._keys.push(pbf.readString());
|
|
51
|
+
else if (tag === 4)
|
|
52
|
+
layer._values.push(readValueMessage(pbf));
|
|
53
|
+
}
|
|
36
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param pbf
|
|
58
|
+
* @returns value
|
|
59
|
+
*/
|
|
37
60
|
function readValueMessage(pbf) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
let value = null;
|
|
62
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
63
|
+
while (pbf.pos < end) {
|
|
64
|
+
const tag = pbf.readVarint() >> 3;
|
|
65
|
+
value =
|
|
66
|
+
tag === 1
|
|
67
|
+
? pbf.readString()
|
|
68
|
+
: tag === 2
|
|
69
|
+
? pbf.readFloat()
|
|
70
|
+
: tag === 3
|
|
71
|
+
? pbf.readDouble()
|
|
72
|
+
: tag === 4
|
|
73
|
+
? pbf.readVarint64()
|
|
74
|
+
: tag === 5
|
|
75
|
+
? pbf.readVarint()
|
|
76
|
+
: tag === 6
|
|
77
|
+
? pbf.readSVarint()
|
|
78
|
+
: tag === 7
|
|
79
|
+
? pbf.readBoolean()
|
|
80
|
+
: null;
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
45
83
|
}
|
|
46
|
-
//# sourceMappingURL=vector-tile-layer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe
|
|
1
|
+
{"version":3,"file":"vector-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,+BAA4B;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,18 +1,23 @@
|
|
|
1
|
+
// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
|
|
1
2
|
import VectorTileLayer from "./vector-tile-layer.js";
|
|
2
3
|
export default class VectorTile {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
constructor(pbf, end) {
|
|
5
|
+
this.layers = pbf.readFields(readTile, {}, end);
|
|
6
|
+
}
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param tag
|
|
11
|
+
* @param layers
|
|
12
|
+
* @param pbf
|
|
13
|
+
*/
|
|
8
14
|
function readTile(tag, layers, pbf) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
if (tag === 3) {
|
|
16
|
+
if (pbf) {
|
|
17
|
+
const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
|
|
18
|
+
if (layer.length && layers) {
|
|
19
|
+
layers[layer.name] = layer;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
|
-
}
|
|
17
23
|
}
|
|
18
|
-
//# sourceMappingURL=vector-tile.js.map
|
package/dist/lib/parse-mvt.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EAEP,uBAAuB,EACvB,YAAY,EACb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAmC,gBAAgB,EAAC,
|
|
1
|
+
{"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EAEP,uBAAuB,EACvB,YAAY,EACb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAmC,gBAAgB,EAAC,wBAAqB;AAOrF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,gBAAgB;;;EAyBpF"}
|