@loaders.gl/mvt 3.1.0-beta.7 → 3.1.0

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 (28) hide show
  1. package/dist/es5/bundle.js +1 -1
  2. package/dist/es5/bundle.js.map +1 -1
  3. package/dist/es5/helpers/binary-util-functions.js +18 -18
  4. package/dist/es5/helpers/binary-util-functions.js.map +1 -1
  5. package/dist/es5/helpers/mapbox-util-functions.js +11 -11
  6. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -1
  7. package/dist/es5/index.js +2 -2
  8. package/dist/es5/lib/binary-vector-tile/features-to-binary.js +180 -133
  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 +131 -104
  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 +23 -15
  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 +8 -8
  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 -147
  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 +23 -15
  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 +8 -8
  21. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -1
  22. package/dist/es5/lib/parse-mvt.js +35 -33
  23. package/dist/es5/lib/parse-mvt.js.map +1 -1
  24. package/dist/es5/mvt-loader.js +38 -5
  25. package/dist/es5/mvt-loader.js.map +1 -1
  26. package/dist/esm/mvt-loader.js +1 -1
  27. package/dist/esm/mvt-loader.js.map +1 -1
  28. package/package.json +4 -4
@@ -1,64 +1,88 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.featuresToBinary = featuresToBinary;
7
9
  exports.TEST_EXPORTS = void 0;
8
10
 
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+
9
13
  var _polygon = require("@math.gl/polygon");
10
14
 
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
+
11
25
  function featuresToBinary(features, firstPassData, options) {
12
- const propArrayTypes = extractNumericPropTypes(features);
13
- const numericPropKeys = Object.keys(propArrayTypes).filter(k => propArrayTypes[k] !== Array);
26
+ var propArrayTypes = extractNumericPropTypes(features);
27
+ var numericPropKeys = Object.keys(propArrayTypes).filter(function (k) {
28
+ return propArrayTypes[k] !== Array;
29
+ });
14
30
  return fillArrays(features, firstPassData, {
15
31
  numericPropKeys: options ? options.numericPropKeys : numericPropKeys,
16
- propArrayTypes,
32
+ propArrayTypes: propArrayTypes,
17
33
  PositionDataType: options ? options.PositionDataType : Float32Array
18
34
  });
19
35
  }
20
36
 
