@loaders.gl/tile-converter 4.0.0-alpha.10 → 4.0.0-alpha.12

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 (79) hide show
  1. package/bin/slpk-extractor.js +4 -0
  2. package/dist/3d-tiles-attributes-worker.js +1 -1
  3. package/dist/converter-cli.js +18 -84
  4. package/dist/converter.min.js +50 -50
  5. package/dist/dist.min.js +21 -18
  6. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  7. package/dist/es5/converter-cli.js +18 -63
  8. package/dist/es5/converter-cli.js.map +1 -1
  9. package/dist/es5/deps-installer/deps-installer.js +1 -1
  10. package/dist/es5/i3s-attributes-worker.js +1 -1
  11. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  12. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  13. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +2 -2
  14. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  15. package/dist/es5/i3s-converter/i3s-converter.js +59 -38
  16. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  17. package/dist/es5/lib/utils/cli-utils.js +57 -0
  18. package/dist/es5/lib/utils/cli-utils.js.map +1 -0
  19. package/dist/es5/pgm-loader.js +1 -1
  20. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +181 -0
  21. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
  22. package/dist/es5/slpk-extractor/slpk-extractor.js +172 -0
  23. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -0
  24. package/dist/es5/slpk-extractor-cli.js +117 -0
  25. package/dist/es5/slpk-extractor-cli.js.map +1 -0
  26. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  27. package/dist/esm/converter-cli.js +1 -46
  28. package/dist/esm/converter-cli.js.map +1 -1
  29. package/dist/esm/deps-installer/deps-installer.js +1 -1
  30. package/dist/esm/i3s-attributes-worker.js +1 -1
  31. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  32. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  33. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +1 -1
  34. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  35. package/dist/esm/i3s-converter/i3s-converter.js +22 -9
  36. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  37. package/dist/esm/lib/utils/cli-utils.js +47 -0
  38. package/dist/esm/lib/utils/cli-utils.js.map +1 -0
  39. package/dist/esm/pgm-loader.js +1 -1
  40. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +43 -0
  41. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
  42. package/dist/esm/slpk-extractor/slpk-extractor.js +63 -0
  43. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -0
  44. package/dist/esm/slpk-extractor-cli.js +74 -0
  45. package/dist/esm/slpk-extractor-cli.js.map +1 -0
  46. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +1 -2
  47. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  48. package/dist/i3s-converter/helpers/coordinate-converter.js +1 -2
  49. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
  50. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  51. package/dist/i3s-converter/helpers/gltf-attributes.js +2 -1
  52. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -3
  53. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  54. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +1 -2
  55. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  56. package/dist/i3s-converter/i3s-converter.js +21 -6
  57. package/dist/lib/utils/cli-utils.d.ts +34 -0
  58. package/dist/lib/utils/cli-utils.d.ts.map +1 -0
  59. package/dist/lib/utils/cli-utils.js +82 -0
  60. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts +48 -0
  61. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +1 -0
  62. package/dist/slpk-extractor/helpers/file-handle-provider.js +71 -0
  63. package/dist/slpk-extractor/slpk-extractor.d.ts +23 -0
  64. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -0
  65. package/dist/slpk-extractor/slpk-extractor.js +78 -0
  66. package/dist/slpk-extractor-cli.d.ts +17 -0
  67. package/dist/slpk-extractor-cli.d.ts.map +1 -0
  68. package/dist/slpk-extractor-cli.js +102 -0
  69. package/dist/slpk-extractor.min.js +189 -0
  70. package/package.json +17 -15
  71. package/src/converter-cli.ts +7 -72
  72. package/src/i3s-converter/helpers/coordinate-converter.ts +1 -2
  73. package/src/i3s-converter/helpers/gltf-attributes.ts +7 -8
  74. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -3
  75. package/src/i3s-converter/i3s-converter.ts +24 -7
  76. package/src/lib/utils/cli-utils.ts +78 -0
  77. package/src/slpk-extractor/helpers/file-handle-provider.ts +91 -0
  78. package/src/slpk-extractor/slpk-extractor.ts +102 -0
  79. package/src/slpk-extractor-cli.ts +128 -0
