@loaders.gl/tile-converter 4.2.0-alpha.4 → 4.2.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.
Files changed (144) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +3 -3
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +329 -293
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +257 -200
  5. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +14 -5
  6. package/dist/3d-tiles-converter/helpers/load-i3s.js +106 -75
  7. package/dist/3d-tiles-converter/helpers/texture-atlas.js +44 -21
  8. package/dist/3d-tiles-converter/json-templates/tileset.js +32 -33
  9. package/dist/constants.js +0 -1
  10. package/dist/converter-cli.js +255 -234
  11. package/dist/converter.min.cjs +80 -90
  12. package/dist/deps-installer/deps-installer.js +72 -58
  13. package/dist/i3s-converter/helpers/attribute-metadata-info.js +207 -153
  14. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +1 -1
  15. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  16. package/dist/i3s-converter/helpers/batch-ids-extensions.js +145 -103
  17. package/dist/i3s-converter/helpers/coordinate-converter.js +100 -65
  18. package/dist/i3s-converter/helpers/create-scene-server-path.js +14 -9
  19. package/dist/i3s-converter/helpers/feature-attributes.js +168 -105
  20. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +1 -1
  21. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  22. package/dist/i3s-converter/helpers/geometry-attributes.js +204 -212
  23. package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -2
  24. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  25. package/dist/i3s-converter/helpers/geometry-converter.js +1148 -829
  26. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
  27. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  28. package/dist/i3s-converter/helpers/gltf-attributes.js +111 -97
  29. package/dist/i3s-converter/helpers/load-3d-tiles.js +103 -66
  30. package/dist/i3s-converter/helpers/node-debug.js +98 -54
  31. package/dist/i3s-converter/helpers/node-index-document.d.ts +3 -3
  32. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  33. package/dist/i3s-converter/helpers/node-index-document.js +248 -177
  34. package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
  35. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  36. package/dist/i3s-converter/helpers/node-pages.js +299 -194
  37. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +1 -1
  38. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  39. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +92 -60
  40. package/dist/i3s-converter/helpers/progress.js +134 -83
  41. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +1 -1
  42. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
  43. package/dist/i3s-converter/helpers/tileset-traversal.js +24 -13
  44. package/dist/i3s-converter/i3s-converter.d.ts +7 -7
  45. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  46. package/dist/i3s-converter/i3s-converter.js +1044 -898
  47. package/dist/i3s-converter/json-templates/geometry-definitions.js +70 -79
  48. package/dist/i3s-converter/json-templates/layers.js +120 -121
  49. package/dist/i3s-converter/json-templates/metadata.js +19 -20
  50. package/dist/i3s-converter/json-templates/node.js +73 -71
  51. package/dist/i3s-converter/json-templates/scene-server.js +25 -26
  52. package/dist/i3s-converter/json-templates/shared-resources.js +107 -108
  53. package/dist/i3s-converter/json-templates/store.js +96 -94
  54. package/dist/i3s-converter/types.js +35 -23
  55. package/dist/i3s-server/app.js +15 -12
  56. package/dist/i3s-server/bin/www.js +14 -7
  57. package/dist/i3s-server/controllers/index-controller.js +18 -15
  58. package/dist/i3s-server/controllers/slpk-controller.js +22 -11
  59. package/dist/i3s-server/routes/index.js +9 -8
  60. package/dist/i3s-server/routes/slpk-router.js +18 -17
  61. package/dist/i3s-server/utils/create-scene-server.js +15 -10
  62. package/dist/i3s-server/utils/server-utils.js +49 -32
  63. package/dist/index.cjs +292 -851
  64. package/dist/index.cjs.map +7 -0
  65. package/dist/index.d.ts +2 -2
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +0 -1
  68. package/dist/lib/json-schemas/conversion-dump-json-schema.js +243 -421
  69. package/dist/lib/utils/cli-utils.js +63 -36
  70. package/dist/lib/utils/compress-util.js +20 -15
  71. package/dist/lib/utils/conversion-dump.d.ts +1 -1
  72. package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
  73. package/dist/lib/utils/conversion-dump.js +209 -187
  74. package/dist/lib/utils/file-utils.js +122 -74
  75. package/dist/lib/utils/geometry-utils.js +13 -7
  76. package/dist/lib/utils/lod-conversion-utils.js +65 -33
  77. package/dist/lib/utils/queue.js +12 -13
  78. package/dist/lib/utils/statistic-utills.d.ts +6 -23
  79. package/dist/lib/utils/statistic-utills.js +64 -59
  80. package/dist/lib/utils/write-queue.d.ts +2 -2
  81. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  82. package/dist/lib/utils/write-queue.js +68 -86
  83. package/dist/pgm-loader.js +16 -12
  84. package/dist/slpk-extractor/slpk-extractor.js +59 -50
  85. package/dist/slpk-extractor-cli.js +82 -59
  86. package/package.json +18 -18
  87. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  88. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  89. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  90. package/dist/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
  91. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  92. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  93. package/dist/constants.js.map +0 -1
  94. package/dist/converter-cli.js.map +0 -1
  95. package/dist/deps-installer/deps-installer.js.map +0 -1
  96. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +0 -1
  97. package/dist/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
  98. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  99. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  100. package/dist/i3s-converter/helpers/feature-attributes.js.map +0 -1
  101. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  102. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  103. package/dist/i3s-converter/helpers/gltf-attributes.js.map +0 -1
  104. package/dist/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
  105. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  106. package/dist/i3s-converter/helpers/node-index-document.js.map +0 -1
  107. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  108. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
  109. package/dist/i3s-converter/helpers/progress.js.map +0 -1
  110. package/dist/i3s-converter/helpers/tileset-traversal.js.map +0 -1
  111. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  112. package/dist/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
  113. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  114. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  115. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  116. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  117. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  118. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  119. package/dist/i3s-converter/types.js.map +0 -1
  120. package/dist/i3s-server/README.md +0 -63
  121. package/dist/i3s-server/app.js.map +0 -1
  122. package/dist/i3s-server/bin/www.js.map +0 -1
  123. package/dist/i3s-server/certs/cert.pem +0 -19
  124. package/dist/i3s-server/certs/key.pem +0 -27
  125. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  126. package/dist/i3s-server/controllers/slpk-controller.js.map +0 -1
  127. package/dist/i3s-server/routes/index.js.map +0 -1
  128. package/dist/i3s-server/routes/slpk-router.js.map +0 -1
  129. package/dist/i3s-server/utils/create-scene-server.js.map +0 -1
  130. package/dist/i3s-server/utils/server-utils.js.map +0 -1
  131. package/dist/index.js.map +0 -1
  132. package/dist/lib/json-schemas/conversion-dump-json-schema.js.map +0 -1
  133. package/dist/lib/utils/cli-utils.js.map +0 -1
  134. package/dist/lib/utils/compress-util.js.map +0 -1
  135. package/dist/lib/utils/conversion-dump.js.map +0 -1
  136. package/dist/lib/utils/file-utils.js.map +0 -1
  137. package/dist/lib/utils/geometry-utils.js.map +0 -1
  138. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  139. package/dist/lib/utils/queue.js.map +0 -1
  140. package/dist/lib/utils/statistic-utills.js.map +0 -1
  141. package/dist/lib/utils/write-queue.js.map +0 -1
  142. package/dist/pgm-loader.js.map +0 -1
  143. package/dist/slpk-extractor/slpk-extractor.js.map +0 -1
  144. package/dist/slpk-extractor-cli.js.map +0 -1
