@loaders.gl/tile-converter 4.3.0-alpha.4 → 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.
Files changed (59) 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/3d-tiles-converter/3d-tiles-converter.js +2 -2
  4. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/load-i3s.js +5 -4
  6. package/dist/converter-cli.js +2 -20
  7. package/dist/converter.min.cjs +69 -69
  8. package/dist/deps-installer/deps-installer.js +1 -1
  9. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  10. package/dist/i3s-converter/helpers/node-index-document.js +6 -14
  11. package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
  12. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  13. package/dist/i3s-converter/helpers/node-pages.js +14 -40
  14. package/dist/i3s-converter/helpers/progress.js +1 -1
  15. package/dist/i3s-converter/i3s-converter.d.ts +23 -23
  16. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  17. package/dist/i3s-converter/i3s-converter.js +64 -134
  18. package/dist/i3s-server/app.d.ts +2 -1
  19. package/dist/i3s-server/app.d.ts.map +1 -1
  20. package/dist/i3s-server/app.js +7 -10
  21. package/dist/i3s-server/bin/i3s-server.min.cjs +71 -71
  22. package/dist/i3s-server/bin/www.js +5 -0
  23. package/dist/index.cjs +92 -185
  24. package/dist/index.cjs.map +3 -3
  25. package/dist/lib/utils/statistic-utils.d.ts +20 -0
  26. package/dist/lib/utils/statistic-utils.d.ts.map +1 -0
  27. package/dist/lib/utils/{statistic-utills.js → statistic-utils.js} +17 -4
  28. package/dist/pgm-loader.js +1 -1
  29. package/package.json +19 -20
  30. package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -3
  31. package/src/3d-tiles-converter/helpers/load-i3s.ts +5 -4
  32. package/src/converter-cli.ts +3 -28
  33. package/src/i3s-converter/helpers/node-index-document.ts +16 -26
  34. package/src/i3s-converter/helpers/node-pages.ts +20 -46
  35. package/src/i3s-converter/helpers/progress.ts +1 -1
  36. package/src/i3s-converter/i3s-converter.ts +92 -160
  37. package/src/i3s-server/app.ts +7 -10
  38. package/src/i3s-server/bin/www.ts +6 -0
  39. package/src/lib/utils/{statistic-utills.ts → statistic-utils.ts} +21 -4
  40. package/bin/slpk-extractor.js +0 -2
  41. package/dist/i3s-server/controllers/index-controller.d.ts +0 -8
  42. package/dist/i3s-server/controllers/index-controller.d.ts.map +0 -1
  43. package/dist/i3s-server/controllers/index-controller.js +0 -31
  44. package/dist/i3s-server/routes/index.d.ts +0 -2
  45. package/dist/i3s-server/routes/index.d.ts.map +0 -1
  46. package/dist/i3s-server/routes/index.js +0 -17
  47. package/dist/lib/utils/statistic-utills.d.ts +0 -8
  48. package/dist/lib/utils/statistic-utills.d.ts.map +0 -1
  49. package/dist/slpk-extractor/slpk-extractor.d.ts +0 -23
  50. package/dist/slpk-extractor/slpk-extractor.d.ts.map +0 -1
  51. package/dist/slpk-extractor/slpk-extractor.js +0 -73
  52. package/dist/slpk-extractor-cli.d.ts +0 -17
  53. package/dist/slpk-extractor-cli.d.ts.map +0 -1
  54. package/dist/slpk-extractor-cli.js +0 -105
  55. package/dist/slpk-extractor.min.cjs +0 -344
  56. package/src/i3s-server/controllers/index-controller.ts +0 -32
  57. package/src/i3s-server/routes/index.ts +0 -18
  58. package/src/slpk-extractor/slpk-extractor.ts +0 -102
  59. package/src/slpk-extractor-cli.ts +0 -136
