@loaders.gl/tile-converter 4.1.0-alpha.5 → 4.1.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.
@@ -5,7 +5,7 @@ import { join } from 'path';
5
5
  import { ChildProcessProxy } from '@loaders.gl/worker-utils';
6
6
  import { DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS } from '@loaders.gl/draco';
7
7
  import { BASIS_EXTERNAL_LIBRARIES } from '@loaders.gl/textures';
8
- const VERSION = typeof "4.1.0-alpha.5" !== 'undefined' ? "4.1.0-alpha.5" : 'latest';
8
+ const VERSION = typeof "4.1.0-alpha.6" !== 'undefined' ? "4.1.0-alpha.6" : 'latest';
9
9
  const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
10
10
  export class DepsInstaller {
11
11
  async install() {
@@ -1,5 +1,5 @@
1
1
  import { Geoid, parsePGM } from '@math.gl/geoid';
2
- const VERSION = typeof "4.1.0-alpha.5" !== 'undefined' ? "4.1.0-alpha.5" : 'latest';
2
+ const VERSION = typeof "4.1.0-alpha.6" !== 'undefined' ? "4.1.0-alpha.6" : 'latest';
3
3
  export { Geoid };
4
4
  export const PGMLoader = {
5
5
  name: '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.1.0-alpha.5",
3
+ "version": "4.1.0-alpha.6",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,18 +52,18 @@
52
52
  "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
53
  },
54
54
  "dependencies": {
55
- "@loaders.gl/3d-tiles": "4.1.0-alpha.5",
56
- "@loaders.gl/crypto": "4.1.0-alpha.5",
57
- "@loaders.gl/draco": "4.1.0-alpha.5",
58
- "@loaders.gl/gltf": "4.1.0-alpha.5",
59
- "@loaders.gl/i3s": "4.1.0-alpha.5",
60
- "@loaders.gl/images": "4.1.0-alpha.5",
61
- "@loaders.gl/loader-utils": "4.1.0-alpha.5",
62
- "@loaders.gl/polyfills": "4.1.0-alpha.5",
63
- "@loaders.gl/textures": "4.1.0-alpha.5",
64
- "@loaders.gl/tiles": "4.1.0-alpha.5",
65
- "@loaders.gl/worker-utils": "4.1.0-alpha.5",
66
- "@loaders.gl/zip": "4.1.0-alpha.5",
55
+ "@loaders.gl/3d-tiles": "4.1.0-alpha.6",
56
+ "@loaders.gl/crypto": "4.1.0-alpha.6",
57
+ "@loaders.gl/draco": "4.1.0-alpha.6",
58
+ "@loaders.gl/gltf": "4.1.0-alpha.6",
59
+ "@loaders.gl/i3s": "4.1.0-alpha.6",
60
+ "@loaders.gl/images": "4.1.0-alpha.6",
61
+ "@loaders.gl/loader-utils": "4.1.0-alpha.6",
62
+ "@loaders.gl/polyfills": "4.1.0-alpha.6",
63
+ "@loaders.gl/textures": "4.1.0-alpha.6",
64
+ "@loaders.gl/tiles": "4.1.0-alpha.6",
65
+ "@loaders.gl/worker-utils": "4.1.0-alpha.6",
66
+ "@loaders.gl/zip": "4.1.0-alpha.6",
67
67
  "@math.gl/core": "^4.0.0",
68
68
  "@math.gl/culling": "^4.0.0",
69
69
  "@math.gl/geoid": "^4.0.0",
@@ -87,7 +87,7 @@
87
87
  "join-images": "^1.1.3",
88
88
  "sharp": "^0.31.3"
89
89
  },
90
- "gitHead": "3250842d8cc0fc8b76a575168c1fd57e5a66b6ba",
90
+ "gitHead": "fd58d91e05ebfd89ab8998a87157bf07c43997a5",
91
91
  "devDependencies": {
92
92
  "@types/express": "^4.17.17",
93
93
  "@types/node": "^20.4.2"
@@ -11,6 +11,9 @@ import {
11
11
  getURLValue,
12
12
  validateOptionsWithEqual
13
13
  } from './lib/utils/cli-utils';
14
+ import {addOneFile, composeHashFile} from '@loaders.gl/zip';
15
+ import {FileHandleFile} from '@loaders.gl/loader-utils';
16
+ import {copyFile} from 'node:fs/promises';
14
17
 
15
18
  type TileConversionOptions = {
16
19
  /** "I3S" - for I3S to 3DTiles conversion, "3DTILES" for 3DTiles to I3S conversion */
@@ -50,6 +53,8 @@ type TileConversionOptions = {
50
53
  maxDepth?: number;
51
54
  /** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */
52
55
  slpk: boolean;
56
+ /** adds hash file to the slpk if there's no one */
57
+ addHash: boolean;
53
58
  /** Feature metadata class from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA extensions */
54
59
  metadataClass?: string;
55
60
  /** With this options the tileset content will be analyzed without conversion */
@@ -92,6 +97,48 @@ async function main() {
92
97
  return;
93
98
  }
94
99
 
100
+ if (options.addHash) {
101
+ const validatedOptions = validateOptions(options, true);
102
+ let finalPath = validatedOptions.tileset;
103
+ if (validatedOptions.output === 'data') {
104
+ const nameWithoutExt = validatedOptions.tileset.substring(
105
+ 0,
106
+ validatedOptions.tileset.length - 5
107
+ );
108
+
109
+ const result = await inquirer.prompt<{isNewFileRequired: boolean}>([
110
+ {
111
+ name: 'isNewFileRequired',
112
+ type: 'list',
113
+ message: 'What would you like to do?',
114
+ choices: [
115
+ {
116
+ name: 'Add hash file to the current SLPK file',
117
+ value: false
118
+ },
119
+ {
120
+ name: `Create a new file ${nameWithoutExt}-hash.slpk with hash file inside`,
121
+ value: true
122
+ }
123
+ ]
124
+ }
125
+ ]);
126
+
127
+ if (result.isNewFileRequired) {
128
+ finalPath = `${nameWithoutExt}-hash.slpk`;
129
+ }
130
+ } else {
131
+ finalPath = validatedOptions.output;
132
+ }
133
+ if (finalPath !== validatedOptions.tileset) {
134
+ await copyFile(validatedOptions.tileset, finalPath);
135
+ }
136
+ const hashTable = await composeHashFile(new FileHandleFile(finalPath));
137
+ await addOneFile(finalPath, hashTable, '@specialIndexFileHASH128@');
138
+
139
+ return;
140
+ }
141
+
95
142
  const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);
96
143
 
97
144
  await convert(validatedOptions);
@@ -199,7 +246,10 @@ async function convert(options: ValidatedTileConversionOptions) {
199
246
  * @param options - input options of the CLI command
200
247
  * @returns validated options
201
248
  */
202
- function validateOptions(options: TileConversionOptions): ValidatedTileConversionOptions {
249
+ function validateOptions(
250
+ options: TileConversionOptions,
251
+ addHash?: boolean
252
+ ): ValidatedTileConversionOptions {
203
253
  const mandatoryOptionsWithExceptions: {
204
254
  [key: string]: {
205
255
  getMessage: () => void;
@@ -208,7 +258,7 @@ function validateOptions(options: TileConversionOptions): ValidatedTileConversio
208
258
  } = {
209
259
  name: {
210
260
  getMessage: () => console.log('Missed: --name [Tileset name]'),
211
- condition: (value: any) => Boolean(value) || Boolean(options.analyze)
261
+ condition: (value: any) => addHash || Boolean(value) || Boolean(options.analyze)
212
262
  },
213
263
  output: {getMessage: () => console.log('Missed: --output [Output path name]')},
214
264
  sevenZipExe: {getMessage: () => console.log('Missed: --7zExe [7z archiver executable path]')},
@@ -218,7 +268,7 @@ function validateOptions(options: TileConversionOptions): ValidatedTileConversio
218
268
  getMessage: () =>
219
269
  console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]'),
220
270
  condition: (value) =>
221
- Boolean(value) && Object.values(TILESET_TYPE).includes(value.toUpperCase())
271
+ addHash || (Boolean(value) && Object.values(TILESET_TYPE).includes(value.toUpperCase()))
222
272
  }
223
273
  };
224
274
  const exceptions: (() => void)[] = [];
@@ -256,7 +306,8 @@ function parseOptions(args: string[]): TileConversionOptions {
256
306
  generateTextures: false,
257
307
  generateBoundingVolumes: false,
258
308
  validate: false,
259
- slpk: false
309
+ slpk: false,
310
+ addHash: false
260
311
  };
261
312
 
262
313
  // eslint-disable-next-line complexity
@@ -287,6 +338,9 @@ function parseOptions(args: string[]): TileConversionOptions {
287
338
  case '--slpk':
288
339
  opts.slpk = getBooleanValue(index, args);
289
340
  break;
341
+ case '--add-hash':
342
+ opts.addHash = getBooleanValue(index, args);
343
+ break;
290
344
  case '--7zExe':
291
345
  opts.sevenZipExe = getStringValue(index, args);
292
346
  break;