@loaders.gl/i3s 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/bundle.js +126 -139
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +147 -62
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +36 -8
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +36 -10
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +175 -51
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +51 -8
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/index.js +6 -6
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +328 -173
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +9 -28
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +69 -27
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +62 -28
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +416 -314
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +109 -49
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +8 -4
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/es5/lib/utils/url-utils.js +14 -17
- package/dist/es5/lib/utils/url-utils.js.map +1 -1
- package/dist/es5/types.js +10 -2
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +1 -1
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/i3s-node-page-loader.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +33 -23
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/constants.js +2 -18
- package/dist/esm/lib/parsers/constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +44 -61
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +40 -25
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/lib/utils/url-utils.js +2 -3
- package/dist/esm/lib/utils/url-utils.js.map +1 -1
- package/dist/esm/types.js +7 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-content-worker.js +62 -81
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +20 -20
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.js +33 -32
- package/dist/lib/parsers/constants.d.ts +1 -17
- package/dist/lib/parsers/constants.d.ts.map +1 -1
- package/dist/lib/parsers/constants.js +3 -21
- package/dist/lib/parsers/parse-i3s-attribute.d.ts +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts +2 -2
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +35 -61
- package/dist/lib/parsers/parse-i3s.d.ts +5 -3
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s.js +37 -32
- package/dist/lib/utils/url-utils.d.ts +6 -6
- package/dist/lib/utils/url-utils.d.ts.map +1 -1
- package/dist/lib/utils/url-utils.js +5 -5
- package/dist/types.d.ts +289 -74
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/package.json +8 -8
- package/src/index.ts +3 -3
- package/src/lib/helpers/i3s-nodepages-tiles.ts +71 -55
- package/src/lib/parsers/constants.ts +2 -22
- package/src/lib/parsers/parse-i3s-tile-content.ts +74 -103
- package/src/lib/parsers/parse-i3s.ts +48 -37
- package/src/lib/utils/url-utils.ts +7 -7
- package/src/types.ts +302 -93
|
@@ -1,87 +1,164 @@
|
|
|
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.loadFeatureAttributes = loadFeatureAttributes;
|
|
7
9
|
exports.I3SAttributeLoader = void 0;
|
|
8
10
|
|
|
11
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
+
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
+
|
|
15
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
|
+
|
|
9
17
|
var _core = require("@loaders.gl/core");
|
|
10
18
|
|
|
11
19
|
var _parseI3sAttribute = require("./lib/parsers/parse-i3s-attribute");
|
|
12
20
|
|
|
13
21
|
var _urlUtils = require("./lib/utils/url-utils");
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
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; }
|
|
24
|
+
|
|
25
|
+
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; }
|
|
26
|
+
|
|
27
|
+
var VERSION = typeof "3.1.0" !== 'undefined' ? "3.1.0" : 'latest';
|
|
28
|
+
var EMPTY_VALUE = '';
|
|
29
|
+
var REJECTED_STATUS = 'rejected';
|
|
30
|
+
var I3SAttributeLoader = {
|
|
19
31
|
name: 'I3S Attribute',
|
|
20
32
|
id: 'i3s-attribute',
|
|
21
33
|
module: 'i3s',
|
|
22
34
|
version: VERSION,
|
|
23
35
|
mimeTypes: ['application/binary'],
|
|
24
|
-
parse,
|
|
36
|
+
parse: parse,
|
|
25
37
|
extensions: ['bin'],
|
|
26
38
|
options: {},
|
|
27
39
|
binary: true
|
|
28
40
|
};
|
|
29
41
|
exports.I3SAttributeLoader = I3SAttributeLoader;
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return data;
|
|
43
|
+
function parse(_x, _x2) {
|
|
44
|
+
return _parse.apply(this, arguments);
|
|
34
45
|
}
|
|
35
46
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const attributeName = attributeStorageInfo[index].name;
|
|
55
|
-
const attributeType = getAttributeValueType(attributeStorageInfo[index]);
|
|
56
|
-
const loadOptions = { ...options,
|
|
57
|
-
attributeName,
|
|
58
|
-
attributeType
|
|
59
|
-
};
|
|
60
|
-
const promise = (0, _core.load)(url, I3SAttributeLoader, loadOptions);
|
|
61
|
-
attributeLoadPromises.push(promise);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
attributes = await Promise.allSettled(attributeLoadPromises);
|
|
66
|
-
} catch (error) {}
|
|
47
|
+
function _parse() {
|
|
48
|
+
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data, options) {
|
|
49
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
50
|
+
while (1) {
|
|
51
|
+
switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
data = (0, _parseI3sAttribute.parseI3STileAttribute)(data, options);
|
|
54
|
+
return _context.abrupt("return", data);
|
|
55
|
+
|
|
56
|
+
case 2:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, _callee);
|
|
62
|
+
}));
|
|
63
|
+
return _parse.apply(this, arguments);
|
|
64
|
+
}
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
function loadFeatureAttributes(_x3, _x4) {
|
|
67
|
+
return _loadFeatureAttributes.apply(this, arguments);
|
|
68
|
+
}
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
function _loadFeatureAttributes() {
|
|
71
|
+
_loadFeatureAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(tile, featureId) {
|
|
72
|
+
var options,
|
|
73
|
+
_getAttributesData,
|
|
74
|
+
attributeStorageInfo,
|
|
75
|
+
attributeUrls,
|
|
76
|
+
tilesetFields,
|
|
77
|
+
attributes,
|
|
78
|
+
attributeLoadPromises,
|
|
79
|
+
index,
|
|
80
|
+
_options$i3s,
|
|
81
|
+
url,
|
|
82
|
+
attributeName,
|
|
83
|
+
attributeType,
|
|
84
|
+
loadOptions,
|
|
85
|
+
promise,
|
|
86
|
+
_args2 = arguments;
|
|
87
|
+
|
|
88
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
89
|
+
while (1) {
|
|
90
|
+
switch (_context2.prev = _context2.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
93
|
+
_getAttributesData = getAttributesData(tile), attributeStorageInfo = _getAttributesData.attributeStorageInfo, attributeUrls = _getAttributesData.attributeUrls, tilesetFields = _getAttributesData.tilesetFields;
|
|
94
|
+
|
|
95
|
+
if (!(!attributeStorageInfo || !attributeUrls || !featureId)) {
|
|
96
|
+
_context2.next = 4;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return _context2.abrupt("return", null);
|
|
101
|
+
|
|
102
|
+
case 4:
|
|
103
|
+
attributes = [];
|
|
104
|
+
attributeLoadPromises = [];
|
|
105
|
+
|
|
106
|
+
for (index = 0; index < attributeStorageInfo.length; index++) {
|
|
107
|
+
url = (0, _urlUtils.getUrlWithToken)(attributeUrls[index], (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
108
|
+
attributeName = attributeStorageInfo[index].name;
|
|
109
|
+
attributeType = getAttributeValueType(attributeStorageInfo[index]);
|
|
110
|
+
loadOptions = _objectSpread(_objectSpread({}, options), {}, {
|
|
111
|
+
attributeName: attributeName,
|
|
112
|
+
attributeType: attributeType
|
|
113
|
+
});
|
|
114
|
+
promise = (0, _core.load)(url, I3SAttributeLoader, loadOptions);
|
|
115
|
+
attributeLoadPromises.push(promise);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
_context2.prev = 7;
|
|
119
|
+
_context2.next = 10;
|
|
120
|
+
return Promise.allSettled(attributeLoadPromises);
|
|
121
|
+
|
|
122
|
+
case 10:
|
|
123
|
+
attributes = _context2.sent;
|
|
124
|
+
_context2.next = 15;
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 13:
|
|
128
|
+
_context2.prev = 13;
|
|
129
|
+
_context2.t0 = _context2["catch"](7);
|
|
130
|
+
|
|
131
|
+
case 15:
|
|
132
|
+
if (attributes.length) {
|
|
133
|
+
_context2.next = 17;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return _context2.abrupt("return", null);
|
|
138
|
+
|
|
139
|
+
case 17:
|
|
140
|
+
return _context2.abrupt("return", generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields));
|
|
141
|
+
|
|
142
|
+
case 18:
|
|
143
|
+
case "end":
|
|
144
|
+
return _context2.stop();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, _callee2, null, [[7, 13]]);
|
|
148
|
+
}));
|
|
149
|
+
return _loadFeatureAttributes.apply(this, arguments);
|
|
73
150
|
}
|
|
74
151
|
|
|
75
152
|
function getAttributesData(tile) {
|
|
76
153
|
var _tile$tileset, _tile$tileset$tileset, _tile$header, _tile$tileset2, _tile$tileset2$tilese;
|
|
77
154
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
155
|
+
var attributeStorageInfo = (_tile$tileset = tile.tileset) === null || _tile$tileset === void 0 ? void 0 : (_tile$tileset$tileset = _tile$tileset.tileset) === null || _tile$tileset$tileset === void 0 ? void 0 : _tile$tileset$tileset.attributeStorageInfo;
|
|
156
|
+
var attributeUrls = (_tile$header = tile.header) === null || _tile$header === void 0 ? void 0 : _tile$header.attributeUrls;
|
|
157
|
+
var tilesetFields = ((_tile$tileset2 = tile.tileset) === null || _tile$tileset2 === void 0 ? void 0 : (_tile$tileset2$tilese = _tile$tileset2.tileset) === null || _tile$tileset2$tilese === void 0 ? void 0 : _tile$tileset2$tilese.fields) || [];
|
|
81
158
|
return {
|
|
82
|
-
attributeStorageInfo,
|
|
83
|
-
attributeUrls,
|
|
84
|
-
tilesetFields
|
|
159
|
+
attributeStorageInfo: attributeStorageInfo,
|
|
160
|
+
attributeUrls: attributeUrls,
|
|
161
|
+
tilesetFields: tilesetFields
|
|
85
162
|
};
|
|
86
163
|
}
|
|
87
164
|
|
|
@@ -96,19 +173,23 @@ function getAttributeValueType(attribute) {
|
|
|
96
173
|
}
|
|
97
174
|
|
|
98
175
|
function getFeatureIdsAttributeName(attributeStorageInfo) {
|
|
99
|
-
|
|
176
|
+
var objectIdsAttribute = attributeStorageInfo.find(function (attribute) {
|
|
177
|
+
return attribute.name.includes('OBJECTID');
|
|
178
|
+
});
|
|
100
179
|
return objectIdsAttribute === null || objectIdsAttribute === void 0 ? void 0 : objectIdsAttribute.name;
|
|
101
180
|
}
|
|
102
181
|
|
|
103
182
|
function generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields) {
|
|
104
|
-
|
|
105
|
-
|
|
183
|
+
var objectIdsAttributeName = getFeatureIdsAttributeName(attributeStorageInfo);
|
|
184
|
+
var objectIds = attributes.find(function (attribute) {
|
|
185
|
+
return attribute.value[objectIdsAttributeName];
|
|
186
|
+
});
|
|
106
187
|
|
|
107
188
|
if (!objectIds) {
|
|
108
189
|
return null;
|
|
109
190
|
}
|
|
110
191
|
|
|
111
|
-
|
|
192
|
+
var attributeIndex = objectIds.value[objectIdsAttributeName].indexOf(featureId);
|
|
112
193
|
|
|
113
194
|
if (attributeIndex < 0) {
|
|
114
195
|
return null;
|
|
@@ -118,12 +199,12 @@ function generateAttributesByFeatureId(attributes, attributeStorageInfo, feature
|
|
|
118
199
|
}
|
|
119
200
|
|
|
120
201
|
function getFeatureAttributesByIndex(attributes, featureIdIndex, attributeStorageInfo, tilesetFields) {
|
|
121
|
-
|
|
202
|
+
var attributesObject = {};
|
|
122
203
|
|
|
123
|
-
for (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
204
|
+
for (var index = 0; index < attributeStorageInfo.length; index++) {
|
|
205
|
+
var attributeName = attributeStorageInfo[index].name;
|
|
206
|
+
var codedValues = getAttributeCodedValues(attributeName, tilesetFields);
|
|
207
|
+
var attribute = getAttributeByIndexAndAttributeName(attributes, index, attributeName);
|
|
127
208
|
attributesObject[attributeName] = formatAttributeValue(attribute, featureIdIndex, codedValues);
|
|
128
209
|
}
|
|
129
210
|
|
|
@@ -133,12 +214,14 @@ function getFeatureAttributesByIndex(attributes, featureIdIndex, attributeStorag
|
|
|
133
214
|
function getAttributeCodedValues(attributeName, tilesetFields) {
|
|
134
215
|
var _attributeField$domai;
|
|
135
216
|
|
|
136
|
-
|
|
217
|
+
var attributeField = tilesetFields.find(function (field) {
|
|
218
|
+
return field.name === attributeName || field.alias === attributeName;
|
|
219
|
+
});
|
|
137
220
|
return (attributeField === null || attributeField === void 0 ? void 0 : (_attributeField$domai = attributeField.domain) === null || _attributeField$domai === void 0 ? void 0 : _attributeField$domai.codedValues) || [];
|
|
138
221
|
}
|
|
139
222
|
|
|
140
223
|
function getAttributeByIndexAndAttributeName(attributes, index, attributesName) {
|
|
141
|
-
|
|
224
|
+
var attributeObject = attributes[index];
|
|
142
225
|
|
|
143
226
|
if (attributeObject.status === REJECTED_STATUS) {
|
|
144
227
|
return null;
|
|
@@ -148,14 +231,16 @@ function getAttributeByIndexAndAttributeName(attributes, index, attributesName)
|
|
|
148
231
|
}
|
|
149
232
|
|
|
150
233
|
function formatAttributeValue(attribute, featureIdIndex, codedValues) {
|
|
151
|
-
|
|
234
|
+
var value = EMPTY_VALUE;
|
|
152
235
|
|
|
153
236
|
if (attribute && featureIdIndex in attribute) {
|
|
154
237
|
value = String(attribute[featureIdIndex]).replace(/\u0000|NaN/g, '').trim();
|
|
155
238
|
}
|
|
156
239
|
|
|
157
240
|
if (codedValues.length) {
|
|
158
|
-
|
|
241
|
+
var codeValue = codedValues.find(function (codedValue) {
|
|
242
|
+
return codedValue.code === Number(value);
|
|
243
|
+
});
|
|
159
244
|
value = (codeValue === null || codeValue === void 0 ? void 0 : codeValue.name) || EMPTY_VALUE;
|
|
160
245
|
}
|
|
161
246
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i3s-attribute-loader.ts"],"names":["VERSION","EMPTY_VALUE","REJECTED_STATUS","I3SAttributeLoader","name","id","module","version","mimeTypes","parse","extensions","options","binary","data","loadFeatureAttributes","tile","featureId","attributeStorageInfo","attributeUrls","tilesetFields","getAttributesData","attributes","attributeLoadPromises","index","length","url","i3s","token","attributeName","attributeType","getAttributeValueType","loadOptions","promise","push","Promise","allSettled","error","generateAttributesByFeatureId","tileset","header","fields","attribute","hasOwnProperty","attributeValues","valueType","getFeatureIdsAttributeName","objectIdsAttribute","find","includes","objectIdsAttributeName","objectIds","value","attributeIndex","indexOf","getFeatureAttributesByIndex","featureIdIndex","attributesObject","codedValues","getAttributeCodedValues","getAttributeByIndexAndAttributeName","formatAttributeValue","attributeField","field","alias","domain","attributesName","attributeObject","status","String","replace","trim","codeValue","codedValue","code","Number"],"mappings":";;;;;;;;AACA;;AACA;;AACA;;AAIA,MAAMA,OAAO,GAAG,0BAAuB,WAAvB,oBAAmD,QAAnE;AACA,MAAMC,WAAW,GAAG,EAApB;AACA,MAAMC,eAAe,GAAG,UAAxB;AAIO,MAAMC,kBAAoC,GAAG;AAClDC,EAAAA,IAAI,EAAE,eAD4C;AAElDC,EAAAA,EAAE,EAAE,eAF8C;AAGlDC,EAAAA,MAAM,EAAE,KAH0C;AAIlDC,EAAAA,OAAO,EAAEP,OAJyC;AAKlDQ,EAAAA,SAAS,EAAE,CAAC,oBAAD,CALuC;AAMlDC,EAAAA,KANkD;AAOlDC,EAAAA,UAAU,EAAE,CAAC,KAAD,CAPsC;AAQlDC,EAAAA,OAAO,EAAE,EARyC;AASlDC,EAAAA,MAAM,EAAE;AAT0C,C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AAN,KAAewB,aAAf,IAAgCkC,KAAK,CAACC,KAAN,KAAgBnC,aAD1C,CAAvB;AAGA,SAAO,CAAAiC,cAAc,SAAd,IAAAA,cAAc,WAAd,qCAAAA,cAAc,CAAEG,MAAhB,gFAAwBP,WAAxB,KAAuC,EAA9C;AACD;;AAQD,SAASE,mCAAT,CAA6CtC,UAA7C,EAAyDE,KAAzD,EAAgE0C,cAAhE,EAAgF;AAC9E,QAAMC,eAAe,GAAG7C,UAAU,CAACE,KAAD,CAAlC;;AAEA,MAAI2C,eAAe,CAACC,MAAhB,KAA2BjE,eAA/B,EAAgD;AAC9C,WAAO,IAAP;AACD;;AAED,SAAOgE,eAAe,CAACf,KAAhB,CAAsBc,cAAtB,CAAP;AACD;;AAQD,SAASL,oBAAT,CAA8BnB,SAA9B,EAAyCc,cAAzC,EAAyDE,WAAzD,EAAsE;AACpE,MAAIN,KAAK,GAAGlD,WAAZ;;AAEA,MAAIwC,SAAS,IAAKc,cAAc,IAAId,SAApC,EAAgD;AAE9CU,IAAAA,KAAK,GAAGiB,MAAM,CAAC3B,SAAS,CAACc,cAAD,CAAV,CAAN,CAAkCc,OAAlC,CAA0C,aAA1C,EAAyD,EAAzD,EAA6DC,IAA7D,EAAR;AACD;;AAGD,MAAIb,WAAW,CAACjC,MAAhB,EAAwB;AACtB,UAAM+C,SAAS,GAAGd,WAAW,CAACV,IAAZ,CAAiByB,UAAU,IAAIA,UAAU,CAACC,IAAX,KAAoBC,MAAM,CAACvB,KAAD,CAAzD,CAAlB;AACAA,IAAAA,KAAK,GAAG,CAAAoB,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEnE,IAAX,KAAmBH,WAA3B;AACD;;AAED,SAAOkD,KAAP;AACD","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {load} from '@loaders.gl/core';\nimport {parseI3STileAttribute} from './lib/parsers/parse-i3s-attribute';\nimport {getUrlWithToken} from './lib/utils/url-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\nconst EMPTY_VALUE = '';\nconst REJECTED_STATUS = 'rejected';\n/**\n * Loader for I3S attributes\n */\nexport const I3SAttributeLoader: LoaderWithParser = {\n name: 'I3S Attribute',\n id: 'i3s-attribute',\n module: 'i3s',\n version: VERSION,\n mimeTypes: ['application/binary'],\n parse,\n extensions: ['bin'],\n options: {},\n binary: true\n};\n\nasync function parse(data, options) {\n data = parseI3STileAttribute(data, options);\n return data;\n}\n\n/**\n * Load attributes based on feature id\n * @param {Object} tile\n * @param {number} featureId\n * @param {Object} options\n * @returns {Promise}\n */\n// eslint-disable-next-line complexity\nexport async function loadFeatureAttributes(tile, featureId, options = {}) {\n const {attributeStorageInfo, attributeUrls, tilesetFields} = getAttributesData(tile);\n\n if (!attributeStorageInfo || !attributeUrls || !featureId) {\n return null;\n }\n\n let attributes: object[] = [];\n const attributeLoadPromises: Promise<object>[] = [];\n\n for (let index = 0; index < attributeStorageInfo.length; index++) {\n // @ts-ignore\n const url = getUrlWithToken(attributeUrls[index], options.i3s?.token);\n const attributeName = attributeStorageInfo[index].name;\n const attributeType = getAttributeValueType(attributeStorageInfo[index]);\n const loadOptions = {...options, attributeName, attributeType};\n const promise = load(url, I3SAttributeLoader, loadOptions);\n\n attributeLoadPromises.push(promise);\n }\n try {\n attributes = await Promise.allSettled(attributeLoadPromises);\n } catch (error) {\n // do nothing\n }\n\n if (!attributes.length) {\n return null;\n }\n\n return generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields);\n}\n\n/**\n * Gets attributes data from tile.\n * @param tile \n * @returns \n */\nfunction getAttributesData(tile) {\n const attributeStorageInfo = tile.tileset?.tileset?.attributeStorageInfo;\n const attributeUrls = tile.header?.attributeUrls;\n const tilesetFields = tile.tileset?.tileset?.fields || [];\n\n return {attributeStorageInfo, attributeUrls, tilesetFields};\n}\n\n/**\n * Get attribute value type based on property names\n * @param {Object} attribute\n * @returns {String}\n */\nfunction getAttributeValueType(attribute) {\n if (attribute.hasOwnProperty('objectIds')) {\n return 'Oid32';\n } else if (attribute.hasOwnProperty('attributeValues')) {\n return attribute.attributeValues.valueType;\n }\n return '';\n}\n\n/**\n * Find in attributeStorageInfo attribute name responsible for feature ids list.\n * @param attributeStorageInfo \n * @returns Feature ids attribute name\n */\nfunction getFeatureIdsAttributeName(attributeStorageInfo) {\n const objectIdsAttribute = attributeStorageInfo.find(attribute => attribute.name.includes('OBJECTID'));\n\n return objectIdsAttribute?.name;\n}\n\n/**\n * Generates mapping featureId to feature attributes\n * @param {Array} attributes\n * @param {Object} attributeStorageInfo\n * @param {number} featureId\n * @returns {Object}\n */\nfunction generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields) {\n const objectIdsAttributeName = getFeatureIdsAttributeName(attributeStorageInfo);\n const objectIds = attributes.find((attribute) => attribute.value[objectIdsAttributeName]);\n\n if (!objectIds) {\n return null;\n }\n\n const attributeIndex = objectIds.value[objectIdsAttributeName].indexOf(featureId);\n\n if (attributeIndex < 0) {\n return null;\n }\n\n return getFeatureAttributesByIndex(attributes, attributeIndex, attributeStorageInfo, tilesetFields);\n}\n\n/**\n * Generates attribute object for feature mapping by feature id\n * @param {Array} attributes\n * @param {Number} featureIdIndex\n * @param {Object} attributeStorageInfo\n * @returns {Object}\n */\nfunction getFeatureAttributesByIndex(attributes, featureIdIndex, attributeStorageInfo, tilesetFields) {\n const attributesObject = {};\n\n for (let index = 0; index < attributeStorageInfo.length; index++) {\n const attributeName = attributeStorageInfo[index].name;\n const codedValues = getAttributeCodedValues(attributeName, tilesetFields);\n const attribute = getAttributeByIndexAndAttributeName(attributes, index, attributeName);\n attributesObject[attributeName] = formatAttributeValue(attribute, featureIdIndex, codedValues);\n }\n\n return attributesObject;\n}\n\n/**\n * Get coded values list from tileset.\n * @param attributeName \n * @param tilesetFields \n */\nfunction getAttributeCodedValues(attributeName, tilesetFields) {\n const attributeField = tilesetFields\n .find(field => field.name === attributeName || field.alias === attributeName);\n\n return attributeField?.domain?.codedValues || [];\n}\n\n/**\n * Return attribute value if it presents in atrributes list\n * @param {array} attributes\n * @param {number} index\n * @param {string} attributesName\n */\nfunction getAttributeByIndexAndAttributeName(attributes, index, attributesName) {\n const attributeObject = attributes[index];\n\n if (attributeObject.status === REJECTED_STATUS) {\n return null;\n }\n\n return attributeObject.value[attributesName];\n}\n\n/**\n * Do formatting of attribute values or return empty string.\n * @param {Array} attribute\n * @param {Number} featureIdIndex\n * @returns {String}\n */\nfunction formatAttributeValue(attribute, featureIdIndex, codedValues) {\n let value = EMPTY_VALUE;\n\n if (attribute && (featureIdIndex in attribute)) {\n // eslint-disable-next-line no-control-regex\n value = String(attribute[featureIdIndex]).replace(/\\u0000|NaN/g, '').trim();\n }\n\n // Check if coded values are existed. If so we use them.\n if (codedValues.length) {\n const codeValue = codedValues.find(codedValue => codedValue.code === Number(value));\n value = codeValue?.name || EMPTY_VALUE;\n }\n\n return value;\n}\n"],"file":"i3s-attribute-loader.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/i3s-attribute-loader.ts"],"names":["VERSION","EMPTY_VALUE","REJECTED_STATUS","I3SAttributeLoader","name","id","module","version","mimeTypes","parse","extensions","options","binary","data","loadFeatureAttributes","tile","featureId","getAttributesData","attributeStorageInfo","attributeUrls","tilesetFields","attributes","attributeLoadPromises","index","length","url","i3s","token","attributeName","attributeType","getAttributeValueType","loadOptions","promise","push","Promise","allSettled","generateAttributesByFeatureId","tileset","header","fields","attribute","hasOwnProperty","attributeValues","valueType","getFeatureIdsAttributeName","objectIdsAttribute","find","includes","objectIdsAttributeName","objectIds","value","attributeIndex","indexOf","getFeatureAttributesByIndex","featureIdIndex","attributesObject","codedValues","getAttributeCodedValues","getAttributeByIndexAndAttributeName","formatAttributeValue","attributeField","field","alias","domain","attributesName","attributeObject","status","String","replace","trim","codeValue","codedValue","code","Number"],"mappings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GAAG5C,UAAU,CAACE,KAAD,CAAlC;;AAEA,MAAI0C,eAAe,CAACC,MAAhB,KAA2BhE,eAA/B,EAAgD;AAC9C,WAAO,IAAP;AACD;;AAED,SAAO+D,eAAe,CAACf,KAAhB,CAAsBc,cAAtB,CAAP;AACD;;AAQD,SAASL,oBAAT,CAA8BnB,SAA9B,EAAyCc,cAAzC,EAAyDE,WAAzD,EAAsE;AACpE,MAAIN,KAAK,GAAGjD,WAAZ;;AAEA,MAAIuC,SAAS,IAAKc,cAAc,IAAId,SAApC,EAAgD;AAE9CU,IAAAA,KAAK,GAAGiB,MAAM,CAAC3B,SAAS,CAACc,cAAD,CAAV,CAAN,CAAkCc,OAAlC,CAA0C,aAA1C,EAAyD,EAAzD,EAA6DC,IAA7D,EAAR;AACD;;AAGD,MAAIb,WAAW,CAAChC,MAAhB,EAAwB;AACtB,QAAM8C,SAAS,GAAGd,WAAW,CAACV,IAAZ,CAAiB,UAAAyB,UAAU;AAAA,aAAIA,UAAU,CAACC,IAAX,KAAoBC,MAAM,CAACvB,KAAD,CAA9B;AAAA,KAA3B,CAAlB;AACAA,IAAAA,KAAK,GAAG,CAAAoB,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAElE,IAAX,KAAmBH,WAA3B;AACD;;AAED,SAAOiD,KAAP;AACD","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {load} from '@loaders.gl/core';\nimport {parseI3STileAttribute} from './lib/parsers/parse-i3s-attribute';\nimport {getUrlWithToken} from './lib/utils/url-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\nconst EMPTY_VALUE = '';\nconst REJECTED_STATUS = 'rejected';\n/**\n * Loader for I3S attributes\n */\nexport const I3SAttributeLoader: LoaderWithParser = {\n name: 'I3S Attribute',\n id: 'i3s-attribute',\n module: 'i3s',\n version: VERSION,\n mimeTypes: ['application/binary'],\n parse,\n extensions: ['bin'],\n options: {},\n binary: true\n};\n\nasync function parse(data, options) {\n data = parseI3STileAttribute(data, options);\n return data;\n}\n\n/**\n * Load attributes based on feature id\n * @param {Object} tile\n * @param {number} featureId\n * @param {Object} options\n * @returns {Promise}\n */\n// eslint-disable-next-line complexity\nexport async function loadFeatureAttributes(tile, featureId, options = {}) {\n const {attributeStorageInfo, attributeUrls, tilesetFields} = getAttributesData(tile);\n\n if (!attributeStorageInfo || !attributeUrls || !featureId) {\n return null;\n }\n\n let attributes: object[] = [];\n const attributeLoadPromises: Promise<object>[] = [];\n\n for (let index = 0; index < attributeStorageInfo.length; index++) {\n // @ts-ignore\n const url = getUrlWithToken(attributeUrls[index], options.i3s?.token);\n const attributeName = attributeStorageInfo[index].name;\n const attributeType = getAttributeValueType(attributeStorageInfo[index]);\n const loadOptions = {...options, attributeName, attributeType};\n const promise = load(url, I3SAttributeLoader, loadOptions);\n\n attributeLoadPromises.push(promise);\n }\n try {\n attributes = await Promise.allSettled(attributeLoadPromises);\n } catch (error) {\n // do nothing\n }\n\n if (!attributes.length) {\n return null;\n }\n\n return generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields);\n}\n\n/**\n * Gets attributes data from tile.\n * @param tile \n * @returns \n */\nfunction getAttributesData(tile) {\n const attributeStorageInfo = tile.tileset?.tileset?.attributeStorageInfo;\n const attributeUrls = tile.header?.attributeUrls;\n const tilesetFields = tile.tileset?.tileset?.fields || [];\n\n return {attributeStorageInfo, attributeUrls, tilesetFields};\n}\n\n/**\n * Get attribute value type based on property names\n * @param {Object} attribute\n * @returns {String}\n */\nfunction getAttributeValueType(attribute) {\n if (attribute.hasOwnProperty('objectIds')) {\n return 'Oid32';\n } else if (attribute.hasOwnProperty('attributeValues')) {\n return attribute.attributeValues.valueType;\n }\n return '';\n}\n\n/**\n * Find in attributeStorageInfo attribute name responsible for feature ids list.\n * @param attributeStorageInfo \n * @returns Feature ids attribute name\n */\nfunction getFeatureIdsAttributeName(attributeStorageInfo) {\n const objectIdsAttribute = attributeStorageInfo.find(attribute => attribute.name.includes('OBJECTID'));\n\n return objectIdsAttribute?.name;\n}\n\n/**\n * Generates mapping featureId to feature attributes\n * @param {Array} attributes\n * @param {Object} attributeStorageInfo\n * @param {number} featureId\n * @returns {Object}\n */\nfunction generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields) {\n const objectIdsAttributeName = getFeatureIdsAttributeName(attributeStorageInfo);\n const objectIds = attributes.find((attribute) => attribute.value[objectIdsAttributeName]);\n\n if (!objectIds) {\n return null;\n }\n\n const attributeIndex = objectIds.value[objectIdsAttributeName].indexOf(featureId);\n\n if (attributeIndex < 0) {\n return null;\n }\n\n return getFeatureAttributesByIndex(attributes, attributeIndex, attributeStorageInfo, tilesetFields);\n}\n\n/**\n * Generates attribute object for feature mapping by feature id\n * @param {Array} attributes\n * @param {Number} featureIdIndex\n * @param {Object} attributeStorageInfo\n * @returns {Object}\n */\nfunction getFeatureAttributesByIndex(attributes, featureIdIndex, attributeStorageInfo, tilesetFields) {\n const attributesObject = {};\n\n for (let index = 0; index < attributeStorageInfo.length; index++) {\n const attributeName = attributeStorageInfo[index].name;\n const codedValues = getAttributeCodedValues(attributeName, tilesetFields);\n const attribute = getAttributeByIndexAndAttributeName(attributes, index, attributeName);\n attributesObject[attributeName] = formatAttributeValue(attribute, featureIdIndex, codedValues);\n }\n\n return attributesObject;\n}\n\n/**\n * Get coded values list from tileset.\n * @param attributeName \n * @param tilesetFields \n */\nfunction getAttributeCodedValues(attributeName, tilesetFields) {\n const attributeField = tilesetFields\n .find(field => field.name === attributeName || field.alias === attributeName);\n\n return attributeField?.domain?.codedValues || [];\n}\n\n/**\n * Return attribute value if it presents in atrributes list\n * @param {array} attributes\n * @param {number} index\n * @param {string} attributesName\n */\nfunction getAttributeByIndexAndAttributeName(attributes, index, attributesName) {\n const attributeObject = attributes[index];\n\n if (attributeObject.status === REJECTED_STATUS) {\n return null;\n }\n\n return attributeObject.value[attributesName];\n}\n\n/**\n * Do formatting of attribute values or return empty string.\n * @param {Array} attribute\n * @param {Number} featureIdIndex\n * @returns {String}\n */\nfunction formatAttributeValue(attribute, featureIdIndex, codedValues) {\n let value = EMPTY_VALUE;\n\n if (attribute && (featureIdIndex in attribute)) {\n // eslint-disable-next-line no-control-regex\n value = String(attribute[featureIdIndex]).replace(/\\u0000|NaN/g, '').trim();\n }\n\n // Check if coded values are existed. If so we use them.\n if (codedValues.length) {\n const codeValue = codedValues.find(codedValue => codedValue.code === Number(value));\n value = codeValue?.name || EMPTY_VALUE;\n }\n\n return value;\n}\n"],"file":"i3s-attribute-loader.js"}
|
|
@@ -1,30 +1,58 @@
|
|
|
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.I3SBuildingSceneLayerLoader = void 0;
|
|
7
9
|
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
8
14
|
var _parseI3sBuildingSceneLayer = require("./lib/parsers/parse-i3s-building-scene-layer");
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
var VERSION = typeof "3.1.0" !== 'undefined' ? "3.1.0" : 'beta';
|
|
17
|
+
var I3SBuildingSceneLayerLoader = {
|
|
12
18
|
name: 'I3S Building Scene Layer',
|
|
13
19
|
id: 'i3s-building-scene-layer',
|
|
14
20
|
module: 'i3s',
|
|
15
21
|
version: VERSION,
|
|
16
22
|
mimeTypes: ['application/json'],
|
|
17
|
-
parse,
|
|
23
|
+
parse: parse,
|
|
18
24
|
extensions: ['json'],
|
|
19
25
|
options: {}
|
|
20
26
|
};
|
|
21
27
|
exports.I3SBuildingSceneLayerLoader = I3SBuildingSceneLayerLoader;
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
function parse(_x, _x2, _x3) {
|
|
30
|
+
return _parse.apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _parse() {
|
|
34
|
+
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data, options, context) {
|
|
35
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
36
|
+
while (1) {
|
|
37
|
+
switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
if (context !== null && context !== void 0 && context.url) {
|
|
40
|
+
_context.next = 2;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
throw new Error('Url is not provided');
|
|
45
|
+
|
|
46
|
+
case 2:
|
|
47
|
+
return _context.abrupt("return", (0, _parseI3sBuildingSceneLayer.parseBuildingSceneLayer)(data, context.url));
|
|
27
48
|
|
|
28
|
-
|
|
49
|
+
case 3:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, _callee);
|
|
55
|
+
}));
|
|
56
|
+
return _parse.apply(this, arguments);
|
|
29
57
|
}
|
|
30
58
|
//# sourceMappingURL=i3s-building-scene-layer-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i3s-building-scene-layer-loader.ts"],"names":["VERSION","I3SBuildingSceneLayerLoader","name","id","module","version","mimeTypes","parse","extensions","options","data","context","url","Error"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/i3s-building-scene-layer-loader.ts"],"names":["VERSION","I3SBuildingSceneLayerLoader","name","id","module","version","mimeTypes","parse","extensions","options","data","context","url","Error"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,MAAnE;AAIO,IAAMC,2BAA6C,GAAG;AAC3DC,EAAAA,IAAI,EAAE,0BADqD;AAE3DC,EAAAA,EAAE,EAAE,0BAFuD;AAG3DC,EAAAA,MAAM,EAAE,KAHmD;AAI3DC,EAAAA,OAAO,EAAEL,OAJkD;AAK3DM,EAAAA,SAAS,EAAE,CAAC,kBAAD,CALgD;AAM3DC,EAAAA,KAAK,EAALA,KAN2D;AAO3DC,EAAAA,UAAU,EAAE,CAAC,MAAD,CAP+C;AAQ3DC,EAAAA,OAAO,EAAE;AARkD,CAAtD;;;SAWQF,K;;;;;qEAAf,iBACEG,IADF,EAEED,OAFF,EAGEE,OAHF;AAAA;AAAA;AAAA;AAAA;AAAA,gBAKOA,OALP,aAKOA,OALP,eAKOA,OAAO,CAAEC,GALhB;AAAA;AAAA;AAAA;;AAAA,kBAMU,IAAIC,KAAJ,CAAU,qBAAV,CANV;;AAAA;AAAA,6CASS,yDAAwBH,IAAxB,EAA8BC,OAAO,CAACC,GAAtC,CATT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import type {LoaderWithParser, LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\nimport type {BuildingSceneLayerTileset} from './types';\n\nimport {parseBuildingSceneLayer} from './lib/parsers/parse-i3s-building-scene-layer';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\n\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\n/**\n * Loader for I3S - Building Scene Layer\n */\nexport const I3SBuildingSceneLayerLoader: LoaderWithParser = {\n name: 'I3S Building Scene Layer',\n id: 'i3s-building-scene-layer',\n module: 'i3s',\n version: VERSION,\n mimeTypes: ['application/json'],\n parse,\n extensions: ['json'],\n options: {}\n};\n\nasync function parse(\n data: ArrayBuffer,\n options?: LoaderOptions,\n context?: LoaderContext\n): Promise<BuildingSceneLayerTileset> {\n if (!context?.url) {\n throw new Error('Url is not provided');\n }\n\n return parseBuildingSceneLayer(data, context.url);\n}\n"],"file":"i3s-building-scene-layer-loader.js"}
|
|
@@ -1,21 +1,27 @@
|
|
|
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.I3SContentLoader = void 0;
|
|
7
9
|
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
8
14
|
var _parseI3sTileContent = require("./lib/parsers/parse-i3s-tile-content");
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
var VERSION = typeof "3.1.0" !== 'undefined' ? "3.1.0" : 'beta';
|
|
17
|
+
var I3SContentLoader = {
|
|
12
18
|
name: 'I3S Content (Indexed Scene Layers)',
|
|
13
19
|
id: 'i3s-content',
|
|
14
20
|
module: 'i3s',
|
|
15
21
|
worker: true,
|
|
16
22
|
version: VERSION,
|
|
17
23
|
mimeTypes: ['application/octet-stream'],
|
|
18
|
-
parse,
|
|
24
|
+
parse: parse,
|
|
19
25
|
extensions: ['bin'],
|
|
20
26
|
options: {
|
|
21
27
|
'i3s-content': {}
|
|
@@ -23,12 +29,32 @@ const I3SContentLoader = {
|
|
|
23
29
|
};
|
|
24
30
|
exports.I3SContentLoader = I3SContentLoader;
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
function parse(_x, _x2, _x3) {
|
|
33
|
+
return _parse.apply(this, arguments);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function _parse() {
|
|
37
|
+
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data, options, context) {
|
|
38
|
+
var _ref, tile, tileset;
|
|
39
|
+
|
|
40
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
41
|
+
while (1) {
|
|
42
|
+
switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
_ref = (options === null || options === void 0 ? void 0 : options.i3s) || {}, tile = _ref.tile, tileset = _ref.tileset;
|
|
45
|
+
_context.next = 3;
|
|
46
|
+
return (0, _parseI3sTileContent.parseI3STileContent)(data, tile, tileset, options, context);
|
|
47
|
+
|
|
48
|
+
case 3:
|
|
49
|
+
return _context.abrupt("return", tile.content);
|
|
50
|
+
|
|
51
|
+
case 4:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, _callee);
|
|
57
|
+
}));
|
|
58
|
+
return _parse.apply(this, arguments);
|
|
33
59
|
}
|
|
34
60
|
//# sourceMappingURL=i3s-content-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i3s-content-loader.ts"],"names":["VERSION","I3SContentLoader","name","id","module","worker","version","mimeTypes","parse","extensions","options","data","context","
|
|
1
|
+
{"version":3,"sources":["../../src/i3s-content-loader.ts"],"names":["VERSION","I3SContentLoader","name","id","module","worker","version","mimeTypes","parse","extensions","options","data","context","i3s","tile","tileset","content"],"mappings":";;;;;;;;;;;;;AACA;;AAKA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,MAAnE;AAIO,IAAMC,gBAAkC,GAAG;AAChDC,EAAAA,IAAI,EAAE,oCAD0C;AAEhDC,EAAAA,EAAE,EAAE,aAF4C;AAGhDC,EAAAA,MAAM,EAAE,KAHwC;AAIhDC,EAAAA,MAAM,EAAE,IAJwC;AAKhDC,EAAAA,OAAO,EAAEN,OALuC;AAMhDO,EAAAA,SAAS,EAAE,CAAC,0BAAD,CANqC;AAOhDC,EAAAA,KAAK,EAALA,KAPgD;AAQhDC,EAAAA,UAAU,EAAE,CAAC,KAAD,CARoC;AAShDC,EAAAA,OAAO,EAAE;AACP,mBAAe;AADR;AATuC,CAA3C;;;SAcQF,K;;;;;qEAAf,iBAAqBG,IAArB,EAA2BD,OAA3B,EAAoDE,OAApD;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,mBAC0B,CAAAF,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEG,GAAT,KAAgB,EAD1C,EACSC,IADT,QACSA,IADT,EACeC,OADf,QACeA,OADf;AAAA;AAAA,mBAEQ,8CAAoBJ,IAApB,EAA0BG,IAA1B,EAAgCC,OAAhC,EAAyCL,OAAzC,EAAkDE,OAAlD,CAFR;;AAAA;AAAA,6CAGSE,IAAI,CAACE,OAHd;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import type {LoaderWithParser, LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\nimport {parseI3STileContent} from './lib/parsers/parse-i3s-tile-content';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\n\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\n/**\n * Loader for I3S - Indexed 3D Scene Layer\n */\nexport const I3SContentLoader: LoaderWithParser = {\n name: 'I3S Content (Indexed Scene Layers)',\n id: 'i3s-content',\n module: 'i3s',\n worker: true,\n version: VERSION,\n mimeTypes: ['application/octet-stream'],\n parse,\n extensions: ['bin'],\n options: {\n 'i3s-content': {}\n }\n};\n\nasync function parse(data, options?: LoaderOptions, context?: LoaderContext) {\n const {tile, tileset} = options?.i3s || {};\n await parseI3STileContent(data, tile, tileset, options, context);\n return tile.content;\n}\n"],"file":"i3s-content-loader.js"}
|