@loaders.gl/gis 3.1.0-beta.3 → 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 +377 -200
- 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/dist/esm/lib/geojson-to-binary.js +13 -6
- package/dist/esm/lib/geojson-to-binary.js.map +1 -1
- package/dist/lib/geojson-to-binary.d.ts +4 -0
- package/dist/lib/geojson-to-binary.d.ts.map +1 -1
- package/dist/lib/geojson-to-binary.js +15 -11
- package/package.json +4 -4
- package/src/lib/geojson-to-binary.ts +19 -10
|
@@ -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,143 +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
|
-
|
|
82
|
-
case 'Polygon':
|
|
83
|
-
polygonFeaturesCount++;
|
|
84
|
-
polygonObjectsCount++;
|
|
85
|
-
polygonRingsCount += geometry.coordinates.length;
|
|
86
|
-
polygonPositionsCount += flatten(geometry.coordinates).length;
|
|
87
107
|
|
|
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(
|
|
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
|
|
133
233
|
};
|
|
134
234
|
}
|
|
135
235
|
|
|
136
236
|
function secondPass(features, firstPassData, options) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
|
|
154
|
-
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 = {
|
|
155
253
|
positions: new PositionDataType(pointPositionsCount * coordLength),
|
|
156
254
|
globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
|
|
157
255
|
featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
|
|
@@ -159,7 +257,7 @@ function secondPass(features, firstPassData, options) {
|
|
|
159
257
|
properties: Array(),
|
|
160
258
|
fields: Array()
|
|
161
259
|
};
|
|
162
|
-
|
|
260
|
+
var lines = {
|
|
163
261
|
positions: new PositionDataType(linePositionsCount * coordLength),
|
|
164
262
|
pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
|
|
165
263
|
globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
|
|
@@ -168,7 +266,7 @@ function secondPass(features, firstPassData, options) {
|
|
|
168
266
|
properties: Array(),
|
|
169
267
|
fields: Array()
|
|
170
268
|
};
|
|
171
|
-
|
|
269
|
+
var polygons = {
|
|
172
270
|
positions: new PositionDataType(polygonPositionsCount * coordLength),
|
|
173
271
|
polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
|
|
174
272
|
primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
|
|
@@ -179,16 +277,29 @@ function secondPass(features, firstPassData, options) {
|
|
|
179
277
|
fields: Array()
|
|
180
278
|
};
|
|
181
279
|
|
|
182
|
-
for (
|
|
183
|
-
|
|
184
|
-
|
|
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();
|
|
185
296
|
}
|
|
186
297
|
}
|
|
187
298
|
|
|
188
299
|
lines.pathIndices[linePathsCount] = linePositionsCount;
|
|
189
300
|
polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
|
|
190
301
|
polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
|
|
191
|
-
|
|
302
|
+
var indexMap = {
|
|
192
303
|
pointPosition: 0,
|
|
193
304
|
pointFeature: 0,
|
|
194
305
|
linePosition: 0,
|
|
@@ -201,52 +312,62 @@ function secondPass(features, firstPassData, options) {
|
|
|
201
312
|
feature: 0
|
|
202
313
|
};
|
|
203
314
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
248
364
|
|
|
249
|
-
|
|
365
|
+
indexMap.feature++;
|
|
366
|
+
}
|
|
367
|
+
} catch (err) {
|
|
368
|
+
_iterator10.e(err);
|
|
369
|
+
} finally {
|
|
370
|
+
_iterator10.f();
|
|
250
371
|
}
|
|
251
372
|
|
|
252
373
|
return makeAccessorObjects(points, lines, polygons, coordLength);
|
|
@@ -261,8 +382,18 @@ function handlePoint(coords, points, indexMap, coordLength, properties) {
|
|
|
261
382
|
}
|
|
262
383
|
|
|
263
384
|
function handleMultiPoint(coords, points, indexMap, coordLength, properties) {
|
|
264
|
-
|
|
265
|
-
|
|
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();
|
|
266
397
|
}
|
|
267
398
|
}
|
|
268
399
|
|
|
@@ -270,7 +401,7 @@ function handleLineString(coords, lines, indexMap, coordLength, properties) {
|
|
|
270
401
|
lines.pathIndices[indexMap.linePath] = indexMap.linePosition;
|
|
271
402
|
indexMap.linePath++;
|
|
272
403
|
fillCoords(lines.positions, coords, indexMap.linePosition, coordLength);
|
|
273
|
-
|
|
404
|
+
var nPositions = coords.length;
|
|
274
405
|
fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
|
|
275
406
|
lines.globalFeatureIds.set(new Uint32Array(nPositions).fill(indexMap.feature), indexMap.linePosition);
|
|
276
407
|
lines.featureIds.set(new Uint32Array(nPositions).fill(indexMap.lineFeature), indexMap.linePosition);
|
|
@@ -278,8 +409,18 @@ function handleLineString(coords, lines, indexMap, coordLength, properties) {
|
|
|
278
409
|
}
|
|
279
410
|
|
|
280
411
|
function handleMultiLineString(coords, lines, indexMap, coordLength, properties) {
|
|
281
|
-
|
|
282
|
-
|
|
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();
|
|
283
424
|
}
|
|
284
425
|
}
|
|
285
426
|
|
|
@@ -287,27 +428,47 @@ function handlePolygon(coords, polygons, indexMap, coordLength, properties) {
|
|
|
287
428
|
polygons.polygonIndices[indexMap.polygonObject] = indexMap.polygonPosition;
|
|
288
429
|
indexMap.polygonObject++;
|
|
289
430
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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();
|
|
299
450
|
}
|
|
300
451
|
}
|
|
301
452
|
|
|
302
453
|
function handleMultiPolygon(coords, polygons, indexMap, coordLength, properties) {
|
|
303
|
-
|
|
304
|
-
|
|
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();
|
|
305
466
|
}
|
|
306
467
|
}
|
|
307
468
|
|
|
308
469
|
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
309
|
-
|
|
310
|
-
points: {
|
|
470
|
+
var returnObj = {
|
|
471
|
+
points: _objectSpread(_objectSpread({}, points), {}, {
|
|
311
472
|
positions: {
|
|
312
473
|
value: points.positions,
|
|
313
474
|
size: coordLength
|
|
@@ -321,8 +482,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
|
321
482
|
size: 1
|
|
322
483
|
},
|
|
323
484
|
type: 'Point'
|
|
324
|
-
},
|
|
325
|
-
lines: {
|
|
485
|
+
}),
|
|
486
|
+
lines: _objectSpread(_objectSpread({}, lines), {}, {
|
|
326
487
|
pathIndices: {
|
|
327
488
|
value: lines.pathIndices,
|
|
328
489
|
size: 1
|
|
@@ -340,8 +501,8 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
|
340
501
|
size: 1
|
|
341
502
|
},
|
|
342
503
|
type: 'LineString'
|
|
343
|
-
},
|
|
344
|
-
polygons: {
|
|
504
|
+
}),
|
|
505
|
+
polygons: _objectSpread(_objectSpread({}, polygons), {}, {
|
|
345
506
|
polygonIndices: {
|
|
346
507
|
value: polygons.polygonIndices,
|
|
347
508
|
size: 1
|
|
@@ -363,11 +524,11 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
|
363
524
|
size: 1
|
|
364
525
|
},
|
|
365
526
|
type: 'Polygon'
|
|
366
|
-
}
|
|
527
|
+
})
|
|
367
528
|
};
|
|
368
529
|
|
|
369
|
-
for (
|
|
370
|
-
for (
|
|
530
|
+
for (var geomType in returnObj) {
|
|
531
|
+
for (var numericProp in returnObj[geomType].numericProps) {
|
|
371
532
|
returnObj[geomType].numericProps[numericProp] = {
|
|
372
533
|
value: returnObj[geomType].numericProps[numericProp],
|
|
373
534
|
size: 1
|
|
@@ -379,7 +540,7 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
|
379
540
|
}
|
|
380
541
|
|
|
381
542
|
function fillNumericProperties(object, properties, index, length) {
|
|
382
|
-
for (
|
|
543
|
+
for (var numericPropName in object.numericProps) {
|
|
383
544
|
if (numericPropName in properties) {
|
|
384
545
|
object.numericProps[numericPropName].set(new Array(length).fill(properties[numericPropName]), index);
|
|
385
546
|
}
|
|
@@ -387,11 +548,11 @@ function fillNumericProperties(object, properties, index, length) {
|
|
|
387
548
|
}
|
|
388
549
|
|
|
389
550
|
function keepStringProperties(properties, numericKeys) {
|
|
390
|
-
|
|
551
|
+
var props = {};
|
|
391
552
|
|
|
392
|
-
for (
|
|
393
|
-
if (!numericKeys.includes(
|
|
394
|
-
props[
|
|
553
|
+
for (var _key2 in properties) {
|
|
554
|
+
if (!numericKeys.includes(_key2)) {
|
|
555
|
+
props[_key2] = properties[_key2];
|
|
395
556
|
}
|
|
396
557
|
}
|
|
397
558
|
|
|
@@ -399,19 +560,35 @@ function keepStringProperties(properties, numericKeys) {
|
|
|
399
560
|
}
|
|
400
561
|
|
|
401
562
|
function fillCoords(array, coords, startVertex, coordLength) {
|
|
402
|
-
|
|
563
|
+
var index = startVertex * coordLength;
|
|
403
564
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
565
|
+
var _iterator15 = _createForOfIteratorHelper(coords),
|
|
566
|
+
_step15;
|
|
567
|
+
|
|
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();
|
|
407
578
|
}
|
|
408
579
|
}
|
|
409
580
|
|
|
410
581
|
function flatten(arrays) {
|
|
411
|
-
|
|
582
|
+
var _ref;
|
|
583
|
+
|
|
584
|
+
return (_ref = []).concat.apply(_ref, (0, _toConsumableArray2.default)(arrays));
|
|
412
585
|
}
|
|
413
586
|
|
|
414
|
-
function
|
|
415
|
-
|
|
587
|
+
function deduceArrayType(x, constructor) {
|
|
588
|
+
if (constructor === Array || !Number.isFinite(x)) {
|
|
589
|
+
return Array;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
|
|
416
593
|
}
|
|
417
594
|
//# sourceMappingURL=geojson-to-binary.js.map
|