@loaders.gl/mvt 3.0.9 → 3.0.13

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 (34) hide show
  1. package/dist/dist.es5.min.js +1 -1
  2. package/dist/dist.es5.min.js.map +1 -1
  3. package/dist/dist.min.js +1 -1
  4. package/dist/dist.min.js.map +1 -1
  5. package/dist/es5/bundle.js +2 -2
  6. package/dist/es5/bundle.js.map +1 -1
  7. package/dist/es5/index.js +2 -2
  8. package/dist/es5/lib/binary-vector-tile/features-to-binary.js +132 -182
  9. package/dist/es5/lib/binary-vector-tile/features-to-binary.js.map +1 -1
  10. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +133 -160
  11. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
  12. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +15 -23
  13. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -1
  14. package/dist/es5/lib/binary-vector-tile/vector-tile.js +7 -7
  15. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -1
  16. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +157 -169
  17. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -1
  18. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +15 -23
  19. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -1
  20. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +7 -7
  21. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -1
  22. package/dist/es5/lib/parse-mvt.js +35 -39
  23. package/dist/es5/lib/parse-mvt.js.map +1 -1
  24. package/dist/es5/mvt-loader.js +5 -38
  25. package/dist/es5/mvt-loader.js.map +1 -1
  26. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +2 -2
  27. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
  28. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +3 -3
  29. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -1
  30. package/dist/esm/mvt-loader.js +1 -1
  31. package/dist/esm/mvt-loader.js.map +1 -1
  32. package/dist/mvt-worker.js +1 -1
  33. package/dist/mvt-worker.js.map +1 -1
  34. package/package.json +4 -4
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var moduleExports = require('./index');
3
+ const moduleExports = require('./index');
4
4
 
5
- var _global = typeof window === 'undefined' ? global : window;
5
+ const _global = typeof window === 'undefined' ? global : window;
6
6
 
7
7
  _global.loaders = _global.loaders || {};
8
8
  module.exports = Object.assign(_global.loaders, moduleExports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","_global","window","global","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACA,IAAMC,OAAO,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,MAAhC,GAAyCD,MAAzD;;AACAD,OAAO,CAACG,OAAR,GAAkBH,OAAO,CAACG,OAAR,IAAmB,EAArC;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACG,OAAtB,EAA+BL,aAA/B,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nconst _global = typeof window === 'undefined' ? global : window;\n_global.loaders = _global.loaders || {};\nmodule.exports = Object.assign(_global.loaders, moduleExports);\n"],"file":"bundle.js"}
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","_global","window","global","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACA,MAAMC,OAAO,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,MAAhC,GAAyCD,MAAzD;;AACAD,OAAO,CAACG,OAAR,GAAkBH,OAAO,CAACG,OAAR,IAAmB,EAArC;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACG,OAAtB,EAA+BL,aAA/B,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nconst _global = typeof window === 'undefined' ? global : window;\n_global.loaders = _global.loaders || {};\nmodule.exports = Object.assign(_global.loaders, moduleExports);\n"],"file":"bundle.js"}
package/dist/es5/index.js CHANGED
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "MVTLoader", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _mvtLoader.MVTLoader;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "MVTWorkerLoader", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _mvtLoader.MVTWorkerLoader;
16
16
  }
17
17
  });
@@ -1,92 +1,65 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.featuresToBinary = featuresToBinary;
9
7
  exports.TEST_EXPORTS = void 0;
10
8
 
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
-
13
9
  var _polygon = require("@math.gl/polygon");
14
10
 
