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