@loaders.gl/tile-converter 4.2.0-alpha.4 → 4.2.0-alpha.6

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