@loaders.gl/i3s 3.4.10 → 3.4.12

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.
Files changed (43) hide show
  1. package/dist/es5/arcgis-webscene-loader.js +1 -1
  2. package/dist/es5/i3s-attribute-loader.js +1 -1
  3. package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
  4. package/dist/es5/i3s-content-loader.js +1 -1
  5. package/dist/es5/i3s-loader.js +1 -1
  6. package/dist/es5/i3s-node-page-loader.js +1 -1
  7. package/dist/es5/i3s-slpk-loader.js +1 -1
  8. package/dist/esm/arcgis-webscene-loader.js +1 -1
  9. package/dist/esm/i3s-attribute-loader.js +1 -1
  10. package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
  11. package/dist/esm/i3s-content-loader.js +1 -1
  12. package/dist/esm/i3s-loader.js +1 -1
  13. package/dist/esm/i3s-node-page-loader.js +1 -1
  14. package/dist/esm/i3s-slpk-loader.js +1 -1
  15. package/dist/i3s-content-nodejs-worker.js +2 -2
  16. package/dist/i3s-content-worker.js +8 -8
  17. package/package.json +9 -9
  18. package/dist/arcgis-webscene-loader.js +0 -28
  19. package/dist/bundle.js +0 -5
  20. package/dist/i3s-attribute-loader.js +0 -178
  21. package/dist/i3s-building-scene-layer-loader.js +0 -26
  22. package/dist/i3s-content-loader.js +0 -33
  23. package/dist/i3s-loader.js +0 -102
  24. package/dist/i3s-node-page-loader.js +0 -26
  25. package/dist/i3s-slpk-loader.js +0 -20
  26. package/dist/index.js +0 -18
  27. package/dist/lib/helpers/i3s-nodepages-tiles.js +0 -242
  28. package/dist/lib/parsers/constants.js +0 -89
  29. package/dist/lib/parsers/parse-arcgis-webscene.js +0 -87
  30. package/dist/lib/parsers/parse-i3s-attribute.js +0 -98
  31. package/dist/lib/parsers/parse-i3s-building-scene-layer.js +0 -46
  32. package/dist/lib/parsers/parse-i3s-tile-content.js +0 -494
  33. package/dist/lib/parsers/parse-i3s.js +0 -95
  34. package/dist/lib/parsers/parse-slpk/parse-slpk.js +0 -50
  35. package/dist/lib/parsers/parse-slpk/slpk-archieve.js +0 -79
  36. package/dist/lib/parsers/parse-zip/cd-file-header.js +0 -48
  37. package/dist/lib/parsers/parse-zip/local-file-header.js +0 -28
  38. package/dist/lib/utils/convert-i3s-obb-to-mbs.js +0 -20
  39. package/dist/lib/utils/customizeColors.js +0 -89
  40. package/dist/lib/utils/url-utils.js +0 -44
  41. package/dist/types.js +0 -20
  42. package/dist/workers/i3s-content-nodejs-worker.js +0 -6
  43. package/dist/workers/i3s-content-worker.js +0 -5
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SLPKArchive = void 0;
7
- const worker_utils_1 = require("@loaders.gl/worker-utils");
8
- const md5_1 = __importDefault(require("md5"));
9
- const compression_1 = require("@loaders.gl/compression");
10
- const local_file_header_1 = require("../parse-zip/local-file-header");
11
- /**
12
- * Class for handling information about slpk file
13
- */
14
- class SLPKArchive {
15
- constructor(slpkArchiveBuffer, hashFile) {
16
- this.slpkArchive = new DataView(slpkArchiveBuffer);
17
- this.hashArray = this.parseHashFile(hashFile);
18
- }
19
- /**
20
- * Reads hash file from buffer and returns it in ready-to-use form
21
- * @param hashFile - bufer containing hash file
22
- * @returns Array containing file info
23
- */
24
- parseHashFile(hashFile) {
25
- const hashFileBuffer = Buffer.from(hashFile);
26
- const hashArray = [];
27
- for (let i = 0; i < hashFileBuffer.buffer.byteLength; i = i + 24) {
28
- const offsetBuffer = new DataView(hashFileBuffer.buffer.slice(hashFileBuffer.byteOffset + i + 16, hashFileBuffer.byteOffset + i + 24));
29
- const offset = offsetBuffer.getUint32(offsetBuffer.byteOffset, true);
30
- hashArray.push({
31
- hash: Buffer.from(hashFileBuffer.subarray(hashFileBuffer.byteOffset + i, hashFileBuffer.byteOffset + i + 16)),
32
- offset
33
- });
34
- }
35
- return hashArray;
36
- }
37
- /**
38
- * Returns file with the given path from slpk archive
39
- * @param path - path inside the slpk
40
- * @param mode - currently only raw mode supported
41
- * @returns buffer with ready to use file
42
- */
43
- async getFile(path, mode = 'raw') {
44
- if (mode === 'http') {
45
- throw new Error('http mode is not supported');
46
- }
47
- const fileToDecompress = this.getFileBytes(`${path}.gz`);
48
- if (fileToDecompress) {
49
- const decompressedData = await (0, worker_utils_1.processOnWorker)(compression_1.CompressionWorker, fileToDecompress, {
50
- compression: 'gzip',
51
- operation: 'decompress',
52
- _workerType: 'test',
53
- gzip: {}
54
- });
55
- return decompressedData;
56
- }
57
- const fileWithoutCompression = this.getFileBytes(path);
58
- if (fileWithoutCompression) {
59
- return Promise.resolve(Buffer.from(fileWithoutCompression));
60
- }
61
- throw new Error('No such file in the archieve');
62
- }
63
- /**
64
- * Trying to get raw file data by adress
65
- * @param path - path inside the archive
66
- * @returns buffer with the raw file data
67
- */
68
- getFileBytes(path) {
69
- const nameHash = Buffer.from((0, md5_1.default)(path), 'hex');
70
- const fileInfo = this.hashArray.find((val) => Buffer.compare(val.hash, nameHash) === 0);
71
- if (!fileInfo) {
72
- return undefined;
73
- }
74
- const localFileHeader = (0, local_file_header_1.parseZipLocalFileHeader)(this.slpkArchive.byteOffset + fileInfo?.offset, this.slpkArchive);
75
- const compressedFile = this.slpkArchive.buffer.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
76
- return compressedFile;
77
- }
78
- }
79
- exports.SLPKArchive = SLPKArchive;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseZipCDFileHeader = void 0;
4
- /**
5
- * Parses central directory file header of zip file
6
- * @param headerOffset - offset in the archive where header starts
7
- * @param buffer - buffer containing whole array
8
- * @returns Info from the header
9
- */
10
- const parseZipCDFileHeader = (headerOffset, buffer) => {
11
- const offsets = {
12
- CD_COMPRESSED_SIZE_OFFSET: 20,
13
- CD_UNCOMPRESSED_SIZE_OFFSET: 24,
14
- CD_FILE_NAME_LENGTH_OFFSET: 28,
15
- CD_EXTRA_FIELD_LENGTH_OFFSET: 30,
16
- CD_LOCAL_HEADER_OFFSET_OFFSET: 42,
17
- CD_FILE_NAME_OFFSET: 46
18
- };
19
- const compressedSize = buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET, true);
20
- const uncompressedSize = buffer.getUint32(headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET, true);
21
- const fileNameLength = buffer.getUint16(headerOffset + offsets.CD_FILE_NAME_LENGTH_OFFSET, true);
22
- const fileName = buffer.buffer.slice(headerOffset + offsets.CD_FILE_NAME_OFFSET, headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength);
23
- const extraOffset = headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength;
24
- const oldFormatOffset = buffer.getUint32(headerOffset + offsets.CD_LOCAL_HEADER_OFFSET_OFFSET, true);
25
- let fileDataOffset = oldFormatOffset;
26
- if (fileDataOffset === 0xffffffff) {
27
- let offsetInZip64Data = 4;
28
- // looking for info that might be also be in zip64 extra field
29
- if (compressedSize === 0xffffffff) {
30
- offsetInZip64Data += 8;
31
- }
32
- if (uncompressedSize === 0xffffffff) {
33
- offsetInZip64Data += 8;
34
- }
35
- // getUint32 needs to be replaced with getBigUint64 for archieves bigger than 2gb
36
- fileDataOffset = buffer.getUint32(extraOffset + offsetInZip64Data, true); // setting it to the one from zip64
37
- }
38
- const localHeaderOffset = fileDataOffset;
39
- return {
40
- compressedSize,
41
- uncompressedSize,
42
- fileNameLength,
43
- fileName,
44
- extraOffset,
45
- localHeaderOffset
46
- };
47
- };
48
- exports.parseZipCDFileHeader = parseZipCDFileHeader;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseZipLocalFileHeader = void 0;
4
- /**
5
- * Parses local file header of zip file
6
- * @param headerOffset - offset in the archive where header starts
7
- * @param buffer - buffer containing whole array
8
- * @returns Info from the header
9
- */
10
- const parseZipLocalFileHeader = (headerOffset, buffer) => {
11
- const offsets = {
12
- COMPRESSED_SIZE_OFFSET: 18,
13
- FILE_NAME_LENGTH_OFFSET: 26,
14
- EXTRA_FIELD_LENGTH_OFFSET: 28,
15
- FILE_NAME_OFFSET: 30
16
- };
17
- const fileNameLength = buffer.getUint16(headerOffset + offsets.FILE_NAME_LENGTH_OFFSET, true);
18
- const extraFieldLength = buffer.getUint16(headerOffset + offsets.EXTRA_FIELD_LENGTH_OFFSET, true);
19
- const fileDataOffset = headerOffset + offsets.FILE_NAME_OFFSET + fileNameLength + extraFieldLength;
20
- const compressedSize = buffer.getUint32(headerOffset + offsets.COMPRESSED_SIZE_OFFSET, true);
21
- return {
22
- fileNameLength,
23
- extraFieldLength,
24
- fileDataOffset,
25
- compressedSize
26
- };
27
- };
28
- exports.parseZipLocalFileHeader = parseZipLocalFileHeader;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertI3SObbToMbs = void 0;
4
- const culling_1 = require("@math.gl/culling");
5
- const geospatial_1 = require("@math.gl/geospatial");
6
- function convertI3SObbToMbs(obb) {
7
- const halfSize = obb.halfSize;
8
- const centerCartesian = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(obb.center);
9
- const sphere = new culling_1.BoundingSphere().fromCornerPoints([
10
- centerCartesian[0] - halfSize[0],
11
- centerCartesian[1] - halfSize[1],
12
- centerCartesian[2] - halfSize[2]
13
- ], [
14
- centerCartesian[0] + halfSize[0],
15
- centerCartesian[1] + halfSize[1],
16
- centerCartesian[2] + halfSize[2]
17
- ]);
18
- return [...obb.center, sphere.radius];
19
- }
20
- exports.convertI3SObbToMbs = convertI3SObbToMbs;
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.customizeColors = void 0;
4
- const core_1 = require("@loaders.gl/core");
5
- const i3s_attribute_loader_1 = require("../../i3s-attribute-loader");
6
- const url_utils_1 = require("../utils/url-utils");
7
- /**
8
- * Modify vertex colors array to visualize 3D objects in a attribute driven way
9
- * @param colors - vertex colors attribute
10
- * @param featureIds - feature Ids attribute
11
- * @param tileOptions - tile - related options
12
- * @param tilesetOptions - tileset-related options
13
- * @param options - loader options
14
- * @returns midified colors attribute
15
- */
16
- async function customizeColors(colors, featureIds, tileOptions, tilesetOptions, options) {
17
- if (!options?.i3s?.colorsByAttribute) {
18
- return colors;
19
- }
20
- const colorizeAttributeField = tilesetOptions.fields.find(({ name }) => name === options?.i3s?.colorsByAttribute?.attributeName);
21
- if (!colorizeAttributeField ||
22
- !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(colorizeAttributeField.type)) {
23
- return colors;
24
- }
25
- const colorizeAttributeData = await loadFeatureAttributeData(colorizeAttributeField.name, tileOptions, tilesetOptions, options);
26
- if (!colorizeAttributeData) {
27
- return colors;
28
- }
29
- const objectIdField = tilesetOptions.fields.find(({ type }) => type === 'esriFieldTypeOID');
30
- if (!objectIdField) {
31
- return colors;
32
- }
33
- const objectIdAttributeData = await loadFeatureAttributeData(objectIdField.name, tileOptions, tilesetOptions, options);
34
- if (!objectIdAttributeData) {
35
- return colors;
36
- }
37
- const attributeValuesMap = {};
38
- for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {
39
- attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(colorizeAttributeData[colorizeAttributeField.name][i], options);
40
- }
41
- for (let i = 0; i < featureIds.value.length; i++) {
42
- const color = attributeValuesMap[featureIds.value[i]];
43
- if (!color) {
44
- continue; // eslint-disable-line no-continue
45
- }
46
- colors.value.set(color, i * 4);
47
- }
48
- return colors;
49
- }
50
- exports.customizeColors = customizeColors;
51
- /**
52
- * Calculate rgba color from the attribute value
53
- * @param attributeValue - value of the attribute
54
- * @param options - loader options
55
- * @returns - color array for a specific attribute value
56
- */
57
- function calculateColorForAttribute(attributeValue, options) {
58
- if (!options?.i3s?.colorsByAttribute) {
59
- return [255, 255, 255, 255];
60
- }
61
- const { minValue, maxValue, minColor, maxColor } = options.i3s.colorsByAttribute;
62
- const rate = (attributeValue - minValue) / (maxValue - minValue);
63
- const color = [255, 255, 255, 255];
64
- for (let i = 0; i < minColor.length; i++) {
65
- color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);
66
- }
67
- return color;
68
- }
69
- /**
70
- * Load feature attribute data from the ArcGIS rest service
71
- * @param attributeName - attribute name
72
- * @param tileOptions - tile-related options
73
- * @param tilesetOptions - tileset-related options
74
- * @param options - loader options
75
- * @returns - Array-like list of the attribute values
76
- */
77
- async function loadFeatureAttributeData(attributeName, { attributeUrls }, { attributeStorageInfo }, options) {
78
- const attributeIndex = attributeStorageInfo.findIndex(({ name }) => attributeName === name);
79
- if (attributeIndex === -1) {
80
- return null;
81
- }
82
- const objectIdAttributeUrl = (0, url_utils_1.getUrlWithToken)(attributeUrls[attributeIndex], options?.i3s?.token);
83
- const attributeType = (0, i3s_attribute_loader_1.getAttributeValueType)(attributeStorageInfo[attributeIndex]);
84
- const objectIdAttributeData = await (0, core_1.load)(objectIdAttributeUrl, i3s_attribute_loader_1.I3SAttributeLoader, {
85
- attributeName,
86
- attributeType
87
- });
88
- return objectIdAttributeData;
89
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateTilesetAttributeUrls = exports.generateTileAttributeUrls = exports.getUrlWithToken = void 0;
4
- /**
5
- * Generates url with token if it is exists.
6
- * @param url
7
- * @param token
8
- * @returns
9
- */
10
- function getUrlWithToken(url, token = null) {
11
- return token ? `${url}?token=${token}` : url;
12
- }
13
- exports.getUrlWithToken = getUrlWithToken;
14
- /**
15
- * Generates attribute urls for tile.
16
- * @param tile
17
- * @returns list of attribute urls
18
- */
19
- function generateTileAttributeUrls(url, tile) {
20
- const { attributeData = [] } = tile;
21
- const attributeUrls = [];
22
- for (let index = 0; index < attributeData.length; index++) {
23
- const attributeUrl = attributeData[index].href.replace('./', '');
24
- attributeUrls.push(`${url}/${attributeUrl}`);
25
- }
26
- return attributeUrls;
27
- }
28
- exports.generateTileAttributeUrls = generateTileAttributeUrls;
29
- /**
30
- * Generates attribute urls for tileset based on tileset and resource
31
- * @param {Object} tileset
32
- * @param {number} resource
33
- * @returns {Array}
34
- */
35
- function generateTilesetAttributeUrls(tileset, resource) {
36
- const attributeUrls = [];
37
- const { attributeStorageInfo, url } = tileset;
38
- for (let index = 0; index < attributeStorageInfo.length; index++) {
39
- const fileName = attributeStorageInfo[index].key;
40
- attributeUrls.push(`${url}/nodes/${resource}/attributes/${fileName}/0`);
41
- }
42
- return attributeUrls;
43
- }
44
- exports.generateTilesetAttributeUrls = generateTilesetAttributeUrls;
package/dist/types.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HeaderAttributeProperty = exports.DATA_TYPE = void 0;
4
- var DATA_TYPE;
5
- (function (DATA_TYPE) {
6
- DATA_TYPE["UInt8"] = "UInt8";
7
- DATA_TYPE["UInt16"] = "UInt16";
8
- DATA_TYPE["UInt32"] = "UInt32";
9
- DATA_TYPE["UInt64"] = "UInt64";
10
- DATA_TYPE["Int16"] = "Int16";
11
- DATA_TYPE["Int32"] = "Int32";
12
- DATA_TYPE["Int64"] = "Int64";
13
- DATA_TYPE["Float32"] = "Float32";
14
- DATA_TYPE["Float64"] = "Float64";
15
- })(DATA_TYPE = exports.DATA_TYPE || (exports.DATA_TYPE = {}));
16
- var HeaderAttributeProperty;
17
- (function (HeaderAttributeProperty) {
18
- HeaderAttributeProperty["vertexCount"] = "vertexCount";
19
- HeaderAttributeProperty["featureCount"] = "featureCount";
20
- })(HeaderAttributeProperty = exports.HeaderAttributeProperty || (exports.HeaderAttributeProperty = {}));
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const loader_utils_1 = require("@loaders.gl/loader-utils");
4
- require("@loaders.gl/polyfills");
5
- const i3s_content_loader_1 = require("../i3s-content-loader");
6
- (0, loader_utils_1.createLoaderWorker)(i3s_content_loader_1.I3SContentLoader);
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const loader_utils_1 = require("@loaders.gl/loader-utils");
4
- const i3s_content_loader_1 = require("../i3s-content-loader");
5
- (0, loader_utils_1.createLoaderWorker)(i3s_content_loader_1.I3SContentLoader);