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