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