@loaders.gl/tile-converter 4.3.0-alpha.3 → 4.3.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 (61) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +4 -1
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  3. package/dist/converter-cli.js +6 -14
  4. package/dist/converter.min.cjs +94 -95
  5. package/dist/deps-installer/deps-installer.js +1 -1
  6. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +2 -2
  7. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  8. package/dist/i3s-converter/helpers/coordinate-converter.js +9 -5
  9. package/dist/i3s-converter/helpers/geometry-converter.d.ts +1 -1
  10. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  11. package/dist/i3s-converter/helpers/geometry-converter.js +4 -2
  12. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  13. package/dist/i3s-converter/helpers/node-index-document.js +6 -14
  14. package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
  15. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  16. package/dist/i3s-converter/helpers/node-pages.js +14 -40
  17. package/dist/i3s-converter/i3s-converter.d.ts +24 -22
  18. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  19. package/dist/i3s-converter/i3s-converter.js +67 -132
  20. package/dist/i3s-server/app.d.ts +2 -1
  21. package/dist/i3s-server/app.d.ts.map +1 -1
  22. package/dist/i3s-server/app.js +7 -10
  23. package/dist/i3s-server/bin/i3s-server.min.cjs +71 -71
  24. package/dist/i3s-server/bin/www.js +5 -0
  25. package/dist/i3s-server/routes/slpk-router.js +7 -1
  26. package/dist/index.cjs +98 -200
  27. package/dist/index.cjs.map +2 -2
  28. package/dist/lib/utils/statistic-utills.d.ts +4 -1
  29. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  30. package/dist/lib/utils/statistic-utills.js +4 -23
  31. package/dist/pgm-loader.js +1 -1
  32. package/package.json +19 -20
  33. package/src/3d-tiles-converter/3d-tiles-converter.ts +2 -1
  34. package/src/converter-cli.ts +8 -20
  35. package/src/i3s-converter/helpers/coordinate-converter.ts +13 -7
  36. package/src/i3s-converter/helpers/geometry-converter.ts +6 -4
  37. package/src/i3s-converter/helpers/node-index-document.ts +16 -26
  38. package/src/i3s-converter/helpers/node-pages.ts +20 -46
  39. package/src/i3s-converter/i3s-converter.ts +101 -161
  40. package/src/i3s-server/app.ts +7 -10
  41. package/src/i3s-server/bin/www.ts +6 -0
  42. package/src/i3s-server/routes/slpk-router.ts +6 -1
  43. package/src/lib/utils/statistic-utills.ts +5 -27
  44. package/bin/slpk-extractor.js +0 -2
  45. package/dist/i3s-server/controllers/index-controller.d.ts +0 -8
  46. package/dist/i3s-server/controllers/index-controller.d.ts.map +0 -1
  47. package/dist/i3s-server/controllers/index-controller.js +0 -31
  48. package/dist/i3s-server/routes/index.d.ts +0 -2
  49. package/dist/i3s-server/routes/index.d.ts.map +0 -1
  50. package/dist/i3s-server/routes/index.js +0 -17
  51. package/dist/slpk-extractor/slpk-extractor.d.ts +0 -23
  52. package/dist/slpk-extractor/slpk-extractor.d.ts.map +0 -1
  53. package/dist/slpk-extractor/slpk-extractor.js +0 -73
  54. package/dist/slpk-extractor-cli.d.ts +0 -17
  55. package/dist/slpk-extractor-cli.d.ts.map +0 -1
  56. package/dist/slpk-extractor-cli.js +0 -105
  57. package/dist/slpk-extractor.min.cjs +0 -344
  58. package/src/i3s-server/controllers/index-controller.ts +0 -32
  59. package/src/i3s-server/routes/index.ts +0 -18
  60. package/src/slpk-extractor/slpk-extractor.ts +0 -102
  61. package/src/slpk-extractor-cli.ts +0 -136
