@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
@@ -4,5 +4,8 @@
4
4
  * @returns string representation of the time
5
5
  */
6
6
  export declare function timeConverter(time: number | [number, number]): string;
7
- export declare function calculateFilesSize(params: any): Promise<number | null>;
7
+ export declare function calculateFilesSize(params: {
8
+ outputPath: string;
9
+ tilesetName: string;
10
+ }): Promise<number | null>;
8
11
  //# sourceMappingURL=statistic-utills.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"statistic-utills.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utills.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAarE;AA6BD,wBAAsB,kBAAkB,CAAC,MAAM,KAAA,0BAkB9C"}
1
+ {"version":3,"file":"statistic-utills.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utills.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAarE;AA6BD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,0BAYzF"}
@@ -42,34 +42,15 @@ function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
42
42
  return result;
43
43
  }
44
44
  export async function calculateFilesSize(params) {
45
- const { slpk, outputPath, tilesetName } = params;
45
+ const { outputPath, tilesetName } = params;
46
46
  const fullOutputPath = getAbsoluteFilePath(outputPath);
47
47
  try {
48
- if (slpk) {
49
- const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
50
- const stat = await fs.stat(slpkPath);
51
- return stat.size;
52
- }
53
- const directoryPath = join(fullOutputPath, tilesetName);
54
- const totalSize = await getTotalFilesSize(directoryPath);
55
- return totalSize;
48
+ const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
49
+ const stat = await fs.stat(slpkPath);
50
+ return stat.size;
56
51
  }
57
52
  catch (error) {
58
53
  console.log('Calculate file sizes error: ', error); // eslint-disable-line
59
54
  return null;
60
55
  }
61
56
  }
62
- async function getTotalFilesSize(dirPath) {
63
- let totalFileSize = 0;
64
- const files = await fs.readdir(dirPath);
65
- for (const file of files) {
66
- const fileStat = await fs.stat(join(dirPath, file));
67
- if (fileStat.isDirectory()) {
68
- totalFileSize += await getTotalFilesSize(join(dirPath, file));
69
- }
70
- else {
71
- totalFileSize += fileStat.size;
72
- }
73
- }
74
- return totalFileSize;
75
- }
@@ -1,7 +1,7 @@
1
1
  import { Geoid, parsePGM } from '@math.gl/geoid';
2
2
  // __VERSION__ is injected by babel-plugin-version-inline
3
3
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
4
- const VERSION = typeof "4.3.0-alpha.2" !== 'undefined' ? "4.3.0-alpha.2" : 'latest';
4
+ const VERSION = typeof "4.3.0-alpha.4" !== 'undefined' ? "4.3.0-alpha.4" : 'latest';
5
5
  export { Geoid };
