@loaders.gl/mvt 4.0.0-alpha.5 → 4.0.0-alpha.7

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 (175) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/dist.min.js +1748 -913
  3. package/dist/es5/bundle.js +6 -0
  4. package/dist/es5/bundle.js.map +1 -0
  5. package/dist/es5/helpers/binary-util-functions.js +82 -0
  6. package/dist/es5/helpers/binary-util-functions.js.map +1 -0
  7. package/dist/es5/helpers/mapbox-util-functions.js +50 -0
  8. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
  9. package/dist/es5/index.js +26 -0
  10. package/dist/es5/index.js.map +1 -0
  11. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +168 -0
  12. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  13. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +62 -0
  14. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  15. package/dist/es5/lib/binary-vector-tile/vector-tile.js +28 -0
  16. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
  17. package/dist/es5/lib/geojson-tiler/LICENSE +19 -0
  18. package/dist/es5/lib/geojson-tiler/clip.js +237 -0
  19. package/dist/es5/lib/geojson-tiler/clip.js.map +1 -0
  20. package/dist/es5/lib/geojson-tiler/convert.js +161 -0
  21. package/dist/es5/lib/geojson-tiler/convert.js.map +1 -0
  22. package/dist/es5/lib/geojson-tiler/feature.js +62 -0
  23. package/dist/es5/lib/geojson-tiler/feature.js.map +1 -0
  24. package/dist/es5/lib/geojson-tiler/geojson-tiler.js +186 -0
  25. package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +1 -0
  26. package/dist/es5/lib/geojson-tiler/simplify.js +52 -0
  27. package/dist/es5/lib/geojson-tiler/simplify.js.map +1 -0
  28. package/dist/es5/lib/geojson-tiler/tile.js +121 -0
  29. package/dist/es5/lib/geojson-tiler/tile.js.map +1 -0
  30. package/dist/es5/lib/geojson-tiler/transform.js +50 -0
  31. package/dist/es5/lib/geojson-tiler/transform.js.map +1 -0
  32. package/dist/es5/lib/geojson-tiler/wrap.js +122 -0
  33. package/dist/es5/lib/geojson-tiler/wrap.js.map +1 -0
  34. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +184 -0
  35. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  36. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +62 -0
  37. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  38. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +28 -0
  39. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  40. package/dist/es5/lib/parse-mvt.js +143 -0
  41. package/dist/es5/lib/parse-mvt.js.map +1 -0
  42. package/dist/es5/lib/types.js +2 -0
  43. package/dist/es5/lib/types.js.map +1 -0
  44. package/dist/es5/mvt-loader.js +58 -0
  45. package/dist/es5/mvt-loader.js.map +1 -0
  46. package/dist/es5/workers/mvt-worker.js +6 -0
  47. package/dist/es5/workers/mvt-worker.js.map +1 -0
  48. package/dist/esm/bundle.js +4 -0
  49. package/dist/esm/bundle.js.map +1 -0
  50. package/dist/esm/helpers/binary-util-functions.js +73 -0
  51. package/dist/esm/helpers/binary-util-functions.js.map +1 -0
  52. package/dist/esm/helpers/mapbox-util-functions.js +41 -0
  53. package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
  54. package/dist/esm/index.js +3 -0
  55. package/dist/esm/index.js.map +1 -0
  56. package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
  57. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +136 -0
  58. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  59. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +47 -0
  60. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  61. package/dist/esm/lib/binary-vector-tile/vector-tile.js +19 -0
  62. package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
  63. package/dist/esm/lib/geojson-tiler/LICENSE +19 -0
  64. package/dist/esm/lib/geojson-tiler/clip.js +173 -0
  65. package/dist/esm/lib/geojson-tiler/clip.js.map +1 -0
  66. package/dist/esm/lib/geojson-tiler/convert.js +116 -0
  67. package/dist/esm/lib/geojson-tiler/convert.js.map +1 -0
  68. package/dist/esm/lib/geojson-tiler/feature.js +35 -0
  69. package/dist/esm/lib/geojson-tiler/feature.js.map +1 -0
  70. package/dist/esm/lib/geojson-tiler/geojson-tiler.js +171 -0
  71. package/dist/esm/lib/geojson-tiler/geojson-tiler.js.map +1 -0
  72. package/dist/esm/lib/geojson-tiler/simplify.js +46 -0
  73. package/dist/esm/lib/geojson-tiler/simplify.js.map +1 -0
  74. package/dist/esm/lib/geojson-tiler/tile.js +103 -0
  75. package/dist/esm/lib/geojson-tiler/tile.js.map +1 -0
  76. package/dist/esm/lib/geojson-tiler/transform.js +32 -0
  77. package/dist/esm/lib/geojson-tiler/transform.js.map +1 -0
  78. package/dist/esm/lib/geojson-tiler/wrap.js +67 -0
  79. package/dist/esm/lib/geojson-tiler/wrap.js.map +1 -0
  80. package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
  81. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +163 -0
  82. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  83. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +47 -0
  84. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  85. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +19 -0
  86. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  87. package/dist/esm/lib/parse-mvt.js +138 -0
  88. package/dist/esm/lib/parse-mvt.js.map +1 -0
  89. package/dist/esm/lib/types.js +2 -0
  90. package/dist/esm/lib/types.js.map +1 -0
  91. package/dist/esm/mvt-loader.js +29 -0
  92. package/dist/esm/mvt-loader.js.map +1 -0
  93. package/dist/esm/workers/mvt-worker.js +4 -0
  94. package/dist/esm/workers/mvt-worker.js.map +1 -0
  95. package/dist/helpers/binary-util-functions.js +111 -77
  96. package/dist/helpers/mapbox-util-functions.d.ts +2 -2
  97. package/dist/helpers/mapbox-util-functions.js +78 -45
  98. package/dist/index.d.ts +2 -0
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +9 -2
  101. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
  102. package/dist/lib/binary-vector-tile/vector-tile-feature.js +142 -143
  103. package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
  104. package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
  105. package/dist/lib/geojson-tiler/clip.d.ts +16 -0
  106. package/dist/lib/geojson-tiler/clip.d.ts.map +1 -0
  107. package/dist/lib/geojson-tiler/clip.js +209 -0
  108. package/dist/lib/geojson-tiler/convert.d.ts +10 -0
  109. package/dist/lib/geojson-tiler/convert.d.ts.map +1 -0
  110. package/dist/lib/geojson-tiler/convert.js +134 -0
  111. package/dist/lib/geojson-tiler/feature.d.ts +3 -0
  112. package/dist/lib/geojson-tiler/feature.d.ts.map +1 -0
  113. package/dist/lib/geojson-tiler/feature.js +46 -0
  114. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +44 -0
  115. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -0
  116. package/dist/lib/geojson-tiler/geojson-tiler.js +210 -0
  117. package/dist/lib/geojson-tiler/simplify.d.ts +10 -0
  118. package/dist/lib/geojson-tiler/simplify.d.ts.map +1 -0
  119. package/dist/lib/geojson-tiler/simplify.js +68 -0
  120. package/dist/lib/geojson-tiler/tile.d.ts +38 -0
  121. package/dist/lib/geojson-tiler/tile.d.ts.map +1 -0
  122. package/dist/lib/geojson-tiler/tile.js +125 -0
  123. package/dist/lib/geojson-tiler/transform.d.ts +7 -0
  124. package/dist/lib/geojson-tiler/transform.d.ts.map +1 -0
  125. package/dist/lib/geojson-tiler/transform.js +43 -0
  126. package/dist/lib/geojson-tiler/wrap.d.ts +17 -0
  127. package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -0
  128. package/dist/lib/geojson-tiler/wrap.js +86 -0
  129. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +4 -4
  130. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
  131. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
  132. package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
  133. package/dist/lib/parse-mvt.d.ts +6 -9
  134. package/dist/lib/parse-mvt.d.ts.map +1 -1
  135. package/dist/lib/parse-mvt.js +148 -98
  136. package/dist/lib/types.d.ts +48 -7
  137. package/dist/lib/types.d.ts.map +1 -1
  138. package/dist/lib/types.js +2 -2
  139. package/dist/mvt-loader.d.ts.map +1 -1
  140. package/dist/mvt-loader.js +43 -22
  141. package/dist/mvt-worker.js +903 -829
  142. package/dist/workers/mvt-worker.js +5 -4
  143. package/package.json +7 -7
  144. package/src/helpers/mapbox-util-functions.ts +2 -2
  145. package/src/index.ts +7 -0
  146. package/src/lib/binary-vector-tile/vector-tile-feature.ts +6 -1
  147. package/src/lib/geojson-tiler/LICENSE +19 -0
  148. package/src/lib/geojson-tiler/clip.ts +248 -0
  149. package/src/lib/geojson-tiler/convert.ts +158 -0
  150. package/src/lib/geojson-tiler/feature.ts +45 -0
  151. package/src/lib/geojson-tiler/geojson-tiler.ts +281 -0
  152. package/src/lib/geojson-tiler/simplify.ts +77 -0
  153. package/src/lib/geojson-tiler/tile.ts +185 -0
  154. package/src/lib/geojson-tiler/transform.ts +55 -0
  155. package/src/lib/geojson-tiler/wrap.ts +108 -0
  156. package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +4 -4
  157. package/src/lib/parse-mvt.ts +136 -93
  158. package/src/lib/types.ts +53 -7
  159. package/src/mvt-loader.ts +13 -9
  160. package/dist/bundle.js.map +0 -1
  161. package/dist/helpers/binary-util-functions.js.map +0 -1
  162. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  163. package/dist/index.js.map +0 -1
  164. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  165. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  166. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  167. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  168. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  169. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  170. package/dist/lib/parse-mvt.js.map +0 -1
  171. package/dist/lib/types.js.map +0 -1
  172. package/dist/mvt-loader.js.map +0 -1
  173. package/dist/workers/mvt-worker.js.map +0 -1
  174. /package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
  175. /package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
