@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,4 +1,6 @@
1
+ // This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
1
2
  import { classifyRings, project, readFeature } from "../../helpers/binary-util-functions.js";
3
+ // Reduce GC by reusing variables
2
4
  let endPos;
3
5
  let cmd;
4
6
  let cmdLen;
@@ -7,129 +9,153 @@ let x;
7
9
  let y;
8
10
  let i;
9
11
  export const TEST_EXPORTS = {
10
- classifyRings
12
+ classifyRings
11
13
  };
12
14
  export default class VectorTileFeature {
13
- constructor(pbf, end, extent, keys, values, geometryInfo) {
14
- this.properties = void 0;
15
- this.extent = void 0;
16
- this.type = void 0;
17
- this.id = void 0;
18
- this._pbf = void 0;
19
- this._geometry = void 0;
20
- this._keys = void 0;
21
- this._values = void 0;
22
- this._geometryInfo = void 0;
23
- this.properties = {};
24
- this.extent = extent;
25
- this.type = 0;
26
- this.id = null;
27
- this._pbf = pbf;
28
- this._geometry = -1;
29
- this._keys = keys;
30
- this._values = values;
31
- this._geometryInfo = geometryInfo;
32
- pbf.readFields(readFeature, this, end);
33
- }
34
- loadGeometry() {
35
- const pbf = this._pbf;
36
- pbf.pos = this._geometry;
37
- endPos = pbf.readVarint() + pbf.pos;
38
- cmd = 1;
39
- length = 0;
40
- x = 0;
41
- y = 0;
42
- i = 0;
43
- const indices = [];
44
- const data = [];
45
- while (pbf.pos < endPos) {
46
- if (length <= 0) {
47
- cmdLen = pbf.readVarint();
48
- cmd = cmdLen & 0x7;
49
- length = cmdLen >> 3;
50
- }
51
- length--;
52
- if (cmd === 1 || cmd === 2) {
53
- x += pbf.readSVarint();
54
- y += pbf.readSVarint();
55
- if (cmd === 1) {
56
- indices.push(i);
57
- }
58
- data.push(x, y);
59
- i += 2;
60
- } else if (cmd === 7) {
61
- if (i > 0) {
62
- const start = indices[indices.length - 1];
63
- data.push(data[start], data[start + 1]);
64
- i += 2;
65
- }
66
- } else {
67
- throw new Error(`unknown command ${cmd}`);
68
- }
15
+ properties;
16
+ extent;
17
+ type;
18
+ id;
19
+ _pbf;
20
+ _geometry;
21
+ _keys;
22
+ _values;
23
+ _geometryInfo;
24
+ // eslint-disable-next-line max-params
25
+ constructor(pbf, end, extent, keys, values, geometryInfo) {
26
+ // Public
27
+ this.properties = {};
28
+ this.extent = extent;
29
+ this.type = 0;
30
+ this.id = null;
31
+ // Private
32
+ this._pbf = pbf;
33
+ this._geometry = -1;
34
+ this._keys = keys;
35
+ this._values = values;
36
+ this._geometryInfo = geometryInfo;
37
+ pbf.readFields(readFeature, this, end);
69
38
  }
70
- return {
71
- data,
72
- indices
73
- };
74
- }
75
- _toBinaryCoordinates(transform) {
76
- const geom = this.loadGeometry();
77
- let geometry;
78
- transform(geom.data, this);
79
- const coordLength = 2;
80
- switch (this.type) {
81
- case 1:
82
- this._geometryInfo.pointFeaturesCount++;
83
- this._geometryInfo.pointPositionsCount += geom.indices.length;
84
- geometry = {
85
- type: 'Point',
86
- ...geom
87
- };
88
- break;
89
- case 2:
90
- this._geometryInfo.lineFeaturesCount++;
91
- this._geometryInfo.linePathsCount += geom.indices.length;
92
- this._geometryInfo.linePositionsCount += geom.data.length / coordLength;
93
- geometry = {
94
- type: 'LineString',
95
- ...geom
96
- };
97
- break;
98
- case 3:
99
- geometry = classifyRings(geom);
100
- this._geometryInfo.polygonFeaturesCount++;
101
- this._geometryInfo.polygonObjectsCount += geometry.indices.length;
102
- for (const indices of geometry.indices) {
103
- this._geometryInfo.polygonRingsCount += indices.length;
39
+ // eslint-disable-next-line complexity, max-statements
40
+ loadGeometry() {
41
+ const pbf = this._pbf;
42
+ pbf.pos = this._geometry;
43
+ endPos = pbf.readVarint() + pbf.pos;
44
+ cmd = 1;
45
+ length = 0;
46
+ x = 0;
47
+ y = 0;
48
+ i = 0;
49
+ // Note: I attempted to replace the `data` array with a
50
+ // Float32Array, but performance was worse, both using
51
+ // `set()` and direct index access. Also, we cannot
52
+ // know how large the buffer should be, so it would
53
+ // increase memory usage
54
+ const indices = []; // Indices where geometries start
55
+ const data = []; // Flat array of coordinate data
56
+ while (pbf.pos < endPos) {
57
+ if (length <= 0) {
58
+ cmdLen = pbf.readVarint();
59
+ cmd = cmdLen & 0x7;
60
+ length = cmdLen >> 3;
61
+ }
62
+ length--;
63
+ if (cmd === 1 || cmd === 2) {
64
+ x += pbf.readSVarint();
65
+ y += pbf.readSVarint();
66
+ if (cmd === 1) {
67
+ // New line
68
+ indices.push(i);
69
+ }
70
+ data.push(x, y);
71
+ i += 2;
72
+ }
73
+ else if (cmd === 7) {
74
+ // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
75
+ if (i > 0) {
76
+ const start = indices[indices.length - 1]; // start index of polygon
77
+ data.push(data[start], data[start + 1]); // closePolygon
78
+ i += 2;
79
+ }
80
+ }
81
+ else {
82
+ throw new Error(`unknown command ${cmd}`);
83
+ }
104
84
  }
105
- this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
106
- break;
107
- default:
108
- throw new Error(`Invalid geometry type: ${this.type}`);
85
+ return { data, indices };
109
86
  }
110
- const result = {
111
- type: 'Feature',
112
- geometry,
113
- properties: this.properties
114
- };
115
- if (this.id !== null) {
116
- result.id = this.id;
87
+ /**
88
+ *
89
+ * @param transform
90
+ * @returns result
91
+ */
92
+ _toBinaryCoordinates(transform) {
93
+ // Expands the protobuf data to an intermediate Flat GeoJSON
94
+ // data format, which maps closely to the binary data buffers.
95
+ // It is similar to GeoJSON, but rather than storing the coordinates
96
+ // in multidimensional arrays, we have a 1D `data` with all the
97
+ // coordinates, and then index into this using the `indices`
98
+ // parameter, e.g.
99
+ //
100
+ // geometry: {
101
+ // type: 'Point', data: [1,2], indices: [0]
102
+ // }
103
+ // geometry: {
104
+ // type: 'LineString', data: [1,2,3,4,...], indices: [0]
105
+ // }
106
+ // geometry: {
107
+ // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
108
+ // }
109
+ // Thus the indices member lets us look up the relevant range
110
+ // from the data array.
111
+ // The Multi* versions of the above types share the same data
112
+ // structure, just with multiple elements in the indices array
113
+ const geom = this.loadGeometry();
114
+ let geometry;
115
+ // Apply the supplied transformation to data
116
+ transform(geom.data, this);
117
+ const coordLength = 2;
118
+ // eslint-disable-next-line default-case
119
+ switch (this.type) {
120
+ case 1: // Point
121
+ this._geometryInfo.pointFeaturesCount++;
122
+ this._geometryInfo.pointPositionsCount += geom.indices.length;
123
+ geometry = { type: 'Point', ...geom };
124
+ break;
125
+ case 2: // LineString
126
+ this._geometryInfo.lineFeaturesCount++;
127
+ this._geometryInfo.linePathsCount += geom.indices.length;
128
+ this._geometryInfo.linePositionsCount += geom.data.length / coordLength;
129
+ geometry = { type: 'LineString', ...geom };
130
+ break;
131
+ case 3: // Polygon
132
+ geometry = classifyRings(geom);
133
+ // Unlike Point & LineString geom.indices is a 2D array, thanks
134
+ // to the classifyRings method
135
+ this._geometryInfo.polygonFeaturesCount++;
136
+ this._geometryInfo.polygonObjectsCount += geometry.indices.length;
137
+ for (const indices of geometry.indices) {
138
+ this._geometryInfo.polygonRingsCount += indices.length;
139
+ }
140
+ this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
141
+ break;
142
+ default:
143
+ throw new Error(`Invalid geometry type: ${this.type}`);
144
+ }
145
+ const result = { type: 'Feature', geometry, properties: this.properties };
146
+ if (this.id !== null) {
147
+ result.id = this.id;
148
+ }
149
+ return result;
117
150
  }
118
- return result;
119
- }
120
- toBinaryCoordinates(options) {
121
- if (typeof options === 'function') {
122
- return this._toBinaryCoordinates(options);
151
+ toBinaryCoordinates(options) {
152
+ if (typeof options === 'function') {
153
+ return this._toBinaryCoordinates(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
+ return this._toBinaryCoordinates((data) => project(data, x0, y0, size));
123
160
  }
124
- const {
125
- x,
126
- y,
127
- z
128
- } = options;
129
- const size = this.extent * Math.pow(2, z);
130
- const x0 = this.extent * x;
131
- const y0 = this.extent * y;
132
- return this._toBinaryCoordinates(data => project(data, x0, y0, size));
133
- }
134
161
  }
135
- //# sourceMappingURL=vector-tile-feature.js.map
@@ -1,4 +1,4 @@
1
- import VectorTileFeature from './vector-tile-feature';
1
+ import VectorTileFeature from "./vector-tile-feature.js";
2
2
  import Protobuf from 'pbf';
3
3
  import { GeojsonGeometryInfo } from '@loaders.gl/schema';
4
4
  export default class VectorTileLayer {
@@ -1 +1 @@
1
- {"version":3,"file":"vector-tile-layer.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-vector-tile/vector-tile-layer.ts"],"names":[],"mappings":"AAGA,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAEvD,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;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,GAAG,iBAAiB;CAiBzE"}
1
+ {"version":3,"file":"vector-tile-layer.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-vector-tile/vector-tile-layer.ts"],"names":[],"mappings":"AAGA,OAAO,iBAAiB,iCAA8B;AACtD,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAEvD,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;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,GAAG,iBAAiB;CAiBzE"}
@@ -1,46 +1,93 @@
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, geometryInfo) {
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
+ *
30
+ * @param index
31
+ * @param geometryInfo
32
+ * @returns {VectorTileFeature}
33
+ */
34
+ feature(i, geometryInfo) {
35
+ if (i < 0 || i >= this._features.length) {
36
+ throw new Error('feature index out of bounds');
37
+ }
38
+ this._pbf.pos = this._features[i];
39
+ const end = this._pbf.readVarint() + this._pbf.pos;
40
+ return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);
26
41
  }
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, geometryInfo);
30
- }
31
42
  }
43
+ /**
44
+ *
45
+ * @param tag
46
+ * @param layer
47
+ * @param pbf
48
+ */
32
49
  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
- }
50
+ if (layer && pbf) {
51
+ if (tag === 15)
52
+ layer.version = pbf.readVarint();
53
+ else if (tag === 1)
54
+ layer.name = pbf.readString();
55
+ else if (tag === 5)
56
+ layer.extent = pbf.readVarint();
57
+ else if (tag === 2)
58
+ layer._features.push(pbf.pos);
59
+ else if (tag === 3)
60
+ layer._keys.push(pbf.readString());
61
+ else if (tag === 4)
62
+ layer._values.push(readValueMessage(pbf));
63
+ }
36
64
  }