6
6
  /**
7
7
  * Loader for PGM - Netpbm grayscale image format
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tile-converter",
3
- "version": "4.3.0-alpha.3",
3
+ "version": "4.3.0-alpha.5",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,7 +29,6 @@
29
29
  "sideEffects": false,
30
30
  "bin": {
31
31
  "i3s-server": "./bin/i3s-server.js",
32
- "slpk-extractor": "./bin/slpk-extractor.js",
33
32
  "tile-converter": "./bin/converter.js"
34
33
  },
35
34
  "files": [
@@ -46,27 +45,26 @@
46
45
  "process": false
47
46
  },
48
47
  "scripts": {
49
- "pre-build": "npm run build-converter-bundle && npm run build-slpk-extractor-bundle && npm run build-i3s-server-bundle && npm run copy-certificates",
48
+ "pre-build": "npm run build-converter-bundle && npm run build-i3s-server-bundle && npm run copy-certificates",
50
49
  "build-converter-bundle": "esbuild src/converter-cli.ts --outfile=dist/converter.min.cjs --platform=node --target=esnext,node14 --external:join-images --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\"",
51
- "build-slpk-extractor-bundle": "esbuild src/slpk-extractor-cli.ts --outfile=dist/slpk-extractor.min.cjs --platform=node --target=esnext,node14 --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\"",
52
50
  "build-i3s-server-bundle": "esbuild src/i3s-server/bin/www.ts --outfile=dist/i3s-server/bin/i3s-server.min.cjs --platform=node --target=esnext,node14 --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\"",
53
51
  "copy-certificates": "cp -R src/i3s-server/certs dist/i3s-server"
54
52
  },
55
53
  "dependencies": {
56
- "@loaders.gl/3d-tiles": "4.3.0-alpha.3",
57
- "@loaders.gl/compression": "4.3.0-alpha.3",
58
- "@loaders.gl/crypto": "4.3.0-alpha.3",
59
- "@loaders.gl/draco": "4.3.0-alpha.3",
60
- "@loaders.gl/gltf": "4.3.0-alpha.3",
61
- "@loaders.gl/i3s": "4.3.0-alpha.3",
62
- "@loaders.gl/images": "4.3.0-alpha.3",
63
- "@loaders.gl/loader-utils": "4.3.0-alpha.3",
64
- "@loaders.gl/math": "4.3.0-alpha.3",
65
- "@loaders.gl/polyfills": "4.3.0-alpha.3",
66
- "@loaders.gl/textures": "4.3.0-alpha.3",
67
- "@loaders.gl/tiles": "4.3.0-alpha.3",
68
- "@loaders.gl/worker-utils": "4.3.0-alpha.3",
69
- "@loaders.gl/zip": "4.3.0-alpha.3",
54
+ "@loaders.gl/3d-tiles": "4.3.0-alpha.5",
55
+ "@loaders.gl/compression": "4.3.0-alpha.5",
56
+ "@loaders.gl/crypto": "4.3.0-alpha.5",
57
+ "@loaders.gl/draco": "4.3.0-alpha.5",
58
+ "@loaders.gl/gltf": "4.3.0-alpha.5",
59
+ "@loaders.gl/i3s": "4.3.0-alpha.5",
60
+ "@loaders.gl/images": "4.3.0-alpha.5",
61
+ "@loaders.gl/loader-utils": "4.3.0-alpha.5",
62
+ "@loaders.gl/math": "4.3.0-alpha.5",
63
+ "@loaders.gl/polyfills": "4.3.0-alpha.5",
64
+ "@loaders.gl/textures": "4.3.0-alpha.5",
65
+ "@loaders.gl/tiles": "4.3.0-alpha.5",
66
+ "@loaders.gl/worker-utils": "4.3.0-alpha.5",
67
+ "@loaders.gl/zip": "4.3.0-alpha.5",
70
68
  "@math.gl/core": "^4.0.0",
71
69
  "@math.gl/culling": "^4.0.0",
72
70
  "@math.gl/geoid": "^4.0.0",
@@ -89,10 +87,11 @@
89
87
  "sharp": "^0.31.3"
90
88
  },
91
89
  "devDependencies": {
92
- "@types/express": "^4.17.17"
90
+ "@types/express": "^4.17.17",
91
+ "@types/inquirer": "^9.0.7"
93
92
  },
94
93
  "peerDependencies": {
95
94
  "@loaders.gl/core": "^4.0.0"
96
95
  },
97
- "gitHead": "3213679d79e6ff2814d48fd3337acfa446c74099"
96
+ "gitHead": "b57553345b3cbf621c95ad9b22aa672217451f61"
98
97
  }
@@ -29,6 +29,7 @@ import {I3SLoaderOptions} from '@loaders.gl/i3s/src/i3s-loader';
29
29
  import {ZipFileSystem} from '../../../zip/src';
30
30
  import {ConversionDump, ConversionDumpOptions} from '../lib/utils/conversion-dump';
31
31
  import {Progress} from '../i3s-converter/helpers/progress';
32
+ import {PromptModule} from 'inquirer';
32
33
 
33
34
  const I3S = 'I3S';
34
35
 
@@ -88,7 +89,7 @@ export default class Tiles3DConverter {
88
89
  tilesetName: string;
89
90
  maxDepth?: number;
90
91
  egmFilePath: string;
91
- inquirer?: Promise<unknown>;
92
+ inquirer?: {prompt: PromptModule};
92
93
  analyze?: boolean;
93
94
  }): Promise<string | undefined> {
94
95
  if (isBrowser) {
@@ -30,12 +30,12 @@ type TileConversionOptions = {
30
30
  instantNodeWriting: boolean;
31
31
  /** Try to merge similar materials to be able to merge meshes into one node (I3S to 3DTiles conversion only) */
32
32
  mergeMaterials: boolean;
33
- /** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: "C:\Program Files\7-Zip\7z.exe" */
34
- sevenZipExe: string;
35
33
  /** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,
36
34
  * default: "./deps/egm2008-5.pgm". A model file can be loaded from GeographicLib
37
35
  * https://geographiclib.sourceforge.io/html/geoid.html */
38
36
  egm: string;
37
+ /** 3DTiles->I3S only. Whether the converter uses Earth Gravity Model (*.pgm) */
38
+ noEgm: boolean;
39
39
  /** 3DTile->I3S only. Token for Cesium ION tileset authentication. */
40
40
  token?: string;
