@loaders.gl/gis 3.0.9 → 3.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,30 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.geojsonToBinary = geojsonToBinary;
9
7
  exports.TEST_EXPORTS = void 0;
10
8
 
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
-
13
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
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
-
25
- function geojsonToBinary(features) {
26
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27
- var firstPassData = firstPass(features);
9
+ function geojsonToBinary(features, options = {}) {
10
+ const firstPassData = firstPass(features);
28
11
  return secondPass(features, firstPassData, {
29
12
  coordLength: options.coordLength || firstPassData.coordLength,
30
13
  numericPropKeys: options.numericPropKeys || firstPassData.numericPropKeys,
@@ -32,222 +15,143 @@ function geojsonToBinary(features) {
32
15
  });
33
16
  }
34
17
 
35
- var TEST_EXPORTS = {
36
- firstPass: firstPass,
37
- secondPass: secondPass
18
+ const TEST_EXPORTS = {
19
+ firstPass,
20
+ secondPass
38
21
  };
39
22
  exports.TEST_EXPORTS = TEST_EXPORTS;
40
23
 
41
24
  function firstPass(features) {
42
- var pointPositionsCount = 0;
43
- var pointFeaturesCount = 0;
44
- var linePositionsCount = 0;
45
- var linePathsCount = 0;
46
- var lineFeaturesCount = 0;
47
- var polygonPositionsCount = 0;
48
- var polygonObjectsCount = 0;
49
- var polygonRingsCount = 0;
50
- var polygonFeaturesCount = 0;
51
- var coordLengths = new Set();
52
- var numericPropKeys = {};
53
-
54
- var _iterator = _createForOfIteratorHelper(features),
55
- _step;
56
-
57
- try {
58
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
59
- var feature = _step.value;
60
- var geometry = feature.geometry;
61
-
62
- switch (geometry.type) {
63
- case 'Point':
64
- pointFeaturesCount++;
65
- pointPositionsCount++;
66
- coordLengths.add(geometry.coordinates.length);
67
- break;
68
-
69
- case 'MultiPoint':
70
- pointFeaturesCount++;
71
- pointPositionsCount += geometry.coordinates.length;
72
-
73
- var _iterator2 = _createForOfIteratorHelper(geometry.coordinates),
74
- _step2;
75
-
76
- try {
77
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
78
- var point = _step2.value;
79
- coordLengths.add(point.length);
80
- }
81
- } catch (err) {
82
- _iterator2.e(err);
83
- } finally {
84
- _iterator2.f();
85
- }
25
+ let pointPositionsCount = 0;
26
+ let pointFeaturesCount = 0;
27
+ let linePositionsCount = 0;
28
+ let linePathsCount = 0;
29
+ let lineFeaturesCount = 0;
30
+ let polygonPositionsCount = 0;
31
+ let polygonObjectsCount = 0;
32
+ let polygonRingsCount = 0;
33
+ let polygonFeaturesCount = 0;
34
+ const coordLengths = new Set();
35
+ const numericPropKeys = {};
36
+
37
+ for (const feature of features) {
38
+ const geometry = feature.geometry;
39
+
40
+ switch (geometry.type) {
41
+ case 'Point':
42
+ pointFeaturesCount++;
43
+ pointPositionsCount++;
44
+ coordLengths.add(geometry.coordinates.length);
45
+ break;
46
+
47
+ case 'MultiPoint':
48
+ pointFeaturesCount++;
49
+ pointPositionsCount += geometry.coordinates.length;
50
+
51
+ for (const point of geometry.coordinates) {
52
+ coordLengths.add(point.length);
53
+ }
54
+
55
+ break;
86
56
 
87
- break;
57
+ case 'LineString':
58
+ lineFeaturesCount++;
59
+ linePositionsCount += geometry.coordinates.length;
60
+ linePathsCount++;
88
61
 
89
- case 'LineString':
90
- lineFeaturesCount++;
91
- linePositionsCount += geometry.coordinates.length;
62
+ for (const coord of geometry.coordinates) {
63
+ coordLengths.add(coord.length);
64
+ }
65
+
66
+ break;
67
+
68
+ case 'MultiLineString':
69
+ lineFeaturesCount++;
70
+
71
+ for (const line of geometry.coordinates) {
72
+ linePositionsCount += line.length;
92
73
  linePathsCount++;
93
74
 
94
- var _iterator3 = _createForOfIteratorHelper(geometry.coordinates),
95
- _step3;
96
-
97
- try {
98
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
99
- var coord = _step3.value;
100
- coordLengths.add(coord.length);
101
- }
102
- } catch (err) {
103
- _iterator3.e(err);
104
- } finally {
105
- _iterator3.f();
75
+ for (const coord of line) {
76
+ coordLengths.add(coord.length);
106
77
  }
78
+ }
107
79
 
108
- break;
109
-
110
- case 'MultiLineString':
111
- lineFeaturesCount++;
112
-
113
- var _iterator4 = _createForOfIteratorHelper(geometry.coordinates),
114
- _step4;
115
-
116
- try {
117
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
118
- var line = _step4.value;
119
- linePositionsCount += line.length;
120
- linePathsCount++;
121
-
122
- var _iterator5 = _createForOfIteratorHelper(line),
123
- _step5;
124
-
125
- try {
126
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
127
- var _coord = _step5.value;
128
- coordLengths.add(_coord.length);
129
- }
130
- } catch (err) {
131
- _iterator5.e(err);
132
- } finally {
133
- _iterator5.f();
134
- }
135
- }
136
- } catch (err) {
137
- _iterator4.e(err);
138
- } finally {
139
- _iterator4.f();
140
- }
80
+ break;
141
81
 
142
- break;
82
+ case 'Polygon':
83
+ polygonFeaturesCount++;
84
+ polygonObjectsCount++;
85
+ polygonRingsCount += geometry.coordinates.length;
86
+ polygonPositionsCount += flatten(geometry.coordinates).length;
143
87
 
144
- case 'Polygon':
145
- polygonFeaturesCount++;
88
+ for (const coord of flatten(geometry.coordinates)) {
89
+ coordLengths.add(coord.length);
90
+ }
91
+
92
+ break;
93
+
94
+ case 'MultiPolygon':
95
+ polygonFeaturesCount++;
96
+
97
+ for (const polygon of geometry.coordinates) {
146
98
  polygonObjectsCount++;
147
- polygonRingsCount += geometry.coordinates.length;
148
- polygonPositionsCount += flatten(geometry.coordinates).length;
149
-
150
- var _iterator6 = _createForOfIteratorHelper(flatten(geometry.coordinates)),
151
- _step6;
152
-
153
- try {
154
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
155
- var _coord2 = _step6.value;
156
- coordLengths.add(_coord2.length);
157
- }
158
- } catch (err) {
159
- _iterator6.e(err);
160
- } finally {
161
- _iterator6.f();
162
- }
99
+ polygonRingsCount += polygon.length;
100
+ polygonPositionsCount += flatten(polygon).length;
163
101
 
164
- break;
165
-
166
- case 'MultiPolygon':
167
- polygonFeaturesCount++;
168
-
169
- var _iterator7 = _createForOfIteratorHelper(geometry.coordinates),
170
- _step7;
171
-
172
- try {
173
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
174
- var polygon = _step7.value;
175
- polygonObjectsCount++;
176
- polygonRingsCount += polygon.length;
177
- polygonPositionsCount += flatten(polygon).length;
178
-
179
- var _iterator8 = _createForOfIteratorHelper(flatten(polygon)),
180
- _step8;
181
-
182
- try {
183
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
184
- var _coord3 = _step8.value;
185
- coordLengths.add(_coord3.length);
186
- }
187
- } catch (err) {
188
- _iterator8.e(err);
189
- } finally {
190
- _iterator8.f();
191
- }
192
- }
193
- } catch (err) {
194
- _iterator7.e(err);
195
- } finally {
196
- _iterator7.f();
102
+ for (const coord of flatten(polygon)) {
103
+ coordLengths.add(coord.length);
197
104
  }
105
+ }
198
106
 
199
- break;
107
+ break;
200
108
 
201
- default:
202
- throw new Error("Unsupported geometry type: ".concat(geometry.type));
203
- }
109
+ default:
110
+ throw new Error("Unsupported geometry type: ".concat(geometry.type));
111
+ }
204
112
 
205
- if (feature.properties) {
206
- for (var key in feature.properties) {
207
- var val = feature.properties[key];
208
- numericPropKeys[key] = numericPropKeys[key] || numericPropKeys[key] === undefined ? isNumeric(val) : numericPropKeys[key];
209
- }
113
+ if (feature.properties) {
114
+ for (const key in feature.properties) {
115
+ const val = feature.properties[key];
116
+ numericPropKeys[key] = numericPropKeys[key] || numericPropKeys[key] === undefined ? isNumeric(val) : numericPropKeys[key];
210
117
  }
211
118
  }
212
- } catch (err) {
213
- _iterator.e(err);
214
- } finally {
215
- _iterator.f();
216
119
  }
217
120
 
218
121
  return {
219
- coordLength: coordLengths.size > 0 ? Math.max.apply(Math, (0, _toConsumableArray2.default)(coordLengths)) : 2,
220
- pointPositionsCount: pointPositionsCount,
221
- pointFeaturesCount: pointFeaturesCount,
222
- linePositionsCount: linePositionsCount,
223
- linePathsCount: linePathsCount,
224
- lineFeaturesCount: lineFeaturesCount,
225
- polygonPositionsCount: polygonPositionsCount,
226
- polygonObjectsCount: polygonObjectsCount,
227
- polygonRingsCount: polygonRingsCount,
228
- polygonFeaturesCount: polygonFeaturesCount,
229
- numericPropKeys: Object.keys(numericPropKeys).filter(function (k) {
230
- return numericPropKeys[k];
231
- })
122
+ coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,
123
+ pointPositionsCount,
124
+ pointFeaturesCount,
125
+ linePositionsCount,
126
+ linePathsCount,
127
+ lineFeaturesCount,
128
+ polygonPositionsCount,
129
+ polygonObjectsCount,
130
+ polygonRingsCount,
131
+ polygonFeaturesCount,
132
+ numericPropKeys: Object.keys(numericPropKeys).filter(k => numericPropKeys[k])
232
133
  };
233
134
  }