65
+ /**
66
+ *
67
+ * @param pbf
68
+ * @returns value
69
+ */
37
70
  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;
71
+ let value = null;
72
+ const end = pbf.readVarint() + pbf.pos;
73
+ while (pbf.pos < end) {
74
+ const tag = pbf.readVarint() >> 3;
75
+ value =
76
+ tag === 1
77
+ ? pbf.readString()
78
+ : tag === 2
79
+ ? pbf.readFloat()
80
+ : tag === 3
81
+ ? pbf.readDouble()
82
+ : tag === 4
83
+ ? pbf.readVarint64()
84
+ : tag === 5
85
+ ? pbf.readVarint()
86
+ : tag === 6
87
+ ? pbf.readSVarint()
88
+ : tag === 7
89
+ ? pbf.readBoolean()
90
+ : null;
91
+ }
92
+ return value;
45
93
  }
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/binary-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/binary-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,4 +1,4 @@
1
- import type { GeoJSONTileFeature } from './tile';
1
+ import type { GeoJSONTileFeature } from "./tile.js";
2
2
  /**
3
3
  * Clip features between two vertical or horizontal axis-parallel lines:
4
4
  * | |
@@ -1 +1 @@
1
- {"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/clip.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,QAAQ,CAAC;AAK/C;;;;;;;;;;GAUG;AAEH,wBAAgB,IAAI,CAClB,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,KAAA,EACJ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAC,WAAW,EAAE,OAAO,CAAA;CAAC,GAC9B,kBAAkB,EAAE,GAAG,IAAI,CA4E7B"}
1
+ {"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/clip.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,kBAAkB,EAAC,kBAAe;AAK/C;;;;;;;;;;GAUG;AAEH,wBAAgB,IAAI,CAClB,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,KAAA,EACJ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAC,WAAW,EAAE,OAAO,CAAA;CAAC,GAC9B,kBAAkB,EAAE,GAAG,IAAI,CA4E7B"}