@loaders.gl/i3s 3.3.0-alpha.1 → 3.3.0-alpha.10
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/dist.min.js +1215 -1478
- package/dist/es5/arcgis-webscene-loader.js +2 -8
- package/dist/es5/arcgis-webscene-loader.js.map +1 -1
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +19 -59
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -10
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +18 -18
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +48 -80
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -12
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/index.js +12 -18
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +18 -78
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +3 -19
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js +128 -30
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +1 -23
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +8 -25
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +90 -199
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +6 -37
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +0 -7
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/es5/lib/utils/customizeColors.js +164 -0
- package/dist/es5/lib/utils/customizeColors.js.map +1 -0
- package/dist/es5/lib/utils/url-utils.js +3 -8
- package/dist/es5/lib/utils/url-utils.js.map +1 -1
- package/dist/es5/types.js +0 -3
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/workers/i3s-content-nodejs-worker.js +7 -0
- package/dist/es5/workers/i3s-content-nodejs-worker.js.map +1 -0
- package/dist/es5/workers/i3s-content-worker.js +0 -2
- package/dist/es5/workers/i3s-content-worker.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +3 -1
- package/dist/esm/arcgis-webscene-loader.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +9 -26
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +2 -3
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +13 -6
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +16 -24
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -2
- 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 +2 -45
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/constants.js +2 -11
- package/dist/esm/lib/parsers/constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js +50 -11
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js +1 -8
- package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +1 -4
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +60 -104
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +16 -18
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/esm/lib/utils/customizeColors.js +96 -0
- package/dist/esm/lib/utils/customizeColors.js.map +1 -0
- package/dist/esm/lib/utils/url-utils.js +5 -5
- package/dist/esm/lib/utils/url-utils.js.map +1 -1
- package/dist/esm/types.js +0 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/workers/i3s-content-nodejs-worker.js +5 -0
- package/dist/esm/workers/i3s-content-nodejs-worker.js.map +1 -0
- package/dist/esm/workers/i3s-content-worker.js.map +1 -1
- package/dist/i3s-attribute-loader.d.ts +6 -0
- package/dist/i3s-attribute-loader.d.ts.map +1 -1
- package/dist/i3s-attribute-loader.js +2 -1
- package/dist/i3s-content-loader.d.ts.map +1 -1
- package/dist/i3s-content-loader.js +9 -4
- package/dist/i3s-content-nodejs-worker.js +201 -0
- package/dist/i3s-content-nodejs-worker.js.map +7 -0
- package/dist/i3s-content-worker.js +672 -1045
- package/dist/i3s-loader.d.ts +5 -0
- package/dist/i3s-loader.d.ts.map +1 -1
- package/dist/i3s-loader.js +12 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/parsers/constants.js +1 -1
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -1
- package/dist/lib/parsers/parse-arcgis-webscene.js +49 -7
- 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 +38 -33
- package/dist/lib/parsers/parse-i3s.d.ts +1 -1
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s.js +1 -1
- package/dist/lib/utils/customizeColors.d.ts +14 -0
- package/dist/lib/utils/customizeColors.d.ts.map +1 -0
- package/dist/lib/utils/customizeColors.js +89 -0
- package/dist/types.d.ts +265 -85
- package/dist/types.d.ts.map +1 -1
- package/dist/workers/i3s-content-nodejs-worker.d.ts +2 -0
- package/dist/workers/i3s-content-nodejs-worker.d.ts.map +1 -0
- package/dist/workers/i3s-content-nodejs-worker.js +6 -0
- package/package.json +12 -12
- package/src/i3s-attribute-loader.ts +1 -1
- package/src/i3s-content-loader.ts +19 -6
- package/src/i3s-loader.ts +22 -13
- package/src/index.ts +8 -1
- package/src/lib/parsers/constants.ts +1 -1
- package/src/lib/parsers/parse-arcgis-webscene.ts +57 -7
- package/src/lib/parsers/parse-i3s-tile-content.ts +56 -43
- package/src/lib/parsers/parse-i3s.ts +1 -1
- package/src/lib/utils/customizeColors.ts +129 -0
- package/src/types.ts +198 -3
- package/src/workers/i3s-content-nodejs-worker.ts +5 -0
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ArcGisWebSceneLoader = void 0;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
10
|
var _parseArcgisWebscene = require("./lib/parsers/parse-arcgis-webscene");
|
|
11
|
+
var VERSION = typeof "3.3.0-alpha.10" !== 'undefined' ? "3.3.0-alpha.10" : 'beta';
|
|
15
12
|
|
|
16
|
-
var VERSION = typeof "3.3.0-alpha.1" !== 'undefined' ? "3.3.0-alpha.1" : 'beta';
|
|
17
13
|
var ArcGisWebSceneLoader = {
|
|
18
14
|
name: 'ArcGIS Web Scene Loader',
|
|
19
15
|
id: 'arcgis-web-scene',
|
|
@@ -24,12 +20,11 @@ var ArcGisWebSceneLoader = {
|
|
|
24
20
|
extensions: ['json'],
|
|
25
21
|
options: {}
|
|
26
22
|
};
|
|
27
|
-
exports.ArcGisWebSceneLoader = ArcGisWebSceneLoader;
|
|
28
23
|
|
|
24
|
+
exports.ArcGisWebSceneLoader = ArcGisWebSceneLoader;
|
|
29
25
|
function parse(_x) {
|
|
30
26
|
return _parse.apply(this, arguments);
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
function _parse() {
|
|
34
29
|
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) {
|
|
35
30
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
@@ -37,7 +32,6 @@ function _parse() {
|
|
|
37
32
|
switch (_context.prev = _context.next) {
|
|
38
33
|
case 0:
|
|
39
34
|
return _context.abrupt("return", (0, _parseArcgisWebscene.parseWebscene)(data));
|
|
40
|
-
|
|
41
35
|
case 1:
|
|
42
36
|
case "end":
|
|
43
37
|
return _context.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"arcgis-webscene-loader.js","names":["VERSION","ArcGisWebSceneLoader","name","id","module","version","mimeTypes","parse","extensions","options","data","parseWebscene"],"sources":["../../src/arcgis-webscene-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {ArcGisWebSceneData} from './types';\n\nimport {parseWebscene} from './lib/parsers/parse-arcgis-webscene';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\n\n/**\n * Loader for ArcGis WebScene\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/webscene/\n */\nexport const ArcGisWebSceneLoader: LoaderWithParser = {\n name: 'ArcGIS Web Scene Loader',\n id: 'arcgis-web-scene',\n module: 'i3s',\n version: VERSION,\n mimeTypes: ['application/json'],\n parse,\n extensions: ['json'],\n options: {}\n};\n\n/**\n * Parse ArcGis webscene\n * @param data\n */\nasync function parse(data: ArrayBuffer): Promise<ArcGisWebSceneData> {\n return parseWebscene(data);\n}\n"],"mappings":";;;;;;;;;AAGA;AAIA,IAAMA,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,MAAM;;AAMlE,IAAMC,oBAAsC,GAAG;EACpDC,IAAI,EAAE,yBAAyB;EAC/BC,EAAE,EAAE,kBAAkB;EACtBC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,KAAK,EAALA,KAAK;EACLC,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,OAAO,EAAE,CAAC;AACZ,CAAC;;AAAC;AAAA,SAMaF,KAAK;EAAA;AAAA;AAAA;EAAA,mEAApB,iBAAqBG,IAAiB;IAAA;MAAA;QAAA;UAAA;YAAA,iCAC7B,IAAAC,kCAAa,EAACD,IAAI,CAAC;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,CAC3B;EAAA;AAAA"}
|
package/dist/es5/bundle.js
CHANGED
package/dist/es5/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAS,CAAC;AACxCC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;AAC7CC,MAAM,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACL,UAAU,CAACC,OAAO,EAAEH,aAAa,CAAC"}
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.loadFeatureAttributes = loadFeatureAttributes;
|
|
9
7
|
exports.I3SAttributeLoader = void 0;
|
|
10
|
-
|
|
8
|
+
exports.getAttributeValueType = getAttributeValueType;
|
|
9
|
+
exports.loadFeatureAttributes = loadFeatureAttributes;
|
|
11
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
-
|
|
13
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
|
|
15
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
|
-
|
|
17
13
|
var _core = require("@loaders.gl/core");
|
|
18
|
-
|
|
19
14
|
var _parseI3sAttribute = require("./lib/parsers/parse-i3s-attribute");
|
|
20
|
-
|
|
21
15
|
var _urlUtils = require("./lib/utils/url-utils");
|
|
22
|
-
|
|
23
|
-
function
|
|
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.3.0-alpha.1" !== 'undefined' ? "3.3.0-alpha.1" : 'latest';
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
+
var VERSION = typeof "3.3.0-alpha.10" !== 'undefined' ? "3.3.0-alpha.10" : 'latest';
|
|
28
19
|
var EMPTY_VALUE = '';
|
|
29
20
|
var REJECTED_STATUS = 'rejected';
|
|
30
21
|
var I3SAttributeLoader = {
|
|
@@ -39,11 +30,9 @@ var I3SAttributeLoader = {
|
|
|
39
30
|
binary: true
|
|
40
31
|
};
|
|
41
32
|
exports.I3SAttributeLoader = I3SAttributeLoader;
|
|
42
|
-
|
|
43
33
|
function parse(_x, _x2) {
|
|
44
34
|
return _parse.apply(this, arguments);
|
|
45
35
|
}
|
|
46
|
-
|
|
47
36
|
function _parse() {
|
|
48
37
|
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data, options) {
|
|
49
38
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
@@ -52,7 +41,6 @@ function _parse() {
|
|
|
52
41
|
case 0:
|
|
53
42
|
data = (0, _parseI3sAttribute.parseI3STileAttribute)(data, options);
|
|
54
43
|
return _context.abrupt("return", data);
|
|
55
|
-
|
|
56
44
|
case 2:
|
|
57
45
|
case "end":
|
|
58
46
|
return _context.stop();
|
|
@@ -62,47 +50,40 @@ function _parse() {
|
|
|
62
50
|
}));
|
|
63
51
|
return _parse.apply(this, arguments);
|
|
64
52
|
}
|
|
65
|
-
|
|
66
53
|
function loadFeatureAttributes(_x3, _x4) {
|
|
67
54
|
return _loadFeatureAttributes.apply(this, arguments);
|
|
68
55
|
}
|
|
69
|
-
|
|
70
56
|
function _loadFeatureAttributes() {
|
|
71
57
|
_loadFeatureAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(tile, featureId) {
|
|
72
58
|
var options,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
59
|
+
_getAttributesData,
|
|
60
|
+
attributeStorageInfo,
|
|
61
|
+
attributeUrls,
|
|
62
|
+
tilesetFields,
|
|
63
|
+
attributes,
|
|
64
|
+
attributeLoadPromises,
|
|
65
|
+
index,
|
|
66
|
+
_options$i3s,
|
|
67
|
+
url,
|
|
68
|
+
attributeName,
|
|
69
|
+
attributeType,
|
|
70
|
+
loadOptions,
|
|
71
|
+
promise,
|
|
72
|
+
_args2 = arguments;
|
|
88
73
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
89
74
|
while (1) {
|
|
90
75
|
switch (_context2.prev = _context2.next) {
|
|
91
76
|
case 0:
|
|
92
77
|
options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
93
78
|
_getAttributesData = getAttributesData(tile), attributeStorageInfo = _getAttributesData.attributeStorageInfo, attributeUrls = _getAttributesData.attributeUrls, tilesetFields = _getAttributesData.tilesetFields;
|
|
94
|
-
|
|
95
79
|
if (!(!attributeStorageInfo || !attributeUrls || featureId < 0)) {
|
|
96
80
|
_context2.next = 4;
|
|
97
81
|
break;
|
|
98
82
|
}
|
|
99
|
-
|
|
100
83
|
return _context2.abrupt("return", null);
|
|
101
|
-
|
|
102
84
|
case 4:
|
|
103
85
|
attributes = [];
|
|
104
86
|
attributeLoadPromises = [];
|
|
105
|
-
|
|
106
87
|
for (index = 0; index < attributeStorageInfo.length; index++) {
|
|
107
88
|
url = (0, _urlUtils.getUrlWithToken)(attributeUrls[index], (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
108
89
|
attributeName = attributeStorageInfo[index].name;
|
|
@@ -114,31 +95,24 @@ function _loadFeatureAttributes() {
|
|
|
114
95
|
promise = (0, _core.load)(url, I3SAttributeLoader, loadOptions);
|
|
115
96
|
attributeLoadPromises.push(promise);
|
|
116
97
|
}
|
|
117
|
-
|
|
118
98
|
_context2.prev = 7;
|
|
119
99
|
_context2.next = 10;
|
|
120
100
|
return Promise.allSettled(attributeLoadPromises);
|
|
121
|
-
|
|
122
101
|
case 10:
|
|
123
102
|
attributes = _context2.sent;
|
|
124
103
|
_context2.next = 15;
|
|
125
104
|
break;
|
|
126
|
-
|
|
127
105
|
case 13:
|
|
128
106
|
_context2.prev = 13;
|
|
129
107
|
_context2.t0 = _context2["catch"](7);
|
|
130
|
-
|
|
131
108
|
case 15:
|
|
132
109
|
if (attributes.length) {
|
|
133
110
|
_context2.next = 17;
|
|
134
111
|
break;
|
|
135
112
|
}
|
|
136
|
-
|
|
137
113
|
return _context2.abrupt("return", null);
|
|
138
|
-
|
|
139
114
|
case 17:
|
|
140
115
|
return _context2.abrupt("return", generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields));
|
|
141
|
-
|
|
142
116
|
case 18:
|
|
143
117
|
case "end":
|
|
144
118
|
return _context2.stop();
|
|
@@ -148,10 +122,8 @@ function _loadFeatureAttributes() {
|
|
|
148
122
|
}));
|
|
149
123
|
return _loadFeatureAttributes.apply(this, arguments);
|
|
150
124
|
}
|
|
151
|
-
|
|
152
125
|
function getAttributesData(tile) {
|
|
153
126
|
var _tile$tileset, _tile$tileset$tileset, _tile$header, _tile$tileset2, _tile$tileset2$tilese;
|
|
154
|
-
|
|
155
127
|
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
128
|
var attributeUrls = (_tile$header = tile.header) === null || _tile$header === void 0 ? void 0 : _tile$header.attributeUrls;
|
|
157
129
|
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) || [];
|
|
@@ -168,7 +140,6 @@ function getAttributeValueType(attribute) {
|
|
|
168
140
|
} else if (attribute.hasOwnProperty('attributeValues')) {
|
|
169
141
|
return attribute.attributeValues.valueType;
|
|
170
142
|
}
|
|
171
|
-
|
|
172
143
|
return '';
|
|
173
144
|
}
|
|
174
145
|
|
|
@@ -184,36 +155,29 @@ function generateAttributesByFeatureId(attributes, attributeStorageInfo, feature
|
|
|
184
155
|
var objectIds = attributes.find(function (attribute) {
|
|
185
156
|
return attribute.value[objectIdsAttributeName];
|
|
186
157
|
});
|
|
187
|
-
|
|
188
158
|
if (!objectIds) {
|
|
189
159
|
return null;
|
|
190
160
|
}
|
|
191
|
-
|
|
192
161
|
var attributeIndex = objectIds.value[objectIdsAttributeName].indexOf(featureId);
|
|
193
|
-
|
|
194
162
|
if (attributeIndex < 0) {
|
|
195
163
|
return null;
|
|
196
164
|
}
|
|
197
|
-
|
|
198
165
|
return getFeatureAttributesByIndex(attributes, attributeIndex, attributeStorageInfo, tilesetFields);
|
|
199
166
|
}
|
|
200
167
|
|
|
201
168
|
function getFeatureAttributesByIndex(attributes, featureIdIndex, attributeStorageInfo, tilesetFields) {
|
|
202
169
|
var attributesObject = {};
|
|
203
|
-
|
|
204
170
|
for (var index = 0; index < attributeStorageInfo.length; index++) {
|
|
205
171
|
var attributeName = attributeStorageInfo[index].name;
|
|
206
172
|
var codedValues = getAttributeCodedValues(attributeName, tilesetFields);
|
|
207
173
|
var attribute = getAttributeByIndexAndAttributeName(attributes, index, attributeName);
|
|
208
174
|
attributesObject[attributeName] = formatAttributeValue(attribute, featureIdIndex, codedValues);
|
|
209
175
|
}
|
|
210
|
-
|
|
211
176
|
return attributesObject;
|
|
212
177
|
}
|
|
213
178
|
|
|
214
179
|
function getAttributeCodedValues(attributeName, tilesetFields) {
|
|
215
180
|
var _attributeField$domai;
|
|
216
|
-
|
|
217
181
|
var attributeField = tilesetFields.find(function (field) {
|
|
218
182
|
return field.name === attributeName || field.alias === attributeName;
|
|
219
183
|
});
|
|
@@ -222,17 +186,14 @@ function getAttributeCodedValues(attributeName, tilesetFields) {
|
|
|
222
186
|
|
|
223
187
|
function getAttributeByIndexAndAttributeName(attributes, index, attributesName) {
|
|
224
188
|
var attributeObject = attributes[index];
|
|
225
|
-
|
|
226
189
|
if (attributeObject.status === REJECTED_STATUS) {
|
|
227
190
|
return null;
|
|
228
191
|
}
|
|
229
|
-
|
|
230
192
|
return attributeObject.value[attributesName];
|
|
231
193
|
}
|
|
232
194
|
|
|
233
195
|
function formatAttributeValue(attribute, featureIdIndex, codedValues) {
|
|
234
196
|
var value = EMPTY_VALUE;
|
|
235
|
-
|
|
236
197
|
if (attribute && featureIdIndex in attribute) {
|
|
237
198
|
value = String(attribute[featureIdIndex]).replace(/\u0000|NaN/g, '').trim();
|
|
238
199
|
}
|
|
@@ -243,7 +204,6 @@ function formatAttributeValue(attribute, featureIdIndex, codedValues) {
|
|
|
243
204
|
});
|
|
244
205
|
value = (codeValue === null || codeValue === void 0 ? void 0 : codeValue.name) || EMPTY_VALUE;
|
|
245
206
|
}
|
|
246
|
-
|
|
247
207
|
return value;
|
|
248
208
|
}
|
|
249
209
|
//# sourceMappingURL=i3s-attribute-loader.js.map
|
|
@@ -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","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":";;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;;;;;AAIA,IAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AACA,IAAMC,WAAW,GAAG,EAApB;AACA,IAAMC,eAAe,GAAG,UAAxB;AAIO,IAAMC,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,KAAK,EAALA,KANkD;AAOlDC,EAAAA,UAAU,EAAE,CAAC,KAAD,CAPsC;AAQlDC,EAAAA,OAAO,EAAE,EARyC;AASlDC,EAAAA,MAAM,EAAE;AAT0C,CAA7C;;;SAYQH,K;;;;;qEAAf,iBAAqBI,IAArB,EAA2BF,OAA3B;AAAA;AAAA;AAAA;AAAA;AACEE,YAAAA,IAAI,GAAG,8CAAsBA,IAAtB,EAA4BF,OAA5B,CAAP;AADF,6CAESE,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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 < 0) {\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,"file":"i3s-attribute-loader.js","names":["VERSION","EMPTY_VALUE","REJECTED_STATUS","I3SAttributeLoader","name","id","module","version","mimeTypes","parse","extensions","options","binary","data","parseI3STileAttribute","loadFeatureAttributes","tile","featureId","getAttributesData","attributeStorageInfo","attributeUrls","tilesetFields","attributes","attributeLoadPromises","index","length","url","getUrlWithToken","i3s","token","attributeName","attributeType","getAttributeValueType","loadOptions","promise","load","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"],"sources":["../../src/i3s-attribute-loader.ts"],"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 < 0) {\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 */\nexport function 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"],"mappings":";;;;;;;;;;;;AACA;AACA;AACA;AAAsD;AAAA;AAItD,IAAMA,OAAO,GAAG,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c,cAAc,IAAId,SAAU,EAAE;IAE9CU,KAAK,GAAGiB,MAAM,CAAC3B,SAAS,CAACc,cAAc,CAAC,CAAC,CAACc,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAACC,IAAI,EAAE;EAC7E;;EAGA,IAAIb,WAAW,CAAClC,MAAM,EAAE;IACtB,IAAMgD,SAAS,GAAGd,WAAW,CAACV,IAAI,CAAC,UAAAyB,UAAU;MAAA,OAAIA,UAAU,CAACC,IAAI,KAAKC,MAAM,CAACvB,KAAK,CAAC;IAAA,EAAC;IACnFA,KAAK,GAAG,CAAAoB,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAErE,IAAI,KAAIH,WAAW;EACxC;EAEA,OAAOoD,KAAK;AACd"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.I3SBuildingSceneLayerLoader = void 0;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
10
|
var _parseI3sBuildingSceneLayer = require("./lib/parsers/parse-i3s-building-scene-layer");
|
|
15
11
|
|
|
16
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
12
|
+
var VERSION = typeof "3.3.0-alpha.10" !== 'undefined' ? "3.3.0-alpha.10" : 'beta';
|
|
17
13
|
var I3SBuildingSceneLayerLoader = {
|
|
18
14
|
name: 'I3S Building Scene Layer',
|
|
19
15
|
id: 'i3s-building-scene-layer',
|
|
@@ -25,11 +21,9 @@ var I3SBuildingSceneLayerLoader = {
|
|
|
25
21
|
options: {}
|
|
26
22
|
};
|
|
27
23
|
exports.I3SBuildingSceneLayerLoader = I3SBuildingSceneLayerLoader;
|
|
28
|
-
|
|
29
24
|
function parse(_x, _x2, _x3) {
|
|
30
25
|
return _parse.apply(this, arguments);
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
function _parse() {
|
|
34
28
|
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data, options, context) {
|
|
35
29
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
@@ -40,12 +34,9 @@ function _parse() {
|
|
|
40
34
|
_context.next = 2;
|
|
41
35
|
break;
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
throw new Error('Url is not provided');
|
|
45
|
-
|
|
46
38
|
case 2:
|
|
47
39
|
return _context.abrupt("return", (0, _parseI3sBuildingSceneLayer.parseBuildingSceneLayer)(data, context.url));
|
|
48
|
-
|
|
49
40
|
case 3:
|
|
50
41
|
case "end":
|
|
51
42
|
return _context.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"i3s-building-scene-layer-loader.js","names":["VERSION","I3SBuildingSceneLayerLoader","name","id","module","version","mimeTypes","parse","extensions","options","data","context","url","Error","parseBuildingSceneLayer"],"sources":["../../src/i3s-building-scene-layer-loader.ts"],"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"],"mappings":";;;;;;;;;AAGA;;AAKA,IAAMA,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,MAAM;AAIlE,IAAMC,2BAA6C,GAAG;EAC3DC,IAAI,EAAE,0BAA0B;EAChCC,EAAE,EAAE,0BAA0B;EAC9BC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,KAAK,EAALA,KAAK;EACLC,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,OAAO,EAAE,CAAC;AACZ,CAAC;AAAC;AAAA,SAEaF,KAAK;EAAA;AAAA;AAAA;EAAA,mEAApB,iBACEG,IAAiB,EACjBD,OAAuB,EACvBE,OAAuB;IAAA;MAAA;QAAA;UAAA;YAAA,IAElBA,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEC,GAAG;cAAA;cAAA;YAAA;YAAA,MACT,IAAIC,KAAK,CAAC,qBAAqB,CAAC;UAAA;YAAA,iCAGjC,IAAAC,mDAAuB,EAACJ,IAAI,EAAEC,OAAO,CAACC,GAAG,CAAC;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,CAClD;EAAA;AAAA"}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.I3SContentLoader = void 0;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
10
|
+
var _workerUtils = require("@loaders.gl/worker-utils");
|
|
14
11
|
var _parseI3sTileContent = require("./lib/parsers/parse-i3s-tile-content");
|
|
15
12
|
|
|
16
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
13
|
+
var VERSION = typeof "3.3.0-alpha.10" !== 'undefined' ? "3.3.0-alpha.10" : 'beta';
|
|
17
14
|
var I3SContentLoader = {
|
|
18
15
|
name: 'I3S Content (Indexed Scene Layers)',
|
|
19
|
-
id: 'i3s-content',
|
|
16
|
+
id: _workerUtils.isBrowser ? 'i3s-content' : 'i3s-content-nodejs',
|
|
20
17
|
module: 'i3s',
|
|
21
18
|
worker: true,
|
|
22
19
|
version: VERSION,
|
|
@@ -28,27 +25,30 @@ var I3SContentLoader = {
|
|
|
28
25
|
}
|
|
29
26
|
};
|
|
30
27
|
exports.I3SContentLoader = I3SContentLoader;
|
|
31
|
-
|
|
32
28
|
function parse(_x, _x2, _x3) {
|
|
33
29
|
return _parse.apply(this, arguments);
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
function _parse() {
|
|
37
32
|
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data, options, context) {
|
|
38
|
-
var _ref, tile, tileset;
|
|
39
|
-
|
|
33
|
+
var _ref, tile, _tileOptions, tileset, _tilesetOptions, tileOptions, tilesetOptions;
|
|
40
34
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
41
35
|
while (1) {
|
|
42
36
|
switch (_context.prev = _context.next) {
|
|
43
37
|
case 0:
|
|
44
|
-
_ref = (options === null || options === void 0 ? void 0 : options.i3s) || {}, tile = _ref.tile, tileset = _ref.tileset;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
_ref = (options === null || options === void 0 ? void 0 : options.i3s) || {}, tile = _ref.tile, _tileOptions = _ref._tileOptions, tileset = _ref.tileset, _tilesetOptions = _ref._tilesetOptions;
|
|
39
|
+
tileOptions = _tileOptions || tile;
|
|
40
|
+
tilesetOptions = _tilesetOptions || tileset;
|
|
41
|
+
if (!(!tileOptions || !tilesetOptions)) {
|
|
42
|
+
_context.next = 5;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return _context.abrupt("return", null);
|
|
46
|
+
case 5:
|
|
47
|
+
_context.next = 7;
|
|
48
|
+
return (0, _parseI3sTileContent.parseI3STileContent)(data, tileOptions, tilesetOptions, options, context);
|
|
49
|
+
case 7:
|
|
50
|
+
return _context.abrupt("return", _context.sent);
|
|
51
|
+
case 8:
|
|
52
52
|
case "end":
|
|
53
53
|
return _context.stop();
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"i3s-content-loader.js","names":["VERSION","I3SContentLoader","name","id","isBrowser","module","worker","version","mimeTypes","parse","extensions","options","data","context","i3s","tile","_tileOptions","tileset","_tilesetOptions","tileOptions","tilesetOptions","parseI3STileContent"],"sources":["../../src/i3s-content-loader.ts"],"sourcesContent":["import {isBrowser} from '@loaders.gl/worker-utils';\nimport type {LoaderWithParser, LoaderContext} from '@loaders.gl/loader-utils';\nimport type {I3SLoaderOptions} from './i3s-loader';\nimport {parseI3STileContent} from './lib/parsers/parse-i3s-tile-content';\nimport {I3STileOptions, I3STilesetOptions} from './types';\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: isBrowser ? 'i3s-content' : 'i3s-content-nodejs',\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?: I3SLoaderOptions, context?: LoaderContext) {\n const {tile, _tileOptions, tileset, _tilesetOptions} = options?.i3s || {};\n const tileOptions = _tileOptions || tile;\n const tilesetOptions = _tilesetOptions || tileset;\n if (!tileOptions || !tilesetOptions) {\n return null;\n }\n return await parseI3STileContent(\n data,\n tileOptions as I3STileOptions,\n tilesetOptions as I3STilesetOptions,\n options,\n context\n );\n}\n"],"mappings":";;;;;;;;;AAAA;AAGA;;AAMA,IAAMA,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,MAAM;AAIlE,IAAMC,gBAAkC,GAAG;EAChDC,IAAI,EAAE,oCAAoC;EAC1CC,EAAE,EAAEC,sBAAS,GAAG,aAAa,GAAG,oBAAoB;EACpDC,MAAM,EAAE,KAAK;EACbC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAEP,OAAO;EAChBQ,SAAS,EAAE,CAAC,0BAA0B,CAAC;EACvCC,KAAK,EAALA,KAAK;EACLC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,OAAO,EAAE;IACP,aAAa,EAAE,CAAC;EAClB;AACF,CAAC;AAAC;AAAA,SAEaF,KAAK;EAAA;AAAA;AAAA;EAAA,mEAApB,iBAAqBG,IAAI,EAAED,OAA0B,EAAEE,OAAuB;IAAA;IAAA;MAAA;QAAA;UAAA;YAAA,OACrB,CAAAF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,GAAG,KAAI,CAAC,CAAC,EAAlEC,IAAI,QAAJA,IAAI,EAAEC,YAAY,QAAZA,YAAY,EAAEC,OAAO,QAAPA,OAAO,EAAEC,eAAe,QAAfA,eAAe;YAC7CC,WAAW,GAAGH,YAAY,IAAID,IAAI;YAClCK,cAAc,GAAGF,eAAe,IAAID,OAAO;YAAA,MAC7C,CAACE,WAAW,IAAI,CAACC,cAAc;cAAA;cAAA;YAAA;YAAA,iCAC1B,IAAI;UAAA;YAAA;YAAA,OAEA,IAAAC,wCAAmB,EAC9BT,IAAI,EACJO,WAAW,EACXC,cAAc,EACdT,OAAO,EACPE,OAAO,CACR;UAAA;YAAA;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,CACF;EAAA;AAAA"}
|