@loaders.gl/tile-converter 4.0.0-alpha.21 → 4.0.0-alpha.23

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 (81) hide show
  1. package/dist/constants.d.ts +0 -2
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +1 -3
  4. package/dist/converter.min.js +114 -114
  5. package/dist/dist.min.js +2409 -1161
  6. package/dist/es5/constants.js +1 -5
  7. package/dist/es5/constants.js.map +1 -1
  8. package/dist/es5/deps-installer/deps-installer.js +1 -1
  9. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +26 -11
  10. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  11. package/dist/es5/i3s-converter/helpers/feature-attributes.js +14 -12
  12. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
  13. package/dist/es5/i3s-converter/helpers/geometry-converter.js +61 -10
  14. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  15. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +70 -4
  16. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/node-index-document.js +3 -2
  18. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +1 -2
  20. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  21. package/dist/es5/i3s-converter/i3s-converter.js +70 -58
  22. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  23. package/dist/es5/i3s-server/controllers/slpk-controller.js +2 -2
  24. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  25. package/dist/es5/pgm-loader.js +1 -1
  26. package/dist/es5/slpk-extractor/slpk-extractor.js +1 -1
  27. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
  28. package/dist/esm/constants.js +0 -2
  29. package/dist/esm/constants.js.map +1 -1
  30. package/dist/esm/deps-installer/deps-installer.js +1 -1
  31. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +21 -6
  32. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  33. package/dist/esm/i3s-converter/helpers/feature-attributes.js +6 -4
  34. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
  35. package/dist/esm/i3s-converter/helpers/geometry-converter.js +59 -8
  36. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  37. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js +33 -4
  38. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
  39. package/dist/esm/i3s-converter/helpers/node-index-document.js +2 -1
  40. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
  41. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +1 -1
  42. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  43. package/dist/esm/i3s-converter/i3s-converter.js +27 -22
  44. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  45. package/dist/esm/i3s-server/bin/i3s-server.min.js +71 -71
  46. package/dist/esm/i3s-server/controllers/slpk-controller.js +1 -1
  47. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  48. package/dist/esm/pgm-loader.js +1 -1
  49. package/dist/esm/slpk-extractor/slpk-extractor.js +2 -1
  50. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
  51. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  52. package/dist/i3s-converter/helpers/batch-ids-extensions.js +37 -16
  53. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  54. package/dist/i3s-converter/helpers/feature-attributes.js +6 -4
  55. package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -2
  56. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  57. package/dist/i3s-converter/helpers/geometry-converter.js +93 -12
  58. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +15 -0
  59. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -1
  60. package/dist/i3s-converter/helpers/load-3d-tiles.js +51 -5
  61. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  62. package/dist/i3s-converter/helpers/node-index-document.js +4 -1
  63. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +2 -2
  64. package/dist/i3s-converter/i3s-converter.d.ts +1 -1
  65. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  66. package/dist/i3s-converter/i3s-converter.js +38 -17
  67. package/dist/i3s-server/controllers/slpk-controller.js +2 -2
  68. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
  69. package/dist/slpk-extractor/slpk-extractor.js +2 -1
  70. package/dist/slpk-extractor.min.js +38 -38
  71. package/package.json +14 -14
  72. package/src/constants.ts +0 -3
  73. package/src/i3s-converter/helpers/batch-ids-extensions.ts +53 -14
  74. package/src/i3s-converter/helpers/feature-attributes.ts +8 -6
  75. package/src/i3s-converter/helpers/geometry-converter.ts +135 -12
  76. package/src/i3s-converter/helpers/load-3d-tiles.ts +61 -5
  77. package/src/i3s-converter/helpers/node-index-document.ts +5 -1
  78. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -1
  79. package/src/i3s-converter/i3s-converter.ts +54 -22
  80. package/src/i3s-server/controllers/slpk-controller.ts +1 -1
  81. package/src/slpk-extractor/slpk-extractor.ts +2 -1