15
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
16
-
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
-
19
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
20
-
21
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
22
-
23
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
-
25
- function featuresToBinary(features, firstPassData) {
26
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
11
+ function featuresToBinary(features, firstPassData, options = {}) {
27
12
  return fillArrays(features, firstPassData, {
28
13
  numericPropKeys: options.numericPropKeys || extractNumericPropKeys(features),
29
14
  PositionDataType: options.PositionDataType || Float32Array
30
15
  });
31
16
  }
32
17
 
33
- var TEST_EXPORTS = {
34
- extractNumericPropKeys: extractNumericPropKeys,
35
- fillArrays: fillArrays
18
+ const TEST_EXPORTS = {
19
+ extractNumericPropKeys,
20
+ fillArrays
36
21
  };
37
22
  exports.TEST_EXPORTS = TEST_EXPORTS;
38
23
 
39
24
  function extractNumericPropKeys(features) {
40
- var numericPropKeys = {};
41
-
42
- var _iterator = _createForOfIteratorHelper(features),
43
- _step;
25
+ const numericPropKeys = {};
44
26
 
45
- try {
46
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
47
- var feature = _step.value;
27
+ for (const feature of features) {
28
+ if (feature.properties) {
29
+ for (const key in feature.properties) {
30
+ const numericSoFar = numericPropKeys[key];
48
31
 
49
- if (feature.properties) {
50
- for (var key in feature.properties) {
51
- var numericSoFar = numericPropKeys[key];
52
-
53
- if (numericSoFar || numericSoFar === undefined) {
54
- var val = feature.properties[key];
55
- numericPropKeys[key] = isNumeric(val);
56
- }
32
+ if (numericSoFar || numericSoFar === undefined) {
33
+ const val = feature.properties[key];
34
+ numericPropKeys[key] = isNumeric(val);
57
35
  }
58
36
  }
59
37
  }
60
- } catch (err) {
61
- _iterator.e(err);
62
- } finally {
63
- _iterator.f();
64
38
  }
65
39
 
66
- return Object.keys(numericPropKeys).filter(function (k) {
67
- return numericPropKeys[k];
68
- });
40
+ return Object.keys(numericPropKeys).filter(k => numericPropKeys[k]);
69
41
  }
70
42
 
71
- function fillArrays(features) {
72
- var firstPassData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
73
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
74
- var pointPositionsCount = firstPassData.pointPositionsCount,
75
- pointFeaturesCount = firstPassData.pointFeaturesCount,
76
- linePositionsCount = firstPassData.linePositionsCount,
77
- linePathsCount = firstPassData.linePathsCount,
78
- lineFeaturesCount = firstPassData.lineFeaturesCount,
79
- polygonPositionsCount = firstPassData.polygonPositionsCount,
80
- polygonObjectsCount = firstPassData.polygonObjectsCount,
81
- polygonRingsCount = firstPassData.polygonRingsCount,
82
- polygonFeaturesCount = firstPassData.polygonFeaturesCount;
83
- var numericPropKeys = options.numericPropKeys,
84
- _options$PositionData = options.PositionDataType,
85
- PositionDataType = _options$PositionData === void 0 ? Float32Array : _options$PositionData;
86
- var hasGlobalId = features[0] && 'id' in features[0];
87
- var coordLength = 2;
88
- var GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
89
- var points = {
43
+ function fillArrays(features, firstPassData = {}, options = {}) {
44
+ const {
45
+ pointPositionsCount,
46
+ pointFeaturesCount,
47
+ linePositionsCount,
48
+ linePathsCount,
49
+ lineFeaturesCount,
50
+ polygonPositionsCount,
51
+ polygonObjectsCount,
52
+ polygonRingsCount,
53
+ polygonFeaturesCount
54
+ } = firstPassData;
55
+ const {
56
+ numericPropKeys,
57
+ PositionDataType = Float32Array
58
+ } = options;
59
+ const hasGlobalId = features[0] && 'id' in features[0];
60
+ const coordLength = 2;
61
+ const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
62
+ const points = {
90
63
  positions: new PositionDataType(pointPositionsCount * coordLength),
91
64
  globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
92
65
  featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
@@ -94,7 +67,7 @@ function fillArrays(features) {
94
67
  properties: [],
95
68
  fields: []
96
69
  };
97
- var lines = {
70
+ const lines = {
98
71
  pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
99
72
  positions: new PositionDataType(linePositionsCount * coordLength),
100
73
  globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
@@ -103,7 +76,7 @@ function fillArrays(features) {
103
76
  properties: [],
104
77
  fields: []
105
78
  };
106
- var polygons = {
79
+ const polygons = {
107
80
  polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
108
81
  primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
109
82
  positions: new PositionDataType(polygonPositionsCount * coordLength),
@@ -115,28 +88,16 @@ function fillArrays(features) {
115
88
  fields: []
116
89
  };
117
90
 
118
- for (var _i = 0, _arr = [points, lines, polygons]; _i < _arr.length; _i++) {
119
- var object = _arr[_i];
120
-
121
- var _iterator2 = _createForOfIteratorHelper(numericPropKeys),
122
- _step2;
123
-
124
- try {
125
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
126
- var propName = _step2.value;
127
- object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
128
- }
129
- } catch (err) {
130
- _iterator2.e(err);
131
- } finally {
132
- _iterator2.f();
91
+ for (const object of [points, lines, polygons]) {
92
+ for (const propName of numericPropKeys) {
93
+ object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
133
94
  }
134
95
  }
135
96
 
136
97
  lines.pathIndices[linePathsCount] = linePositionsCount;
137
98
  polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
138
99
  polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
139
- var indexMap = {
100
+ const indexMap = {
140
101
  pointPosition: 0,
141
102
  pointFeature: 0,
142
103
  linePosition: 0,
@@ -149,68 +110,58 @@ function fillArrays(features) {
149
110
  feature: 0
150
111
  };
151
112
 
152
- var _iterator3 = _createForOfIteratorHelper(features),
153
- _step3;
154
-
155
- try {
156
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
157
- var feature = _step3.value;
158
- var geometry = feature.geometry;
159
- var properties = feature.properties || {};
160
-
161
- switch (geometry.type) {
162
- case 'Point':
163
- case 'MultiPoint':
164
- handlePoint(geometry, points, indexMap, coordLength, properties);
165
- points.properties.push(keepStringProperties(properties, numericPropKeys));
166
-
167
- if (hasGlobalId) {
168
- points.fields.push({
169
- id: feature.id
170
- });
171
- }
172
-
173
- indexMap.pointFeature++;
174
- break;
175
-
176
- case 'LineString':
177
- case 'MultiLineString':
178
- handleLineString(geometry, lines, indexMap, coordLength, properties);
179
- lines.properties.push(keepStringProperties(properties, numericPropKeys));
180
-
181
- if (hasGlobalId) {
182
- lines.fields.push({
183
- id: feature.id
184
- });
185
- }
186
-
187
- indexMap.lineFeature++;
188
- break;
189
-
190
- case 'Polygon':
191
- case 'MultiPolygon':
192
- handlePolygon(geometry, polygons, indexMap, coordLength, properties);
193
- polygons.properties.push(keepStringProperties(properties, numericPropKeys));
194
-
195
- if (hasGlobalId) {
196
- polygons.fields.push({
197
- id: feature.id
198
- });
199
- }
200
-
201
- indexMap.polygonFeature++;
202
- break;
203
-
204
- default:
205
- throw new Error('Invalid geometry type');
206
- }
113
+ for (const feature of features) {
114
+ const geometry = feature.geometry;
115
+ const properties = feature.properties || {};
116
+
117
+ switch (geometry.type) {
118
+ case 'Point':
119
+ case 'MultiPoint':
120
+ handlePoint(geometry, points, indexMap, coordLength, properties);
121
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
207
122
 
208
- indexMap.feature++;
123
+ if (hasGlobalId) {
124
+ points.fields.push({
125
+ id: feature.id
126
+ });
127
+ }
128
+
129
+ indexMap.pointFeature++;
130
+ break;
131
+
132
+ case 'LineString':
133
+ case 'MultiLineString':
134
+ handleLineString(geometry, lines, indexMap, coordLength, properties);
135
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
136
+
137
+ if (hasGlobalId) {
138
+ lines.fields.push({
139
+ id: feature.id
140
+ });
141
+ }
142
+
143
+ indexMap.lineFeature++;
144
+ break;
145
+
146
+ case 'Polygon':
147
+ case 'MultiPolygon':
148
+ handlePolygon(geometry, polygons, indexMap, coordLength, properties);
149
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
150
+
151
+ if (hasGlobalId) {
152
+ polygons.fields.push({
153
+ id: feature.id
154
+ });
155
+ }
156
+
157
+ indexMap.polygonFeature++;
158
+ break;
159
+
160
+ default:
161
+ throw new Error('Invalid geometry type');
209
162
  }
210
- } catch (err) {
211
- _iterator3.e(err);
212
- } finally {
213
- _iterator3.f();
163
+
164
+ indexMap.feature++;
214
165
  }
215
166
 
216
167
  return makeAccessorObjects(points, lines, polygons, coordLength);
@@ -218,7 +169,7 @@ function fillArrays(features) {
218
169
 
219
170
  function handlePoint(geometry, points, indexMap, coordLength, properties) {
220
171
  points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
221
- var nPositions = geometry.data.length / coordLength;
172
+ const nPositions = geometry.data.length / coordLength;
222
173
  fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
223
174
  points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
224
175
  points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
@@ -227,14 +178,14 @@ function handlePoint(geometry, points, indexMap, coordLength, properties) {
227
178
 
228
179
  function handleLineString(geometry, lines, indexMap, coordLength, properties) {
229
180
  lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
230
- var nPositions = geometry.data.length / coordLength;
181
+ const nPositions = geometry.data.length / coordLength;
231
182
  fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
232
183
  lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
233
184
  lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
234
185
 
235
- for (var i = 0, il = geometry.lines.length; i < il; ++i) {
236
- var start = geometry.lines[i];
237
- var end = i === il - 1 ? geometry.data.length : geometry.lines[i + 1];
186
+ for (let i = 0, il = geometry.lines.length; i < il; ++i) {
187
+ const start = geometry.lines[i];
188
+ const end = i === il - 1 ? geometry.data.length : geometry.lines[i + 1];
238
189
  lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
239
190
  indexMap.linePosition += (end - start) / coordLength;
240
191
  }
@@ -242,55 +193,54 @@ function handleLineString(geometry, lines, indexMap, coordLength, properties) {
242
193
 
243
194
  function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
244
195
  polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
245
- var nPositions = geometry.data.length / coordLength;
196
+ const nPositions = geometry.data.length / coordLength;
246
197
  fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
247
198
  polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
248
199
  polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
249
200
 
250
- for (var l = 0, ll = geometry.lines.length; l < ll; ++l) {
251
- var startPosition = indexMap.polygonPosition;
201
+ for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {
202
+ const startPosition = indexMap.polygonPosition;
252
203
  polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
253
- var areas = geometry.areas[l];
254
- var lines = geometry.lines[l];
255
- var nextLines = geometry.lines[l + 1];
204
+ const areas = geometry.areas[l];
205
+ const lines = geometry.lines[l];
206
+ const nextLines = geometry.lines[l + 1];
256
207
 
257
- for (var i = 0, il = lines.length; i < il; ++i) {
258
- var start = lines[i];
259
- var end = i === il - 1 ? nextLines === undefined ? geometry.data.length : nextLines[0] : lines[i + 1];
208
+ for (let i = 0, il = lines.length; i < il; ++i) {
209
+ const start = lines[i];
210
+ const end = i === il - 1 ? nextLines === undefined ? geometry.data.length : nextLines[0] : lines[i + 1];
260
211
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
261
212
  indexMap.polygonPosition += (end - start) / coordLength;
262
213
  }
263
214
 
264
- var endPosition = indexMap.polygonPosition;
215
+ const endPosition = indexMap.polygonPosition;
265
216
  triangulatePolygon(polygons, areas, lines, {
266
- startPosition: startPosition,
267
- endPosition: endPosition,
268
- coordLength: coordLength
217
+ startPosition,
218
+ endPosition,
219
+ coordLength
269
220
  });
270
221
  }
271
222
  }
272
223
 
273
- function triangulatePolygon(polygons, areas, lines, _ref) {
274
- var startPosition = _ref.startPosition,
275
- endPosition = _ref.endPosition,
276
- coordLength = _ref.coordLength;
277
- var start = startPosition * coordLength;
278
- var end = endPosition * coordLength;
279
- var polygonPositions = polygons.positions.subarray(start, end);
280
- var offset = lines[0];
281
- var holes = lines.slice(1).map(function (n) {
282
- return (n - offset) / coordLength;
283
- });
284
- var indices = (0, _polygon.earcut)(polygonPositions, holes, coordLength, areas);
285
-
286
- for (var t = 0, tl = indices.length; t < tl; ++t) {
224
+ function triangulatePolygon(polygons, areas, lines, {
225
+ startPosition,
226
+ endPosition,
227
+ coordLength
228
+ }) {
229
+ const start = startPosition * coordLength;
230
+ const end = endPosition * coordLength;
231
+ const polygonPositions = polygons.positions.subarray(start, end);
232
+ const offset = lines[0];
233
+ const holes = lines.slice(1).map(n => (n - offset) / coordLength);
234
+ const indices = (0, _polygon.earcut)(polygonPositions, holes, coordLength, areas);
235
+
236
+ for (let t = 0, tl = indices.length; t < tl; ++t) {
287
237
  polygons.triangles.push(startPosition + indices[t]);
288
238
  }
289
239
  }
290
240
 
291
241
  function makeAccessorObjects(points, lines, polygons, coordLength) {
292
- var returnObj = {
293
- points: _objectSpread(_objectSpread({}, points), {}, {
242
+ const returnObj = {
243
+ points: { ...points,
294
244
  positions: {
295
245
  value: points.positions,
296
246
  size: coordLength
@@ -303,8 +253,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
303
253
  value: points.featureIds,
304
254
  size: 1
305
255
  }
306
- }),
307
- lines: _objectSpread(_objectSpread({}, lines), {}, {
256
+ },
257
+ lines: { ...lines,
308
258
  pathIndices: {
309
259
  value: lines.pathIndices,
310
260
  size: 1
@@ -321,8 +271,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
321
271
  value: lines.featureIds,
322
272
  size: 1
323
273
  }
324
- }),
325
- polygons: _objectSpread(_objectSpread({}, polygons), {}, {
274
+ },
275
+ polygons: { ...polygons,
326
276
  polygonIndices: {
327
277
  value: polygons.polygonIndices,
328
278
  size: 1
@@ -347,11 +297,11 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
347
297
  value: polygons.featureIds,
348
298
  size: 1
349
299
  }
350
- })
300
+ }
351
301
  };
352
302
 
353
- for (var geomType in returnObj) {
354
- for (var numericProp in returnObj[geomType].numericProps) {
303
+ for (const geomType in returnObj) {
304
+ for (const numericProp in returnObj[geomType].numericProps) {
355
305
  returnObj[geomType].numericProps[numericProp] = {
356
306
  value: returnObj[geomType].numericProps[numericProp],
357
307
  size: 1
@@ -363,7 +313,7 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
363
313
  }
364
314
 
365
315
  function fillNumericProperties(object, properties, index, length) {
366
- for (var numericPropName in object.numericProps) {
316
+ for (const numericPropName in object.numericProps) {
367
317
  if (numericPropName in properties) {
368
318
  object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);
369
319
  }
@@ -371,9 +321,9 @@ function fillNumericProperties(object, properties, index, length) {
371
321
  }
372
322
 
373
323
  function keepStringProperties(properties, numericKeys) {
374
- var props = {};
324
+ const props = {};
375
325
 
376
- for (var key in properties) {
326
+ for (const key in properties) {
377
327
  if (!numericKeys.includes(key)) {
378
328
  props[key] = properties[key];
379
329
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-vector-tile/features-to-binary.js"],"names":["featuresToBinary","features","firstPassData","options","fillArrays","numericPropKeys","extractNumericPropKeys","PositionDataType","Float32Array","TEST_EXPORTS","feature","properties","key","numericSoFar","undefined","val","isNumeric","Object","keys","filter","k","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","hasGlobalId","coordLength","GlobalFeatureIdsDataType","length","Uint32Array","Uint16Array","points","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","triangles","object","propName","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","geometry","type","handlePoint","push","keepStringProperties","id","handleLineString","handlePolygon","Error","makeAccessorObjects","set","data","nPositions","fillNumericProperties","fill","i","il","start","end","l","ll","startPosition","areas","nextLines","endPosition","triangulatePolygon","polygonPositions","subarray","offset","holes","slice","map","n","indices","t","tl","returnObj","value","size","geomType","numericProp","index","numericPropName","numericKeys","props","includes","x","Number","isFinite"],"mappings":";;;;;;;;;;;;AACA;;;;;;;;;;;;AAUO,SAASA,gBAAT,CAA0BC,QAA1B,EAAoCC,aAApC,EAAiE;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACtE,SAAOC,UAAU,CAACH,QAAD,EAAWC,aAAX,EAA0B;AACzCG,IAAAA,eAAe,EAAEF,OAAO,CAACE,eAAR,IAA2BC,sBAAsB,CAACL,QAAD,CADzB;AAEzCM,IAAAA,gBAAgB,EAAEJ,OAAO,CAACI,gBAAR,IAA4BC;AAFL,GAA1B,CAAjB;AAID;;AAEM,IAAMC,YAAY,GAAG;AAC1BH,EAAAA,sBAAsB,EAAtBA,sBAD0B;AAE1BF,EAAAA,UAAU,EAAVA;AAF0B,CAArB;;;AAOP,SAASE,sBAAT,CAAgCL,QAAhC,EAA0C;AACxC,MAAMI,eAAe,GAAG,EAAxB;;AADwC,6CAElBJ,QAFkB;AAAA;;AAAA;AAExC,wDAAgC;AAAA,UAArBS,OAAqB;;AAC9B,UAAIA,OAAO,CAACC,UAAZ,EAAwB;AACtB,aAAK,IAAMC,GAAX,IAAkBF,OAAO,CAACC,UAA1B,EAAsC;AAIpC,cAAME,YAAY,GAAGR,eAAe,CAACO,GAAD,CAApC;;AAEA,cAAIC,YAAY,IAAIA,YAAY,KAAKC,SAArC,EAAgD;AAC9C,gBAAMC,GAAG,GAAGL,OAAO,CAACC,UAAR,CAAmBC,GAAnB,CAAZ;AACAP,YAAAA,eAAe,CAACO,GAAD,CAAf,GAAuBI,SAAS,CAACD,GAAD,CAAhC;AACD;AACF;AACF;AACF;AAhBuC;AAAA;AAAA;AAAA;A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AX,IAAuBH,SAAvB,EAAkC;AAChC,SAAK,IAAMI,WAAX,IAA0BJ,SAAS,CAACG,QAAD,CAAT,CAAoB3D,YAA9C,EAA4D;AAC1DwD,MAAAA,SAAS,CAACG,QAAD,CAAT,CAAoB3D,YAApB,CAAiC4D,WAAjC,IAAgD;AAC9CH,QAAAA,KAAK,EAAED,SAAS,CAACG,QAAD,CAAT,CAAoB3D,YAApB,CAAiC4D,WAAjC,CADuC;AAE9CF,QAAAA,IAAI,EAAE;AAFwC,OAAhD;AAID;AACF;;AACD,SAAOF,SAAP;AACD;;AAGD,SAASvB,qBAAT,CAA+BzB,MAA/B,EAAuCrC,UAAvC,EAAmD0F,KAAnD,EAA0DpE,MAA1D,EAAkE;AAChE,OAAK,IAAMqE,eAAX,IAA8BtD,MAAM,CAACR,YAArC,EAAmD;AACjD,QAAI8D,eAAe,IAAI3F,UAAvB,EAAmC;AACjCqC,MAAAA,MAAM,CAACR,YAAP,CAAoB8D,eAApB,EAAqC5B,IAArC,CAA0C/D,UAAU,CAAC2F,eAAD,CAApD,EAAuED,KAAvE,EAA8EA,KAAK,GAAGpE,MAAtF;AACD;AACF;AACF;;AAGD,SAAS+B,oBAAT,CAA8BrD,UAA9B,EAA0C4F,WAA1C,EAAuD;AACrD,MAAMC,KAAK,GAAG,EAAd;;AACA,OAAK,IAAM5F,GAAX,IAAkBD,UAAlB,EAA8B;AAC5B,QAAI,CAAC4F,WAAW,CAACE,QAAZ,CAAqB7F,GAArB,CAAL,EAAgC;AAC9B4F,MAAAA,KAAK,CAAC5F,GAAD,CAAL,GAAaD,UAAU,CAACC,GAAD,CAAvB;AACD;AACF;;AACD,SAAO4F,KAAP;AACD;;AAED,SAASxF,SAAT,CAAmB0F,CAAnB,EAAsB;AACpB,SAAOC,MAAM,CAACC,QAAP,CAAgBF,CAAhB,CAAP;AACD","sourcesContent":["// @ts-nocheck\nimport {earcut} from '@math.gl/polygon';\n\n/**\n * Convert binary features to flat binary arrays. Similar to\n * `geojsonToBinary` helper function, except that it expects\n * a binary representation of the feature data, which enables\n * 2X-3X speed increase in parse speed, compared to using\n * geoJSON. See `binary-vector-tile/VectorTileFeature` for\n * data format detais\n */\nexport function featuresToBinary(features, firstPassData, options = {}) {\n return fillArrays(features, firstPassData, {\n numericPropKeys: options.numericPropKeys || extractNumericPropKeys(features),\n PositionDataType: options.PositionDataType || Float32Array\n });\n}\n\nexport const TEST_EXPORTS = {\n extractNumericPropKeys,\n fillArrays\n};\n\n// Extracts properties that are always numeric\n// eslint-disable-next-line complexity, max-statements\nfunction extractNumericPropKeys(features) {\n const numericPropKeys = {};\n for (const feature of features) {\n if (feature.properties) {\n for (const key in feature.properties) {\n // If property has not been seen before, or if property has been numeric\n // in all previous features, check if numeric in this feature\n // If not numeric, false is stored to prevent rechecking in the future\n const numericSoFar = numericPropKeys[key];\n // eslint-disable-next-line max-depth\n if (numericSoFar || numericSoFar === undefined) {\n const val = feature.properties[key];\n numericPropKeys[key] = isNumeric(val);\n }\n }\n }\n }\n\n return Object.keys(numericPropKeys).filter((k) => numericPropKeys[k]);\n}\n\n// Fills coordinates into pre-allocated typed arrays\n// eslint-disable-next-line complexity\nfunction fillArrays(features, firstPassData = {}, options = {}) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount\n } = firstPassData;\n const {numericPropKeys, PositionDataType = Float32Array} = options;\n const hasGlobalId = features[0] && 'id' in features[0];\n const coordLength = 2;\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points = {\n positions: new PositionDataType(pointPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),\n featureIds:\n pointFeaturesCount > 65535\n ? new Uint32Array(pointPositionsCount)\n : new Uint16Array(pointPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const lines = {\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n positions: new PositionDataType(linePositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const polygons = {\n polygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonObjectsCount + 1)\n : new Uint16Array(polygonObjectsCount + 1),\n primitivePolygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonRingsCount + 1)\n : new Uint16Array(polygonRingsCount + 1),\n positions: new PositionDataType(polygonPositionsCount * coordLength),\n triangles: [],\n globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n\n // Instantiate numeric properties arrays; one value per vertex\n for (const object of [points, lines, polygons]) {\n for (const propName of numericPropKeys) {\n // If property has been numeric in all previous features in which the property existed, check\n // if numeric in this feature\n object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);\n }\n }\n\n // Set last element of path/polygon indices as positions length\n lines.pathIndices[linePathsCount] = linePositionsCount;\n polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;\n polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;\n\n const indexMap = {\n pointPosition: 0,\n pointFeature: 0,\n linePosition: 0,\n linePath: 0,\n lineFeature: 0,\n polygonPosition: 0,\n polygonObject: 0,\n polygonRing: 0,\n polygonFeature: 0,\n feature: 0\n };\n\n for (const feature of features) {\n const geometry = feature.geometry;\n const properties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n case 'MultiPoint':\n handlePoint(geometry, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n points.fields.push({id: feature.id});\n }\n indexMap.pointFeature++;\n break;\n case 'LineString':\n case 'MultiLineString':\n handleLineString(geometry, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n lines.fields.push({id: feature.id});\n }\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n case 'MultiPolygon':\n handlePolygon(geometry, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n polygons.fields.push({id: feature.id});\n }\n indexMap.polygonFeature++;\n break;\n default:\n throw new Error('Invalid geometry type');\n }\n\n indexMap.feature++;\n }\n\n // Wrap each array in an accessor object with value and size keys\n return makeAccessorObjects(points, lines, polygons, coordLength);\n}\n\n// Fills (Multi)Point coordinates into points object of arrays\nfunction handlePoint(geometry, points, indexMap, coordLength, properties) {\n points.positions.set(geometry.data, indexMap.pointPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);\n points.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n points.featureIds.fill(\n indexMap.pointFeature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n\n indexMap.pointPosition += nPositions;\n}\n\n// Fills (Multi)LineString coordinates into lines object of arrays\nfunction handleLineString(geometry, lines, indexMap, coordLength, properties) {\n lines.positions.set(geometry.data, indexMap.linePosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n lines.featureIds.fill(\n indexMap.lineFeature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n\n for (let i = 0, il = geometry.lines.length; i < il; ++i) {\n // Extract range of data we are working with, defined by start\n // and end indices (these index into the geometry.data array)\n const start = geometry.lines[i];\n const end =\n i === il - 1\n ? geometry.data.length // last line, so read to end of data\n : geometry.lines[i + 1]; // start index for next line\n\n lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;\n indexMap.linePosition += (end - start) / coordLength;\n }\n}\n\n// Fills (Multi)Polygon coordinates into polygons object of arrays\nfunction handlePolygon(geometry, polygons, indexMap, coordLength, properties) {\n polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n polygons.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n polygons.featureIds.fill(\n indexMap.polygonFeature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n\n // Unlike Point & LineString geometry.lines is a 2D array\n for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {\n const startPosition = indexMap.polygonPosition;\n polygons.polygonIndices[indexMap.polygonObject++] = startPosition;\n\n const areas = geometry.areas[l];\n const lines = geometry.lines[l];\n const nextLines = geometry.lines[l + 1];\n\n for (let i = 0, il = lines.length; i < il; ++i) {\n const start = lines[i];\n const end =\n i === il - 1\n ? // last line, so either read to:\n nextLines === undefined\n ? geometry.data.length // end of data (no next lines)\n : nextLines[0] // start of first line in nextLines\n : lines[i + 1]; // start index for next line\n\n polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;\n indexMap.polygonPosition += (end - start) / coordLength;\n }\n\n const endPosition = indexMap.polygonPosition;\n triangulatePolygon(polygons, areas, lines, {startPosition, endPosition, coordLength});\n }\n}\n\n/**\n * Triangulate polygon using earcut\n */\nfunction triangulatePolygon(polygons, areas, lines, {startPosition, endPosition, coordLength}) {\n const start = startPosition * coordLength;\n const end = endPosition * coordLength;\n\n // Extract positions and holes for just this polygon\n const polygonPositions = polygons.positions.subarray(start, end);\n\n // Holes are referenced relative to outer polygon\n const offset = lines[0];\n const holes = lines.slice(1).map((n) => (n - offset) / coordLength);\n\n // Compute triangulation\n const indices = earcut(polygonPositions, holes, coordLength, areas);\n\n // Indices returned by triangulation are relative to start\n // of polygon, so we need to offset\n for (let t = 0, tl = indices.length; t < tl; ++t) {\n polygons.triangles.push(startPosition + indices[t]);\n }\n}\n\n// Wrap each array in an accessor object with value and size keys\nfunction makeAccessorObjects(points, lines, polygons, coordLength) {\n const returnObj = {\n points: {\n ...points,\n positions: {value: points.positions, size: coordLength},\n globalFeatureIds: {value: points.globalFeatureIds, size: 1},\n featureIds: {value: points.featureIds, size: 1}\n },\n lines: {\n ...lines,\n pathIndices: {value: lines.pathIndices, size: 1},\n positions: {value: lines.positions, size: coordLength},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1}\n },\n polygons: {\n ...polygons,\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n positions: {value: polygons.positions, size: coordLength},\n triangles: {value: new Uint32Array(polygons.triangles), size: 1},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1}\n }\n };\n\n for (const geomType in returnObj) {\n for (const numericProp in returnObj[geomType].numericProps) {\n returnObj[geomType].numericProps[numericProp] = {\n value: returnObj[geomType].numericProps[numericProp],\n size: 1\n };\n }\n }\n return returnObj;\n}\n\n// Add numeric properties to object\nfunction fillNumericProperties(object, properties, index, length) {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);\n }\n }\n}\n\n// Keep string properties in object\nfunction keepStringProperties(properties, numericKeys) {\n const props = {};\n for (const key in properties) {\n if (!numericKeys.includes(key)) {\n props[key] = properties[key];\n }\n }\n return props;\n}\n\nfunction isNumeric(x) {\n return Number.isFinite(x);\n}\n"],"file":"features-to-binary.js"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-vector-tile/features-to-binary.js"],"names":["featuresToBinary","features","firstPassData","options","fillArrays","numericPropKeys","extractNumericPropKeys","PositionDataType","Float32Array","TEST_EXPORTS","feature","properties","key","numericSoFar","undefined","val","isNumeric","Object","keys","filter","k","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","hasGlobalId","coordLength","GlobalFeatureIdsDataType","length","Uint32Array","Uint16Array","points","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","triangles","object","propName","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","geometry","type","handlePoint","push","keepStringProperties","id","handleLineString","handlePolygon","Error","makeAccessorObjects","set","data","nPositions","fillNumericProperties","fill","i","il","start","end","l","ll","startPosition","areas","nextLines","endPosition","triangulatePolygon","polygonPositions","subarray","offset","holes","slice","map","n","indices","t","tl","returnObj","value","size","geomType","numericProp","index","numericPropName","numericKeys","props","includes","x","Number","isFinite"],"mappings":";;;;;;;;AACA;;AAUO,SAASA,gBAAT,CAA0BC,QAA1B,EAAoCC,aAApC,EAAmDC,OAAO,GAAG,EAA7D,EAAiE;AACtE,SAAOC,UAAU,CAACH,QAAD,EAAWC,aAAX,EAA0B;AACzCG,IAAAA,eAAe,EAAEF,OAAO,CAACE,eAAR,IAA2BC,sBAAsB,CAACL,QAAD,CADzB;AAEzCM,IAAAA,gBAAgB,EAAEJ,OAAO,CAACI,gBAAR,IAA4BC;AAFL,GAA1B,CAAjB;AAID;;AAEM,MAAMC,YAAY,GAAG;AAC1BH,EAAAA,sBAD0B;AAE1BF,EAAAA;AAF0B,CAArB;;;AAOP,SAASE,sBAAT,CAAgCL,QAAhC,EAA0C;AACxC,QAAMI,eAAe,GAAG,EAAxB;;AACA,OAAK,MAAMK,OAAX,IAAsBT,QAAtB,EAAgC;AAC9B,QAAIS,OAAO,CAACC,UAAZ,EAAw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C9CH,QAAAA,KAAK,EAAED,SAAS,CAACG,QAAD,CAAT,CAAoB3D,YAApB,CAAiC4D,WAAjC,CADuC;AAE9CF,QAAAA,IAAI,EAAE;AAFwC,OAAhD;AAID;AACF;;AACD,SAAOF,SAAP;AACD;;AAGD,SAASvB,qBAAT,CAA+BzB,MAA/B,EAAuCrC,UAAvC,EAAmD0F,KAAnD,EAA0DpE,MAA1D,EAAkE;AAChE,OAAK,MAAMqE,eAAX,IAA8BtD,MAAM,CAACR,YAArC,EAAmD;AACjD,QAAI8D,eAAe,IAAI3F,UAAvB,EAAmC;AACjCqC,MAAAA,MAAM,CAACR,YAAP,CAAoB8D,eAApB,EAAqC5B,IAArC,CAA0C/D,UAAU,CAAC2F,eAAD,CAApD,EAAuED,KAAvE,EAA8EA,KAAK,GAAGpE,MAAtF;AACD;AACF;AACF;;AAGD,SAAS+B,oBAAT,CAA8BrD,UAA9B,EAA0C4F,WAA1C,EAAuD;AACrD,QAAMC,KAAK,GAAG,EAAd;;AACA,OAAK,MAAM5F,GAAX,IAAkBD,UAAlB,EAA8B;AAC5B,QAAI,CAAC4F,WAAW,CAACE,QAAZ,CAAqB7F,GAArB,CAAL,EAAgC;AAC9B4F,MAAAA,KAAK,CAAC5F,GAAD,CAAL,GAAaD,UAAU,CAACC,GAAD,CAAvB;AACD;AACF;;AACD,SAAO4F,KAAP;AACD;;AAED,SAASxF,SAAT,CAAmB0F,CAAnB,EAAsB;AACpB,SAAOC,MAAM,CAACC,QAAP,CAAgBF,CAAhB,CAAP;AACD","sourcesContent":["// @ts-nocheck\nimport {earcut} from '@math.gl/polygon';\n\n/**\n * Convert binary features to flat binary arrays. Similar to\n * `geojsonToBinary` helper function, except that it expects\n * a binary representation of the feature data, which enables\n * 2X-3X speed increase in parse speed, compared to using\n * geoJSON. See `binary-vector-tile/VectorTileFeature` for\n * data format detais\n */\nexport function featuresToBinary(features, firstPassData, options = {}) {\n return fillArrays(features, firstPassData, {\n numericPropKeys: options.numericPropKeys || extractNumericPropKeys(features),\n PositionDataType: options.PositionDataType || Float32Array\n });\n}\n\nexport const TEST_EXPORTS = {\n extractNumericPropKeys,\n fillArrays\n};\n\n// Extracts properties that are always numeric\n// eslint-disable-next-line complexity, max-statements\nfunction extractNumericPropKeys(features) {\n const numericPropKeys = {};\n for (const feature of features) {\n if (feature.properties) {\n for (const key in feature.properties) {\n // If property has not been seen before, or if property has been numeric\n // in all previous features, check if numeric in this feature\n // If not numeric, false is stored to prevent rechecking in the future\n const numericSoFar = numericPropKeys[key];\n // eslint-disable-next-line max-depth\n if (numericSoFar || numericSoFar === undefined) {\n const val = feature.properties[key];\n numericPropKeys[key] = isNumeric(val);\n }\n }\n }\n }\n\n return Object.keys(numericPropKeys).filter((k) => numericPropKeys[k]);\n}\n\n// Fills coordinates into pre-allocated typed arrays\n// eslint-disable-next-line complexity\nfunction fillArrays(features, firstPassData = {}, options = {}) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount\n } = firstPassData;\n const {numericPropKeys, PositionDataType = Float32Array} = options;\n const hasGlobalId = features[0] && 'id' in features[0];\n const coordLength = 2;\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points = {\n positions: new PositionDataType(pointPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),\n featureIds:\n pointFeaturesCount > 65535\n ? new Uint32Array(pointPositionsCount)\n : new Uint16Array(pointPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const lines = {\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n positions: new PositionDataType(linePositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const polygons = {\n polygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonObjectsCount + 1)\n : new Uint16Array(polygonObjectsCount + 1),\n primitivePolygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonRingsCount + 1)\n : new Uint16Array(polygonRingsCount + 1),\n positions: new PositionDataType(polygonPositionsCount * coordLength),\n triangles: [],\n globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n\n // Instantiate numeric properties arrays; one value per vertex\n for (const object of [points, lines, polygons]) {\n for (const propName of numericPropKeys) {\n // If property has been numeric in all previous features in which the property existed, check\n // if numeric in this feature\n object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);\n }\n }\n\n // Set last element of path/polygon indices as positions length\n lines.pathIndices[linePathsCount] = linePositionsCount;\n polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;\n polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;\n\n const indexMap = {\n pointPosition: 0,\n pointFeature: 0,\n linePosition: 0,\n linePath: 0,\n lineFeature: 0,\n polygonPosition: 0,\n polygonObject: 0,\n polygonRing: 0,\n polygonFeature: 0,\n feature: 0\n };\n\n for (const feature of features) {\n const geometry = feature.geometry;\n const properties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n case 'MultiPoint':\n handlePoint(geometry, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n points.fields.push({id: feature.id});\n }\n indexMap.pointFeature++;\n break;\n case 'LineString':\n case 'MultiLineString':\n handleLineString(geometry, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n lines.fields.push({id: feature.id});\n }\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n case 'MultiPolygon':\n handlePolygon(geometry, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n polygons.fields.push({id: feature.id});\n }\n indexMap.polygonFeature++;\n break;\n default:\n throw new Error('Invalid geometry type');\n }\n\n indexMap.feature++;\n }\n\n // Wrap each array in an accessor object with value and size keys\n return makeAccessorObjects(points, lines, polygons, coordLength);\n}\n\n// Fills (Multi)Point coordinates into points object of arrays\nfunction handlePoint(geometry, points, indexMap, coordLength, properties) {\n points.positions.set(geometry.data, indexMap.pointPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);\n points.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n points.featureIds.fill(\n indexMap.pointFeature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n\n indexMap.pointPosition += nPositions;\n}\n\n// Fills (Multi)LineString coordinates into lines object of arrays\nfunction handleLineString(geometry, lines, indexMap, coordLength, properties) {\n lines.positions.set(geometry.data, indexMap.linePosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n lines.featureIds.fill(\n indexMap.lineFeature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n\n for (let i = 0, il = geometry.lines.length; i < il; ++i) {\n // Extract range of data we are working with, defined by start\n // and end indices (these index into the geometry.data array)\n const start = geometry.lines[i];\n const end =\n i === il - 1\n ? geometry.data.length // last line, so read to end of data\n : geometry.lines[i + 1]; // start index for next line\n\n lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;\n indexMap.linePosition += (end - start) / coordLength;\n }\n}\n\n// Fills (Multi)Polygon coordinates into polygons object of arrays\nfunction handlePolygon(geometry, polygons, indexMap, coordLength, properties) {\n polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n polygons.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n polygons.featureIds.fill(\n indexMap.polygonFeature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n\n // Unlike Point & LineString geometry.lines is a 2D array\n for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {\n const startPosition = indexMap.polygonPosition;\n polygons.polygonIndices[indexMap.polygonObject++] = startPosition;\n\n const areas = geometry.areas[l];\n const lines = geometry.lines[l];\n const nextLines = geometry.lines[l + 1];\n\n for (let i = 0, il = lines.length; i < il; ++i) {\n const start = lines[i];\n const end =\n i === il - 1\n ? // last line, so either read to:\n nextLines === undefined\n ? geometry.data.length // end of data (no next lines)\n : nextLines[0] // start of first line in nextLines\n : lines[i + 1]; // start index for next line\n\n polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;\n indexMap.polygonPosition += (end - start) / coordLength;\n }\n\n const endPosition = indexMap.polygonPosition;\n triangulatePolygon(polygons, areas, lines, {startPosition, endPosition, coordLength});\n }\n}\n\n/**\n * Triangulate polygon using earcut\n */\nfunction triangulatePolygon(polygons, areas, lines, {startPosition, endPosition, coordLength}) {\n const start = startPosition * coordLength;\n const end = endPosition * coordLength;\n\n // Extract positions and holes for just this polygon\n const polygonPositions = polygons.positions.subarray(start, end);\n\n // Holes are referenced relative to outer polygon\n const offset = lines[0];\n const holes = lines.slice(1).map((n) => (n - offset) / coordLength);\n\n // Compute triangulation\n const indices = earcut(polygonPositions, holes, coordLength, areas);\n\n // Indices returned by triangulation are relative to start\n // of polygon, so we need to offset\n for (let t = 0, tl = indices.length; t < tl; ++t) {\n polygons.triangles.push(startPosition + indices[t]);\n }\n}\n\n// Wrap each array in an accessor object with value and size keys\nfunction makeAccessorObjects(points, lines, polygons, coordLength) {\n const returnObj = {\n points: {\n ...points,\n positions: {value: points.positions, size: coordLength},\n globalFeatureIds: {value: points.globalFeatureIds, size: 1},\n featureIds: {value: points.featureIds, size: 1}\n },\n lines: {\n ...lines,\n pathIndices: {value: lines.pathIndices, size: 1},\n positions: {value: lines.positions, size: coordLength},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1}\n },\n polygons: {\n ...polygons,\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n positions: {value: polygons.positions, size: coordLength},\n triangles: {value: new Uint32Array(polygons.triangles), size: 1},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1}\n }\n };\n\n for (const geomType in returnObj) {\n for (const numericProp in returnObj[geomType].numericProps) {\n returnObj[geomType].numericProps[numericProp] = {\n value: returnObj[geomType].numericProps[numericProp],\n size: 1\n };\n }\n }\n return returnObj;\n}\n\n// Add numeric properties to object\nfunction fillNumericProperties(object, properties, index, length) {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);\n }\n }\n}\n\n// Keep string properties in object\nfunction keepStringProperties(properties, numericKeys) {\n const props = {};\n for (const key in properties) {\n if (!numericKeys.includes(key)) {\n props[key] = properties[key];\n }\n }\n return props;\n}\n\nfunction isNumeric(x) {\n return Number.isFinite(x);\n}\n"],"file":"features-to-binary.js"}