@loaders.gl/tile-converter 4.3.0-alpha.5 → 4.3.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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Converts time value to string.
3
+ * @param time - high-resolution real time in a [seconds, nanoseconds] tuple Array, or a value on milliseconds.
4
+ * @returns string representation of the time
5
+ */
6
+ export declare function timeConverter(time: number | [number, number]): string;
7
+ /**
8
+ * Calculates overall datatset size
9
+ * @param params - params object
10
+ * @param params.slpk - if dataset is in slpk format
11
+ * @param params.outputPath - path to the folder containing the dataset
12
+ * @param params.tilesetName - tileset name
13
+ * @returns dataset size in bytes
14
+ */
15
+ export declare function calculateDatasetSize(params: {
16
+ slpk?: boolean;
17
+ outputPath: string;
18
+ tilesetName: string;
19
+ }): Promise<number | null>;
20
+ //# sourceMappingURL=statistic-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statistic-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utils.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAarE;AA6BD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBzB"}
@@ -41,16 +41,48 @@ function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
41
41
  }
42
42
  return result;
43
43
  }
44
- export async function calculateFilesSize(params) {
45
- const { outputPath, tilesetName } = params;
44
+ /**
45
+ * Calculates overall datatset size
46
+ * @param params - params object
47
+ * @param params.slpk - if dataset is in slpk format
48
+ * @param params.outputPath - path to the folder containing the dataset
49
+ * @param params.tilesetName - tileset name
50
+ * @returns dataset size in bytes
51
+ */
52
+ export async function calculateDatasetSize(params) {
53
+ const { slpk, outputPath, tilesetName } = params;
46
54
  const fullOutputPath = getAbsoluteFilePath(outputPath);
47
55
  try {
48
- const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
49
- const stat = await fs.stat(slpkPath);
50
- return stat.size;
56
+ if (slpk) {
57
+ const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
58
+ const stat = await fs.stat(slpkPath);
59
+ return stat.size;
60
+ }
61
+ const directoryPath = join(fullOutputPath, tilesetName);
62
+ const totalSize = await getDirectorySize(directoryPath);
63
+ return totalSize;
51
64
  }
52
65
  catch (error) {
53
66
  console.log('Calculate file sizes error: ', error); // eslint-disable-line
54
67
  return null;
55
68
  }
56
69
  }
70
+ /**
71
+ * Calculates directory size
72
+ * @param dirPath - path to the directory
73
+ * @returns directory size in bytes
74
+ */
75
+ async function getDirectorySize(dirPath) {
76
+ let totalFileSize = 0;
77
+ const files = await fs.readdir(dirPath);
78
+ for (const file of files) {
79
+ const fileStat = await fs.stat(join(dirPath, file));
80
+ if (fileStat.isDirectory()) {
81
+ totalFileSize += await getDirectorySize(join(dirPath, file));
82
+ }
83
+ else {
84
+ totalFileSize += fileStat.size;
85
+ }
86
+ }
87
+ return totalFileSize;
88
+ }
@@ -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.4" !== 'undefined' ? "4.3.0-alpha.4" : 'latest';
4
+ const VERSION = typeof "4.3.0-alpha.5" !== 'undefined' ? "4.3.0-alpha.5" : '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.5",
3
+ "version": "4.3.0-alpha.6",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -51,20 +51,20 @@
51
51
  "copy-certificates": "cp -R src/i3s-server/certs dist/i3s-server"
52
52
  },
53
53
  "dependencies": {
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",
54
+ "@loaders.gl/3d-tiles": "4.3.0-alpha.6",
55
+ "@loaders.gl/compression": "4.3.0-alpha.6",
56
+ "@loaders.gl/crypto": "4.3.0-alpha.6",
57
+ "@loaders.gl/draco": "4.3.0-alpha.6",
58
+ "@loaders.gl/gltf": "4.3.0-alpha.6",
59
+ "@loaders.gl/i3s": "4.3.0-alpha.6",
60
+ "@loaders.gl/images": "4.3.0-alpha.6",
61
+ "@loaders.gl/loader-utils": "4.3.0-alpha.6",
62
+ "@loaders.gl/math": "4.3.0-alpha.6",
63
+ "@loaders.gl/polyfills": "4.3.0-alpha.6",
64
+ "@loaders.gl/textures": "4.3.0-alpha.6",
65
+ "@loaders.gl/tiles": "4.3.0-alpha.6",
66
+ "@loaders.gl/worker-utils": "4.3.0-alpha.6",
67
+ "@loaders.gl/zip": "4.3.0-alpha.6",
68
68
  "@math.gl/core": "^4.0.0",
69
69
  "@math.gl/culling": "^4.0.0",
70
70
  "@math.gl/geoid": "^4.0.0",
@@ -93,5 +93,5 @@
93
93
  "peerDependencies": {
94
94
  "@loaders.gl/core": "^4.0.0"
95
95
  },
96
- "gitHead": "b57553345b3cbf621c95ad9b22aa672217451f61"
96
+ "gitHead": "315f2e232fc4e6a477c41de800a54d3e3d957e8c"
97
97
  }