@@ -178,7 +178,7 @@ class I3SConverter {
178
178
  if (preloadOptions.headers) {
179
179
  this.loadOptions.fetch = { headers: preloadOptions.headers };
180
180
  }
181
- this.sourceTileset = await (0, core_1.load)(tilesetUrl, this.Loader, this.loadOptions);
181
+ this.sourceTileset = await (0, load_3d_tiles_1.loadFromArchive)(tilesetUrl, this.Loader, this.loadOptions);
182
182
  const preprocessResult = await this.preprocessConversion();
183
183
  if (preprocessResult) {
184
184
  await this._createAndSaveTileset(outputPath, tilesetName);
@@ -253,7 +253,8 @@ class I3SConverter {
253
253
  * @returns - nothing
254
254
  */
255
255
  async analyzeTile(sourceTile, traversalProps) {
256
- if (sourceTile.type === 'json') {
256
+ const isTileset = (0, load_3d_tiles_1.isNestedTileset)(sourceTile);
257
+ if (isTileset) {
257
258
  await (0, load_3d_tiles_1.loadNestedTileset)(this.sourceTileset, sourceTile, this.loadOptions);
258
259
  return null;
259
260
  }
@@ -417,8 +418,9 @@ class I3SConverter {
417
418
  * @returns - traversal properties for the child tiles
418
419
  */
419
420
  async convertTile(sourceTile, traversalProps) {
420
- if (sourceTile.type === 'json' || sourceTile.type === 'empty') {
421
- if (sourceTile.type === 'json') {
421
+ const isTileset = (0, load_3d_tiles_1.isNestedTileset)(sourceTile);
422
+ if (isTileset || sourceTile.type === 'empty') {
423
+ if (isTileset) {
422
424
  if (sourceTile.id) {
423
425
  console.log(`[load]: ${sourceTile.id}`); // eslint-disable-line
424
426
  }
@@ -479,7 +481,14 @@ class I3SConverter {
479
481
  const sourceBoundingVolume = (0, tiles_1.createBoundingVolume)(sourceTile.boundingVolume, transformationMatrix, null);
480
482
  let boundingVolumes = (0, coordinate_converter_1.createBoundingVolumes)(sourceBoundingVolume, this.geoidHeightModel);
481
483
  const propertyTable = (0, geometry_converter_1.getPropertyTable)(tileContent, this.options.metadataClass);
482
- if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {
484
+ if (propertyTable) {
485
+ /*
486
+ Call the convertion procedure even if the node attributes have been already created.
487
+ We will append new attributes only in case the property table is updated.
488
+ According to ver 1.9 (see https://github.com/Esri/i3s-spec/blob/master/docs/1.9/attributeStorageInfo.cmn.md):
489
+ "The attributeStorageInfo object describes the structure of the binary attribute data resource of a layer, which is the same for every node in the layer."
490
+ But the specification of ver 2.1 doesn't have such a requirement ("...the same for every node...")
491
+ */
483
492
  this._convertPropertyTableToNodeAttributes(propertyTable);
484
493
  }
485
494
  const resourcesData = await this._convertResources(sourceTile, transformationMatrix, sourceBoundingVolume, tileContent, parentNode.inPageId, propertyTable);
@@ -531,7 +540,7 @@ class I3SConverter {
531
540
  * @param boundingVolume - initialized bounding volume of the source tile
532
541
  * @param tileContent - content of the source tile
533
542
  * @param parentId - id of parent node in node pages
534
- * @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA
543
+ * @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA, EXT_MESH_FEATURES or EXT_STRUCTURAL_METADATA
535
544
  * @returns - converted node resources
536
545
  */
537
546
  async _convertResources(sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable) {
@@ -778,7 +787,10 @@ class I3SConverter {
778
787
  */
779
788
  async _writeAttributes(attributes = [], childPath, slpkChildPath) {
780
789
  if (attributes?.length && this.layers0?.attributeStorageInfo?.length) {
781
- for (let index = 0; index < attributes.length; index++) {
790
+ const minimumLength = attributes.length < this.layers0.attributeStorageInfo.length
791
+ ? attributes.length
792
+ : this.layers0.attributeStorageInfo.length;
793
+ for (let index = 0; index < minimumLength; index++) {
782
794
  const folderName = this.layers0.attributeStorageInfo[index].key;
783
795
  const fileBuffer = new Uint8Array(attributes[index]);
784
796
  if (this.options.slpk) {
@@ -855,16 +867,25 @@ class I3SConverter {
855
867
  ...propertyTable
856
868
  };
857
869
  for (const key in propertyTableWithObjectId) {
858
- const firstAttribute = propertyTableWithObjectId[key][0];
859
- const attributeType = (0, feature_attributes_1.getAttributeType)(key, firstAttribute);
860
- const storageAttribute = (0, feature_attributes_1.createdStorageAttribute)(attributeIndex, key, attributeType);
861
- const fieldAttributeType = (0, feature_attributes_1.getFieldAttributeType)(attributeType);
862
- const fieldAttribute = (0, feature_attributes_1.createFieldAttribute)(key, fieldAttributeType);
863
- const popupInfo = (0, feature_attributes_1.createPopupInfo)(propertyTableWithObjectId);
864
- this.layers0.attributeStorageInfo.push(storageAttribute);
865
- this.layers0.fields.push(fieldAttribute);
866
- this.layers0.popupInfo = popupInfo;
867
- this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
870
+ /*
871
+ We will append new attributes only in case the property table is updated.
872
+ According to ver 1.9 (see https://github.com/Esri/i3s-spec/blob/master/docs/1.9/attributeStorageInfo.cmn.md):
873
+ "The attributeStorageInfo object describes the structure of the binary attribute data resource of a layer, which is the same for every node in the layer."
874
+ But the specification of ver 2.1 doesn't have such a requirement ("...the same for every node...")
875
+ */
876
+ const found = this.layers0.attributeStorageInfo.find((element) => element.name === key);
877
+ if (!found) {
878
+ const firstAttribute = propertyTableWithObjectId[key][0];
879
+ const attributeType = (0, feature_attributes_1.getAttributeType)(key, firstAttribute);
880
+ const storageAttribute = (0, feature_attributes_1.createdStorageAttribute)(attributeIndex, key, attributeType);
881
+ const fieldAttributeType = (0, feature_attributes_1.getFieldAttributeType)(attributeType);
882
+ const fieldAttribute = (0, feature_attributes_1.createFieldAttribute)(key, fieldAttributeType);
883
+ const popupInfo = (0, feature_attributes_1.createPopupInfo)(propertyTableWithObjectId);
884
+ this.layers0.attributeStorageInfo.push(storageAttribute);
885
+ this.layers0.fields.push(fieldAttribute);
886
+ this.layers0.popupInfo = popupInfo;
887
+ this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
888
+ }
868
889
  attributeIndex += 1;
869
890
  }
870
891
  }
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFileByUrl = exports.loadArchive = void 0;
4
4
  require("@loaders.gl/polyfills");
5
5
  const i3s_1 = require("@loaders.gl/i3s");
6
- const zip_1 = require("@loaders.gl/zip");
6
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
7
7
  let slpkArchive;
8
8
  /**
9
9
  * Open SLPK file for reading and load HASH file
10
10
  * @param fullLayerPath - full path to SLPK file
11
11
  */
12
12
  const loadArchive = async (fullLayerPath) => {
13
- slpkArchive = await (0, i3s_1.parseSLPK)(await zip_1.FileHandleFile.from(fullLayerPath), (msg) => console.log(msg));
13
+ slpkArchive = await (0, i3s_1.parseSLPK)(await loader_utils_1.FileHandleFile.from(fullLayerPath), (msg) => console.log(msg));
14
14
  console.log('The server is ready to use');
15
15
  };
16
16
  exports.loadArchive = loadArchive;
@@ -1 +1 @@
1
- {"version":3,"file":"slpk-extractor.d.ts","sourceRoot":"","sources":["../../src/slpk-extractor/slpk-extractor.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;;OAKG;IACU,OAAO,CAAC,OAAO,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BtF;;;OAGG;IAEH,OAAO,CAAC,iBAAiB;YAYX,MAAM;YAWN,SAAS;CASxB"}
1
+ {"version":3,"file":"slpk-extractor.d.ts","sourceRoot":"","sources":["../../src/slpk-extractor/slpk-extractor.ts"],"names":[],"mappings":"AAuBA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;;OAKG;IACU,OAAO,CAAC,OAAO,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BtF;;;OAGG;IAEH,OAAO,CAAC,iBAAiB;YAYX,MAAM;YAWN,SAAS;CASxB"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@loaders.gl/core");
4
4
  const constants_1 = require("../constants");
5
5
  const loader_utils_1 = require("@loaders.gl/loader-utils");
6
+ const loader_utils_2 = require("@loaders.gl/loader-utils");
6
7
  const zip_1 = require("@loaders.gl/zip");
7
8
  const compression_1 = require("@loaders.gl/compression");
8
9
  const file_utils_1 = require("../lib/utils/file-utils");
@@ -27,7 +28,7 @@ class SLPKExtractor {
27
28
  return constants_1.BROWSER_ERROR_MESSAGE;
28
29
  }
29
30
  const { inputUrl } = options;
30
- const provider = await zip_1.FileHandleFile.from(inputUrl);
31
+ const provider = await loader_utils_2.FileHandleFile.from(inputUrl);
31
32
  let localHeader = await (0, zip_1.parseZipLocalFileHeader)(0n, provider);
32
33
  while (localHeader) {
33
34
  await this.writeFile(await this.unGzip({