234
135
 
235
136
  function secondPass(features, firstPassData, options) {
236
- var pointPositionsCount = firstPassData.pointPositionsCount,
237
- pointFeaturesCount = firstPassData.pointFeaturesCount,
238
- linePositionsCount = firstPassData.linePositionsCount,
239
- linePathsCount = firstPassData.linePathsCount,
240
- lineFeaturesCount = firstPassData.lineFeaturesCount,
241
- polygonPositionsCount = firstPassData.polygonPositionsCount,
242
- polygonObjectsCount = firstPassData.polygonObjectsCount,
243
- polygonRingsCount = firstPassData.polygonRingsCount,
244
- polygonFeaturesCount = firstPassData.polygonFeaturesCount;
245
- var coordLength = options.coordLength,
246
- numericPropKeys = options.numericPropKeys,
247
- _options$PositionData = options.PositionDataType,
248
- PositionDataType = _options$PositionData === void 0 ? Float32Array : _options$PositionData;
249
- var GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
250
- var points = {
137
+ const {
138
+ pointPositionsCount,
139
+ pointFeaturesCount,
140
+ linePositionsCount,
141
+ linePathsCount,
142
+ lineFeaturesCount,
143
+ polygonPositionsCount,
144
+ polygonObjectsCount,
145
+ polygonRingsCount,
146
+ polygonFeaturesCount
147
+ } = firstPassData;
148
+ const {
149
+ coordLength,
150
+ numericPropKeys,
151
+ PositionDataType = Float32Array
152
+ } = options;
153
+ const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
154
+ const points = {
251
155
  positions: new PositionDataType(pointPositionsCount * coordLength),
252
156
  globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
253
157
  featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
@@ -255,7 +159,7 @@ function secondPass(features, firstPassData, options) {
255
159
  properties: Array(),
256
160
  fields: Array()
257
161
  };
258
- var lines = {
162
+ const lines = {
259
163
  positions: new PositionDataType(linePositionsCount * coordLength),
260
164
  pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
261
165
  globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
@@ -264,7 +168,7 @@ function secondPass(features, firstPassData, options) {
264
168
  properties: Array(),
265
169
  fields: Array()
266
170
  };
267
- var polygons = {
171
+ const polygons = {
268
172
  positions: new PositionDataType(polygonPositionsCount * coordLength),
269
173
  polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
270
174
  primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
@@ -275,28 +179,16 @@ function secondPass(features, firstPassData, options) {
275
179
  fields: Array()
276
180
  };
277
181
 
278
- for (var _i = 0, _arr = [points, lines, polygons]; _i < _arr.length; _i++) {
279
- var object = _arr[_i];
280
-
281
- var _iterator9 = _createForOfIteratorHelper(numericPropKeys || []),
282
- _step9;
283
-
284
- try {
285
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
286
- var propName = _step9.value;
287
- object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
288
- }
289
- } catch (err) {
290
- _iterator9.e(err);
291
- } finally {
292
- _iterator9.f();
182
+ for (const object of [points, lines, polygons]) {
183
+ for (const propName of numericPropKeys || []) {
184
+ object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
293
185
  }
294
186
  }
295
187
 
296
188
  lines.pathIndices[linePathsCount] = linePositionsCount;
297
189
  polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
298
190
  polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
299
- var indexMap = {
191
+ const indexMap = {
300
192
  pointPosition: 0,
301
193
  pointFeature: 0,
302
194
  linePosition: 0,
@@ -309,62 +201,52 @@ function secondPass(features, firstPassData, options) {
309
201
  feature: 0
310
202
  };
311
203
 
312
- var _iterator10 = _createForOfIteratorHelper(features),
313
- _step10;
314
-
315
- try {
316
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
317
- var feature = _step10.value;
318
- var geometry = feature.geometry;
319
- var properties = feature.properties || {};
320
-
321
- switch (geometry.type) {
322
- case 'Point':
323
- handlePoint(geometry.coordinates, points, indexMap, coordLength, properties);
324
- points.properties.push(keepStringProperties(properties, numericPropKeys));
325
- indexMap.pointFeature++;
326
- break;
327
-
328
- case 'MultiPoint':
329
- handleMultiPoint(geometry.coordinates, points, indexMap, coordLength, properties);
330
- points.properties.push(keepStringProperties(properties, numericPropKeys));
331
- indexMap.pointFeature++;
332
- break;
333
-
334
- case 'LineString':
335
- handleLineString(geometry.coordinates, lines, indexMap, coordLength, properties);
336
- lines.properties.push(keepStringProperties(properties, numericPropKeys));
337
- indexMap.lineFeature++;
338
- break;
339
-
340
- case 'MultiLineString':
341
- handleMultiLineString(geometry.coordinates, lines, indexMap, coordLength, properties);
342
- lines.properties.push(keepStringProperties(properties, numericPropKeys));
343
- indexMap.lineFeature++;
344
- break;
345
-
346
- case 'Polygon':
347
- handlePolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);
348
- polygons.properties.push(keepStringProperties(properties, numericPropKeys));
349
- indexMap.polygonFeature++;
350
- break;
351
-
352
- case 'MultiPolygon':
353
- handleMultiPolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);
354
- polygons.properties.push(keepStringProperties(properties, numericPropKeys));
355
- indexMap.polygonFeature++;
356
- break;
357
-
358
- default:
359
- throw new Error('Invalid geometry type');
360
- }
361
-
362
- indexMap.feature++;
204
+ for (const feature of features) {
205
+ const geometry = feature.geometry;
206
+ const properties = feature.properties || {};
207
+
208
+ switch (geometry.type) {
209
+ case 'Point':
210
+ handlePoint(geometry.coordinates, points, indexMap, coordLength, properties);
211
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
212
+ indexMap.pointFeature++;
213
+ break;
214
+
215
+ case 'MultiPoint':
216
+ handleMultiPoint(geometry.coordinates, points, indexMap, coordLength, properties);
217
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
218
+ indexMap.pointFeature++;
219
+ break;
220
+
221
+ case 'LineString':
222
+ handleLineString(geometry.coordinates, lines, indexMap, coordLength, properties);
223
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
224
+ indexMap.lineFeature++;
225
+ break;
226
+
227
+ case 'MultiLineString':
228
+ handleMultiLineString(geometry.coordinates, lines, indexMap, coordLength, properties);
229
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
230
+ indexMap.lineFeature++;
231
+ break;
232
+
233
+ case 'Polygon':
234
+ handlePolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);
235
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
236
+ indexMap.polygonFeature++;
237
+ break;
238
+
239
+ case 'MultiPolygon':
240
+ handleMultiPolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);
241
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
242
+ indexMap.polygonFeature++;
243
+ break;
244
+
245
+ default:
246
+ throw new Error('Invalid geometry type');
363
247
  }
364
- } catch (err) {
365
- _iterator10.e(err);
366
- } finally {
367
- _iterator10.f();
248
+
249
+ indexMap.feature++;
368
250
  }
369
251
 
370
252
  return makeAccessorObjects(points, lines, polygons, coordLength);
@@ -379,18 +261,8 @@ function handlePoint(coords, points, indexMap, coordLength, properties) {
379
261
  }
380
262
 
381
263
  function handleMultiPoint(coords, points, indexMap, coordLength, properties) {
382
- var _iterator11 = _createForOfIteratorHelper(coords),
383
- _step11;
384
-
385
- try {
386
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
387
- var point = _step11.value;
388
- handlePoint(point, points, indexMap, coordLength, properties);
389
- }
390
- } catch (err) {
391
- _iterator11.e(err);
392
- } finally {
393
- _iterator11.f();
264
+ for (const point of coords) {
265
+ handlePoint(point, points, indexMap, coordLength, properties);
394
266
  }
395
267
  }
396
268
 
@@ -398,7 +270,7 @@ function handleLineString(coords, lines, indexMap, coordLength, properties) {
398
270
  lines.pathIndices[indexMap.linePath] = indexMap.linePosition;
399
271
  indexMap.linePath++;
400
272
  fillCoords(lines.positions, coords, indexMap.linePosition, coordLength);
401
- var nPositions = coords.length;
273
+ const nPositions = coords.length;
402
274
  fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
403
275
  lines.globalFeatureIds.set(new Uint32Array(nPositions).fill(indexMap.feature), indexMap.linePosition);
404
276
  lines.featureIds.set(new Uint32Array(nPositions).fill(indexMap.lineFeature), indexMap.linePosition);
@@ -406,18 +278,8 @@ function handleLineString(coords, lines, indexMap, coordLength, properties) {
406
278
  }
407
279
 
408
280
  function handleMultiLineString(coords, lines, indexMap, coordLength, properties) {
409
- var _iterator12 = _createForOfIteratorHelper(coords),
410
- _step12;
411
-
412
- try {
413
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
414
- var line = _step12.value;
415
- handleLineString(line, lines, indexMap, coordLength, properties);
416
- }
417
- } catch (err) {
418
- _iterator12.e(err);
419
- } finally {
420
- _iterator12.f();
281
+ for (const line of coords) {
282
+ handleLineString(line, lines, indexMap, coordLength, properties);
421
283
  }
422
284
  }
423
285
 
@@ -425,47 +287,27 @@ function handlePolygon(coords, polygons, indexMap, coordLength, properties) {
425
287
  polygons.polygonIndices[indexMap.polygonObject] = indexMap.polygonPosition;
426
288
  indexMap.polygonObject++;
427
289
 
428
- var _iterator13 = _createForOfIteratorHelper(coords),
429
- _step13;
430
-
431
- try {
432
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
433
- var ring = _step13.value;
434
- polygons.primitivePolygonIndices[indexMap.polygonRing] = indexMap.polygonPosition;
435
- indexMap.polygonRing++;
436
- fillCoords(polygons.positions, ring, indexMap.polygonPosition, coordLength);
437
- var nPositions = ring.length;
438
- fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
439
- polygons.globalFeatureIds.set(new Uint32Array(nPositions).fill(indexMap.feature), indexMap.polygonPosition);
440
- polygons.featureIds.set(new Uint32Array(nPositions).fill(indexMap.polygonFeature), indexMap.polygonPosition);
441
- indexMap.polygonPosition += nPositions;
442
- }
443
- } catch (err) {
444
- _iterator13.e(err);
445
- } finally {
446
- _iterator13.f();
290
+ for (const ring of coords) {
291
+ polygons.primitivePolygonIndices[indexMap.polygonRing] = indexMap.polygonPosition;
292
+ indexMap.polygonRing++;
293
+ fillCoords(polygons.positions, ring, indexMap.polygonPosition, coordLength);
294
+ const nPositions = ring.length;
295
+ fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
296
+ polygons.globalFeatureIds.set(new Uint32Array(nPositions).fill(indexMap.feature), indexMap.polygonPosition);
297
+ polygons.featureIds.set(new Uint32Array(nPositions).fill(indexMap.polygonFeature), indexMap.polygonPosition);
298
+ indexMap.polygonPosition += nPositions;
447
299
  }
448
300
  }
449
301
 
450
302
  function handleMultiPolygon(coords, polygons, indexMap, coordLength, properties) {
451
- var _iterator14 = _createForOfIteratorHelper(coords),
452
- _step14;
453
-
454
- try {
455
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
456
- var polygon = _step14.value;
457
- handlePolygon(polygon, polygons, indexMap, coordLength, properties);
458
- }
459
- } catch (err) {
460
- _iterator14.e(err);
461
- } finally {
462
- _iterator14.f();
303
+ for (const polygon of coords) {
304
+ handlePolygon(polygon, polygons, indexMap, coordLength, properties);
463
305
  }
464
306
  }
465
307
 
466
308
  function makeAccessorObjects(points, lines, polygons, coordLength) {
467
- var returnObj = {
468
- points: _objectSpread(_objectSpread({}, points), {}, {
309
+ const returnObj = {
310
+ points: { ...points,
469
311
  positions: {
470
312
  value: points.positions,
471
313
  size: coordLength
@@ -479,8 +321,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
479
321
  size: 1
480
322
  },
481
323
  type: 'Point'
482
- }),
483
- lines: _objectSpread(_objectSpread({}, lines), {}, {
324
+ },
325
+ lines: { ...lines,
484
326
  pathIndices: {
485
327
  value: lines.pathIndices,
486
328
  size: 1
@@ -498,8 +340,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
498
340
  size: 1
499
341
  },
500
342
  type: 'LineString'
501
- }),
502
- polygons: _objectSpread(_objectSpread({}, polygons), {}, {
343
+ },
344
+ polygons: { ...polygons,
503
345
  polygonIndices: {
504
346
  value: polygons.polygonIndices,
505
347
  size: 1
@@ -521,11 +363,11 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
521
363
  size: 1
522
364
  },
523
365
  type: 'Polygon'
524
- })
366
+ }
525
367
  };
526
368
 
527
- for (var geomType in returnObj) {
528
- for (var numericProp in returnObj[geomType].numericProps) {
369
+ for (const geomType in returnObj) {
370
+ for (const numericProp in returnObj[geomType].numericProps) {
529
371
  returnObj[geomType].numericProps[numericProp] = {
530
372
  value: returnObj[geomType].numericProps[numericProp],
531
373
  size: 1
@@ -537,7 +379,7 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
537
379
  }
538
380
 
539
381
  function fillNumericProperties(object, properties, index, length) {
540
- for (var numericPropName in object.numericProps) {
382
+ for (const numericPropName in object.numericProps) {
541
383
  if (numericPropName in properties) {
542
384
  object.numericProps[numericPropName].set(new Array(length).fill(properties[numericPropName]), index);
543
385
  }
@@ -545,9 +387,9 @@ function fillNumericProperties(object, properties, index, length) {
545
387
  }
546
388
 
547
389
  function keepStringProperties(properties, numericKeys) {
548
- var props = {};
390
+ const props = {};
549
391
 
550
- for (var key in properties) {
392
+ for (const key in properties) {
551
393
  if (!numericKeys.includes(key)) {
552
394
  props[key] = properties[key];
553
395
  }
@@ -557,28 +399,16 @@ function keepStringProperties(properties, numericKeys) {
557
399
  }
558
400
 
559
401
  function fillCoords(array, coords, startVertex, coordLength) {
560
- var index = startVertex * coordLength;
561
-
562
- var _iterator15 = _createForOfIteratorHelper(coords),
563
- _step15;
402
+ let index = startVertex * coordLength;
564
403
 
565
- try {
566
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
567
- var coord = _step15.value;
568
- array.set(coord, index);
569
- index += coordLength;
570
- }
571
- } catch (err) {
572
- _iterator15.e(err);
573
- } finally {
574
- _iterator15.f();
404
+ for (const coord of coords) {
405
+ array.set(coord, index);
406
+ index += coordLength;
575
407
  }
576
408
  }
577
409
 
578
410
  function flatten(arrays) {
579
- var _ref;
580
-
581
- return (_ref = []).concat.apply(_ref, (0, _toConsumableArray2.default)(arrays));
411
+ return [].concat(...arrays);
582
412
  }
583
413
 
584
414
  function isNumeric(x) {