@@ -17,7 +17,7 @@ import {PGMLoader} from '../pgm-loader';
17
17
  import {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';
18
18
  import {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';
19
19
  import {writeFile, removeDir} from '../lib/utils/file-utils';
20
- import {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';
20
+ import {calculateDatasetSize, timeConverter} from '../lib/utils/statistic-utils';
21
21
  import {TILESET as tilesetTemplate} from './json-templates/tileset';
22
22
  import {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';
23
23
  import {WorkerFarm} from '@loaders.gl/worker-utils';
@@ -475,7 +475,7 @@ export default class Tiles3DConverter {
475
475
  outputPath: string;
476
476
  tilesetName: string;
477
477
  }): Promise<void> {
478
- const filesSize = await calculateFilesSize(params);
478
+ const filesSize = await calculateDatasetSize(params);
479
479
  const diff = process.hrtime(this.conversionStartTime);
480
480
  const conversionTime = timeConverter(diff);
481
481
 
@@ -115,13 +115,14 @@ export async function getNodeCount(fileSystem: ZipFileSystem | null): Promise<nu
115
115
  if (!fileSystem?.fileProvider) {
116
116
  return 0;
117
117
  }
118
- let count = 0;
118
+ const nodeSet = new Set();
119
119
  const filesIterator = makeZipCDHeaderIterator(fileSystem.fileProvider);
120
120
  for await (const file of filesIterator) {
121
121
  const filename = file.fileName;
122
- if (filename.indexOf('3dNodeIndexDocument.json.gz') >= 0) {
123
- count++;
122
+ const nodeNumberSearchResult = /^nodes\/(\d+)\//.exec(filename);
123
+ if (nodeNumberSearchResult) {
124
+ nodeSet.add(nodeNumberSearchResult[1]);
124
125
  }
125
126
  }
126
- return count;
127
+ return nodeSet.size;
127
128
  }
@@ -31,11 +31,10 @@ type TileConversionOptions = {
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
33
  /** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,
34
+ * "None" for not using Earth Gravity Model (*.pgm)
34
35
  * default: "./deps/egm2008-5.pgm". A model file can be loaded from GeographicLib
35
36
  * https://geographiclib.sourceforge.io/html/geoid.html */
36
37
  egm: string;
37
- /** 3DTiles->I3S only. Whether the converter uses Earth Gravity Model (*.pgm) */
38
- noEgm: boolean;
39
38
  /** 3DTile->I3S only. Token for Cesium ION tileset authentication. */
40
39
  token?: string;
41
40
  /** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */
@@ -179,9 +178,8 @@ function printHelp(): void {
179
178
  );
180
179
  console.log('--input-type [tileset input type: I3S or 3DTILES]');
181
180
  console.log(
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"'
181
+ '--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format or "None" to not use it. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: "./deps/egm2008-5.zip"'
183
182
  );
184
- console.log('--no-egm [Disable Geod transformation via the EGM file]');
185
183
  console.log('--token [Token for Cesium ION tilesets authentication]');
186
184
  console.log('--no-draco [Disable draco compression for geometry]');
187
185
  console.log(
@@ -311,8 +309,7 @@ function parseOptions(args: string[]): TileConversionOptions {
311
309
  generateBoundingVolumes: false,
312
310
  validate: false,
313
311
  addHash: false,
314
- quiet: false,
315
- noEgm: false
312
+ quiet: false
316
313
  };
317
314
 
318
315
  // eslint-disable-next-line complexity
@@ -346,9 +343,6 @@ function parseOptions(args: string[]): TileConversionOptions {
346
343
  case '--egm':
347
344
  opts.egm = getStringValue(index, args);
348
345
  break;
349
- case '--no-egm':
350
- opts.noEgm = getBooleanValue(index, args);
351
- break;
352
346
  case '--token':
353
347
  opts.token = getStringValue(index, args);
354
348
  break;
@@ -1,5 +1,5 @@
1
1
  import process from 'process';
2
- import {timeConverter} from '../../lib/utils/statistic-utills';
2
+ import {timeConverter} from '../../lib/utils/statistic-utils';
3
3
 
4
4
  /** Defines a threshold that is used to check if the process velocity can be consifered trust. */
5
5
  const THRESHOLD_DEFAULT = 0.2;
@@ -32,7 +32,7 @@ import md5 from 'md5';
32
32
  import NodePages from './helpers/node-pages';
33
33
  import {writeFile, removeDir, writeFileForSlpk, removeFile} from '../lib/utils/file-utils';
34
34
  import {compressFileWithGzip} from '../lib/utils/compress-util';
35
- import {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';
35
+ import {calculateDatasetSize, timeConverter} from '../lib/utils/statistic-utils';
36
36
  import convertB3dmToI3sGeometry, {getPropertyTable} from './helpers/geometry-converter';
37
37
  import {
38
38
  createBoundingVolumes,
@@ -107,7 +107,6 @@ type ConverterProps = {
107
107
  inquirer?: {prompt: PromptModule};
108
108
  metadataClass?: string;
109
109
  analyze?: boolean;
110
- noEgm?: boolean;
111
110
  };
112
111
 
113
112
  /**
@@ -224,8 +223,7 @@ export default class I3SConverter {
224
223
  mergeMaterials = true,
225
224
  inquirer,
226
225
  metadataClass,
227
- analyze = false,
228
- noEgm = false
226
+ analyze = false
229
227
  } = options;
230
228
  this.options = {
231
229
  outputPath,
@@ -250,8 +248,8 @@ export default class I3SConverter {
250
248
  this.writeQueue = new WriteQueue(this.conversionDump);
251
249
  this.writeQueue.startListening();
252
250
 
253
- if (!noEgm) {
254
- console.log('--no-egm option selected, skip loading egm file'); // eslint-disable-line
251
+ if (egmFilePath.toLowerCase() === 'none') {
252
+ console.log('--egm chousen to be "none", skip loading egm file'); // eslint-disable-line
255
253
  } else {
256
254
  console.log('Loading egm file...'); // eslint-disable-line
257
255
  this.geoidHeightModel = await load(egmFilePath, PGMLoader);
@@ -1528,7 +1526,7 @@ export default class I3SConverter {
1528
1526
  const addRefinementPercentage = tilesWithAddRefineCount
1529
1527
  ? (tilesWithAddRefineCount / tilesCount) * 100
1530
1528
  : 0;
1531
- const filesSize = await calculateFilesSize(params);
1529
+ const filesSize = await calculateDatasetSize(params);
1532
1530
  const diff = process.hrtime(this.conversionStartTime);
1533
1531
  const conversionTime = timeConverter(diff);
1534
1532
  console.log('------------------------------------------------'); // eslint-disable-line no-undef, no-console
@@ -49,16 +49,55 @@ function timeConverterFromSecondsAndMilliseconds(timeInSeconds: number, millisec
49
49
  return result;
50
50
  }
51
51
 
52
- export async function calculateFilesSize(params: {outputPath: string; tilesetName: string}) {
53
- const {outputPath, tilesetName} = params;
52
+ /**
53
+ * Calculates overall datatset size
54
+ * @param params - params object
55
+ * @param params.slpk - if dataset is in slpk format
56
+ * @param params.outputPath - path to the folder containing the dataset
57
+ * @param params.tilesetName - tileset name
58
+ * @returns dataset size in bytes
59
+ */
60
+ export async function calculateDatasetSize(params: {
61
+ slpk?: boolean;
62
+ outputPath: string;
63
+ tilesetName: string;
64
+ }): Promise<number | null> {
65
+ const {slpk, outputPath, tilesetName} = params;
54
66
  const fullOutputPath = getAbsoluteFilePath(outputPath);
55
67
 
56
68
  try {
57
- const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
58
- const stat = await fs.stat(slpkPath);
59
- return stat.size;
69
+ if (slpk) {
70
+ const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
71
+ const stat = await fs.stat(slpkPath);
72
+ return stat.size;
73
+ }
74
+
75
+ const directoryPath = join(fullOutputPath, tilesetName);
76
+ const totalSize = await getDirectorySize(directoryPath);
77
+ return totalSize;
60
78
  } catch (error) {
61
79
  console.log('Calculate file sizes error: ', error); // eslint-disable-line
62
80
  return null;
63
81
  }
64
82
  }
83
+
84
+ /**
85
+ * Calculates directory size
86
+ * @param dirPath - path to the directory
87
+ * @returns directory size in bytes
88
+ */
89
+ async function getDirectorySize(dirPath: string): Promise<number> {
90
+ let totalFileSize = 0;
91
+
92
+ const files = await fs.readdir(dirPath);
93
+
94
+ for (const file of files) {
95
+ const fileStat = await fs.stat(join(dirPath, file));
96
+ if (fileStat.isDirectory()) {
97
+ totalFileSize += await getDirectorySize(join(dirPath, file));
98
+ } else {
99
+ totalFileSize += fileStat.size;
100
+ }
101
+ }
102
+ return totalFileSize;
103
+ }
@@ -1,11 +0,0 @@
1
- /**
2
- * Converts time value to string.
3
- * @param time - high-resolution real time in a [seconds, nanoseconds] tuple Array, or a value on milliseconds.
4
- * @returns string representation of the time
5
- */
6
- export declare function timeConverter(time: number | [number, number]): string;
7
- export declare function calculateFilesSize(params: {
8
- outputPath: string;
9
- tilesetName: string;
10
- }): Promise<number | null>;
11
- //# sourceMappingURL=statistic-utills.d.ts.map
@@ -1 +0,0 @@
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"}