@@ -5,68 +5,82 @@ import { join, dirname } from 'path';
5
5
  import { ChildProcessProxy } from '@loaders.gl/worker-utils';
6
6
  import { DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS } from '@loaders.gl/draco';
7
7
  import { BASIS_EXTERNAL_LIBRARIES } from '@loaders.gl/textures';
8
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
9
  const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : 'latest';
9
10
  const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
11
+ /**
12
+ * Install external dependencies for converter:
13
+ * * PGM file (implemented);
14
+ * * Draco library (not implemented);
15
+ * * 7z archiver (not implemented);
16
+ */
10
17
  export class DepsInstaller {
11
- async install() {
12
- let path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
13
- console.log('Installing "EGM2008-5" model...');
14
- const fileMap = await load(PGM_LINK, ZipLoader, {});
15
- let depsPath = process.cwd();
16
- if (path) {
17
- depsPath = join(depsPath, path);
18
+ /**
19
+ * Run instalation
20
+ * @param path destination folder
21
+ * @param workersPath destination folder for workers.
22
+ * This path is '' by default and is not used by tile-converter.
23
+ * It is used in tests to prevent rewriting actual workers during tests running
24
+ */
25
+ async install(path = '') {
26
+ console.log('Installing "EGM2008-5" model...'); // eslint-disable-line no-console
27
+ const fileMap = await load(PGM_LINK, ZipLoader, {});
28
+ let depsPath = process.cwd();
29
+ if (path) {
30
+ depsPath = join(depsPath, path);
31
+ }
32
+ await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');
33
+ console.log('Installing "I3S Content Loader" worker'); // eslint-disable-line no-console
34
+ await this.installFromNpm('i3s', 'i3s-content-worker-node.js');
35
+ console.log('Installing "Draco Loader" worker'); // eslint-disable-line no-console
36
+ await this.installFromNpm('draco', 'draco-worker-node.js');
37
+ console.log('Installing "Draco Writer" worker'); // eslint-disable-line no-console
38
+ await this.installFromNpm('draco', 'draco-writer-worker-node.js');
39
+ console.log('Installing "Basis Loader" worker'); // eslint-disable-line no-console
40
+ await this.installFromNpm('textures', 'basis-worker-node.js');
41
+ console.log('Installing "KTX2 Basis Writer" worker'); // eslint-disable-line no-console
42
+ await this.installFromNpm('textures', 'ktx2-basis-writer-worker-node.js');
43
+ console.log('Installing "Draco decoder" library'); // eslint-disable-line no-console
44
+ await this.installFromUrl(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER], 'draco', DRACO_EXTERNAL_LIBRARIES.DECODER);
45
+ await this.installFromUrl(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM], 'draco', DRACO_EXTERNAL_LIBRARIES.DECODER_WASM);
46
+ console.log('Installing "Draco encoder" library'); // eslint-disable-line no-console
47
+ await this.installFromUrl(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER], 'draco', DRACO_EXTERNAL_LIBRARIES.ENCODER);
48
+ console.log('Installing "Basis transcoder" library'); // eslint-disable-line no-console
49
+ await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'libs');
50
+ await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'libs');
51
+ console.log('Installing "Basis encoder" library'); // eslint-disable-line no-console
52
+ await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER, 'libs');
53
+ await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'libs');
54
+ console.log('Installing "join-images" npm package');
55
+ const childProcess = new ChildProcessProxy();
56
+ const nodeDir = dirname(process.execPath);
57
+ await childProcess.start({
58
+ command: `${nodeDir}/${process.platform === 'win32' ? 'npm.cmd' : 'npm'}`,
59
+ // `npm install sharp join-images` works unstable. It fails because installed `sharp` version
60
+ // may be different from the version required by `join-images`. Pointing to specific versions
61
+ // resolve this issue
62
+ arguments: ['install', 'sharp@0.30.4', 'join-images@1.1.3'],
63
+ wait: 0,
64
+ ignoreStderr: true
65
+ });
66
+ console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console
18
67
  }