@@ -1,73 +0,0 @@
1
- import { isBrowser } from '@loaders.gl/core';
2
- import { BROWSER_ERROR_MESSAGE } from "../constants.js";
3
- import { path } from '@loaders.gl/loader-utils';
4
- import { FileHandleFile } from '@loaders.gl/loader-utils';
5
- import { parseZipLocalFileHeader } from '@loaders.gl/zip';
6
- import { GZipCompression } from '@loaders.gl/compression';
7
- import { writeFile } from "../lib/utils/file-utils.js";
8
- const indexNames = [
9
- '3dSceneLayer.json.gz',
10
- '3dNodeIndexDocument.json.gz',
11
- 'sharedResource.json.gz'
12
- ];
13
- /**
14
- * Converter from slpk to i3s
15
- */
16
- export default class SLPKExtractor {
17
- /**
18
- * Extract slpk to i3s
19
- * @param options
20
- * @param options.inputUrl the url to read SLPK file
21
- * @param options.outputPath the output filename
22
- */
23
- async extract(options) {
24
- if (isBrowser) {
25
- // eslint-disable-next-line no-console
26
- console.log(BROWSER_ERROR_MESSAGE);
27
- return BROWSER_ERROR_MESSAGE;
28
- }
29
- const { inputUrl } = options;
30
- const provider = new FileHandleFile(inputUrl);
31
- let localHeader = await parseZipLocalFileHeader(0n, provider);
32
- while (localHeader) {
33
- await this.writeFile(await this.unGzip({
34
- name: this.correctIndexNames(localHeader.fileName),
35
- data: await provider.slice(localHeader.fileDataOffset, localHeader.fileDataOffset + localHeader.compressedSize)
36
- }), options.outputPath);
37
- localHeader = await parseZipLocalFileHeader(localHeader.fileDataOffset + localHeader?.compressedSize, provider);
38
- }
39
- return 'success';
40
- }
41
- /**
42
- * Defines file name and path for i3s format
43
- * @param fileName initial file name and path
44
- */
45
- correctIndexNames(fileName) {
46
- if (indexNames.includes(path.filename(path.join('/', fileName)))) {
47
- return path.join(path.dirname(fileName), 'index.json.gz');
48
- }
49
- // finds path with name part and extention part
50
- const parts = /^(.*\/[^\/\.]*)(\..+)$/.exec(fileName);
51
- if (!parts) {
52
- return null;
53
- }
54
- return `${parts?.at(1)}/index${parts?.at(2)}`;
55
- }
56
- async unGzip(file) {
57
- if (/\.gz$/.test(file.name ?? '')) {
58
- const compression = new GZipCompression();
59
- const decompressedData = await compression.decompress(file.data);
60
- return { data: decompressedData, name: (file.name ?? '').slice(0, -3) };
61
- }
62
- return Promise.resolve(file);
63
- }
64
- async writeFile(options, outputPath) {
65
- if (!options.name) {
66
- return;
67
- }
68
- const finalPath = path.join(outputPath, options.name);
69
- const dirName = path.dirname(finalPath);
70
- const fileName = path.filename(finalPath);
71
- await writeFile(dirName, options.data, fileName);
72
- }
73
- }
@@ -1,17 +0,0 @@
1
- import '@loaders.gl/polyfills';
2
- type SLPKExtractionOptions = {
3
- /** "tileset.json" file (3DTiles) / "http://..../SceneServer/layers/0" resource (I3S) */
4
- tileset?: string;
5
- /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.
6
- * Default: "data" folder */
7
- output?: string;
8
- };
9
- export type ValidatedSLPKExtractionOptions = SLPKExtractionOptions & {
10
- /** slpk file */
11
- tileset: string;
12
- /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.
13
- * Default: "data" folder */
14
- output: string;
15
- };
16
- export {};
17
- //# sourceMappingURL=slpk-extractor-cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slpk-extractor-cli.d.ts","sourceRoot":"","sources":["../src/slpk-extractor-cli.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAI/B,KAAK,qBAAqB,GAAG;IAC3B,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;gCAC4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAGF,MAAM,MAAM,8BAA8B,GAAG,qBAAqB,GAAG;IACnE,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB;gCAC4B;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -1,105 +0,0 @@
1
- import '@loaders.gl/polyfills';
2
- import SLPKExtractor from "./slpk-extractor/slpk-extractor.js";
3
- import { getURLValue, validateOptionsWithEqual } from "./lib/utils/cli-utils.js";
4
- /**
5
- * CLI entry
6
- * @returns
7
- */
8
- async function main() {
9
- const [, , ...args] = process.argv;
10
- if (args.length === 0) {
11
- printHelp();
12
- }
13
- const validatedOptionsArr = validateOptionsWithEqual(args);
14
- const options = parseOptions(validatedOptionsArr);
15
- const validatedOptions = validateOptions(options);
16
- await convert(validatedOptions);
17
- }
18
- main().catch((error) => {
19
- console.log(error); // eslint-disable-line no-console
20
- process.exit(1); // eslint-disable-line no-process-exit
21
- });
22
- /**
23
- * Output for `npx slpk-extractor --help`
24
- */
25
- function printHelp() {
26
- // eslint-disable-next-line no-console
27
- console.log('cli: converter slpk to I3S...');
28
- // eslint-disable-next-line no-console
29
- console.log('--output [Output folder, default: "data" folder]');
30
- // eslint-disable-next-line no-console
31
- console.log('--tileset [SLPK file]');
32
- process.exit(0); // eslint-disable-line no-process-exit
33
- }
34
- /**
35
- * Run extraction process
36
- * @param options validated slpk-extractor options
37
- */
38
- async function convert(options) {
39
- // eslint-disable-next-line no-console
40
- console.log('------------------------------------------------');
41
- // eslint-disable-next-line no-console
42
- console.log('Starting conversion of SLPK');
43
- // eslint-disable-next-line no-console
44
- console.log('------------------------------------------------');
45
- const slpkExtractor = new SLPKExtractor();
46
- slpkExtractor.extract({
47
- inputUrl: options.tileset,
48
- outputPath: options.output
49
- });
50
- }
51
- // OPTIONS
52
- /**
53
- * Validate input options of the CLI command
54
- * @param options - input options of the CLI command
55
- * @returns validated options
56
- */
57
- function validateOptions(options) {
58
- const mandatoryOptionsWithExceptions = {
59
- // eslint-disable-next-line no-console
60
- output: () => console.log('Missed: --output [Output path name]'),
61
- // eslint-disable-next-line no-console
62
- tileset: () => console.log('Missed: --tileset [SLPK file]')
63
- };
64
- const exceptions = [];
65
- for (const mandatoryOption in mandatoryOptionsWithExceptions) {
66
- const optionValue = options[mandatoryOption];
67
- if (!optionValue) {
68
- exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);
69
- }
70
- }
71
- if (exceptions.length) {
72
- exceptions.forEach((exeption) => exeption());
73
- process.exit(1); // eslint-disable-line no-process-exit
74
- }
75
- return options;
76
- }
77
- /**
78
- * Parse option from the cli arguments array
79
- * @param args
80
- * @returns
81
- */
82
- function parseOptions(args) {
83
- const opts = {};
84
- // eslint-disable-next-line complexity
85
- args.forEach((arg, index) => {
86
- if (arg.indexOf('--') === 0) {
87
- switch (arg) {
88
- case '--tileset':
89
- opts.tileset = getURLValue(index, args);
90
- break;
91
- case '--output':
92
- opts.output = getURLValue(index, args);
93
- break;
94
- case '--help':
95
- printHelp();
96
- break;
97
- default:
98
- // eslint-disable-next-line no-console
99
- console.warn(`Unknown option ${arg}`);
100
- process.exit(0); // eslint-disable-line
101
- }
102
- }
103
- });
104
- return opts;
105
- }