@loaders.gl/i3s 3.1.3 → 4.0.0-alpha.5
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 +2 -2
- package/dist/bundle.js.map +1 -0
- package/dist/dist.min.js +28 -25
- package/dist/i3s-attribute-loader.js +130 -155
- package/dist/i3s-attribute-loader.js.map +1 -0
- package/dist/i3s-building-scene-layer-loader.js +18 -23
- package/dist/i3s-building-scene-layer-loader.js.map +1 -0
- package/dist/i3s-content-loader.js +22 -25
- package/dist/i3s-content-loader.js.map +1 -0
- package/dist/i3s-content-worker.js +23 -21
- package/dist/i3s-loader.js +81 -84
- package/dist/i3s-loader.js.map +1 -0
- package/dist/i3s-node-page-loader.js +17 -21
- package/dist/i3s-node-page-loader.js.map +1 -0
- package/dist/index.js +6 -14
- package/dist/index.js.map +1 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.js +228 -221
- package/dist/lib/helpers/i3s-nodepages-tiles.js.map +1 -0
- package/dist/lib/parsers/constants.js +63 -85
- package/dist/lib/parsers/constants.js.map +1 -0
- package/dist/lib/parsers/parse-i3s-attribute.js +62 -86
- package/dist/lib/parsers/parse-i3s-attribute.js.map +1 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js +40 -41
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +458 -441
- package/dist/lib/parsers/parse-i3s-tile-content.js.map +1 -0
- package/dist/lib/parsers/parse-i3s.js +88 -86
- package/dist/lib/parsers/parse-i3s.js.map +1 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js +8 -19
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -0
- package/dist/lib/utils/url-utils.js +28 -41
- package/dist/lib/utils/url-utils.js.map +1 -0
- package/dist/types.d.ts +2 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -18
- package/dist/types.js.map +1 -0
- package/dist/workers/i3s-content-worker.js +4 -5
- package/dist/workers/i3s-content-worker.js.map +1 -0
- package/package.json +12 -12
- package/src/i3s-building-scene-layer-loader.ts +1 -1
- package/src/i3s-content-loader.ts +1 -1
- package/src/lib/parsers/parse-i3s-tile-content.ts +4 -1
- package/src/types.ts +2 -3
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/i3s-attribute-loader.js +0 -249
- package/dist/es5/i3s-attribute-loader.js.map +0 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +0 -58
- package/dist/es5/i3s-building-scene-layer-loader.js.map +0 -1
- package/dist/es5/i3s-content-loader.js +0 -60
- package/dist/es5/i3s-content-loader.js.map +0 -1
- package/dist/es5/i3s-loader.js +0 -233
- package/dist/es5/i3s-loader.js.map +0 -1
- package/dist/es5/i3s-node-page-loader.js +0 -72
- package/dist/es5/i3s-node-page-loader.js.map +0 -1
- package/dist/es5/index.js +0 -52
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +0 -393
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
- package/dist/es5/lib/parsers/constants.js +0 -89
- package/dist/es5/lib/parsers/constants.js.map +0 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +0 -124
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +0 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +0 -86
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +0 -635
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +0 -1
- package/dist/es5/lib/parsers/parse-i3s.js +0 -155
- package/dist/es5/lib/parsers/parse-i3s.js.map +0 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +0 -24
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
- package/dist/es5/lib/utils/url-utils.js +0 -40
- package/dist/es5/lib/utils/url-utils.js.map +0 -1
- package/dist/es5/types.js +0 -29
- package/dist/es5/types.js.map +0 -1
- package/dist/es5/workers/i3s-content-worker.js +0 -8
- package/dist/es5/workers/i3s-content-worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/i3s-attribute-loader.js +0 -152
- package/dist/esm/i3s-attribute-loader.js.map +0 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +0 -21
- package/dist/esm/i3s-building-scene-layer-loader.js.map +0 -1
- package/dist/esm/i3s-content-loader.js +0 -25
- package/dist/esm/i3s-content-loader.js.map +0 -1
- package/dist/esm/i3s-loader.js +0 -97
- package/dist/esm/i3s-loader.js.map +0 -1
- package/dist/esm/i3s-node-page-loader.js +0 -22
- package/dist/esm/i3s-node-page-loader.js.map +0 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +0 -239
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
- package/dist/esm/lib/parsers/constants.js +0 -67
- package/dist/esm/lib/parsers/constants.js.map +0 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js +0 -74
- package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +0 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +0 -45
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +0 -494
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +0 -1
- package/dist/esm/lib/parsers/parse-i3s.js +0 -91
- package/dist/esm/lib/parsers/parse-i3s.js.map +0 -1
- package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js +0 -9
- package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
- package/dist/esm/lib/utils/url-utils.js +0 -31
- package/dist/esm/lib/utils/url-utils.js.map +0 -1
- package/dist/esm/types.js +0 -21
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/workers/i3s-content-worker.js +0 -4
- package/dist/esm/workers/i3s-content-worker.js.map +0 -1
package/dist/bundle.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
|
package/dist/dist.min.js
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
var DEFAULT_VERSION, VERSION;
|
|
65
65
|
var init_version = __esm({
|
|
66
66
|
"../worker-utils/src/lib/env-utils/version.ts"() {
|
|
67
|
-
DEFAULT_VERSION = "
|
|
67
|
+
DEFAULT_VERSION = "beta";
|
|
68
68
|
VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
|
|
69
69
|
if (typeof __VERSION__ === "undefined") {
|
|
70
70
|
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
@@ -500,7 +500,7 @@
|
|
|
500
500
|
var init_get_worker_url = __esm({
|
|
501
501
|
"../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
|
|
502
502
|
init_assert2();
|
|
503
|
-
NPM_TAG = "
|
|
503
|
+
NPM_TAG = "beta";
|
|
504
504
|
}
|
|
505
505
|
});
|
|
506
506
|
|
|
@@ -598,7 +598,7 @@
|
|
|
598
598
|
node = __toModule(require_require_utils());
|
|
599
599
|
init_assert2();
|
|
600
600
|
init_version();
|
|
601
|
-
LATEST = "
|
|
601
|
+
LATEST = "beta";
|
|
602
602
|
VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
|
|
603
603
|
loadLibraryPromises = {};
|
|
604
604
|
}
|
|
@@ -1592,29 +1592,29 @@
|
|
|
1592
1592
|
}
|
|
1593
1593
|
});
|
|
1594
1594
|
|
|
1595
|
-
// ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
|
|
1595
|
+
// ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
|
|
1596
1596
|
var init_hi_res_timestamp2 = __esm({
|
|
1597
|
-
"../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
|
|
1597
|
+
"../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
|
|
1598
1598
|
}
|
|
1599
1599
|
});
|
|
1600
1600
|
|
|
1601
|
-
// ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
|
|
1601
|
+
// ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js
|
|
1602
1602
|
var init_stat = __esm({
|
|
1603
|
-
"../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
|
|
1603
|
+
"../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
|
|
1604
1604
|
init_hi_res_timestamp2();
|
|
1605
1605
|
}
|
|
1606
1606
|
});
|
|
1607
1607
|
|
|
1608
|
-
// ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
|
|
1608
|
+
// ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js
|
|
1609
1609
|
var init_stats = __esm({
|
|
1610
|
-
"../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
|
|
1610
|
+
"../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
|
|
1611
1611
|
init_stat();
|
|
1612
1612
|
}
|
|
1613
1613
|
});
|
|
1614
1614
|
|
|
1615
|
-
// ../../node_modules/@probe.gl/stats/dist/esm/index.js
|
|
1615
|
+
// ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js
|
|
1616
1616
|
var init_esm = __esm({
|
|
1617
|
-
"../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
|
|
1617
|
+
"../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js"() {
|
|
1618
1618
|
init_stats();
|
|
1619
1619
|
init_stat();
|
|
1620
1620
|
init_hi_res_timestamp2();
|
|
@@ -7060,7 +7060,7 @@
|
|
|
7060
7060
|
var VERSION6;
|
|
7061
7061
|
var init_version4 = __esm({
|
|
7062
7062
|
"../textures/src/lib/utils/version.ts"() {
|
|
7063
|
-
VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
7063
|
+
VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
7064
7064
|
}
|
|
7065
7065
|
});
|
|
7066
7066
|
|
|
@@ -7131,7 +7131,7 @@
|
|
|
7131
7131
|
var init_basis_module_loader = __esm({
|
|
7132
7132
|
"../textures/src/lib/parsers/basis-module-loader.ts"() {
|
|
7133
7133
|
init_src();
|
|
7134
|
-
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
7134
|
+
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
7135
7135
|
BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION7}/dist/libs/basis_encoder.wasm`;
|
|
7136
7136
|
BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION7}/dist/libs/basis_encoder.js`;
|
|
7137
7137
|
}
|
|
@@ -7532,7 +7532,7 @@
|
|
|
7532
7532
|
const basisFile = new BasisFile(new Uint8Array(data));
|
|
7533
7533
|
try {
|
|
7534
7534
|
if (!basisFile.startTranscoding()) {
|
|
7535
|
-
|
|
7535
|
+
throw new Error("Failed to start basis transcoding");
|
|
7536
7536
|
}
|
|
7537
7537
|
const imageCount = basisFile.getNumImages();
|
|
7538
7538
|
const images = [];
|
|
@@ -7558,22 +7558,22 @@
|
|
|
7558
7558
|
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
7559
7559
|
const decodedData = new Uint8Array(decodedSize);
|
|
7560
7560
|
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
7561
|
-
|
|
7561
|
+
throw new Error("failed to start Basis transcoding");
|
|
7562
7562
|
}
|
|
7563
7563
|
return {
|
|
7564
7564
|
width,
|
|
7565
7565
|
height,
|
|
7566
7566
|
data: decodedData,
|
|
7567
7567
|
compressed,
|
|
7568
|
-
|
|
7569
|
-
|
|
7568
|
+
format,
|
|
7569
|
+
hasAlpha
|
|
7570
7570
|
};
|
|
7571
7571
|
}
|
|
7572
7572
|
function parseKTX2File(KTX2File, data, options) {
|
|
7573
7573
|
const ktx2File = new KTX2File(new Uint8Array(data));
|
|
7574
7574
|
try {
|
|
7575
7575
|
if (!ktx2File.startTranscoding()) {
|
|
7576
|
-
|
|
7576
|
+
throw new Error("failed to start KTX2 transcoding");
|
|
7577
7577
|
}
|
|
7578
7578
|
const levelsCount = ktx2File.getLevels();
|
|
7579
7579
|
const levels = [];
|
|
@@ -7581,7 +7581,7 @@
|
|
|
7581
7581
|
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
7582
7582
|
break;
|
|
7583
7583
|
}
|
|
7584
|
-
return levels;
|
|
7584
|
+
return [levels];
|
|
7585
7585
|
} finally {
|
|
7586
7586
|
ktx2File.close();
|
|
7587
7587
|
ktx2File.delete();
|
|
@@ -7593,14 +7593,14 @@
|
|
|
7593
7593
|
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
7594
7594
|
const decodedData = new Uint8Array(decodedSize);
|
|
7595
7595
|
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
7596
|
-
|
|
7596
|
+
throw new Error("Failed to transcode KTX2 image");
|
|
7597
7597
|
}
|
|
7598
7598
|
return {
|
|
7599
7599
|
width,
|
|
7600
7600
|
height,
|
|
7601
7601
|
data: decodedData,
|
|
7602
7602
|
compressed,
|
|
7603
|
-
alphaFlag,
|
|
7603
|
+
hasAlpha: alphaFlag,
|
|
7604
7604
|
format
|
|
7605
7605
|
};
|
|
7606
7606
|
}
|
|
@@ -8073,7 +8073,7 @@
|
|
|
8073
8073
|
containerFormat: "ktx2",
|
|
8074
8074
|
module: "encoder"
|
|
8075
8075
|
};
|
|
8076
|
-
return await parseBasis(arrayBuffer, options);
|
|
8076
|
+
return (await parseBasis(arrayBuffer, options))[0];
|
|
8077
8077
|
}
|
|
8078
8078
|
return parseCompressedTexture(arrayBuffer);
|
|
8079
8079
|
}
|
|
@@ -8857,7 +8857,10 @@
|
|
|
8857
8857
|
tile.content.texture = await parse(arrayBuffer2, loader, options2);
|
|
8858
8858
|
}
|
|
8859
8859
|
} else if (loader === CompressedTextureLoader || loader === BasisLoader) {
|
|
8860
|
-
|
|
8860
|
+
let texture = await load(arrayBuffer2, loader, tile.textureLoaderOptions);
|
|
8861
|
+
if (loader === BasisLoader) {
|
|
8862
|
+
texture = texture[0];
|
|
8863
|
+
}
|
|
8861
8864
|
tile.content.texture = {
|
|
8862
8865
|
compressed: true,
|
|
8863
8866
|
mipmaps: false,
|
|
@@ -9216,7 +9219,7 @@
|
|
|
9216
9219
|
var init_i3s_content_loader = __esm({
|
|
9217
9220
|
"src/i3s-content-loader.ts"() {
|
|
9218
9221
|
init_parse_i3s_tile_content();
|
|
9219
|
-
VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
9222
|
+
VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
9220
9223
|
I3SContentLoader = {
|
|
9221
9224
|
name: "I3S Content (Indexed Scene Layers)",
|
|
9222
9225
|
id: "i3s-content",
|
|
@@ -10325,7 +10328,7 @@
|
|
|
10325
10328
|
var init_i3s_building_scene_layer_loader = __esm({
|
|
10326
10329
|
"src/i3s-building-scene-layer-loader.ts"() {
|
|
10327
10330
|
init_parse_i3s_building_scene_layer();
|
|
10328
|
-
VERSION12 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
10331
|
+
VERSION12 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
10329
10332
|
I3SBuildingSceneLayerLoader = {
|
|
10330
10333
|
name: "I3S Building Scene Layer",
|
|
10331
10334
|
id: "i3s-building-scene-layer",
|
|
@@ -1,177 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const parse_i3s_attribute_1 = require("./lib/parsers/parse-i3s-attribute");
|
|
6
|
-
const url_utils_1 = require("./lib/utils/url-utils");
|
|
7
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
9
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
1
|
+
import { load } from '@loaders.gl/core';
|
|
2
|
+
import { parseI3STileAttribute } from './lib/parsers/parse-i3s-attribute';
|
|
3
|
+
import { getUrlWithToken } from './lib/utils/url-utils';
|
|
4
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
|
|
10
5
|
const EMPTY_VALUE = '';
|
|
11
6
|
const REJECTED_STATUS = 'rejected';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
extensions: ['bin'],
|
|
23
|
-
options: {},
|
|
24
|
-
binary: true
|
|
7
|
+
export const I3SAttributeLoader = {
|
|
8
|
+
name: 'I3S Attribute',
|
|
9
|
+
id: 'i3s-attribute',
|
|
10
|
+
module: 'i3s',
|
|
11
|
+
version: VERSION,
|
|
12
|
+
mimeTypes: ['application/binary'],
|
|
13
|
+
parse,
|
|
14
|
+
extensions: ['bin'],
|
|
15
|
+
options: {},
|
|
16
|
+
binary: true
|
|
25
17
|
};
|
|
18
|
+
|
|
26
19
|
async function parse(data, options) {
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
data = parseI3STileAttribute(data, options);
|
|
21
|
+
return data;
|
|
29
22
|
}
|
|
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
|
-
|
|
23
|
+
|
|
24
|
+
export async function loadFeatureAttributes(tile, featureId, options = {}) {
|
|
25
|
+
const {
|
|
26
|
+
attributeStorageInfo,
|
|
27
|
+
attributeUrls,
|
|
28
|
+
tilesetFields
|
|
29
|
+
} = getAttributesData(tile);
|
|
30
|
+
|
|
31
|
+
if (!attributeStorageInfo || !attributeUrls || !featureId) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let attributes = [];
|
|
36
|
+
const attributeLoadPromises = [];
|
|
37
|
+
|
|
38
|
+
for (let index = 0; index < attributeStorageInfo.length; index++) {
|
|
39
|
+
var _options$i3s;
|
|
40
|
+
|
|
41
|
+
const url = getUrlWithToken(attributeUrls[index], (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
42
|
+
const attributeName = attributeStorageInfo[index].name;
|
|
43
|
+
const attributeType = getAttributeValueType(attributeStorageInfo[index]);
|
|
44
|
+
const loadOptions = { ...options,
|
|
45
|
+
attributeName,
|
|
46
|
+
attributeType
|
|
47
|
+
};
|
|
48
|
+
const promise = load(url, I3SAttributeLoader, loadOptions);
|
|
49
|
+
attributeLoadPromises.push(promise);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
attributes = await Promise.allSettled(attributeLoadPromises);
|
|
54
|
+
} catch (error) {}
|
|
55
|
+
|
|
56
|
+
if (!attributes.length) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields);
|
|
64
61
|
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Gets attributes data from tile.
|
|
68
|
-
* @param tile
|
|
69
|
-
* @returns
|
|
70
|
-
*/
|
|
62
|
+
|
|
71
63
|
function getAttributesData(tile) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
var _tile$tileset, _tile$tileset$tileset, _tile$header, _tile$tileset2, _tile$tileset2$tilese;
|
|
65
|
+
|
|
66
|
+
const 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;
|
|
67
|
+
const attributeUrls = (_tile$header = tile.header) === null || _tile$header === void 0 ? void 0 : _tile$header.attributeUrls;
|
|
68
|
+
const 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) || [];
|
|
69
|
+
return {
|
|
70
|
+
attributeStorageInfo,
|
|
71
|
+
attributeUrls,
|
|
72
|
+
tilesetFields
|
|
73
|
+
};
|
|
76
74
|
}
|
|
77
|
-
|
|
78
|
-
* Get attribute value type based on property names
|
|
79
|
-
* @param {Object} attribute
|
|
80
|
-
* @returns {String}
|
|
81
|
-
*/
|
|
75
|
+
|
|
82
76
|
function getAttributeValueType(attribute) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
77
|
+
if (attribute.hasOwnProperty('objectIds')) {
|
|
78
|
+
return 'Oid32';
|
|
79
|
+
} else if (attribute.hasOwnProperty('attributeValues')) {
|
|
80
|
+
return attribute.attributeValues.valueType;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return '';
|
|
90
84
|
}
|
|
91
|
-
|
|
92
|
-
* Find in attributeStorageInfo attribute name responsible for feature ids list.
|
|
93
|
-
* @param attributeStorageInfo
|
|
94
|
-
* @returns Feature ids attribute name
|
|
95
|
-
*/
|
|
85
|
+
|
|
96
86
|
function getFeatureIdsAttributeName(attributeStorageInfo) {
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
const objectIdsAttribute = attributeStorageInfo.find(attribute => attribute.name.includes('OBJECTID'));
|
|
88
|
+
return objectIdsAttribute === null || objectIdsAttribute === void 0 ? void 0 : objectIdsAttribute.name;
|
|
99
89
|
}
|
|
100
|
-
|
|
101
|
-
* Generates mapping featureId to feature attributes
|
|
102
|
-
* @param {Array} attributes
|
|
103
|
-
* @param {Object} attributeStorageInfo
|
|
104
|
-
* @param {number} featureId
|
|
105
|
-
* @returns {Object}
|
|
106
|
-
*/
|
|
90
|
+
|
|
107
91
|
function generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
92
|
+
const objectIdsAttributeName = getFeatureIdsAttributeName(attributeStorageInfo);
|
|
93
|
+
const objectIds = attributes.find(attribute => attribute.value[objectIdsAttributeName]);
|
|
94
|
+
|
|
95
|
+
if (!objectIds) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const attributeIndex = objectIds.value[objectIdsAttributeName].indexOf(featureId);
|
|
100
|
+
|
|
101
|
+
if (attributeIndex < 0) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return getFeatureAttributesByIndex(attributes, attributeIndex, attributeStorageInfo, tilesetFields);
|
|
118
106
|
}
|
|
119
|
-
|
|
120
|
-
* Generates attribute object for feature mapping by feature id
|
|
121
|
-
* @param {Array} attributes
|
|
122
|
-
* @param {Number} featureIdIndex
|
|
123
|
-
* @param {Object} attributeStorageInfo
|
|
124
|
-
* @returns {Object}
|
|
125
|
-
*/
|
|
107
|
+
|
|
126
108
|
function getFeatureAttributesByIndex(attributes, featureIdIndex, attributeStorageInfo, tilesetFields) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
109
|
+
const attributesObject = {};
|
|
110
|
+
|
|
111
|
+
for (let index = 0; index < attributeStorageInfo.length; index++) {
|
|
112
|
+
const attributeName = attributeStorageInfo[index].name;
|
|
113
|
+
const codedValues = getAttributeCodedValues(attributeName, tilesetFields);
|
|
114
|
+
const attribute = getAttributeByIndexAndAttributeName(attributes, index, attributeName);
|
|
115
|
+
attributesObject[attributeName] = formatAttributeValue(attribute, featureIdIndex, codedValues);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return attributesObject;
|
|
135
119
|
}
|
|
136
|
-
|
|
137
|
-
* Get coded values list from tileset.
|
|
138
|
-
* @param attributeName
|
|
139
|
-
* @param tilesetFields
|
|
140
|
-
*/
|
|
120
|
+
|
|
141
121
|
function getAttributeCodedValues(attributeName, tilesetFields) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
122
|
+
var _attributeField$domai;
|
|
123
|
+
|
|
124
|
+
const attributeField = tilesetFields.find(field => field.name === attributeName || field.alias === attributeName);
|
|
125
|
+
return (attributeField === null || attributeField === void 0 ? void 0 : (_attributeField$domai = attributeField.domain) === null || _attributeField$domai === void 0 ? void 0 : _attributeField$domai.codedValues) || [];
|
|
145
126
|
}
|
|
146
|
-
|
|
147
|
-
* Return attribute value if it presents in atrributes list
|
|
148
|
-
* @param {array} attributes
|
|
149
|
-
* @param {number} index
|
|
150
|
-
* @param {string} attributesName
|
|
151
|
-
*/
|
|
127
|
+
|
|
152
128
|
function getAttributeByIndexAndAttributeName(attributes, index, attributesName) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
129
|
+
const attributeObject = attributes[index];
|
|
130
|
+
|
|
131
|
+
if (attributeObject.status === REJECTED_STATUS) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return attributeObject.value[attributesName];
|
|
158
136
|
}
|
|
159
|
-
|
|
160
|
-
* Do formatting of attribute values or return empty string.
|
|
161
|
-
* @param {Array} attribute
|
|
162
|
-
* @param {Number} featureIdIndex
|
|
163
|
-
* @returns {String}
|
|
164
|
-
*/
|
|
137
|
+
|
|
165
138
|
function formatAttributeValue(attribute, featureIdIndex, codedValues) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
139
|
+
let value = EMPTY_VALUE;
|
|
140
|
+
|
|
141
|
+
if (attribute && featureIdIndex in attribute) {
|
|
142
|
+
value = String(attribute[featureIdIndex]).replace(/\u0000|NaN/g, '').trim();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (codedValues.length) {
|
|
146
|
+
const codeValue = codedValues.find(codedValue => codedValue.code === Number(value));
|
|
147
|
+
value = (codeValue === null || codeValue === void 0 ? void 0 : codeValue.name) || EMPTY_VALUE;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return value;
|
|
177
151
|
}
|
|
152
|
+
//# sourceMappingURL=i3s-attribute-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i3s-attribute-loader.ts"],"names":["load","parseI3STileAttribute","getUrlWithToken","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,SAAQA,IAAR,QAAmB,kBAAnB;AACA,SAAQC,qBAAR,QAAoC,mCAApC;AACA,SAAQC,eAAR,QAA8B,uBAA9B;AAIA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AACA,MAAMC,WAAW,GAAG,EAApB;AACA,MAAMC,eAAe,GAAG,UAAxB;AAIA,OAAO,MAAMC,kBAAoC,GAAG;AAClDC,EAAAA,IAAI,EAAE,eAD4C;AAElDC,EAAAA,EAAE,EAAE,eAF8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,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,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
name: 'I3S Building Scene Layer',
|
|
13
|
-
id: 'i3s-building-scene-layer',
|
|
14
|
-
module: 'i3s',
|
|
15
|
-
version: VERSION,
|
|
16
|
-
mimeTypes: ['application/json'],
|
|
17
|
-
parse,
|
|
18
|
-
extensions: ['json'],
|
|
19
|
-
options: {}
|
|
1
|
+
import { parseBuildingSceneLayer } from './lib/parsers/parse-i3s-building-scene-layer';
|
|
2
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'beta';
|
|
3
|
+
export const I3SBuildingSceneLayerLoader = {
|
|
4
|
+
name: 'I3S Building Scene Layer',
|
|
5
|
+
id: 'i3s-building-scene-layer',
|
|
6
|
+
module: 'i3s',
|
|
7
|
+
version: VERSION,
|
|
8
|
+
mimeTypes: ['application/json'],
|
|
9
|
+
parse,
|
|
10
|
+
extensions: ['json'],
|
|
11
|
+
options: {}
|
|
20
12
|
};
|
|
13
|
+
|
|
21
14
|
async function parse(data, options, context) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
if (!(context !== null && context !== void 0 && context.url)) {
|
|
16
|
+
throw new Error('Url is not provided');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return parseBuildingSceneLayer(data, context.url);
|
|
26
20
|
}
|
|
21
|
+
//# sourceMappingURL=i3s-building-scene-layer-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i3s-building-scene-layer-loader.ts"],"names":["parseBuildingSceneLayer","VERSION","I3SBuildingSceneLayerLoader","name","id","module","version","mimeTypes","parse","extensions","options","data","context","url","Error"],"mappings":"AAGA,SAAQA,uBAAR,QAAsC,8CAAtC;AAKA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,MAAnE;AAIA,OAAO,MAAMC,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,KAN2D;AAO3DC,EAAAA,UAAU,EAAE,CAAC,MAAD,CAP+C;AAQ3DC,EAAAA,OAAO,EAAE;AARkD,CAAtD;;AAWP,eAAeF,KAAf,CACEG,IADF,EAEED,OAFF,EAGEE,OAHF,EAIsC;AACpC,MAAI,EAACA,OAAD,aAACA,OAAD,eAACA,OAAO,CAAEC,GAAV,CAAJ,EAAmB;AACjB,UAAM,IAAIC,KAAJ,CAAU,qBAAV,CAAN;AACD;;AAED,SAAOd,uBAAuB,CAACW,IAAD,EAAOC,OAAO,CAACC,GAAf,CAA9B;AACD","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,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
worker: true,
|
|
16
|
-
version: VERSION,
|
|
17
|
-
mimeTypes: ['application/octet-stream'],
|
|
18
|
-
parse,
|
|
19
|
-
extensions: ['bin'],
|
|
20
|
-
options: {
|
|
21
|
-
'i3s-content': {}
|
|
22
|
-
}
|
|
1
|
+
import { parseI3STileContent } from './lib/parsers/parse-i3s-tile-content';
|
|
2
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'beta';
|
|
3
|
+
export const I3SContentLoader = {
|
|
4
|
+
name: 'I3S Content (Indexed Scene Layers)',
|
|
5
|
+
id: 'i3s-content',
|
|
6
|
+
module: 'i3s',
|
|
7
|
+
worker: true,
|
|
8
|
+
version: VERSION,
|
|
9
|
+
mimeTypes: ['application/octet-stream'],
|
|
10
|
+
parse,
|
|
11
|
+
extensions: ['bin'],
|
|
12
|
+
options: {
|
|
13
|
+
'i3s-content': {}
|
|
14
|
+
}
|
|
23
15
|
};
|
|
16
|
+
|
|
24
17
|
async function parse(data, options, context) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
const {
|
|
19
|
+
tile,
|
|
20
|
+
tileset
|
|
21
|
+
} = (options === null || options === void 0 ? void 0 : options.i3s) || {};
|
|
22
|
+
await parseI3STileContent(data, tile, tileset, options, context);
|
|
23
|
+
return tile.content;
|
|
28
24
|
}
|
|
25
|
+
//# sourceMappingURL=i3s-content-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i3s-content-loader.ts"],"names":["parseI3STileContent","VERSION","I3SContentLoader","name","id","module","worker","version","mimeTypes","parse","extensions","options","data","context","tile","tileset","i3s","content"],"mappings":"AACA,SAAQA,mBAAR,QAAkC,sCAAlC;AAKA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,MAAnE;AAIA,OAAO,MAAMC,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,KAPgD;AAQhDC,EAAAA,UAAU,EAAE,CAAC,KAAD,CARoC;AAShDC,EAAAA,OAAO,EAAE;AACP,mBAAe;AADR;AATuC,CAA3C;;AAcP,eAAeF,KAAf,CAAqBG,IAArB,EAA2BD,OAA3B,EAAoDE,OAApD,EAA6E;AAC3E,QAAM;AAACC,IAAAA,IAAD;AAAOC,IAAAA;AAAP,MAAkB,CAAAJ,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEK,GAAT,KAAgB,EAAxC;AACA,QAAMhB,mBAAmB,CAACY,IAAD,EAAOE,IAAP,EAAaC,OAAb,EAAsBJ,OAAtB,EAA+BE,OAA/B,CAAzB;AACA,SAAOC,IAAI,CAACG,OAAZ;AACD","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"}
|