@loaders.gl/mvt 4.2.0-alpha.4 → 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.
Files changed (92) hide show
  1. package/dist/dist.dev.js +274 -252
  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 +37 -61
  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 +135 -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 +77 -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 +17 -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 +177 -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 +197 -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 +71 -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 +156 -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 +75 -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 +17 -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 +41 -21
  60. package/dist/mvt-source.js +148 -139
  61. package/dist/tilejson-loader.d.ts +1 -1
  62. package/dist/tilejson-loader.d.ts.map +1 -1
  63. package/dist/tilejson-loader.js +31 -30
  64. package/dist/workers/mvt-worker.js +0 -1
  65. package/package.json +12 -8
  66. package/dist/helpers/binary-util-functions.js.map +0 -1
  67. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  68. package/dist/index.js.map +0 -1
  69. package/dist/lib/binary-vector-tile/LICENSE.txt +0 -31
  70. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  71. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  72. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  73. package/dist/lib/geojson-tiler/LICENSE +0 -19
  74. package/dist/lib/geojson-tiler/clip.js.map +0 -1
  75. package/dist/lib/geojson-tiler/convert.js.map +0 -1
  76. package/dist/lib/geojson-tiler/feature.js.map +0 -1
  77. package/dist/lib/geojson-tiler/geojson-tiler.js.map +0 -1
  78. package/dist/lib/geojson-tiler/simplify.js.map +0 -1
  79. package/dist/lib/geojson-tiler/tile.js.map +0 -1
  80. package/dist/lib/geojson-tiler/transform.js.map +0 -1
  81. package/dist/lib/geojson-tiler/wrap.js.map +0 -1
  82. package/dist/lib/mapbox-vector-tile/LICENSE.txt +0 -31
  83. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  84. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  85. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  86. package/dist/lib/parse-mvt.js.map +0 -1
  87. package/dist/lib/parse-tilejson.js.map +0 -1
  88. package/dist/lib/types.js.map +0 -1
  89. package/dist/mvt-loader.js.map +0 -1
  90. package/dist/mvt-source.js.map +0 -1
  91. package/dist/tilejson-loader.js.map +0 -1
  92. 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
- 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
+ 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
- } else {
55
- throw new Error(`unknown command ${cmd}`);
56
- }
59
+ if (line)
60
+ lines.push(line);
61
+ return lines;
57
62
  }
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
- }
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
- 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];
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 = points;
105
- transform(coords, this);
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
- 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
- }
133
+ else {
134
+ type = `Multi${type}`;
118
135
  }
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);
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
- 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
- }
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,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,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
- 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
+ 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
- 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
- }
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
- 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;
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,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,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
- constructor(pbf, end) {
4
- this.layers = void 0;
5
- this.layers = pbf.readFields(readTile, {}, end);
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
- 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
- }
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
@@ -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"}