41
41
  /** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */
@@ -52,8 +52,6 @@ type TileConversionOptions = {
52
52
  validate: boolean;
53
53
  /** Maximal depth of the hierarchical tiles tree traversal, default: infinite */
54
54
  maxDepth?: number;
55
- /** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */
56
- slpk: boolean;
57
55
  /** adds hash file to the slpk if there's no one */
58
56
  addHash: boolean;
59
57
  /** Feature metadata class from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA extensions */
@@ -176,17 +174,14 @@ function printHelp(): void {
176
174
  console.log(
177
175
  '--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]'
178
176
  );
179
- console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');
180
177
  console.log(
181
178
  '--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'
182
179
  );
183
180
  console.log('--input-type [tileset input type: I3S or 3DTILES]');
184
- console.log(
185
- '--7zExe [location of 7z.exe archiver to create slpk on Windows, default: "C:\\Program Files\\7-Zip\\7z.exe"]'
186
- );
187
181
  console.log(
188
182
  '--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: "./deps/egm2008-5.zip"'
189
183
  );
184
+ console.log('--no-egm [Disable Geod transformation via the EGM file]');
190
185
  console.log('--token [Token for Cesium ION tilesets authentication]');
191
186
  console.log('--no-draco [Disable draco compression for geometry]');
192
187
  console.log(
@@ -233,8 +228,6 @@ async function convert(options: ValidatedTileConversionOptions) {
233
228
  outputPath: options.output,
234
229
  tilesetName: options.name,
235
230
  maxDepth: options.maxDepth,
236
- slpk: options.slpk,
237
- sevenZipExe: options.sevenZipExe,
238
231
  egmFilePath: options.egm,
239
232
  token: options.token,
240
233
  draco: options.draco,
@@ -274,7 +267,6 @@ function validateOptions(
274
267
  condition: (value: any) => addHash || Boolean(value) || Boolean(options.analyze)
275
268
  },
276
269
  output: {getMessage: () => console.log('Missed: --output [Output path name]')},
277
- sevenZipExe: {getMessage: () => console.log('Missed: --7zExe [7z archiver executable path]')},
278
270
  egm: {getMessage: () => console.log('Missed: --egm [*.pgm earth gravity model file path]')},
279
271
  tileset: {getMessage: () => console.log('Missed: --tileset [tileset.json file]')},
280
272
  inputType: {
@@ -312,16 +304,15 @@ function parseOptions(args: string[]): TileConversionOptions {
312
304
  output: 'data',
313
305
  instantNodeWriting: false,
314
306
  mergeMaterials: true,
315
- sevenZipExe: 'C:\\Program Files\\7-Zip\\7z.exe',
316
307
  egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),
317
308
  draco: true,
318
309
  installDependencies: false,
319
310
  generateTextures: false,
320
311
  generateBoundingVolumes: false,
321
312
  validate: false,
322
- slpk: false,
323
313
  addHash: false,
324
- quiet: false
314
+ quiet: false,
315
+ noEgm: false
325
316
  };
326
317
 
327
318
  // eslint-disable-next-line complexity
@@ -349,18 +340,15 @@ function parseOptions(args: string[]): TileConversionOptions {
349
340
  case '--max-depth':
350
341
  opts.maxDepth = getIntegerValue(index, args);
351
342
  break;
352
- case '--slpk':
353
- opts.slpk = getBooleanValue(index, args);
354
- break;
355
343
  case '--add-hash':
356
344
  opts.addHash = getBooleanValue(index, args);
357
345
  break;
358
- case '--7zExe':
359
- opts.sevenZipExe = getStringValue(index, args);
360
- break;
361
346
  case '--egm':
362
347
  opts.egm = getStringValue(index, args);
363
348
  break;
349
+ case '--no-egm':
350
+ opts.noEgm = getBooleanValue(index, args);
351
+ break;
364
352
  case '--token':
365
353
  opts.token = getStringValue(index, args);
366
354
  break;
@@ -18,7 +18,7 @@ import {Geoid} from '@math.gl/geoid';
18
18
  */
19
19
  export function createBoundingVolumes(
20
20
  sourceBoundingVolume: OrientedBoundingBox | BoundingSphere,
21
- geoidHeightModel: Geoid
21
+ geoidHeightModel: Geoid | null
22
22
  ): BoundingVolumes {
23
23
  let radius;
24
24
  let halfSize;
@@ -28,9 +28,13 @@ export function createBoundingVolumes(
28
28
  sourceBoundingVolume.center,
29
29
  new Vector3()
30
30
  );
31
- cartographicCenter[2] =
32
- cartographicCenter[2] -
33
- geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
31
+
32
+ if (geoidHeightModel) {
33
+ cartographicCenter[2] =
34
+ cartographicCenter[2] -
35
+ geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
36
+ }
37
+
34
38
  if (sourceBoundingVolume instanceof OrientedBoundingBox) {
35
39
  halfSize = sourceBoundingVolume.halfSize;
36
40
  radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
@@ -60,7 +64,7 @@ export function createBoundingVolumes(
60
64
  */
61
65
  export function createBoundingVolumesFromGeometry(
62
66
  cartesianPositions: Float32Array,
63
- geoidHeightModel: Geoid
67
+ geoidHeightModel: Geoid | null
64
68
  ): {mbs: Mbs; obb: Obb} {
65
69
  const positionVectors = convertPositionsToVectors(cartesianPositions);
66
70
 
@@ -70,8 +74,10 @@ export function createBoundingVolumesFromGeometry(
70
74
  const mbsCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new Vector3());
71
75
  const obbCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new Vector3());
72
76
 
73
- mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
74
- obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
77
+ if (geoidHeightModel) {
78
+ mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
79
+ obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
80
+ }
75
81
 
76
82
  return {
77
83
  mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],
@@ -121,7 +121,7 @@ export default async function convertB3dmToI3sGeometry({
121
121
  draco: boolean;
122
122
  generateBoundingVolumes: boolean;
123
123
  shouldMergeMaterials: boolean;
124
- geoidHeightModel: Geoid;
124
+ geoidHeightModel: Geoid | null;
125
125
  libraries: Record<string, string>;
126
126
  metadataClass?: string;
127
127
  }): Promise<I3SConvertedResources[] | null> {
@@ -197,7 +197,7 @@ export default async function convertB3dmToI3sGeometry({
197
197
  */
198
198
  function _generateBoundingVolumesFromGeometry(
199
199
  convertedAttributesMap: Map<string, ConvertedAttributes>,
200
- geoidHeightModel: Geoid
200
+ geoidHeightModel: Geoid | null
201
201
  ) {
202
202
  for (const attributes of convertedAttributesMap.values()) {
203
203
  const boundingVolumes = createBoundingVolumesFromGeometry(
@@ -211,8 +211,10 @@ function _generateBoundingVolumesFromGeometry(
211
211
  for (let index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {
212
212
  const vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);
213
213
  Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
214
- scratchVector[2] =
215
- scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
214
+ if (geoidHeightModel) {
215
+ scratchVector[2] =
216
+ scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
217
+ }
216
218
  scratchVector = scratchVector.subtract(cartographicOrigin);
217
219
  attributes.positions.set(scratchVector, index);
218
220
  }
@@ -8,7 +8,7 @@ import {
8
8
  } from '@loaders.gl/i3s';
9
9
  import transform from 'json-map-transform';
10
10
  import {v4 as uuidv4} from 'uuid';
11
- import {openJson, writeFile, writeFileForSlpk} from '../../lib/utils/file-utils';
11
+ import {openJson, writeFileForSlpk} from '../../lib/utils/file-utils';
12
12
  import I3SConverter from '../i3s-converter';
13
13
  import {NODE as nodeTemplate} from '../json-templates/node';
14
14
  import {I3SConvertedResources} from '../types';
@@ -155,27 +155,20 @@ export class NodeIndexDocument {
155
155
  */
156
156
  private async write(node: Node3DIndexDocument): Promise<void> {
157
157
  const path = join(this.converter.layers0Path, 'nodes', this.id);
158
- if (this.converter.options.slpk) {
159
- await this.converter.writeQueue.enqueue(
160
- {
161
- archiveKey: `nodes/${this.id}/3dNodeIndexDocument.json.gz`,
162
- writePromise: () =>
163
- writeFileForSlpk(
164
- path,
165
- JSON.stringify(node),
166
- '3dNodeIndexDocument.json',
167
- true,
168
- this.converter.compressList
169
- )
170
- },
171
- true
172
- );
173
- } else {
174
- await this.converter.writeQueue.enqueue(
175
- {writePromise: () => writeFile(path, JSON.stringify(node))},
176
- true
177
- );
178
- }
158
+ await this.converter.writeQueue.enqueue(
159
+ {
160
+ archiveKey: `nodes/${this.id}/3dNodeIndexDocument.json.gz`,
161
+ writePromise: () =>
162
+ writeFileForSlpk(
163
+ path,
164
+ JSON.stringify(node),
165
+ '3dNodeIndexDocument.json',
166
+ true,
167
+ this.converter.compressList
168
+ )
169
+ },
170
+ true
171
+ );
179
172
  }
180
173
 
181
174
  /**
@@ -188,10 +181,7 @@ export class NodeIndexDocument {
188
181
  }
189
182
  const path = this.id;
190
183
  const parentNodePath = join(this.converter.layers0Path, 'nodes', path);
191
- let parentNodeFileName = 'index.json';
192
- if (this.converter.options.slpk) {
193
- parentNodeFileName = '3dNodeIndexDocument.json';
194
- }
184
+ const parentNodeFileName = '3dNodeIndexDocument.json';
195
185
  return (await openJson(parentNodePath, parentNodeFileName)) as Node3DIndexDocument;
196
186
  }
197
187
 
@@ -51,7 +51,7 @@ export default class NodePages {
51
51
  * @param writeFileFunc - function to save one nodePage into a file
52
52
  * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met
53
53
  */
54
- constructor(writeFileFunc, nodesPerPage, converter: I3SConverter) {
54
+ constructor(writeFileFunc, nodesPerPage: number, converter: I3SConverter) {
55
55
  this.nodesPerPage = nodesPerPage;
56
56
  this.nodesCounter = 0;
57
57
  // @ts-expect-error
@@ -75,16 +75,9 @@ export default class NodePages {
75
75
  * @param nodePageId - node page id
76
76
  * @returns file path and file name
77
77
  */
78
- private getNodePageFileName(nodePageId): {filePath: string; fileName: string} {
79
- let filePath;
80
- let fileName;
81
- if (this.converter.options.slpk) {
82
- filePath = join(this.converter.layers0Path, 'nodepages');
83
- fileName = `${nodePageId.toString()}.json`;
84
- } else {
85
- filePath = join(this.converter.layers0Path, 'nodepages', nodePageId.toString());
86
- fileName = 'index.json';
87
- }
78
+ private getNodePageFileName(nodePageId: number): {filePath: string; fileName: string} {
79
+ const filePath = join(this.converter.layers0Path, 'nodepages');
80
+ const fileName = `${nodePageId.toString()}.json`;
88
81
  return {filePath, fileName};
89
82
  }
90
83
 
@@ -190,23 +183,14 @@ export default class NodePages {
190
183
  nodePage.nodes.push(node);
191
184
  }
192
185
  const nodePageStr = JSON.stringify(nodePage);
193
- if (this.converter.options.slpk) {
194
- await this.converter.writeQueue.enqueue(
195
- {
196
- archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
197
- writePromise: () =>
198
- this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
199
- },
200
- true
201
- );
202
- } else {
203
- await this.converter.writeQueue.enqueue(
204
- {
205
- writePromise: () => this.writeFile(filePath, nodePageStr)
206
- },
207
- true
208
- );
209
- }
186
+ await this.converter.writeQueue.enqueue(
187
+ {
188
+ archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
189
+ writePromise: () =>
190
+ this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
191
+ },
192
+ true
193
+ );
210
194
  }
211
195
 
212
196
  /**
@@ -236,25 +220,15 @@ export default class NodePages {
236
220
  await this.saveMetadata();
237
221
  return;
238
222
  }
239
- if (this.converter.options.slpk) {
240
- for (const [index, nodePage] of this.nodePages.entries()) {
241
- const nodePageStr = JSON.stringify(nodePage);
242
- const slpkPath = join(this.converter.layers0Path, 'nodepages');
243
- await this.converter.writeQueue.enqueue({
244
- archiveKey: `nodePages/${index.toString()}.json.gz`,
245
- writePromise: () => this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)
246
- });
247
- }
248
- await this.saveMetadata();
249
- } else {
250
- for (const [index, nodePage] of this.nodePages.entries()) {
251
- const nodePageStr = JSON.stringify(nodePage);
252
- const nodePagePath = join(this.converter.layers0Path, 'nodepages', index.toString());
253
- await this.converter.writeQueue.enqueue({
254
- writePromise: () => this.writeFile(nodePagePath, nodePageStr)
255
- });
256
- }
223
+ for (const [index, nodePage] of this.nodePages.entries()) {
224
+ const nodePageStr = JSON.stringify(nodePage);
225
+ const slpkPath = join(this.converter.layers0Path, 'nodepages');
226
+ await this.converter.writeQueue.enqueue({
227
+ archiveKey: `nodePages/${index.toString()}.json.gz`,
228
+ writePromise: () => this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)
229
+ });
257
230
  }
231
+ await this.saveMetadata();
258
232
  }
259
233
 
260
234
  /**