@loaders.gl/mvt 3.0.13 → 3.0.14

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 (29) 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 +182 -132
  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 +160 -133
  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 +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 +169 -157
  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 +7 -7
  21. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -1
  22. package/dist/es5/lib/parse-mvt.js +39 -35
  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/mvt-worker.js +1 -1
  28. package/dist/mvt-worker.js.map +1 -1
  29. package/package.json +4 -4
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- const moduleExports = require('./index');
3
+ var moduleExports = require('./index');
4
4
 
5
- const _global = typeof window === 'undefined' ? global : window;
5
+ var _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,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"}
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"}
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 () {
8
+ get: function get() {
9
9
  return _mvtLoader.MVTLoader;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "MVTWorkerLoader", {
13
13
  enumerable: true,
14
- get: function () {
14
+ get: function get() {
15
15
  return _mvtLoader.MVTWorkerLoader;
16
16
  }
17
17
  });
@@ -1,65 +1,92 @@
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
 
11
- function featuresToBinary(features, firstPassData, options = {}) {
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] : {};
12
27
  return fillArrays(features, firstPassData, {
13
28
  numericPropKeys: options.numericPropKeys || extractNumericPropKeys(features),
14
29
  PositionDataType: options.PositionDataType || Float32Array
15
30
  });
16
31
  }
17
32
 
18
- const TEST_EXPORTS = {
19
- extractNumericPropKeys,
20
- fillArrays
33
+ var TEST_EXPORTS = {
34
+ extractNumericPropKeys: extractNumericPropKeys,
35
+ fillArrays: fillArrays
21
36
  };
22
37
  exports.TEST_EXPORTS = TEST_EXPORTS;
23
38
 
24
39
  function extractNumericPropKeys(features) {
25
- const numericPropKeys = {};
40
+ var numericPropKeys = {};
41
+
42
+ var _iterator = _createForOfIteratorHelper(features),
43
+ _step;
26
44
 
27
- for (const feature of features) {
28
- if (feature.properties) {
29
- for (const key in feature.properties) {
30
- const numericSoFar = numericPropKeys[key];
45
+ try {
46
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
47
+ var feature = _step.value;
31
48
 
32
- if (numericSoFar || numericSoFar === undefined) {
33
- const val = feature.properties[key];
34
- numericPropKeys[key] = isNumeric(val);
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
+ }
35
57
  }
36
58
  }
37
59
  }
60
+ } catch (err) {
61
+ _iterator.e(err);
62
+ } finally {
63
+ _iterator.f();
38
64
  }
39
65
 
40
- return Object.keys(numericPropKeys).filter(k => numericPropKeys[k]);
66
+ return Object.keys(numericPropKeys).filter(function (k) {
67
+ return numericPropKeys[k];
68
+ });
41
69
  }
42
70
 
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 = {
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 = {
63
90
  positions: new PositionDataType(pointPositionsCount * coordLength),
64
91
  globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
65
92
  featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
@@ -67,7 +94,7 @@ function fillArrays(features, firstPassData = {}, options = {}) {
67
94
  properties: [],
68
95
  fields: []
69
96
  };
70
- const lines = {
97
+ var lines = {
71
98
  pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
72
99
  positions: new PositionDataType(linePositionsCount * coordLength),
73
100
  globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
@@ -76,7 +103,7 @@ function fillArrays(features, firstPassData = {}, options = {}) {
76
103
  properties: [],
77
104
  fields: []
78
105
  };
79
- const polygons = {
106
+ var polygons = {
80
107
  polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
81
108
  primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
82
109
  positions: new PositionDataType(polygonPositionsCount * coordLength),
@@ -88,16 +115,28 @@ function fillArrays(features, firstPassData = {}, options = {}) {
88
115
  fields: []
89
116
  };
90
117
 
91
- for (const object of [points, lines, polygons]) {
92
- for (const propName of numericPropKeys) {
93
- object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
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();
94
133
  }
95
134
  }
96
135
 
97
136
  lines.pathIndices[linePathsCount] = linePositionsCount;
98
137
  polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
99
138
  polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
100
- const indexMap = {
139
+ var indexMap = {
101
140
  pointPosition: 0,
102
141
  pointFeature: 0,
103
142
  linePosition: 0,
@@ -110,58 +149,68 @@ function fillArrays(features, firstPassData = {}, options = {}) {
110
149
  feature: 0
111
150
  };
112
151
 
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;
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
+ }
159
207
 
160
- default:
161
- throw new Error('Invalid geometry type');
208
+ indexMap.feature++;
162
209
  }
163
-
164
- indexMap.feature++;
210
+ } catch (err) {
211
+ _iterator3.e(err);
212
+ } finally {
213
+ _iterator3.f();
165
214
  }
166
215
 
167
216
  return makeAccessorObjects(points, lines, polygons, coordLength);
@@ -169,7 +218,7 @@ function fillArrays(features, firstPassData = {}, options = {}) {
169
218
 
170
219
  function handlePoint(geometry, points, indexMap, coordLength, properties) {
171
220
  points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
172
- const nPositions = geometry.data.length / coordLength;
221
+ var nPositions = geometry.data.length / coordLength;
173
222
  fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
174
223
  points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
175
224
  points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
@@ -178,14 +227,14 @@ function handlePoint(geometry, points, indexMap, coordLength, properties) {
178
227
 
179
228
  function handleLineString(geometry, lines, indexMap, coordLength, properties) {
180
229
  lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
181
- const nPositions = geometry.data.length / coordLength;
230
+ var nPositions = geometry.data.length / coordLength;
182
231
  fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
183
232
  lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
184
233
  lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
185
234
 
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];
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];
189
238
  lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
190
239
  indexMap.linePosition += (end - start) / coordLength;
191
240
  }
@@ -193,54 +242,55 @@ function handleLineString(geometry, lines, indexMap, coordLength, properties) {
193
242
 
194
243
  function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
195
244
  polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
196
- const nPositions = geometry.data.length / coordLength;
245
+ var nPositions = geometry.data.length / coordLength;
197
246
  fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
198
247
  polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
199
248
  polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
200
249
 
201
- for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {
202
- const startPosition = indexMap.polygonPosition;
250
+ for (var l = 0, ll = geometry.lines.length; l < ll; ++l) {
251
+ var startPosition = indexMap.polygonPosition;
203
252
  polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
204
- const areas = geometry.areas[l];
205
- const lines = geometry.lines[l];
206
- const nextLines = geometry.lines[l + 1];
253
+ var areas = geometry.areas[l];
254
+ var lines = geometry.lines[l];
255
+ var nextLines = geometry.lines[l + 1];
207
256
 
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];
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];
211
260
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
212
261
  indexMap.polygonPosition += (end - start) / coordLength;
213
262
  }
214
263
 
215
- const endPosition = indexMap.polygonPosition;
264
+ var endPosition = indexMap.polygonPosition;
216
265
  triangulatePolygon(polygons, areas, lines, {
217
- startPosition,
218
- endPosition,
219
- coordLength
266
+ startPosition: startPosition,
267
+ endPosition: endPosition,
268
+ coordLength: coordLength
220
269
  });
221
270
  }
222
271
  }
223
272
 
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) {
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) {
237
287
  polygons.triangles.push(startPosition + indices[t]);
238
288
  }
239
289
  }
240
290
 
241
291
  function makeAccessorObjects(points, lines, polygons, coordLength) {
242
- const returnObj = {
243
- points: { ...points,
292
+ var returnObj = {
293
+ points: _objectSpread(_objectSpread({}, points), {}, {
244
294
  positions: {
245
295
  value: points.positions,
246
296
  size: coordLength
@@ -253,8 +303,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
253
303
  value: points.featureIds,
254
304
  size: 1
255
305
  }
256
- },
257
- lines: { ...lines,
306
+ }),
307
+ lines: _objectSpread(_objectSpread({}, lines), {}, {
258
308
  pathIndices: {
259
309
  value: lines.pathIndices,
260
310
  size: 1
@@ -271,8 +321,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
271
321
  value: lines.featureIds,
272
322
  size: 1
273
323
  }
274
- },
275
- polygons: { ...polygons,
324
+ }),
325
+ polygons: _objectSpread(_objectSpread({}, polygons), {}, {
276
326
  polygonIndices: {
277
327
  value: polygons.polygonIndices,
278
328
  size: 1
@@ -297,11 +347,11 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
297
347
  value: polygons.featureIds,
298
348
  size: 1
299
349
  }
300
- }
350
+ })
301
351
  };
302
352
 
303
- for (const geomType in returnObj) {
304
- for (const numericProp in returnObj[geomType].numericProps) {
353
+ for (var geomType in returnObj) {
354
+ for (var numericProp in returnObj[geomType].numericProps) {
305
355
  returnObj[geomType].numericProps[numericProp] = {
306
356
  value: returnObj[geomType].numericProps[numericProp],
307
357
  size: 1
@@ -313,7 +363,7 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
313
363
  }
314
364
 
315
365
  function fillNumericProperties(object, properties, index, length) {
316
- for (const numericPropName in object.numericProps) {
366
+ for (var numericPropName in object.numericProps) {
317
367
  if (numericPropName in properties) {
318
368
  object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);
319
369
  }
@@ -321,9 +371,9 @@ function fillNumericProperties(object, properties, index, length) {
321
371
  }
322
372
 
323
373
  function keepStringProperties(properties, numericKeys) {
324
- const props = {};
374
+ var props = {};
325
375
 
326
- for (const key in properties) {
376
+ for (var key in properties) {
327
377
  if (!numericKeys.includes(key)) {
328
378
  props[key] = properties[key];
329
379
  }
@@ -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,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,EAAwB;AACtB,WAAK,MAAMC,GAAX,IAAkBF,OAAO,CAACC,UAA1B,EAAsC;AAIpC,cAAME,YAAY,GAAGR,eAAe,CAACO,GAAD,CAApC;;AAEA,YAAIC,YAAY,IAAIA,YAAY,KAAKC,SAArC,EAAgD;AAC9C,gBAAMC,GAAG,GAAGL,OAAO,CAACC,UAAR,CAAmBC,GAAnB,CAAZ;AACAP,UAAAA,eAAe,CAACO,GAAD,CAAf,GAAuBI,SAAS,CAACD,GAAD,CAAhC;AACD;AACF;AACF;AACF;;AAED,SAAOE,MAAM,CAACC,IAAP,CAAYb,eAAZ,EAA6Bc,MAA7B,CAAqCC,CAAD,IAAOf,eAAe,CAACe,CAAD,CAA1D,CAAP;AACD;;AAID,SAAShB,UAAT,CAAoBH,QAApB,EAA8BC,aAAa,GAAG,EAA9C,EAAkDC,OAAO,GAAG,EAA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AAS+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"}
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,CA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AA,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"}