19
- await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');
20
- console.log('Installing "I3S Content Loader" worker');
21
- await this.installFromNpm('i3s', 'i3s-content-worker-node.js');
22
- console.log('Installing "Draco Loader" worker');
23
- await this.installFromNpm('draco', 'draco-worker-node.js');
24
- console.log('Installing "Draco Writer" worker');
25
- await this.installFromNpm('draco', 'draco-writer-worker-node.js');
26
- console.log('Installing "Basis Loader" worker');
27
- await this.installFromNpm('textures', 'basis-worker-node.js');
28
- console.log('Installing "KTX2 Basis Writer" worker');
29
- await this.installFromNpm('textures', 'ktx2-basis-writer-worker-node.js');
30
- console.log('Installing "Draco decoder" library');
31
- await this.installFromUrl(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER], 'draco', DRACO_EXTERNAL_LIBRARIES.DECODER);
32
- await this.installFromUrl(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM], 'draco', DRACO_EXTERNAL_LIBRARIES.DECODER_WASM);
33
- console.log('Installing "Draco encoder" library');
34
- await this.installFromUrl(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER], 'draco', DRACO_EXTERNAL_LIBRARIES.ENCODER);
35
- console.log('Installing "Basis transcoder" library');
36
- await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'libs');
37
- await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'libs');
38
- console.log('Installing "Basis encoder" library');
39
- await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER, 'libs');
40
- await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'libs');
41
- console.log('Installing "join-images" npm package');
42
- const childProcess = new ChildProcessProxy();
43
- const nodeDir = dirname(process.execPath);
44
- await childProcess.start({
45
- command: `${nodeDir}/${process.platform === 'win32' ? 'npm.cmd' : 'npm'}`,
46
- arguments: ['install', 'sharp@0.30.4', 'join-images@1.1.3'],
47
- wait: 0,
48
- ignoreStderr: true
49
- });
50
- console.log('All dependencies were installed succesfully.');
51
- }
52
- async installFromNpm(module, name) {
53
- let extraPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
54
- const fileResponse = await fetchFile(`https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${extraPath}/${name}`);
55
- const fileData = await fileResponse.arrayBuffer();
56
- if (!fileData) {
57
- return;
68
+ async installFromNpm(module, name, extraPath = '') {
69
+ const fileResponse = await fetchFile(`https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${extraPath}/${name}`);
70
+ const fileData = await fileResponse.arrayBuffer();
71
+ if (!fileData) {
72
+ return;
73
+ }
74
+ const path = join(process.cwd(), 'modules', module, 'dist', extraPath);
75
+ await writeFile(path, fileData, name);
58
76
  }
59
- const path = join(process.cwd(), 'modules', module, 'dist', extraPath);
60
- await writeFile(path, fileData, name);
61
- }
62
- async installFromUrl(url, module, name) {
63
- const fileResponse = await fetchFile(url);
64
- const fileData = await fileResponse.arrayBuffer();
65
- if (!fileData) {
66
- return;
77
+ async installFromUrl(url, module, name) {
78
+ const fileResponse = await fetchFile(url);
79
+ const fileData = await fileResponse.arrayBuffer();
80
+ if (!fileData) {
81
+ return;
82
+ }
83
+ const path = join(process.cwd(), 'modules', module, 'dist', 'libs');
84
+ await writeFile(path, fileData, name);
67
85
  }
68
- const path = join(process.cwd(), 'modules', module, 'dist', 'libs');
69
- await writeFile(path, fileData, name);
70
- }
71
86
  }
72
- //# sourceMappingURL=deps-installer.js.map
@@ -1,162 +1,216 @@
1
1
  import { AttributeType } from "../types.js";
2
2
  export class AttributeMetadataInfo {
3
- constructor() {
4
- this._attributeStorageInfo = void 0;
5
- this._fields = void 0;
6
- this._popupInfo = void 0;
7
- this._attributeStorageInfo = [];
8
- this._fields = [];
9
- }
10
- get attributeStorageInfo() {
11
- return this._attributeStorageInfo;
12
- }
13
- get fields() {
14
- return this._fields;
15
- }
16
- get popupInfo() {
17
- return this._popupInfo;
18
- }
19
- addMetadataInfo(attributeTypesMap) {
20
- if (!Object.keys(attributeTypesMap).length) {
21
- return;
3
+ constructor() {
4
+ this._attributeStorageInfo = [];
5
+ this._fields = [];
22
6
  }
23
- const attributeTypes = {
24
- OBJECTID: AttributeType.OBJECT_ID_TYPE,
25
- ...attributeTypesMap
26
- };
27
- let isUpdated = false;
28
- let attributeIndex = this._attributeStorageInfo.length;
29
- for (const key in attributeTypes) {
30
- const elementFound = this._attributeStorageInfo.find(element => element.name === key);
31
- if (!elementFound) {
32
- const attributeType = attributeTypes[key];
33
- const storageAttribute = this.createStorageAttribute(attributeIndex, key, attributeType);
34
- const fieldAttributeType = this.getFieldAttributeType(attributeType);
35
- const fieldAttribute = this.createFieldAttribute(key, fieldAttributeType);
36
- this._attributeStorageInfo.push(storageAttribute);
37
- this._fields.push(fieldAttribute);
38
- attributeIndex += 1;
39
- isUpdated = true;
40
- }
7
+ get attributeStorageInfo() {
8
+ return this._attributeStorageInfo;
41
9
  }
42
- if (isUpdated) {
43
- const attributeNames = [];
44
- for (let info of this._attributeStorageInfo) {
45
- attributeNames.push(info.name);
46
- }
47
- this._popupInfo = this.createPopupInfo(attributeNames);
10
+ get fields() {
11
+ return this._fields;
48
12
  }
49
- }
50
- fromObject(object) {
51
- this._attributeStorageInfo = object.attributeStorageInfo;
52
- this._fields = object.fields;
53
- this._popupInfo = object.popupInfo;
54
- }
55
- createStorageAttribute(attributeIndex, key, attributeType) {
56
- const storageAttribute = {
57
- key: `f_${attributeIndex}`,
58
- name: key,
59
- ordering: ['attributeValues'],
60
- header: [{
61
- property: 'count',
62
- valueType: 'UInt32'
63
- }],
64
- attributeValues: {
65
- valueType: 'Int32',
66
- valuesPerElement: 1
67
- }
68
- };
69
- switch (attributeType) {
70
- case AttributeType.OBJECT_ID_TYPE:
71
- this.setupIdAttribute(storageAttribute);
72
- break;
73
- case AttributeType.STRING_TYPE:
74
- this.setupStringAttribute(storageAttribute);
75
- break;
76
- case AttributeType.DOUBLE_TYPE:
77
- this.setupDoubleAttribute(storageAttribute);
78
- break;
79
- case AttributeType.SHORT_INT_TYPE:
80
- break;
81
- default:
82
- this.setupStringAttribute(storageAttribute);
13
+ get popupInfo() {
14
+ return this._popupInfo;
83
15
  }
84
- return storageAttribute;
85
- }
86
- getFieldAttributeType(attributeType) {
87
- switch (attributeType) {
88
- case AttributeType.OBJECT_ID_TYPE:
89
- return 'esriFieldTypeOID';
90
- case AttributeType.STRING_TYPE:
91
- return 'esriFieldTypeString';
92
- case AttributeType.SHORT_INT_TYPE:
93
- return 'esriFieldTypeInteger';
94
- case AttributeType.DOUBLE_TYPE:
95
- return 'esriFieldTypeDouble';
96
- default:
97
- return 'esriFieldTypeString';
16
+ /**
17
+ * Creates and stores Attribute Storage Info, Fields and PopupInfo objects based on attribute's types.
18
+ * Appends objects that have not been stored yet.
19
+ * @param attributeTypesMap - set of attribute's types
20
+ * @example AttributeStorageInfo, Fields and PopupInfo already contain objects for the following attributes:
21
+ * {
22
+ * color: 'string',
23
+ * name: 'string',
24
+ * opt_uint8: 'Int32'
25
+ * }
26
+ * Then, we call the addMetadataInfo method with the following attributeTypesMap:
27
+ * {
28
+ * // The same attributes
29
+ * color: 'string',
30
+ * name: 'string',
31
+ * opt_uint8: 'Int32',
32
+ * // New attributes
33
+ * opt_uint64: 'string',
34
+ * opt_float32: 'double',
35
+ * }
36
+ * The method creates and stores objects for opt_uint64, opt_float32 attributes.
37
+ */
38
+ addMetadataInfo(attributeTypesMap) {
39
+ if (!Object.keys(attributeTypesMap).length) {
40
+ return;
41
+ }
42
+ const attributeTypes = {
43
+ OBJECTID: AttributeType.OBJECT_ID_TYPE,
44
+ ...attributeTypesMap
45
+ };
46
+ let isUpdated = false;
47
+ let attributeIndex = this._attributeStorageInfo.length;
48
+ for (const key in attributeTypes) {
49
+ /*
50
+ We will append a new attribute only in case it has not been added to the attribute storage info yet.
51
+ */
52
+ const elementFound = this._attributeStorageInfo.find((element) => element.name === key);
53
+ if (!elementFound) {
54
+ const attributeType = attributeTypes[key];
55
+ const storageAttribute = this.createStorageAttribute(attributeIndex, key, attributeType);
56
+ const fieldAttributeType = this.getFieldAttributeType(attributeType);
57
+ const fieldAttribute = this.createFieldAttribute(key, fieldAttributeType);
58
+ this._attributeStorageInfo.push(storageAttribute);
59
+ this._fields.push(fieldAttribute);
60
+ attributeIndex += 1;
61
+ isUpdated = true;
62
+ }
63
+ }
64
+ if (isUpdated) {
65
+ /*
66
+ The attributeStorageInfo is updated. So, popupInfo should be recreated.
67
+ Use attributeStorageInfo as a source of attribute names to create the popupInfo.
68
+ */
69
+ const attributeNames = [];
70
+ for (let info of this._attributeStorageInfo) {
71
+ attributeNames.push(info.name);
72
+ }
73
+ this._popupInfo = this.createPopupInfo(attributeNames);
74
+ }
98
75
  }
99
- }
100
- setupIdAttribute(storageAttribute) {
101
- storageAttribute.attributeValues = {
102
- valueType: 'Oid32',
103
- valuesPerElement: 1
104
- };
105
- }
106
- setupStringAttribute(storageAttribute) {
107
- storageAttribute.ordering.unshift('attributeByteCounts');
108
- storageAttribute.header.push({
109
- property: 'attributeValuesByteCount',
110
- valueType: 'UInt32'
111
- });
112
- storageAttribute.attributeValues = {
113
- valueType: 'String',
114
- encoding: 'UTF-8',
115
- valuesPerElement: 1
116
- };
117
- storageAttribute.attributeByteCounts = {
118
- valueType: 'UInt32',
119
- valuesPerElement: 1
120
- };
121
- }
122
- setupDoubleAttribute(storageAttribute) {
123
- storageAttribute.attributeValues = {
124
- valueType: 'Float64',
125
- valuesPerElement: 1
126
- };
127
- }
128
- createFieldAttribute(key, fieldAttributeType) {
129
- return {
130
- name: key,
131
- type: fieldAttributeType,
132
- alias: key
133
- };
134
- }
135
- createPopupInfo(propertyNames) {
136
- const title = '{OBJECTID}';
137
- const mediaInfos = [];
138
- const fieldInfos = [];
139
- const popupElements = [];
140
- const expressionInfos = [];
141
- for (const propertyName of propertyNames) {
142
- fieldInfos.push({
143
- fieldName: propertyName,
144
- visible: true,
145
- isEditable: false,
146
- label: propertyName
147
- });
76
+ /**
77
+ * Set AttributeMetadataInfo from object
78
+ * @param object - object with AttributeMetadataInfo props
79
+ */
80
+ fromObject(object) {
81
+ this._attributeStorageInfo = object.attributeStorageInfo;
82
+ this._fields = object.fields;
83
+ this._popupInfo = object.popupInfo;
84
+ }
85
+ /**
86
+ * Generates storage attribute for map segmentation.
87
+ * @param attributeIndex - order index of attribute (f_0, f_1 ...).
88
+ * @param key - attribute key from propertyTable.
89
+ * @param attributeType - attribute type.
90
+ * @return Updated storageAttribute.
91
+ */
92
+ createStorageAttribute(attributeIndex, key, attributeType) {
93
+ const storageAttribute = {
94
+ key: `f_${attributeIndex}`,
95
+ name: key,
96
+ ordering: ['attributeValues'],
97
+ header: [{ property: 'count', valueType: 'UInt32' }],
98
+ attributeValues: { valueType: 'Int32', valuesPerElement: 1 }
99
+ };
100
+ switch (attributeType) {
101
+ case AttributeType.OBJECT_ID_TYPE:
102
+ this.setupIdAttribute(storageAttribute);
103
+ break;
104
+ case AttributeType.STRING_TYPE:
105
+ this.setupStringAttribute(storageAttribute);
106
+ break;
107
+ case AttributeType.DOUBLE_TYPE:
108
+ this.setupDoubleAttribute(storageAttribute);
109
+ break;
110
+ case AttributeType.SHORT_INT_TYPE:
111
+ break;
112
+ default:
113
+ this.setupStringAttribute(storageAttribute);
114
+ }
115
+ return storageAttribute;
116
+ }
117
+ /**
118
+ * Finds and returns attribute type based on key form propertyTable.
119
+ * @param attributeType
120
+ */
121
+ getFieldAttributeType(attributeType) {
122
+ switch (attributeType) {
123
+ case AttributeType.OBJECT_ID_TYPE:
124
+ return 'esriFieldTypeOID';
125
+ case AttributeType.STRING_TYPE:
126
+ return 'esriFieldTypeString';
127
+ case AttributeType.SHORT_INT_TYPE:
128
+ return 'esriFieldTypeInteger';
129
+ case AttributeType.DOUBLE_TYPE:
130
+ return 'esriFieldTypeDouble';
131
+ default:
132
+ return 'esriFieldTypeString';
133
+ }
134
+ }
135
+ /**
136
+ * Sets up Id attribute for map segmentation.
137
+ * @param storageAttribute - attribute for map segmentation .
138
+ */
139
+ setupIdAttribute(storageAttribute) {
140
+ storageAttribute.attributeValues = {
141
+ valueType: 'Oid32',
142
+ valuesPerElement: 1
143
+ };
144
+ }
145
+ /**
146
+ * Sets up storage attribute as string.
147
+ * @param storageAttribute - attribute for map segmentation.
148
+ */
149
+ setupStringAttribute(storageAttribute) {
150
+ // @ts-expect-error
151
+ storageAttribute.ordering.unshift('attributeByteCounts');
152
+ storageAttribute.header.push({ property: 'attributeValuesByteCount', valueType: 'UInt32' });
153
+ storageAttribute.attributeValues = {
154
+ valueType: 'String',
155
+ encoding: 'UTF-8',
156
+ valuesPerElement: 1
157
+ };
158
+ storageAttribute.attributeByteCounts = {
159
+ valueType: 'UInt32',
160
+ valuesPerElement: 1
161
+ };
162
+ }
163
+ /**
164
+ * Sets up double attribute for map segmentation.
165
+ * @param storageAttribute - attribute for map segmentation .
166
+ */
167
+ setupDoubleAttribute(storageAttribute) {
168
+ storageAttribute.attributeValues = {
169
+ valueType: 'Float64',
170
+ valuesPerElement: 1
171
+ };
172
+ }
173
+ /**
174
+ * Sets up field attribute for map segmentation.
175
+ * @param key - attribute for map segmentation.
176
+ * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
177
+ */
178
+ createFieldAttribute(key, fieldAttributeType) {
179
+ return {
180
+ name: key,
181
+ type: fieldAttributeType,
182
+ alias: key
183
+ };
184
+ }
185
+ /**
186
+ * Generates popup info to show metadata on the map.
187
+ * @param propertyNames - array of property names including OBJECTID.
188
+ * @return data for correct rendering of popup.
189
+ */
190
+ createPopupInfo(propertyNames) {
191
+ const title = '{OBJECTID}';
192
+ const mediaInfos = [];
193
+ const fieldInfos = [];
194
+ const popupElements = [];
195
+ const expressionInfos = [];
196
+ for (const propertyName of propertyNames) {
197
+ fieldInfos.push({
198
+ fieldName: propertyName,
199
+ visible: true,
200
+ isEditable: false,
201
+ label: propertyName
202
+ });
203
+ }
204
+ popupElements.push({
205
+ fieldInfos,
206
+ type: 'fields'
207
+ });
208
+ return {
209
+ title,
210
+ mediaInfos,
211
+ popupElements,
212
+ fieldInfos,
213
+ expressionInfos
214
+ };
148
215
  }
149
- popupElements.push({
150
- fieldInfos,
151
- type: 'fields'
152
- });
153
- return {
154
- title,
155
- mediaInfos,
156
- popupElements,
157
- fieldInfos,
158
- expressionInfos
159
- };
160
- }
161
216
  }
162
- //# sourceMappingURL=attribute-metadata-info.js.map
@@ -1,6 +1,6 @@
1
1
  import { GLTFAccessorPostprocessed, GLTFMeshPrimitivePostprocessed } from '@loaders.gl/gltf';
2
2
  import type { NumericArray } from '@loaders.gl/loader-utils';
3
- import { TextureImageProperties } from '../types';
3
+ import { TextureImageProperties } from "../types.js";
4
4
  import { Tiles3DTileContent } from '@loaders.gl/3d-tiles';
5
5
  /**
6
6
  * Get featureTexture by a metadata class.
@@ -1 +1 @@
1
- {"version":3,"file":"batch-ids-extensions.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAE,8BAA8B,EAAC,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAU3D,OAAO,EAAC,sBAAsB,EAAC,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,kBAAkB,EAC/B,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,GAAG,IAAI,CAcf;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAC;CAC1C,EACD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,CAAC,sBAAsB,GAAG,IAAI,CAAC,EAAE,EACzC,cAAc,EAAE,MAAM,GAAG,IAAI,GAC5B,YAAY,CAuBd"}
1
+ {"version":3,"file":"batch-ids-extensions.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAE,8BAA8B,EAAC,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAU3D,OAAO,EAAC,sBAAsB,EAAC,oBAAiB;AAGhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,kBAAkB,EAC/B,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,GAAG,IAAI,CAcf;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAC;CAC1C,EACD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,CAAC,sBAAsB,GAAG,IAAI,CAAC,EAAE,EACzC,cAAc,EAAE,MAAM,GAAG,IAAI,GAC5B,YAAY,CAuBd"}