21
- const TEST_EXPORTS = {
22
- fillArrays
37
+ var TEST_EXPORTS = {
38
+ fillArrays: fillArrays
23
39
  };
24
40
  exports.TEST_EXPORTS = TEST_EXPORTS;
25
41
 
26
42
  function extractNumericPropTypes(features) {
27
- const propArrayTypes = {};
43
+ var propArrayTypes = {};
28
44
 
29
- for (const feature of features) {
30
- if (feature.properties) {
31
- for (const key in feature.properties) {
32
- const val = feature.properties[key];
33
- propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);
45
+ var _iterator = _createForOfIteratorHelper(features),
46
+ _step;
47
+
48
+ try {
49
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
50
+ var feature = _step.value;
51
+
52
+ if (feature.properties) {
53
+ for (var _key in feature.properties) {
54
+ var val = feature.properties[_key];
55
+ propArrayTypes[_key] = deduceArrayType(val, propArrayTypes[_key]);
56
+ }
34
57
  }
35
58
  }
59
+ } catch (err) {
60
+ _iterator.e(err);
61
+ } finally {
62
+ _iterator.f();
36
63
  }
37
64
 
38
65
  return propArrayTypes;
39
66
  }
40
67
 
41
68
  function fillArrays(features, firstPassData, options) {
42
- const {
43
- pointPositionsCount,
44
- pointFeaturesCount,
45
- linePositionsCount,
46
- linePathsCount,
47
- lineFeaturesCount,
48
- polygonPositionsCount,
49
- polygonObjectsCount,
50
- polygonRingsCount,
51
- polygonFeaturesCount
52
- } = firstPassData;
53
- const {
54
- numericPropKeys,
55
- propArrayTypes,
56
- PositionDataType = Float32Array
57
- } = options;
58
- const hasGlobalId = features[0] && 'id' in features[0];
59
- const coordLength = 2;
60
- const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
61
- const points = {
69
+ var pointPositionsCount = firstPassData.pointPositionsCount,
70
+ pointFeaturesCount = firstPassData.pointFeaturesCount,
71
+ linePositionsCount = firstPassData.linePositionsCount,
72
+ linePathsCount = firstPassData.linePathsCount,
73
+ lineFeaturesCount = firstPassData.lineFeaturesCount,
74
+ polygonPositionsCount = firstPassData.polygonPositionsCount,
75
+ polygonObjectsCount = firstPassData.polygonObjectsCount,
76
+ polygonRingsCount = firstPassData.polygonRingsCount,
77
+ polygonFeaturesCount = firstPassData.polygonFeaturesCount;
78
+ var numericPropKeys = options.numericPropKeys,
79
+ propArrayTypes = options.propArrayTypes,
80
+ _options$PositionData = options.PositionDataType,
81
+ PositionDataType = _options$PositionData === void 0 ? Float32Array : _options$PositionData;
82
+ var hasGlobalId = features[0] && 'id' in features[0];
83
+ var coordLength = 2;
84
+ var GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
85
+ var points = {
62
86
  positions: new PositionDataType(pointPositionsCount * coordLength),
63
87
  globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
64
88
  featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
@@ -66,7 +90,7 @@ function fillArrays(features, firstPassData, options) {
66
90
  properties: [],
67
91
  fields: []
68
92
  };
69
- const lines = {
93
+ var lines = {
70
94
  pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
71
95
  positions: new PositionDataType(linePositionsCount * coordLength),
72
96
  globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
@@ -75,7 +99,7 @@ function fillArrays(features, firstPassData, options) {
75
99
  properties: [],
76
100
  fields: []
77
101
  };
78
- const polygons = {
102
+ var polygons = {
79
103
  polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
80
104
  primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
81
105
  positions: new PositionDataType(polygonPositionsCount * coordLength),
@@ -87,17 +111,29 @@ function fillArrays(features, firstPassData, options) {
87
111
  fields: []
88
112
  };
89
113
 
90
- for (const object of [points, lines, polygons]) {
91
- for (const propName of numericPropKeys) {
92
- const TypedArray = propArrayTypes[propName];
93
- object.numericProps[propName] = new TypedArray(object.positions.length / coordLength);
114
+ for (var _i = 0, _arr = [points, lines, polygons]; _i < _arr.length; _i++) {
115
+ var object = _arr[_i];
116
+
117
+ var _iterator2 = _createForOfIteratorHelper(numericPropKeys),
118
+ _step2;
119
+
120
+ try {
121
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
122
+ var propName = _step2.value;
123
+ var TypedArray = propArrayTypes[propName];
124
+ object.numericProps[propName] = new TypedArray(object.positions.length / coordLength);
125
+ }
126
+ } catch (err) {
127
+ _iterator2.e(err);
128
+ } finally {
129
+ _iterator2.f();
94
130
  }
95
131
  }
96
132
 
97
133
  lines.pathIndices[linePathsCount] = linePositionsCount;
98
134
  polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
99
135
  polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
100
- const indexMap = {
136
+ var indexMap = {
101
137
  pointPosition: 0,
102
138
  pointFeature: 0,
103
139
  linePosition: 0,
@@ -110,58 +146,68 @@ function fillArrays(features, firstPassData, options) {
110
146
  feature: 0
111
147
  };
112
148
 
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));
122
-
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;
149
+ var _iterator3 = _createForOfIteratorHelper(features),
150
+ _step3;
151
+
152
+ try {
153
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
154
+ var feature = _step3.value;
155
+ var geometry = feature.geometry;
156
+ var properties = feature.properties || {};
157
+
158
+ switch (geometry.type) {
159
+ case 'Point':
160
+ case 'MultiPoint':
161
+ handlePoint(geometry, points, indexMap, coordLength, properties);
162
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
163
+
164
+ if (hasGlobalId) {
165
+ points.fields.push({
166
+ id: feature.id
167
+ });
168
+ }
169
+
170
+ indexMap.pointFeature++;
171
+ break;
172
+
173
+ case 'LineString':
174
+ case 'MultiLineString':
175
+ handleLineString(geometry, lines, indexMap, coordLength, properties);
176
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
177
+
178
+ if (hasGlobalId) {
179
+ lines.fields.push({
180
+ id: feature.id
181
+ });
182
+ }
183
+
184
+ indexMap.lineFeature++;
185
+ break;
186
+
187
+ case 'Polygon':
188
+ case 'MultiPolygon':
189
+ handlePolygon(geometry, polygons, indexMap, coordLength, properties);
190
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
191
+
192
+ if (hasGlobalId) {
193
+ polygons.fields.push({
194
+ id: feature.id
195
+ });
196
+ }
197
+
198
+ indexMap.polygonFeature++;
199
+ break;
200
+
201
+ default:
202
+ throw new Error('Invalid geometry type');
203
+ }
159
204
 
160
- default:
161
- throw new Error('Invalid geometry type');
205
+ indexMap.feature++;
162
206
  }
163
-
164
- indexMap.feature++;
207
+ } catch (err) {
208
+ _iterator3.e(err);
209
+ } finally {
210
+ _iterator3.f();
165
211
  }
166
212
 
167
213
  return makeAccessorObjects(points, lines, polygons, coordLength);
@@ -169,7 +215,7 @@ function fillArrays(features, firstPassData, options) {
169
215
 
170
216
  function handlePoint(geometry, points, indexMap, coordLength, properties) {
171
217
  points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
172
- const nPositions = geometry.data.length / coordLength;
218
+ var nPositions = geometry.data.length / coordLength;
173
219
  fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
174
220
  points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
175
221
  points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
@@ -178,14 +224,14 @@ function handlePoint(geometry, points, indexMap, coordLength, properties) {
178
224
 
179
225
  function handleLineString(geometry, lines, indexMap, coordLength, properties) {
180
226
  lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
181
- const nPositions = geometry.data.length / coordLength;
227
+ var nPositions = geometry.data.length / coordLength;
182
228
  fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
183
229
  lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
184
230
  lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
185
231
 
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];
232
+ for (var i = 0, il = geometry.lines.length; i < il; ++i) {
233
+ var start = geometry.lines[i];
234
+ var end = i === il - 1 ? geometry.data.length : geometry.lines[i + 1];
189
235
  lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
190
236
  indexMap.linePosition += (end - start) / coordLength;
191
237
  }
@@ -193,54 +239,55 @@ function handleLineString(geometry, lines, indexMap, coordLength, properties) {
193
239
 
194
240
  function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
195
241
  polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
196
- const nPositions = geometry.data.length / coordLength;
242
+ var nPositions = geometry.data.length / coordLength;
197
243
  fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
198
244
  polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
199
245
  polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
200
246
 
201
- for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {
202
- const startPosition = indexMap.polygonPosition;
247
+ for (var l = 0, ll = geometry.lines.length; l < ll; ++l) {
248
+ var startPosition = indexMap.polygonPosition;
203
249
  polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
204
- const areas = geometry.areas[l];
205
- const lines = geometry.lines[l];
206
- const nextLines = geometry.lines[l + 1];
250
+ var areas = geometry.areas[l];
251
+ var lines = geometry.lines[l];
252
+ var nextLines = geometry.lines[l + 1];
207
253
 
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];
254
+ for (var i = 0, il = lines.length; i < il; ++i) {
255
+ var start = lines[i];
256
+ var end = i === il - 1 ? nextLines === undefined ? geometry.data.length : nextLines[0] : lines[i + 1];
211
257
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
212
258
  indexMap.polygonPosition += (end - start) / coordLength;
213
259
  }
214
260
 
215
- const endPosition = indexMap.polygonPosition;
261
+ var endPosition = indexMap.polygonPosition;
216
262
  triangulatePolygon(polygons, areas, lines, {
217
- startPosition,
218
- endPosition,
219
- coordLength
263
+ startPosition: startPosition,
264
+ endPosition: endPosition,
265
+ coordLength: coordLength
220
266
  });
221
267
  }
222
268
  }
223
269
 
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) {
270
+ function triangulatePolygon(polygons, areas, lines, _ref) {
271
+ var startPosition = _ref.startPosition,
272
+ endPosition = _ref.endPosition,
273
+ coordLength = _ref.coordLength;
274
+ var start = startPosition * coordLength;
275
+ var end = endPosition * coordLength;
276
+ var polygonPositions = polygons.positions.subarray(start, end);
277
+ var offset = lines[0];
278
+ var holes = lines.slice(1).map(function (n) {
279
+ return (n - offset) / coordLength;
280
+ });
281
+ var indices = (0, _polygon.earcut)(polygonPositions, holes, coordLength, areas);
282
+
283
+ for (var t = 0, tl = indices.length; t < tl; ++t) {
237
284
  polygons.triangles.push(startPosition + indices[t]);
238
285
  }
239
286
  }
240
287
 
241
288
  function makeAccessorObjects(points, lines, polygons, coordLength) {
242
- const returnObj = {
243
- points: { ...points,
289
+ var returnObj = {
290
+ points: _objectSpread(_objectSpread({}, points), {}, {
244
291
  positions: {
245
292
  value: points.positions,
246
293
  size: coordLength
@@ -253,8 +300,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
253
300
  value: points.featureIds,
254
301
  size: 1
255
302
  }
256
- },
257
- lines: { ...lines,
303
+ }),
304
+ lines: _objectSpread(_objectSpread({}, lines), {}, {
258
305
  pathIndices: {
259
306
  value: lines.pathIndices,
260
307
  size: 1
@@ -271,8 +318,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
271
318
  value: lines.featureIds,
272
319
  size: 1
273
320
  }
274
- },
275
- polygons: { ...polygons,
321
+ }),
322
+ polygons: _objectSpread(_objectSpread({}, polygons), {}, {
276
323
  polygonIndices: {
277
324
  value: polygons.polygonIndices,
278
325
  size: 1
@@ -297,11 +344,11 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
297
344
  value: polygons.featureIds,
298
345
  size: 1
299
346
  }
300
- }
347
+ })
301
348
  };
302
349
 
303
- for (const geomType in returnObj) {
304
- for (const numericProp in returnObj[geomType].numericProps) {
350
+ for (var geomType in returnObj) {
351
+ for (var numericProp in returnObj[geomType].numericProps) {
305
352
  returnObj[geomType].numericProps[numericProp] = {
306
353
  value: returnObj[geomType].numericProps[numericProp],
307
354
  size: 1
@@ -313,7 +360,7 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
313
360
  }
314
361
 
315
362
  function fillNumericProperties(object, properties, index, length) {
316
- for (const numericPropName in object.numericProps) {
363
+ for (var numericPropName in object.numericProps) {
317
364
  if (numericPropName in properties) {
318
365
  object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);
319
366
  }
@@ -321,11 +368,11 @@ function fillNumericProperties(object, properties, index, length) {
321
368
  }
322
369
 
323
370
  function keepStringProperties(properties, numericKeys) {
324
- const props = {};
371
+ var props = {};
325
372
 
326
- for (const key in properties) {
327
- if (!numericKeys.includes(key)) {
328
- props[key] = properties[key];
373
+ for (var _key2 in properties) {
374
+ if (!numericKeys.includes(_key2)) {
375
+ props[_key2] = properties[_key2];
329
376
  }
330
377
  }
331
378
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/binary-vector-tile/features-to-binary.ts"],"names":["featuresToBinary","features","firstPassData","options","propArrayTypes","extractNumericPropTypes","numericPropKeys","Object","keys","filter","k","Array","fillArrays","PositionDataType","Float32Array","TEST_EXPORTS","feature","properties","key","val","deduceArrayType","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","TypedArray","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","undefined","endPosition","triangulatePolygon","polygonPositions","subarray","offset","holes","slice","map","n","indices","t","tl","returnObj","value","size","geomType","numericProp","index","numericPropName","numericKeys","props","includes","x","constructor","Number","isFinite","Float64Array","Math","fround"],"mappings":";;;;;;;;AACA;;AAyBO,SAASA,gBAAT,CACLC,QADK,EAELC,aAFK,EAGLC,OAHK,EAIL;AACA,QAAMC,cAAc,GAAGC,uBAAuB,CAACJ,QAAD,CAA9C;AACA,QAAMK,eAAe,GAAGC,MAAM,CAACC,IAAP,CAAYJ,cAAZ,EAA4BK,MAA5B,CAAoCC,CAAD,IAAON,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F,MAAIA,WAAW,KAAKlG,KAAhB,IAAyB,CAACmG,MAAM,CAACC,QAAP,CAAgBH,CAAhB,CAA9B,EAAkD;AAChD,WAAOjG,KAAP;AACD;;AAGD,SAAOkG,WAAW,KAAKG,YAAhB,IAAgCC,IAAI,CAACC,MAAL,CAAYN,CAAZ,MAAmBA,CAAnD,GAAuDI,YAAvD,GAAsElG,YAA7E;AACD","sourcesContent":["/* eslint-disable indent */\nimport {earcut} from '@math.gl/polygon';\nimport {\n MvtBinaryCoordinates,\n MvtBinaryGeometry,\n MvtBinaryOptions,\n MvtPropArrayConstructor,\n MvtFirstPassedData,\n MvtLines,\n MvtPoints,\n MvtPolygons\n} from '../types';\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 *\n * @param features\n * @param firstPassData\n * @param options\n * @returns filled arrays\n */\nexport function featuresToBinary(\n features: MvtBinaryCoordinates[],\n firstPassData: MvtFirstPassedData,\n options?: MvtBinaryOptions\n) {\n const propArrayTypes = extractNumericPropTypes(features);\n const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);\n return fillArrays(features, firstPassData, {\n numericPropKeys: options ? options.numericPropKeys : numericPropKeys,\n propArrayTypes,\n PositionDataType: options ? options.PositionDataType : Float32Array\n });\n}\n\nexport const TEST_EXPORTS = {\n fillArrays\n};\n\n/**\n * Extracts properties that are always numeric\n *\n * @param features\n * @returns object with numeric types\n */\nfunction extractNumericPropTypes(features: MvtBinaryCoordinates[]): {\n [key: string]: MvtPropArrayConstructor;\n} {\n const propArrayTypes = {};\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, Array is stored to prevent rechecking in the future\n // Additionally, detects if 64 bit precision is required\n const val = feature.properties[key];\n propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);\n }\n }\n }\n\n return propArrayTypes;\n}\n\n/**\n * Fills coordinates into pre-allocated typed arrays\n *\n * @param features\n * @param firstPassData\n * @param options\n * @returns an accessor object with value and size keys\n */\n// eslint-disable-next-line complexity\nfunction fillArrays(\n features: MvtBinaryCoordinates[],\n firstPassData: MvtFirstPassedData,\n options: MvtBinaryOptions\n) {\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, propArrayTypes, 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: MvtPoints = {\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: MvtLines = {\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: MvtPolygons = {\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 const TypedArray = propArrayTypes[propName];\n object.numericProps[propName] = new TypedArray(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/**\n * Fills (Multi)Point coordinates into points object of arrays\n *\n * @param geometry\n * @param points\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePoint(\n geometry: MvtBinaryGeometry,\n points: MvtPoints,\n indexMap: {\n pointPosition: number;\n pointFeature: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\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/**\n * Fills (Multi)LineString coordinates into lines object of arrays\n *\n * @param geometry\n * @param lines\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handleLineString(\n geometry: MvtBinaryGeometry,\n lines: MvtLines,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition: number;\n linePath: number;\n lineFeature: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\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/**\n * Fills (Multi)Polygon coordinates into polygons object of arrays\n *\n * @param geometry\n * @param polygons\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePolygon(\n geometry: MvtBinaryGeometry,\n polygons: MvtPolygons,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition: number;\n polygonObject: number;\n polygonRing: number;\n polygonFeature: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\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 *\n * @param polygons\n * @param areas\n * @param lines\n * @param param3\n */\nfunction triangulatePolygon(\n polygons: MvtPolygons,\n areas: number,\n lines: number[],\n {\n startPosition,\n endPosition,\n coordLength\n }: {startPosition: number; endPosition: number; coordLength: number}\n): void {\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: number) => (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/**\n * Wrap each array in an accessor object with value and size keys\n *\n * @param points\n * @param lines\n * @param polygons\n * @param coordLength\n * @returns object\n */\nfunction makeAccessorObjects(\n points: MvtPoints,\n lines: MvtLines,\n polygons: MvtPolygons,\n coordLength: number\n) {\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/**\n * Add numeric properties to object\n *\n * @param object\n * @param properties\n * @param index\n * @param length\n */\nfunction fillNumericProperties(\n object: MvtPoints,\n properties: {[x: string]: string | number | boolean | null},\n index: number,\n length: number\n): void {\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/**\n * Keep string properties in object\n *\n * @param properties\n * @param numericKeys\n * @returns object\n */\nfunction keepStringProperties(\n properties: {[x: string]: string | number | boolean | null},\n numericKeys: string[]\n) {\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 deduceArrayType(x: any, constructor: MvtPropArrayConstructor): MvtPropArrayConstructor {\n if (constructor === Array || !Number.isFinite(x)) {\n return Array;\n }\n\n // If this or previous value required 64bits use Float64Array\n return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;\n}\n"],"file":"features-to-binary.js"}
1
+ {"version":3,"sources":["../../../../src/lib/binary-vector-tile/features-to-binary.ts"],"names":["featuresToBinary","features","firstPassData","options","propArrayTypes","extractNumericPropTypes","numericPropKeys","Object","keys","filter","k","Array","fillArrays","PositionDataType","Float32Array","TEST_EXPORTS","feature","properties","key","val","deduceArrayType","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","TypedArray","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","undefined","endPosition","triangulatePolygon","polygonPositions","subarray","offset","holes","slice","map","n","indices","t","tl","returnObj","value","size","geomType","numericProp","index","numericPropName","numericKeys","props","includes","x","constructor","Number","isFinite","Float64Array","Math","fround"],"mappings":";;;;;;;;;;;;AACA;;;;;;;;;;;;AAyBO,SAASA,gBAAT,CACLC,QADK,EAELC,aAFK,EAGLC,OAHK,EAIL;AACA,MAAMC,cAAc,GAAGC,uBAAuB,CAACJ,QAAD,CAA9C;AACA,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAP,CAAYJ,cAAZ,EAA4BK,MAA5B,CAAmC,UAACC,CAAD;AAAA,WAAON,cAAc,CAACM,CAAD,CAAd,KAAsBC,KAA7B;AAAA,GAAnC,CAAxB;AACA,SAAOC,UAAU,CAACX,QAAD,EAAWC,aAAX,EAA0B;AACzCI,IAAAA,eAAe,EAAEH,OAAO,GAAGA,OAAO,CAACG,eAAX,GAA6BA,eADZ;AAEzCF,IAAAA,cAAc,EAAdA,cAFyC;AAGzCS,IAAAA,gBAAgB,EAAEV,OAAO,GAAGA,OAAO,CAACU,gBAAX,GAA8BC;AAHd,GAA1B,CAAjB;AAKD;;AAEM,IAAMC,YAAY,GAAG;AAC1BH,EAAAA,UAAU,EAAVA;AAD0B,CAArB;;;AAUP,SAASP,uBAAT,CAAiCJ,QAAjC,EAEE;AACA,MAAMG,cAAc,GAAG,EAAvB;;AADA,6CAEsBH,QAFtB;AAAA;;AAAA;AAEA,wDAAgC;AAAA,UAArBe,OAAqB;;AAC9B,UAAIA,OAAO,CAACC,UAAZ,EAAwB;AACtB,aAAK,IAAMC,IAAX,IAAkBF,OAAO,CAACC,UAA1B,EAAsC;AAKpC,cAAME,GAAG,GAAGH,OAAO,CAACC,UAA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D;AAChD,WAAOjG,KAAP;AACD;;AAGD,SAAOkG,WAAW,KAAKG,YAAhB,IAAgCC,IAAI,CAACC,MAAL,CAAYN,CAAZ,MAAmBA,CAAnD,GAAuDI,YAAvD,GAAsElG,YAA7E;AACD","sourcesContent":["/* eslint-disable indent */\nimport {earcut} from '@math.gl/polygon';\nimport {\n MvtBinaryCoordinates,\n MvtBinaryGeometry,\n MvtBinaryOptions,\n MvtPropArrayConstructor,\n MvtFirstPassedData,\n MvtLines,\n MvtPoints,\n MvtPolygons\n} from '../types';\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 *\n * @param features\n * @param firstPassData\n * @param options\n * @returns filled arrays\n */\nexport function featuresToBinary(\n features: MvtBinaryCoordinates[],\n firstPassData: MvtFirstPassedData,\n options?: MvtBinaryOptions\n) {\n const propArrayTypes = extractNumericPropTypes(features);\n const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);\n return fillArrays(features, firstPassData, {\n numericPropKeys: options ? options.numericPropKeys : numericPropKeys,\n propArrayTypes,\n PositionDataType: options ? options.PositionDataType : Float32Array\n });\n}\n\nexport const TEST_EXPORTS = {\n fillArrays\n};\n\n/**\n * Extracts properties that are always numeric\n *\n * @param features\n * @returns object with numeric types\n */\nfunction extractNumericPropTypes(features: MvtBinaryCoordinates[]): {\n [key: string]: MvtPropArrayConstructor;\n} {\n const propArrayTypes = {};\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, Array is stored to prevent rechecking in the future\n // Additionally, detects if 64 bit precision is required\n const val = feature.properties[key];\n propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);\n }\n }\n }\n\n return propArrayTypes;\n}\n\n/**\n * Fills coordinates into pre-allocated typed arrays\n *\n * @param features\n * @param firstPassData\n * @param options\n * @returns an accessor object with value and size keys\n */\n// eslint-disable-next-line complexity\nfunction fillArrays(\n features: MvtBinaryCoordinates[],\n firstPassData: MvtFirstPassedData,\n options: MvtBinaryOptions\n) {\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, propArrayTypes, 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: MvtPoints = {\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: MvtLines = {\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: MvtPolygons = {\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 const TypedArray = propArrayTypes[propName];\n object.numericProps[propName] = new TypedArray(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/**\n * Fills (Multi)Point coordinates into points object of arrays\n *\n * @param geometry\n * @param points\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePoint(\n geometry: MvtBinaryGeometry,\n points: MvtPoints,\n indexMap: {\n pointPosition: number;\n pointFeature: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\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/**\n * Fills (Multi)LineString coordinates into lines object of arrays\n *\n * @param geometry\n * @param lines\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handleLineString(\n geometry: MvtBinaryGeometry,\n lines: MvtLines,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition: number;\n linePath: number;\n lineFeature: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\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/**\n * Fills (Multi)Polygon coordinates into polygons object of arrays\n *\n * @param geometry\n * @param polygons\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePolygon(\n geometry: MvtBinaryGeometry,\n polygons: MvtPolygons,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition: number;\n polygonObject: number;\n polygonRing: number;\n polygonFeature: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\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 *\n * @param polygons\n * @param areas\n * @param lines\n * @param param3\n */\nfunction triangulatePolygon(\n polygons: MvtPolygons,\n areas: number,\n lines: number[],\n {\n startPosition,\n endPosition,\n coordLength\n }: {startPosition: number; endPosition: number; coordLength: number}\n): void {\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: number) => (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/**\n * Wrap each array in an accessor object with value and size keys\n *\n * @param points\n * @param lines\n * @param polygons\n * @param coordLength\n * @returns object\n */\nfunction makeAccessorObjects(\n points: MvtPoints,\n lines: MvtLines,\n polygons: MvtPolygons,\n coordLength: number\n) {\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/**\n * Add numeric properties to object\n *\n * @param object\n * @param properties\n * @param index\n * @param length\n */\nfunction fillNumericProperties(\n object: MvtPoints,\n properties: {[x: string]: string | number | boolean | null},\n index: number,\n length: number\n): void {\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/**\n * Keep string properties in object\n *\n * @param properties\n * @param numericKeys\n * @returns object\n */\nfunction keepStringProperties(\n properties: {[x: string]: string | number | boolean | null},\n numericKeys: string[]\n) {\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 deduceArrayType(x: any, constructor: MvtPropArrayConstructor): MvtPropArrayConstructor {\n if (constructor === Array || !Number.isFinite(x)) {\n return Array;\n }\n\n // If this or previous value required 64bits use Float64Array\n return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;\n}\n"],"file":"features-to-binary.js"}