@@ -0,0 +1,128 @@
1
+ /* eslint-disable no-console */
2
+ import '@loaders.gl/polyfills';
3
+ import SLPKExtractor from './slpk-extractor/slpk-extractor';
4
+ import {getURLValue, validateOptionsWithEqual} from './lib/utils/cli-utils';
5
+
6
+ type SLPKExtractionOptions = {
7
+ /** "tileset.json" file (3DTiles) / "http://..../SceneServer/layers/0" resource (I3S) */
8
+ tileset?: string;
9
+ /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.
10
+ * Default: "data" folder */
11
+ output?: string;
12
+ };
13
+
14
+ /* During validation we check that particular options are defined so they can't be undefined */
15
+ export type ValidatedSLPKExtractionOptions = SLPKExtractionOptions & {
16
+ /** slpk file */
17
+ tileset: string;
18
+ /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.
19
+ * Default: "data" folder */
20
+ output: string;
21
+ };
22
+
23
+ /**
24
+ * CLI entry
25
+ * @returns
26
+ */
27
+ async function main() {
28
+ const [, , ...args] = process.argv;
29
+
30
+ if (args.length === 0) {
31
+ printHelp();
32
+ }
33
+
34
+ const validatedOptionsArr = validateOptionsWithEqual(args);
35
+
36
+ const options: SLPKExtractionOptions = parseOptions(validatedOptionsArr);
37
+
38
+ const validatedOptions: ValidatedSLPKExtractionOptions = validateOptions(options);
39
+
40
+ await convert(validatedOptions);
41
+ }
42
+
43
+ main().catch((error) => {
44
+ console.log(error);
45
+ process.exit(1); // eslint-disable-line
46
+ });
47
+
48
+ /**
49
+ * Output for `npx slpk-extractor --help`
50
+ */
51
+ function printHelp(): void {
52
+ console.log('cli: converter slpk to I3S...');
53
+ console.log('--output [Output folder, default: "data" folder]');
54
+ console.log('--tileset [SLPK file]');
55
+ process.exit(0); // eslint-disable-line
56
+ }
57
+
58
+ /**
59
+ * Run extraction process
60
+ * @param options validated slpk-extractor options
61
+ */
62
+ async function convert(options: ValidatedSLPKExtractionOptions) {
63
+ console.log(`------------------------------------------------`); // eslint-disable-line
64
+ console.log(`Starting conversion of SLPK`); // eslint-disable-line
65
+ console.log(`------------------------------------------------`); // eslint-disable-line
66
+ const slpkExtractor = new SLPKExtractor();
67
+ slpkExtractor.extract({
68
+ inputUrl: options.tileset,
69
+ outputPath: options.output
70
+ });
71
+ }
72
+
73
+ // OPTIONS
74
+ /**
75
+ * Validate input options of the CLI command
76
+ * @param options - input options of the CLI command
77
+ * @returns validated options
78
+ */
79
+ function validateOptions(options: SLPKExtractionOptions): ValidatedSLPKExtractionOptions {
80
+ const mandatoryOptionsWithExceptions: {
81
+ [key: string]: () => void;
82
+ } = {
83
+ output: () => console.log('Missed: --output [Output path name]'),
84
+ tileset: () => console.log('Missed: --tileset [SLPK file]')
85
+ };
86
+ const exceptions: (() => void)[] = [];
87
+ for (const mandatoryOption in mandatoryOptionsWithExceptions) {
88
+ const optionValue = options[mandatoryOption];
89
+ if (!optionValue) {
90
+ exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);
91
+ }
92
+ }
93
+ if (exceptions.length) {
94
+ exceptions.forEach((exeption) => exeption());
95
+ process.exit(1);
96
+ }
97
+ return <ValidatedSLPKExtractionOptions>options;
98
+ }
99
+
100
+ /**
101
+ * Parse option from the cli arguments array
102
+ * @param args
103
+ * @returns
104
+ */
105
+ function parseOptions(args: string[]): SLPKExtractionOptions {
106
+ const opts: SLPKExtractionOptions = {};
107
+
108
+ // eslint-disable-next-line complexity
109
+ args.forEach((arg, index) => {
110
+ if (arg.indexOf('--') === 0) {
111
+ switch (arg) {
112
+ case '--tileset':
113
+ opts.tileset = getURLValue(index, args);
114
+ break;
115
+ case '--output':
116
+ opts.output = getURLValue(index, args);
117
+ break;
118
+ case '--help':
119
+ printHelp();
120
+ break;
121
+ default:
122
+ console.warn(`Unknown option ${arg}`);
123
+ process.exit(0); // eslint-disable-line
124
+ }
125
+ }
126
+ });
127
+ return opts;
128
+ }