@@ -1,202 +1,170 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { readFeature, classifyRings } from '../../helpers/mapbox-util-functions';
3
- export default class VectorTileFeature {
4
- static get types() {
5
- return ['Unknown', 'Point', 'LineString', 'Polygon'];
6
- }
7
-
8
- constructor(pbf, end, extent, keys, values) {
9
- _defineProperty(this, "properties", void 0);
10
-
11
- _defineProperty(this, "extent", void 0);
12
-
13
- _defineProperty(this, "type", void 0);
14
-
15
- _defineProperty(this, "id", void 0);
16
-
17
- _defineProperty(this, "_pbf", void 0);
18
-
19
- _defineProperty(this, "_geometry", void 0);
20
-
21
- _defineProperty(this, "_keys", void 0);
22
-
23
- _defineProperty(this, "_values", void 0);
24
-
25
- this.properties = {};
26
- this.extent = extent;
27
- this.type = 0;
28
- this.id = null;
29
- this._pbf = pbf;
30
- this._geometry = -1;
31
- this._keys = keys;
32
- this._values = values;
33
- pbf.readFields(readFeature, this, end);
34
- }
35
-
36
- loadGeometry() {
37
- const pbf = this._pbf;
38
- pbf.pos = this._geometry;
39
- const end = pbf.readVarint() + pbf.pos;
40
- let cmd = 1;
41
- let length = 0;
42
- let x = 0;
43
- let y = 0;
44
- const lines = [];
45
- let line;
46
-
47
- while (pbf.pos < end) {
48
- if (length <= 0) {
49
- const cmdLen = pbf.readVarint();
50
- cmd = cmdLen & 0x7;
51
- length = cmdLen >> 3;
52
- }
53
-
54
- length--;
55
-
56
- if (cmd === 1 || cmd === 2) {
57
- x += pbf.readSVarint();
58
- y += pbf.readSVarint();
59
-
60
- if (cmd === 1) {
61
- if (line) lines.push(line);
62
- line = [];
63
- }
64
-
65
- if (line) line.push([x, y]);
66
- } else if (cmd === 7) {
67
- if (line) {
68
- line.push(line[0].slice());
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mapbox_util_functions_1 = require("../../helpers/mapbox-util-functions");
4
+ class VectorTileFeature {
5
+ static get types() {
6
+ return ['Unknown', 'Point', 'LineString', 'Polygon'];
7
+ }
8
+ constructor(pbf, end, extent, keys, values) {
9
+ // Public
10
+ this.properties = {};
11
+ this.extent = extent;
12
+ this.type = 0;
13
+ this.id = null;
14
+ // Private
15
+ this._pbf = pbf;
16
+ this._geometry = -1;
17
+ this._keys = keys;
18
+ this._values = values;
19
+ pbf.readFields(mapbox_util_functions_1.readFeature, this, end);
20
+ }
21
+ // eslint-disable-next-line complexity, max-statements
22
+ loadGeometry() {
23
+ const pbf = this._pbf;
24
+ pbf.pos = this._geometry;
25
+ const end = pbf.readVarint() + pbf.pos;
26
+ let cmd = 1;
27
+ let length = 0;
28
+ let x = 0;
29
+ let y = 0;
30
+ const lines = [];
31
+ let line;
32
+ while (pbf.pos < end) {
33
+ if (length <= 0) {
34
+ const cmdLen = pbf.readVarint();
35
+ cmd = cmdLen & 0x7;
36
+ length = cmdLen >> 3;
37
+ }
38
+ length--;
39
+ if (cmd === 1 || cmd === 2) {
40
+ x += pbf.readSVarint();
41
+ y += pbf.readSVarint();
42
+ if (cmd === 1) {
43
+ // moveTo
44
+ if (line)
45
+ lines.push(line);
46
+ line = [];
47
+ }
48
+ if (line)
49
+ line.push([x, y]);
50
+ }
51
+ else if (cmd === 7) {
52
+ // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
53
+ if (line) {
54
+ line.push(line[0].slice()); // closePolygon
55
+ }
56
+ }
57
+ else {
58
+ throw new Error(`unknown command ${cmd}`);
59
+ }
69
60
  }
70
- } else {
71
- throw new Error("unknown command ".concat(cmd));
72
- }
61
+ if (line)
62
+ lines.push(line);
63
+ return lines;
73
64
  }
74
-
75
- if (line) lines.push(line);
76
- return lines;
77
- }
78
-
79
- bbox() {
80
- const pbf = this._pbf;
81
- pbf.pos = this._geometry;
82
- const end = pbf.readVarint() + pbf.pos;
83
- let cmd = 1;
84
- let length = 0;
85
- let x = 0;
86
- let y = 0;
87
- let x1 = Infinity;
88
- let x2 = -Infinity;
89
- let y1 = Infinity;
90
- let y2 = -Infinity;
91
-
92
- while (pbf.pos < end) {
93
- if (length <= 0) {
94
- const cmdLen = pbf.readVarint();
95
- cmd = cmdLen & 0x7;
96
- length = cmdLen >> 3;
97
- }
98
-
99
- length--;
100
-
101
- if (cmd === 1 || cmd === 2) {
102
- x += pbf.readSVarint();
103
- y += pbf.readSVarint();
104
- if (x < x1) x1 = x;
105
- if (x > x2) x2 = x;
106
- if (y < y1) y1 = y;
107
- if (y > y2) y2 = y;
108
- } else if (cmd !== 7) {
109
- throw new Error("unknown command ".concat(cmd));
110
- }
65
+ // eslint-disable-next-line max-statements
66
+ bbox() {
67
+ const pbf = this._pbf;
68
+ pbf.pos = this._geometry;
69
+ const end = pbf.readVarint() + pbf.pos;
70
+ let cmd = 1;
71
+ let length = 0;
72
+ let x = 0;
73
+ let y = 0;
74
+ let x1 = Infinity;
75
+ let x2 = -Infinity;
76
+ let y1 = Infinity;
77
+ let y2 = -Infinity;
78
+ while (pbf.pos < end) {
79
+ if (length <= 0) {
80
+ const cmdLen = pbf.readVarint();
81
+ cmd = cmdLen & 0x7;
82
+ length = cmdLen >> 3;
83
+ }
84
+ length--;
85
+ if (cmd === 1 || cmd === 2) {
86
+ x += pbf.readSVarint();
87
+ y += pbf.readSVarint();
88
+ if (x < x1)
89
+ x1 = x;
90
+ if (x > x2)
91
+ x2 = x;
92
+ if (y < y1)
93
+ y1 = y;
94
+ if (y > y2)
95
+ y2 = y;
96
+ }
97
+ else if (cmd !== 7) {
98
+ throw new Error(`unknown command ${cmd}`);
99
+ }
100
+ }
101
+ return [x1, y1, x2, y2];
111
102
  }
112
-
113
- return [x1, y1, x2, y2];
114
- }
115
-
116
- _toGeoJSON(transform) {
117
- let coords = this.loadGeometry();
118
- let type = VectorTileFeature.types[this.type];
119
- let i;
120
- let j;
121
-
122
- switch (this.type) {
123
- case 1:
124
- const points = [];
125
-
126
- for (i = 0; i < coords.length; i++) {
127
- points[i] = coords[i][0];
103
+ _toGeoJSON(transform) {
104
+ let coords = this.loadGeometry();
105
+ let type = VectorTileFeature.types[this.type];
106
+ let i;
107
+ let j;
108
+ // eslint-disable-next-line default-case
109
+ switch (this.type) {
110
+ case 1:
111
+ const points = [];
112
+ for (i = 0; i < coords.length; i++) {
113
+ points[i] = coords[i][0];
114
+ }
115
+ coords = points;
116
+ transform(coords, this);
117
+ break;
118
+ case 2:
119
+ for (i = 0; i < coords.length; i++) {
120
+ transform(coords[i], this);
121
+ }
122
+ break;
123
+ case 3:
124
+ coords = (0, mapbox_util_functions_1.classifyRings)(coords);
125
+ for (i = 0; i < coords.length; i++) {
126
+ for (j = 0; j < coords[i].length; j++) {
127
+ transform(coords[i][j], this);
128
+ }
129
+ }
130
+ break;
128
131
  }
129
-
130
- coords = points;
131
- transform(coords, this);
132
- break;
133
-
134
- case 2:
135
- for (i = 0; i < coords.length; i++) {
136
- transform(coords[i], this);
132
+ if (coords.length === 1) {
133
+ coords = coords[0];
137
134
  }
138
-
139
- break;
140
-
141
- case 3:
142
- coords = classifyRings(coords);
143
-
144
- for (i = 0; i < coords.length; i++) {
145
- for (j = 0; j < coords[i].length; j++) {
146
- transform(coords[i][j], this);
147
- }
135
+ else {
136
+ type = `Multi${type}`;
148
137
  }
149
-
150
- break;
151
- }
152
-
153
- if (coords.length === 1) {
154
- coords = coords[0];
155
- } else {
156
- type = "Multi".concat(type);
157
- }
158
-
159
- const result = {
160
- type: 'Feature',
161
- geometry: {
162
- type,
163
- coordinates: coords
164
- },
165
- properties: this.properties
166
- };
167
-
168
- if (this.id !== null) {
169
- result.id = this.id;
170
- }
171
-
172
- return result;
173
- }
174
-
175
- toGeoJSON(options) {
176
- if (typeof options === 'function') {
177
- return this._toGeoJSON(options);
138
+ const result = {
139
+ type: 'Feature',
140
+ geometry: {
141
+ type,
142
+ coordinates: coords
143
+ },
144
+ properties: this.properties
145
+ };
146
+ if (this.id !== null) {
147
+ result.id = this.id;
148
+ }
149
+ return result;
178
150
  }
179
-
180
- const {
181
- x,
182
- y,
183
- z
184
- } = options;
185
- const size = this.extent * Math.pow(2, z);
186
- const x0 = this.extent * x;
187
- const y0 = this.extent * y;
188
-
189
- function project(line) {
190
- for (let j = 0; j < line.length; j++) {
191
- const p = line[j];
192
- p[0] = (p[0] + x0) * 360 / size - 180;
193
- const y2 = 180 - (p[1] + y0) * 360 / size;
194
- p[1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
195
- }
151
+ toGeoJSON(options) {
152
+ if (typeof options === 'function') {
153
+ return this._toGeoJSON(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
+ function project(line) {
160
+ for (let j = 0; j < line.length; j++) {
161
+ const p = line[j];
162
+ p[0] = ((p[0] + x0) * 360) / size - 180;
163
+ const y2 = 180 - ((p[1] + y0) * 360) / size;
164
+ p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
165
+ }
166
+ }
167
+ return this._toGeoJSON(project);
196
168
  }
197
-
198
- return this._toGeoJSON(project);
199
- }
200
-
201
169
  }
202
- //# sourceMappingURL=vector-tile-feature.js.map
170
+ exports.default = VectorTileFeature;
@@ -1,64 +1,89 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import VectorTileFeature from './vector-tile-feature';
3
- export default class VectorTileLayer {
4
- constructor(pbf, end) {
5
- _defineProperty(this, "version", void 0);
6
-
7
- _defineProperty(this, "name", void 0);
8
-
9
- _defineProperty(this, "extent", void 0);
10
-
11
- _defineProperty(this, "length", void 0);
12
-
13
- _defineProperty(this, "_pbf", void 0);
14
-
15
- _defineProperty(this, "_keys", void 0);
16
-
17
- _defineProperty(this, "_values", void 0);
18
-
19
- _defineProperty(this, "_features", void 0);
20
-
21
- this.version = 1;
22
- this.name = '';
23
- this.extent = 4096;
24
- this.length = 0;
25
- this._pbf = pbf;
26
- this._keys = [];
27
- this._values = [];
28
- this._features = [];
29
- pbf.readFields(readLayer, this, end);
30
- this.length = this._features.length;
31
- }
32
-
33
- feature(i) {
34
- if (i < 0 || i >= this._features.length) {
35
- throw new Error('feature index out of bounds');
1
+ "use strict";
2
+ /* eslint-disable indent */
3
+ // This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const vector_tile_feature_1 = __importDefault(require("./vector-tile-feature"));
9
+ class VectorTileLayer {
10
+ constructor(pbf, end) {
11
+ // Public
12
+ this.version = 1;
13
+ this.name = '';
14
+ this.extent = 4096;
15
+ this.length = 0;
16
+ // Private
17
+ this._pbf = pbf;
18
+ this._keys = [];
19
+ this._values = [];
20
+ this._features = [];
21
+ pbf.readFields(readLayer, this, end);
22
+ this.length = this._features.length;
23
+ }
24
+ /**
25
+ * return feature `i` from this layer as a `VectorTileFeature`
26
+ * @param index
27
+ * @returns feature
28
+ */
29
+ feature(i) {
30
+ if (i < 0 || i >= this._features.length) {
31
+ throw new Error('feature index out of bounds');
32
+ }
33
+ this._pbf.pos = this._features[i];
34
+ const end = this._pbf.readVarint() + this._pbf.pos;
35
+ return new vector_tile_feature_1.default(this._pbf, end, this.extent, this._keys, this._values);
36
36
  }
37
-
38
- this._pbf.pos = this._features[i];
39
-
40
- const end = this._pbf.readVarint() + this._pbf.pos;
41
-
42
- return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
43
- }
44
-
45
37
  }
46
-
38
+ exports.default = VectorTileLayer;
39
+ /**
40
+ *
41
+ * @param tag
42
+ * @param layer
43
+ * @param pbf
44
+ */
47
45
  function readLayer(tag, layer, pbf) {
48
- if (layer && pbf) {
49
- 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));
50
- }
46
+ if (layer && pbf) {
47
+ if (tag === 15)
48
+ layer.version = pbf.readVarint();
49
+ else if (tag === 1)
50
+ layer.name = pbf.readString();
51
+ else if (tag === 5)
52
+ layer.extent = pbf.readVarint();
53
+ else if (tag === 2)
54
+ layer._features.push(pbf.pos);
55
+ else if (tag === 3)
56
+ layer._keys.push(pbf.readString());
57
+ else if (tag === 4)
58
+ layer._values.push(readValueMessage(pbf));
59
+ }
51
60
  }
52
-
61
+ /**
62
+ *
63
+ * @param pbf
64
+ * @returns value
65
+ */
53
66
  function readValueMessage(pbf) {
54
- let value = null;
55
- const end = pbf.readVarint() + pbf.pos;
56
-
57
- while (pbf.pos < end) {
58
- const tag = pbf.readVarint() >> 3;
59
- 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;
60
- }
61
-
62
- return value;
67
+ let value = null;
68
+ const end = pbf.readVarint() + pbf.pos;
69
+ while (pbf.pos < end) {
70
+ const tag = pbf.readVarint() >> 3;
71
+ value =
72
+ tag === 1
73
+ ? pbf.readString()
74
+ : tag === 2
75
+ ? pbf.readFloat()
76
+ : tag === 3
77
+ ? pbf.readDouble()
78
+ : tag === 4
79
+ ? pbf.readVarint64()
80
+ : tag === 5
81
+ ? pbf.readVarint()
82
+ : tag === 6
83
+ ? pbf.readSVarint()
84
+ : tag === 7
85
+ ? pbf.readBoolean()
86
+ : null;
87
+ }
88
+ return value;
63
89
  }
64
- //# sourceMappingURL=vector-tile-layer.js.map
@@ -1,23 +1,29 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import VectorTileLayer from './vector-tile-layer';
3
- export default class VectorTile {
4
- constructor(pbf, end) {
5
- _defineProperty(this, "layers", void 0);
6
-
7
- this.layers = pbf.readFields(readTile, {}, end);
8
- }
9
-
1
+ "use strict";
2
+ // This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const vector_tile_layer_1 = __importDefault(require("./vector-tile-layer"));
8
+ class VectorTile {
9
+ constructor(pbf, end) {
10
+ this.layers = pbf.readFields(readTile, {}, end);
11
+ }
10
12
  }
11
-
13
+ exports.default = VectorTile;
14
+ /**
15
+ *
16
+ * @param tag
17
+ * @param layers
18
+ * @param pbf
19
+ */
12
20
  function readTile(tag, layers, pbf) {
13
- if (tag === 3) {
14
- if (pbf) {
15
- const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
16
-
17
- if (layer.length && layers) {
18
- layers[layer.name] = layer;
19
- }
21
+ if (tag === 3) {
22
+ if (pbf) {
23
+ const layer = new vector_tile_layer_1.default(pbf, pbf.readVarint() + pbf.pos);
24
+ if (layer.length && layers) {
25
+ layers[layer.name] = layer;
26
+ }
27
+ }
20
28
  }
21
- }
22
29
  }
23
- //# sourceMappingURL=vector-tile.js.map
@@ -1,5 +1,5 @@
1
- import type { MvtMapboxCoordinates } from '../lib/types';
2
- import { LoaderOptions } from '@loaders.gl/loader-utils';
1
+ import type { Feature, BinaryFeatures, GeoJSONRowTable } from '@loaders.gl/schema';
2
+ import type { MVTLoaderOptions } from '../lib/types';
3
3
  /**
4
4
  * Parse MVT arrayBuffer and return GeoJSON.
5
5
  *
@@ -7,11 +7,8 @@ import { LoaderOptions } from '@loaders.gl/loader-utils';
7
7
  * @param options
8
8
  * @returns A GeoJSON geometry object or a binary representation
9
9
  */
10
- export default function parseMVT(arrayBuffer: ArrayBuffer, options?: LoaderOptions): (MvtMapboxCoordinates | {
11
- type: "Feature";
12
- geometry: import("@loaders.gl/schema").FlatGeometry;
13
- id?: string | number | undefined;
14
- properties: import("geojson").GeoJsonProperties;
15
- bbox?: import("geojson").BBox | undefined;
16
- })[] | import("@loaders.gl/schema").BinaryFeatures;
10
+ export default function parseMVT(arrayBuffer: ArrayBuffer, options?: MVTLoaderOptions): BinaryFeatures | GeoJSONRowTable | Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>[] | {
11
+ shape: string;
12
+ data: BinaryFeatures;
13
+ };
17
14
  //# sourceMappingURL=parse-mvt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,oBAAoB,EAAa,MAAM,cAAc,CAAC;AAGnE,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,aAAa;;;;;;mDA0DjF"}
1
+ {"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EAEP,cAAc,EACd,eAAe,EAChB,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;;;EAuBpF"}