@@ -125,8 +125,6 @@ export default class I3SConverter {
125
125
  * @param options.outputPath the output filename
126
126
  * @param options.tilesetName the output name of the tileset
127
127
  * @param options.maxDepth The max tree depth of conversion
128
- * @param options.slpk Generate slpk (Scene Layer Packages) output file
129
- * @param options.sevenZipExe Location of 7z.exe archiver to create slpk on Windows
130
128
  * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
131
129
  * @param options.token Token for Cesium ION tilesets authentication
132
130
  * @param options.draco Generate I3S 1.7 draco compressed geometries
@@ -142,13 +140,11 @@ export default class I3SConverter {
142
140
  return BROWSER_ERROR_MESSAGE;
143
141
  }
144
142
  this.conversionStartTime = process.hrtime();
145
- const { tilesetName, slpk, egmFilePath, inputUrl, validate, outputPath, draco = true, sevenZipExe, maxDepth, token, generateTextures, generateBoundingVolumes, instantNodeWriting = false, mergeMaterials = true, inquirer, metadataClass, analyze = false } = options;
143
+ const { tilesetName, egmFilePath, inputUrl, validate, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, instantNodeWriting = false, mergeMaterials = true, inquirer, metadataClass, analyze = false, noEgm = false } = options;
146
144
  this.options = {
147
145
  outputPath,
148
146
  tilesetName,
149
147
  maxDepth,
150
- slpk,
151
- sevenZipExe,
152
148
  egmFilePath,
153
149
  draco,
154
150
  token,
@@ -166,12 +162,15 @@ export default class I3SConverter {
166
162
  this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
167
163
  this.writeQueue = new WriteQueue(this.conversionDump);
168
164
  this.writeQueue.startListening();
169
- console.log('Loading egm file...'); // eslint-disable-line
170
- this.geoidHeightModel = await load(egmFilePath, PGMLoader);
171
- console.log('Loading egm file completed!'); // eslint-disable-line
172
- if (slpk) {
173
- this.nodePages.useWriteFunction(writeFileForSlpk);
165
+ if (!noEgm) {
166
+ console.log('--no-egm option selected, skip loading egm file'); // eslint-disable-line
174
167
  }
168
+ else {
169
+ console.log('Loading egm file...'); // eslint-disable-line
170
+ this.geoidHeightModel = await load(egmFilePath, PGMLoader);
171
+ console.log('Loading egm file completed!'); // eslint-disable-line
172
+ }
173
+ this.nodePages.useWriteFunction(writeFileForSlpk);
175
174
  try {
176
175
  const preloadOptions = await this._fetchPreloadOptions();
177
176
  let tilesetUrl = inputUrl;
@@ -187,7 +186,7 @@ export default class I3SConverter {
187
186
  const selectMetadataClassResult = await this.selectMetadataClass();
188
187
  if (selectMetadataClassResult) {
189
188
  await this._createAndSaveTileset(outputPath, tilesetName);
190
- await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
189
+ await this._finishConversion({ outputPath, tilesetName });
191
190
  }
192
191
  }
193
192
  }
@@ -445,17 +444,10 @@ export default class I3SConverter {
445
444
  * Write 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md in file
446
445
  */
447
446
  async _writeLayers0() {
448
- if (this.options.slpk) {
449
- await this.writeQueue.enqueue({
450
- archiveKey: '3dSceneLayer.json.gz',
451
- writePromise: () => writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
452
- });
453
- }
454
- else {
455
- await this.writeQueue.enqueue({
456
- writePromise: () => writeFile(this.layers0Path, JSON.stringify(this.layers0))
457
- });
458
- }
447
+ await this.writeQueue.enqueue({
448
+ archiveKey: '3dSceneLayer.json.gz',
449
+ writePromise: () => writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
450
+ });
459
451
  }
460
452
  /**
461
453
  * Pack files into *.slpk archive
@@ -463,19 +455,17 @@ export default class I3SConverter {
463
455
  */
464
456
  async _createSlpk(tilesetPath) {
465
457
  await this.conversionDump.deleteDumpFile();
466
- if (this.options.slpk) {
467
- const slpkTilesetPath = join(tilesetPath, 'SceneServer', 'layers', '0');
468
- const slpkFileName = `${tilesetPath}.slpk`;
469
- await createZip(slpkTilesetPath, slpkFileName, async (fileList) => ({
470
- path: '@specialIndexFileHASH128@',
471
- file: await composeHashFile(fileList)
472
- }));
473
- try {
474
- await removeDir(tilesetPath);
475
- }
476
- catch (e) {
477
- // do nothing
478
- }
458
+ const slpkTilesetPath = join(tilesetPath, 'SceneServer', 'layers', '0');
459
+ const slpkFileName = `${tilesetPath}.slpk`;
460
+ await createZip(slpkTilesetPath, slpkFileName, async (fileList) => ({
461
+ path: '@specialIndexFileHASH128@',
462
+ file: await composeHashFile(fileList)
463
+ }));
464
+ try {
465
+ await removeDir(tilesetPath);
466
+ }
467
+ catch (e) {
468
+ // do nothing
479
469
  }
480
470
  }
481
471
  /**
@@ -723,9 +713,9 @@ export default class I3SConverter {
723
713
  propertyTable,
724
714
  featuresHashArray: this.featuresHashArray,
725
715
  attributeStorageInfo: this.attributeMetadataInfo.attributeStorageInfo,
726
- draco: this.options.draco,
716
+ draco: this.options.draco ?? false,
727
717
  generateBoundingVolumes: this.generateBoundingVolumes,
728
- shouldMergeMaterials: this.options.mergeMaterials,
718
+ shouldMergeMaterials: this.options.mergeMaterials ?? false,
729
719
  geoidHeightModel: this.geoidHeightModel,
730
720
  libraries: this.loadOptions.modules,
731
721
  metadataClass: this.options.metadataClass
@@ -857,47 +847,25 @@ export default class I3SConverter {
857
847
  return;
858
848
  }
859
849
  this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.GEOMETRY, false);
860
- if (this.options.slpk) {
861
- const slpkGeometryPath = join(childPath, 'geometries');
862
- await this.writeQueue.enqueue({
863
- archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,
864
- sourceId,
865
- outputId: nodeId,
866
- resourceType: ResourceType.GEOMETRY,
867
- writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
868
- });
869
- }
870
- else {
871
- const geometryPath = join(childPath, 'geometries/0/');
850
+ const slpkGeometryPath = join(childPath, 'geometries');
851
+ await this.writeQueue.enqueue({
852
+ archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,
853
+ sourceId,
854
+ outputId: nodeId,
855
+ resourceType: ResourceType.GEOMETRY,
856
+ writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
857
+ });
858
+ if (this.options.draco && compressedGeometry) {
859
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.DRACO_GEOMETRY, false);
860
+ const slpkCompressedGeometryPath = join(childPath, 'geometries');
872
861
  await this.writeQueue.enqueue({
862
+ archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,
873
863
  sourceId,
874
864
  outputId: nodeId,
875
- resourceType: ResourceType.GEOMETRY,
876
- writePromise: () => writeFile(geometryPath, geometryBuffer, 'index.bin')
865
+ resourceType: ResourceType.DRACO_GEOMETRY,
866
+ writePromise: () => writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
877
867
  });
878
868
  }
879
- if (this.options.draco && compressedGeometry) {
880
- this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.DRACO_GEOMETRY, false);
881
- if (this.options.slpk) {
882
- const slpkCompressedGeometryPath = join(childPath, 'geometries');
883
- await this.writeQueue.enqueue({
884
- archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,
885
- sourceId,
886
- outputId: nodeId,
887
- resourceType: ResourceType.DRACO_GEOMETRY,
888
- writePromise: () => writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
889
- });
890
- }
891
- else {
892
- const compressedGeometryPath = join(childPath, 'geometries/1/');
893
- await this.writeQueue.enqueue({
894
- sourceId,
895
- outputId: nodeId,
896
- resourceType: ResourceType.DRACO_GEOMETRY,
897
- writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
898
- });
899
- }
900
- }
901
869
  }
902
870
  /**
903
871
  * Write shared resources in a file
@@ -916,25 +884,14 @@ export default class I3SConverter {
916
884
  const sharedData = transform(sharedResources, sharedResourcesTemplate());
917
885
  const sharedDataStr = JSON.stringify(sharedData);
918
886
  this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.SHARED, false);
919
- if (this.options.slpk) {
920
- const slpkSharedPath = join(childPath, 'shared');
921
- await this.writeQueue.enqueue({
922
- archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,
923
- sourceId,
924
- outputId: nodeId,
925
- resourceType: ResourceType.SHARED,
926
- writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
927
- });
928
- }
929
- else {
930
- const sharedPath = join(childPath, 'shared/');
931
- await this.writeQueue.enqueue({
932
- sourceId,
933
- outputId: nodeId,
934
- resourceType: ResourceType.SHARED,
935
- writePromise: () => writeFile(sharedPath, sharedDataStr)
936
- });
937
- }
887
+ const slpkSharedPath = join(childPath, 'shared');
888
+ await this.writeQueue.enqueue({
889
+ archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,
890
+ sourceId,
891
+ outputId: nodeId,
892
+ resourceType: ResourceType.SHARED,
893
+ writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
894
+ });
938
895
  }
939
896
  /**
940
897
  * Generates textures based on texture mime type and fill in textureSetDefinitions data.
@@ -1044,26 +1001,15 @@ export default class I3SConverter {
1044
1001
  * @param nodeId
1045
1002
  */
1046
1003
  async writeTextureFile({ textureData, name, format, childPath, slpkChildPath, sourceId, nodeId }) {
1047
- if (this.options.slpk) {
1048
- const slpkTexturePath = join(childPath, 'textures');
1049
- const compress = false;
1050
- await this.writeQueue.enqueue({
1051
- archiveKey: `${slpkChildPath}/textures/${name}.${format}`,
1052
- sourceId,
1053
- outputId: nodeId,
1054
- resourceType: `${ResourceType.TEXTURE}/${format}`,
1055
- writePromise: () => writeFileForSlpk(slpkTexturePath, textureData, `${name}.${format}`, compress)
1056
- });
1057
- }
1058
- else {
1059
- const texturePath = join(childPath, `textures/${name}/`);
1060
- await this.writeQueue.enqueue({
1061
- sourceId,
1062
- outputId: nodeId,
1063
- resourceType: `${ResourceType.TEXTURE}/${format}`,
1064
- writePromise: () => writeFile(texturePath, textureData, `index.${format}`)
1065
- });
1066
- }
1004
+ const slpkTexturePath = join(childPath, 'textures');
1005
+ const compress = false;
1006
+ await this.writeQueue.enqueue({
1007
+ archiveKey: `${slpkChildPath}/textures/${name}.${format}`,
1008
+ sourceId,
1009
+ outputId: nodeId,
1010
+ resourceType: `${ResourceType.TEXTURE}/${format}`,
1011
+ writePromise: () => writeFileForSlpk(slpkTexturePath, textureData, `${name}.${format}`, compress)
1012
+ });
1067
1013
  }
1068
1014
  /**
1069
1015
  * Write feature attributes in files
@@ -1082,25 +1028,14 @@ export default class I3SConverter {
1082
1028
  const folderName = this.attributeMetadataInfo.attributeStorageInfo[index].key;
1083
1029
  const fileBuffer = new Uint8Array(attributes[index]);
1084
1030
  this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.ATTRIBUTES}/${folderName}`, false);
1085
- if (this.options.slpk) {
1086
- const slpkAttributesPath = join(childPath, 'attributes', folderName);
1087
- await this.writeQueue.enqueue({
1088
- archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,
1089
- sourceId,
1090
- outputId: nodeId,
1091
- resourceType: `${ResourceType.ATTRIBUTES}/${folderName}`,
1092
- writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
1093
- });
1094
- }
1095
- else {
1096
- const attributesPath = join(childPath, `attributes/${folderName}/0`);
1097
- await this.writeQueue.enqueue({
1098
- sourceId,
1099
- outputId: nodeId,
1100
- resourceType: `${ResourceType.ATTRIBUTES}/${folderName}`,
1101
- writePromise: () => writeFile(attributesPath, fileBuffer, 'index.bin')
1102
- });
1103
- }
1031
+ const slpkAttributesPath = join(childPath, 'attributes', folderName);
1032
+ await this.writeQueue.enqueue({
1033
+ archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,
1034
+ sourceId,
1035
+ outputId: nodeId,
1036
+ resourceType: `${ResourceType.ATTRIBUTES}/${folderName}`,
1037
+ writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
1038
+ });
1104
1039
  }
1105
1040
  }
1106
1041
  }
@@ -1207,7 +1142,7 @@ export default class I3SConverter {
1207
1142
  const options = {
1208
1143
  'cesium-ion': { accessToken: this.options.token || ION_DEFAULT_TOKEN }
1209
1144
  };
1210
- const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);
1145
+ const preloadOptions = await this.Loader.preload(this.options.inputUrl ?? '', options);
1211
1146
  this.refreshTokenTime = process.hrtime();
1212
1147
  return { ...options, ...preloadOptions };
1213
1148
  }
@@ -1,2 +1,3 @@
1
- export declare const app: import("express-serve-static-core").Express;
1
+ import express from 'express';
2
+ export declare let app: ReturnType<typeof express> | undefined;
2
3
  //# sourceMappingURL=app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,GAAG,6CAAY,CAAC"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAgB9B,eAAO,IAAI,GAAG,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,GAAG,SAAS,CAAC"}
@@ -5,20 +5,20 @@ import cors from 'cors';
5
5
  // For local debug
6
6
  // import {fileURLToPath} from 'url';
7
7
  import { loadArchive } from "./controllers/slpk-controller.js";
8
- import { router as indexRouter } from "./routes.js";
9
8
  import { sceneServerRouter, router } from "./routes/slpk-router.js";
10
9
  // For local debug
11
10
  // const __filename = fileURLToPath(import.meta.url);
12
11
  // const __dirname = path.dirname(__filename);
13
12
  const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
14
13
  const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef
15
- export const app = express();
16
- app.use(logger('dev'));
17
- app.use(express.json());
18
- app.use(express.urlencoded({ extended: false }));
19
- app.use(express.static(path.join(__dirname, 'public')));
20
- app.use(cors());
14
+ export let app;
21
15
  if (/\.slpk$/.test(I3S_LAYER_PATH)) {
16
+ app = express();
17
+ app.use(logger('dev'));
18
+ app.use(express.json());
19
+ app.use(express.urlencoded({ extended: false }));
20
+ app.use(express.static(path.join(__dirname, 'public')));
21
+ app.use(cors());
22
22
  let filePath = FULL_LAYER_PATH;
23
23
  // Checks if the first character is not a point to indicate absolute path
24
24
  const absolutePath = /^[^.]/.exec(I3S_LAYER_PATH);
@@ -29,6 +29,3 @@ if (/\.slpk$/.test(I3S_LAYER_PATH)) {
29
29
  app.use('/SceneServer/layers/0', router);
30
30
  app.use('/SceneServer', sceneServerRouter);
31
31
  }
32
- else {
33
- app.use('/', indexRouter);
34
- }