@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.
- package/bin/slpk-extractor.js +4 -0
- package/dist/3d-tiles-attributes-worker.js +1 -1
- package/dist/converter-cli.js +18 -84
- package/dist/converter.min.js +50 -50
- package/dist/dist.min.js +21 -18
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/converter-cli.js +18 -63
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +2 -2
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +59 -38
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/lib/utils/cli-utils.js +57 -0
- package/dist/es5/lib/utils/cli-utils.js.map +1 -0
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +181 -0
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
- package/dist/es5/slpk-extractor/slpk-extractor.js +172 -0
- package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -0
- package/dist/es5/slpk-extractor-cli.js +117 -0
- package/dist/es5/slpk-extractor-cli.js.map +1 -0
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/converter-cli.js +1 -46
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +22 -9
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/lib/utils/cli-utils.js +47 -0
- package/dist/esm/lib/utils/cli-utils.js.map +1 -0
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +43 -0
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
- package/dist/esm/slpk-extractor/slpk-extractor.js +63 -0
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -0
- package/dist/esm/slpk-extractor-cli.js +74 -0
- package/dist/esm/slpk-extractor-cli.js.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +1 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +1 -2
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +2 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -3
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +1 -2
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +21 -6
- package/dist/lib/utils/cli-utils.d.ts +34 -0
- package/dist/lib/utils/cli-utils.d.ts.map +1 -0
- package/dist/lib/utils/cli-utils.js +82 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts +48 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +1 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.js +71 -0
- package/dist/slpk-extractor/slpk-extractor.d.ts +23 -0
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -0
- package/dist/slpk-extractor/slpk-extractor.js +78 -0
- package/dist/slpk-extractor-cli.d.ts +17 -0
- package/dist/slpk-extractor-cli.d.ts.map +1 -0
- package/dist/slpk-extractor-cli.js +102 -0
- package/dist/slpk-extractor.min.js +189 -0
- package/package.json +17 -15
- package/src/converter-cli.ts +7 -72
- package/src/i3s-converter/helpers/coordinate-converter.ts +1 -2
- package/src/i3s-converter/helpers/gltf-attributes.ts +7 -8
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -3
- package/src/i3s-converter/i3s-converter.ts +24 -7
- package/src/lib/utils/cli-utils.ts +78 -0
- package/src/slpk-extractor/helpers/file-handle-provider.ts +91 -0
- package/src/slpk-extractor/slpk-extractor.ts +102 -0
- 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
|
+
}
|