@loaders.gl/tile-converter 4.0.2 → 4.0.4
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/dist/converter.min.cjs +98 -98
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/deps-installer/deps-installer.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/progress.d.ts +90 -0
- package/dist/i3s-converter/helpers/progress.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/progress.js +92 -0
- package/dist/i3s-converter/helpers/progress.js.map +1 -0
- package/dist/i3s-converter/i3s-converter.d.ts +2 -9
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +20 -13
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/index.cjs +199 -46
- package/dist/lib/utils/statistic-utills.d.ts +6 -1
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
- package/dist/lib/utils/statistic-utills.js +13 -3
- package/dist/lib/utils/statistic-utills.js.map +1 -1
- package/package.json +14 -14
- package/src/deps-installer/deps-installer.ts +1 -1
- package/src/i3s-converter/helpers/geometry-converter.ts +19 -14
- package/src/i3s-converter/helpers/progress.ts +166 -0
- package/src/i3s-converter/i3s-converter.ts +24 -25
- package/src/lib/utils/statistic-utills.ts +22 -4
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements methods to keep track on the progress of a long process.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Progress {
|
|
5
|
+
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
6
|
+
private _stepsTotal;
|
|
7
|
+
/** Amount of work already done */
|
|
8
|
+
private _stepsDone;
|
|
9
|
+
/** Time in milli-seconds when the process started */
|
|
10
|
+
private startTime;
|
|
11
|
+
/** Time in milli-seconds when the process stopped */
|
|
12
|
+
private stopTime;
|
|
13
|
+
/** Time in milli-seconds when stepsDone was updated */
|
|
14
|
+
private timeOfUpdatingStepsDone;
|
|
15
|
+
/** Time in milli-seconds spent for performing one step*/
|
|
16
|
+
private milliSecForOneStep;
|
|
17
|
+
private trust;
|
|
18
|
+
/**
|
|
19
|
+
* The number of digits to appear after decimal point in the string representation of the count of steps already done.
|
|
20
|
+
* It's calculated based on the total count of steps.
|
|
21
|
+
*/
|
|
22
|
+
private numberOfDigitsInPercentage;
|
|
23
|
+
/** Defines a threshold that is used to check if the process velocity can be consifered trust. */
|
|
24
|
+
private threshold;
|
|
25
|
+
/** Function that is used to get the time stamp */
|
|
26
|
+
private getTime;
|
|
27
|
+
constructor(options?: {
|
|
28
|
+
threshold?: number;
|
|
29
|
+
getTime?: () => bigint;
|
|
30
|
+
});
|
|
31
|
+
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
32
|
+
get stepsTotal(): number;
|
|
33
|
+
set stepsTotal(stepsTotal: number);
|
|
34
|
+
/** Amount of work already done */
|
|
35
|
+
get stepsDone(): number;
|
|
36
|
+
set stepsDone(stepsDone: number);
|
|
37
|
+
/**
|
|
38
|
+
* Saves the current time as we start monitoring the process.
|
|
39
|
+
*/
|
|
40
|
+
startMonitoring(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Saves the current time as we stop monitoring the process.
|
|
43
|
+
*/
|
|
44
|
+
stopMonitoring(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Gets percentage of the work already done.
|
|
47
|
+
* @returns percentage of the work already done.
|
|
48
|
+
*/
|
|
49
|
+
getPercent(): number | null;
|
|
50
|
+
/**
|
|
51
|
+
* Gets string representation of percentage of the work already done.
|
|
52
|
+
* @returns string representation of percentage or an empty string if the percetage value cannot be calculated.
|
|
53
|
+
*/
|
|
54
|
+
getPercentString(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the time elapsed since the monitoring started
|
|
57
|
+
* @returns Number of milliseconds elapsed
|
|
58
|
+
*/
|
|
59
|
+
getTimeCurrentlyElapsed(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Gets the time remaining (expected at the moment of updating 'stepsDone') to complete the work.
|
|
62
|
+
* @returns Number of milliseconds remaining
|
|
63
|
+
*/
|
|
64
|
+
getTimeRemaining(): {
|
|
65
|
+
timeRemaining: number;
|
|
66
|
+
trust: boolean;
|
|
67
|
+
} | null;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the string representation of the time remaining (expected at the moment of updating 'stepsDone') to complete the work.
|
|
70
|
+
* @returns string representation of the time remaining.
|
|
71
|
+
* It's an empty string if the time cannot be pedicted or it's still being calculated.
|
|
72
|
+
*/
|
|
73
|
+
getTimeRemainingString(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Check if the computed velociy of the process can be considered trust.
|
|
76
|
+
* At the beginning of the process the number of samples collected ('time necessary to perform one step' averaged) is too small,
|
|
77
|
+
* which results in huge deviation of the cumputed velocity of the process.
|
|
78
|
+
* It makes sense to perform the check before reporting the time remainig so the end user is not confused.
|
|
79
|
+
* @param current - current value
|
|
80
|
+
* @param previous - previous value
|
|
81
|
+
* @returns true if the computed velociy can be considered trust, or false otherwise
|
|
82
|
+
*/
|
|
83
|
+
private isVelocityTrust;
|
|
84
|
+
/**
|
|
85
|
+
* Gets current time in milliseconds.
|
|
86
|
+
* @returns current time in milliseconds.
|
|
87
|
+
*/
|
|
88
|
+
private getCurrentTimeInMilliSeconds;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/progress.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,qBAAa,QAAQ;IACnB,oFAAoF;IACpF,OAAO,CAAC,WAAW,CAAa;IAChC,kCAAkC;IAClC,OAAO,CAAC,UAAU,CAAa;IAC/B,qDAAqD;IACrD,OAAO,CAAC,SAAS,CAAa;IAC9B,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAa;IAC7B,uDAAuD;IACvD,OAAO,CAAC,uBAAuB,CAAa;IAC5C,yDAAyD;IACzD,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,KAAK,CAAkB;IAC/B;;;OAGG;IACH,OAAO,CAAC,0BAA0B,CAAa;IAC/C,iGAAiG;IACjG,OAAO,CAAC,SAAS,CAAS;IAC1B,kDAAkD;IAClD,OAAO,CAAC,OAAO,CAAe;gBAElB,OAAO,GAAE;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,MAAM,CAAA;KAAM;IAKtE,oFAAoF;IACpF,IAAI,UAAU,WAEb;IAED,IAAI,UAAU,CAAC,UAAU,QAAA,EAIxB;IAED,kCAAkC;IAClC,IAAI,SAAS,WAEZ;IAED,IAAI,SAAS,CAAC,SAAS,QAAA,EAUtB;IAED;;OAEG;IACH,eAAe;IASf;;OAEG;IACH,cAAc;IAId;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,IAAI;IAQ3B;;;OAGG;IACH,gBAAgB;IAKhB;;;OAGG;IACH,uBAAuB,IAAI,MAAM;IAMjC;;;OAGG;IACH,gBAAgB,IAAI;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAC,GAAG,IAAI;IAUlE;;;;OAIG;IACH,sBAAsB,IAAI,MAAM;IAKhC;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAQvB;;;OAGG;IACH,OAAO,CAAC,4BAA4B;CAIrC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import process from 'process';
|
|
2
|
+
import { timeConverter } from "../../lib/utils/statistic-utills.js";
|
|
3
|
+
const THRESHOLD_DEFAULT = 0.2;
|
|
4
|
+
export class Progress {
|
|
5
|
+
constructor() {
|
|
6
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
this._stepsTotal = 0;
|
|
8
|
+
this._stepsDone = 0;
|
|
9
|
+
this.startTime = 0;
|
|
10
|
+
this.stopTime = 0;
|
|
11
|
+
this.timeOfUpdatingStepsDone = 0;
|
|
12
|
+
this.milliSecForOneStep = 0;
|
|
13
|
+
this.trust = false;
|
|
14
|
+
this.numberOfDigitsInPercentage = 0;
|
|
15
|
+
this.threshold = void 0;
|
|
16
|
+
this.getTime = void 0;
|
|
17
|
+
this.getTime = options.getTime || process.hrtime.bigint;
|
|
18
|
+
this.threshold = options.threshold || THRESHOLD_DEFAULT;
|
|
19
|
+
}
|
|
20
|
+
get stepsTotal() {
|
|
21
|
+
return this._stepsTotal;
|
|
22
|
+
}
|
|
23
|
+
set stepsTotal(stepsTotal) {
|
|
24
|
+
this._stepsTotal = stepsTotal;
|
|
25
|
+
this.numberOfDigitsInPercentage = this.stepsTotal > 100 ? Math.ceil(Math.log10(this.stepsTotal)) - 2 : 0;
|
|
26
|
+
}
|
|
27
|
+
get stepsDone() {
|
|
28
|
+
return this._stepsDone;
|
|
29
|
+
}
|
|
30
|
+
set stepsDone(stepsDone) {
|
|
31
|
+
this._stepsDone = stepsDone;
|
|
32
|
+
this.timeOfUpdatingStepsDone = this.getCurrentTimeInMilliSeconds();
|
|
33
|
+
if (this._stepsDone) {
|
|
34
|
+
const diff = this.timeOfUpdatingStepsDone - this.startTime;
|
|
35
|
+
const milliSecForOneStep = diff / this._stepsDone;
|
|
36
|
+
this.trust = this.isVelocityTrust(milliSecForOneStep, this.milliSecForOneStep);
|
|
37
|
+
this.milliSecForOneStep = milliSecForOneStep;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
startMonitoring() {
|
|
41
|
+
this.startTime = this.getCurrentTimeInMilliSeconds();
|
|
42
|
+
this.milliSecForOneStep = 0;
|
|
43
|
+
this.trust = false;
|
|
44
|
+
this.timeOfUpdatingStepsDone = 0;
|
|
45
|
+
this.stopTime = 0;
|
|
46
|
+
this.stepsDone = 0;
|
|
47
|
+
}
|
|
48
|
+
stopMonitoring() {
|
|
49
|
+
this.stopTime = this.getCurrentTimeInMilliSeconds();
|
|
50
|
+
}
|
|
51
|
+
getPercent() {
|
|
52
|
+
if (!this._stepsTotal) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const percent = this._stepsDone / this._stepsTotal * 100.0;
|
|
56
|
+
return percent;
|
|
57
|
+
}
|
|
58
|
+
getPercentString() {
|
|
59
|
+
const percent = this.getPercent();
|
|
60
|
+
return percent !== null ? percent.toFixed(this.numberOfDigitsInPercentage) : '';
|
|
61
|
+
}
|
|
62
|
+
getTimeCurrentlyElapsed() {
|
|
63
|
+
const currentTime = this.stopTime ? this.stopTime : this.getCurrentTimeInMilliSeconds();
|
|
64
|
+
const diff = currentTime - this.startTime;
|
|
65
|
+
return diff;
|
|
66
|
+
}
|
|
67
|
+
getTimeRemaining() {
|
|
68
|
+
if (!this._stepsDone || !this.startTime) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const timeRemainingInMilliSeconds = (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;
|
|
72
|
+
return {
|
|
73
|
+
timeRemaining: timeRemainingInMilliSeconds,
|
|
74
|
+
trust: this.trust
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
getTimeRemainingString() {
|
|
78
|
+
const timeRemainingObject = this.getTimeRemaining();
|
|
79
|
+
return timeRemainingObject !== null && timeRemainingObject !== void 0 && timeRemainingObject.trust ? timeConverter(timeRemainingObject.timeRemaining) : '';
|
|
80
|
+
}
|
|
81
|
+
isVelocityTrust(current, previous) {
|
|
82
|
+
if (previous) {
|
|
83
|
+
const dev = Math.abs((current - previous) / previous);
|
|
84
|
+
return dev < this.threshold;
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
getCurrentTimeInMilliSeconds() {
|
|
89
|
+
return Number(this.getTime() / BigInt(1e6));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","names":["process","timeConverter","THRESHOLD_DEFAULT","Progress","constructor","options","arguments","length","undefined","_stepsTotal","_stepsDone","startTime","stopTime","timeOfUpdatingStepsDone","milliSecForOneStep","trust","numberOfDigitsInPercentage","threshold","getTime","hrtime","bigint","stepsTotal","Math","ceil","log10","stepsDone","getCurrentTimeInMilliSeconds","diff","isVelocityTrust","startMonitoring","stopMonitoring","getPercent","percent","getPercentString","toFixed","getTimeCurrentlyElapsed","currentTime","getTimeRemaining","timeRemainingInMilliSeconds","timeRemaining","getTimeRemainingString","timeRemainingObject","current","previous","dev","abs","Number","BigInt"],"sources":["../../../src/i3s-converter/helpers/progress.ts"],"sourcesContent":["import process from 'process';\nimport {timeConverter} from '../../lib/utils/statistic-utills';\n\n/** Defines a threshold that is used to check if the process velocity can be consifered trust. */\nconst THRESHOLD_DEFAULT = 0.2;\n\n/**\n * Implements methods to keep track on the progress of a long process.\n */\nexport class Progress {\n /** Total amount of work, e.g. number of files to save or number of bytes to send */\n private _stepsTotal: number = 0;\n /** Amount of work already done */\n private _stepsDone: number = 0;\n /** Time in milli-seconds when the process started */\n private startTime: number = 0;\n /** Time in milli-seconds when the process stopped */\n private stopTime: number = 0;\n /** Time in milli-seconds when stepsDone was updated */\n private timeOfUpdatingStepsDone: number = 0;\n /** Time in milli-seconds spent for performing one step*/\n private milliSecForOneStep: number = 0;\n private trust: boolean = false;\n /**\n * The number of digits to appear after decimal point in the string representation of the count of steps already done.\n * It's calculated based on the total count of steps.\n */\n private numberOfDigitsInPercentage: number = 0;\n /** Defines a threshold that is used to check if the process velocity can be consifered trust. */\n private threshold: number;\n /** Function that is used to get the time stamp */\n private getTime: () => bigint;\n\n constructor(options: {threshold?: number; getTime?: () => bigint} = {}) {\n this.getTime = options.getTime || process.hrtime.bigint;\n this.threshold = options.threshold || THRESHOLD_DEFAULT;\n }\n\n /** Total amount of work, e.g. number of files to save or number of bytes to send */\n get stepsTotal() {\n return this._stepsTotal;\n }\n\n set stepsTotal(stepsTotal) {\n this._stepsTotal = stepsTotal;\n this.numberOfDigitsInPercentage =\n this.stepsTotal > 100 ? Math.ceil(Math.log10(this.stepsTotal)) - 2 : 0;\n }\n\n /** Amount of work already done */\n get stepsDone() {\n return this._stepsDone;\n }\n\n set stepsDone(stepsDone) {\n this._stepsDone = stepsDone;\n this.timeOfUpdatingStepsDone = this.getCurrentTimeInMilliSeconds();\n if (this._stepsDone) {\n const diff = this.timeOfUpdatingStepsDone - this.startTime;\n const milliSecForOneStep = diff / this._stepsDone;\n\n this.trust = this.isVelocityTrust(milliSecForOneStep, this.milliSecForOneStep);\n this.milliSecForOneStep = milliSecForOneStep;\n }\n }\n\n /**\n * Saves the current time as we start monitoring the process.\n */\n startMonitoring() {\n this.startTime = this.getCurrentTimeInMilliSeconds();\n this.milliSecForOneStep = 0;\n this.trust = false;\n this.timeOfUpdatingStepsDone = 0;\n this.stopTime = 0;\n this.stepsDone = 0;\n }\n\n /**\n * Saves the current time as we stop monitoring the process.\n */\n stopMonitoring() {\n this.stopTime = this.getCurrentTimeInMilliSeconds();\n }\n\n /**\n * Gets percentage of the work already done.\n * @returns percentage of the work already done.\n */\n getPercent(): number | null {\n if (!this._stepsTotal) {\n return null;\n }\n const percent = (this._stepsDone / this._stepsTotal) * 100.0;\n return percent;\n }\n\n /**\n * Gets string representation of percentage of the work already done.\n * @returns string representation of percentage or an empty string if the percetage value cannot be calculated.\n */\n getPercentString() {\n const percent = this.getPercent();\n return percent !== null ? percent.toFixed(this.numberOfDigitsInPercentage) : '';\n }\n\n /**\n * Gets the time elapsed since the monitoring started\n * @returns Number of milliseconds elapsed\n */\n getTimeCurrentlyElapsed(): number {\n const currentTime = this.stopTime ? this.stopTime : this.getCurrentTimeInMilliSeconds();\n const diff = currentTime - this.startTime;\n return diff;\n }\n\n /**\n * Gets the time remaining (expected at the moment of updating 'stepsDone') to complete the work.\n * @returns Number of milliseconds remaining\n */\n getTimeRemaining(): {timeRemaining: number; trust: boolean} | null {\n if (!this._stepsDone || !this.startTime) {\n return null;\n }\n\n const timeRemainingInMilliSeconds =\n (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;\n return {timeRemaining: timeRemainingInMilliSeconds, trust: this.trust};\n }\n\n /**\n * Gets the string representation of the time remaining (expected at the moment of updating 'stepsDone') to complete the work.\n * @returns string representation of the time remaining.\n * It's an empty string if the time cannot be pedicted or it's still being calculated.\n */\n getTimeRemainingString(): string {\n const timeRemainingObject = this.getTimeRemaining();\n return timeRemainingObject?.trust ? timeConverter(timeRemainingObject.timeRemaining) : '';\n }\n\n /**\n * Check if the computed velociy of the process can be considered trust.\n * At the beginning of the process the number of samples collected ('time necessary to perform one step' averaged) is too small,\n * which results in huge deviation of the cumputed velocity of the process.\n * It makes sense to perform the check before reporting the time remainig so the end user is not confused.\n * @param current - current value\n * @param previous - previous value\n * @returns true if the computed velociy can be considered trust, or false otherwise\n */\n private isVelocityTrust(current: number, previous: number): boolean {\n if (previous) {\n const dev = Math.abs((current - previous) / previous);\n return dev < this.threshold;\n }\n return false;\n }\n\n /**\n * Gets current time in milliseconds.\n * @returns current time in milliseconds.\n */\n private getCurrentTimeInMilliSeconds(): number {\n // process.hrtime.bigint() returns the time in nanoseconds. We need the time in milliseconds.\n return Number(this.getTime() / BigInt(1e6));\n }\n}\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAAC,SACtBC,aAAa;AAGrB,MAAMC,iBAAiB,GAAG,GAAG;AAK7B,OAAO,MAAMC,QAAQ,CAAC;EAwBpBC,WAAWA,CAAA,EAA6D;IAAA,IAA5DC,OAAqD,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,KAtB9DG,WAAW,GAAW,CAAC;IAAA,KAEvBC,UAAU,GAAW,CAAC;IAAA,KAEtBC,SAAS,GAAW,CAAC;IAAA,KAErBC,QA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AAa,EAAED,2BAA2B;MAAEvB,KAAK,EAAE,IAAI,CAACA;IAAK,CAAC;EACxE;EAOAyB,sBAAsBA,CAAA,EAAW;IAC/B,MAAMC,mBAAmB,GAAG,IAAI,CAACJ,gBAAgB,CAAC,CAAC;IACnD,OAAOI,mBAAmB,aAAnBA,mBAAmB,eAAnBA,mBAAmB,CAAE1B,KAAK,GAAGd,aAAa,CAACwC,mBAAmB,CAACF,aAAa,CAAC,GAAG,EAAE;EAC3F;EAWQX,eAAeA,CAACc,OAAe,EAAEC,QAAgB,EAAW;IAClE,IAAIA,QAAQ,EAAE;MACZ,MAAMC,GAAG,GAAGtB,IAAI,CAACuB,GAAG,CAAC,CAACH,OAAO,GAAGC,QAAQ,IAAIA,QAAQ,CAAC;MACrD,OAAOC,GAAG,GAAG,IAAI,CAAC3B,SAAS;IAC7B;IACA,OAAO,KAAK;EACd;EAMQS,4BAA4BA,CAAA,EAAW;IAE7C,OAAOoB,MAAM,CAAC,IAAI,CAAC5B,OAAO,CAAC,CAAC,GAAG6B,MAAM,CAAC,GAAG,CAAC,CAAC;EAC7C;AACF"}
|
|
@@ -8,6 +8,7 @@ import { LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
|
8
8
|
import { I3SMaterialDefinition } from '@loaders.gl/i3s';
|
|
9
9
|
import { PreprocessData } from './types';
|
|
10
10
|
import WriteQueue from '../lib/utils/write-queue';
|
|
11
|
+
import { Progress } from './helpers/progress';
|
|
11
12
|
/**
|
|
12
13
|
* Converter from 3d-tiles tileset to i3s layer
|
|
13
14
|
*/
|
|
@@ -47,15 +48,7 @@ export default class I3SConverter {
|
|
|
47
48
|
writeQueue: WriteQueue<WriteQueueItem>;
|
|
48
49
|
compressList: string[] | null;
|
|
49
50
|
preprocessData: PreprocessData;
|
|
50
|
-
|
|
51
|
-
tileCountTotal: number;
|
|
52
|
-
/** Count of tiles already converted plus one (refers to the tile currently being converted) */
|
|
53
|
-
tileCountCurrentlyConverting: number;
|
|
54
|
-
/**
|
|
55
|
-
* The number of digits to appear after decimal point in the string representation of the tile count.
|
|
56
|
-
* It's calculated based on the total count of tiles.
|
|
57
|
-
*/
|
|
58
|
-
numberOfDigitsInPercentage: number;
|
|
51
|
+
progresses: Record<string, Progress>;
|
|
59
52
|
constructor();
|
|
60
53
|
/**
|
|
61
54
|
* Convert a 3d tileset
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AAExE,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAuB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,iBAAiB,CAAC;AAGnF,OAAO,EAGL,cAAc,EAEf,MAAM,SAAS,CAAC;AAEjB,OAAO,UAAU,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AAExE,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAC,KAAK,EAAC,MA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;YACW,mBAAmB;IA6BjC;;;;OAIG;YACW,qBAAqB;IAqFnC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAgCpB;;OAEG;YACW,aAAa;IAc3B;;;OAGG;YACW,WAAW;IAsCzB;;;;;;OAMG;YACW,WAAW;IA+CzB;;;;OAIG;YACW,YAAY;IAc1B;;;;;;;OAOG;YACW,WAAW;IAmGzB;;;;;;;;;;OAUG;YACW,iBAAiB;IAkC/B;;;;;;;;;;;;;;OAcG;YACW,sBAAsB;IA+DpC;;;;;;;;;OASG;YACW,eAAe;IAiB7B;;;;;;OAMG;YACW,gBAAgB;IAoC9B;;;;;;OAMG;YACW,YAAY;IAwB1B;;;;;OAKG;YACW,aAAa;IAmE3B;;;;;;;OAOG;YACW,gBAAgB;IAwB9B;;;;;OAKG;YACW,gBAAgB;IA+B9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IA4BlC;;;OAGG;YACW,iBAAiB;IAqB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAG3B"}
|
|
@@ -33,12 +33,14 @@ import { Matrix4 } from '@math.gl/core';
|
|
|
33
33
|
import { createBoundingVolume } from '@loaders.gl/tiles';
|
|
34
34
|
import { traverseDatasetWith } from "./helpers/tileset-traversal.js";
|
|
35
35
|
import { analyzeTileContent, mergePreprocessData } from "./helpers/preprocess-3d-tiles.js";
|
|
36
|
+
import { Progress } from "./helpers/progress.js";
|
|
36
37
|
const ION_DEFAULT_TOKEN = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken;
|
|
37
38
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
38
39
|
const _3D_TILES = '3DTILES';
|
|
39
40
|
const _3D_OBJECT_LAYER_TYPE = '3DObject';
|
|
40
41
|
const REFRESH_TOKEN_TIMEOUT = 1800;
|
|
41
42
|
const CESIUM_DATASET_PREFIX = 'https://';
|
|
43
|
+
const PROGRESS_PHASE1_COUNT = 'phase1-count';
|
|
42
44
|
export default class I3SConverter {
|
|
43
45
|
constructor() {
|
|
44
46
|
this.attributeMetadataInfo = void 0;
|
|
@@ -84,9 +86,7 @@ export default class I3SConverter {
|
|
|
84
86
|
meshTopologyTypes: new Set(),
|
|
85
87
|
metadataClasses: new Set()
|
|
86
88
|
};
|
|
87
|
-
this.
|
|
88
|
-
this.tileCountCurrentlyConverting = 0;
|
|
89
|
-
this.numberOfDigitsInPercentage = 0;
|
|
89
|
+
this.progresses = {};
|
|
90
90
|
this.attributeMetadataInfo = new AttributeMetadataInfo();
|
|
91
91
|
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
|
|
92
92
|
this.options = {};
|
|
@@ -146,6 +146,7 @@ export default class I3SConverter {
|
|
|
146
146
|
inquirer,
|
|
147
147
|
metadataClass
|
|
148
148
|
};
|
|
149
|
+
this.progresses[PROGRESS_PHASE1_COUNT] = new Progress();
|
|
149
150
|
this.compressList = this.options.instantNodeWriting && [] || null;
|
|
150
151
|
this.validate = Boolean(validate);
|
|
151
152
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
|
|
@@ -200,10 +201,9 @@ export default class I3SConverter {
|
|
|
200
201
|
meshTopologyTypes,
|
|
201
202
|
metadataClasses
|
|
202
203
|
} = this.preprocessData;
|
|
203
|
-
this.numberOfDigitsInPercentage = this.tileCountTotal > 100 ? Math.ceil(Math.log10(this.tileCountTotal)) - 2 : 0;
|
|
204
204
|
console.log(`------------------------------------------------`);
|
|
205
205
|
console.log(`Preprocess results:`);
|
|
206
|
-
console.log(`Tile count: ${this.
|
|
206
|
+
console.log(`Tile count: ${this.progresses[PROGRESS_PHASE1_COUNT].stepsTotal}`);
|
|
207
207
|
console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(', ')}`);
|
|
208
208
|
if (metadataClasses.size) {
|
|
209
209
|
console.log(`Feature metadata classes have been found: ${Array.from(metadataClasses).join(', ')}`);
|
|
@@ -225,7 +225,7 @@ export default class I3SConverter {
|
|
|
225
225
|
return null;
|
|
226
226
|
}
|
|
227
227
|
if (sourceTile.id) {
|
|
228
|
-
this.
|
|
228
|
+
this.progresses[PROGRESS_PHASE1_COUNT].stepsTotal += 1;
|
|
229
229
|
console.log(`[analyze]: ${sourceTile.id}`);
|
|
230
230
|
}
|
|
231
231
|
let tileContent = null;
|
|
@@ -288,11 +288,14 @@ export default class I3SConverter {
|
|
|
288
288
|
obb: boundingVolumes.obb,
|
|
289
289
|
children: []
|
|
290
290
|
});
|
|
291
|
+
this.progresses[PROGRESS_PHASE1_COUNT].startMonitoring();
|
|
291
292
|
const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);
|
|
292
293
|
await traverseDatasetWith(sourceRootTile, {
|
|
293
294
|
transform: new Matrix4(sourceRootTile.transform),
|
|
294
295
|
parentNodes: [rootNode]
|
|
295
296
|
}, this.convertTile.bind(this), this.finalizeTile.bind(this), this.options.maxDepth);
|
|
297
|
+
this.progresses[PROGRESS_PHASE1_COUNT].stopMonitoring();
|
|
298
|
+
console.log(`[finalizing conversion]`);
|
|
296
299
|
this.layers0.attributeStorageInfo = this.attributeMetadataInfo.attributeStorageInfo;
|
|
297
300
|
this.layers0.fields = this.attributeMetadataInfo.fields;
|
|
298
301
|
this.layers0.popupInfo = this.attributeMetadataInfo.popupInfo;
|
|
@@ -381,13 +384,7 @@ export default class I3SConverter {
|
|
|
381
384
|
return traversalProps;
|
|
382
385
|
}
|
|
383
386
|
if (sourceTile.id) {
|
|
384
|
-
|
|
385
|
-
let percentString = '';
|
|
386
|
-
if (this.tileCountTotal) {
|
|
387
|
-
const percent = this.tileCountCurrentlyConverting / this.tileCountTotal * 100;
|
|
388
|
-
percentString = ' ' + percent.toFixed(this.numberOfDigitsInPercentage);
|
|
389
|
-
}
|
|
390
|
-
console.log(`[convert${percentString}%]: ${sourceTile.id}`);
|
|
387
|
+
console.log(`[convert]: ${sourceTile.id}`);
|
|
391
388
|
}
|
|
392
389
|
const {
|
|
393
390
|
parentNodes,
|
|
@@ -404,6 +401,16 @@ export default class I3SConverter {
|
|
|
404
401
|
transform: transformationMatrix,
|
|
405
402
|
parentNodes: childNodes
|
|
406
403
|
};
|
|
404
|
+
if (sourceTile.id) {
|
|
405
|
+
this.progresses[PROGRESS_PHASE1_COUNT].stepsDone += 1;
|
|
406
|
+
let timeRemainingString = 'Calculating time left...';
|
|
407
|
+
const timeRemainingStringBasedOnCount = this.progresses[PROGRESS_PHASE1_COUNT].getTimeRemainingString();
|
|
408
|
+
if (timeRemainingStringBasedOnCount) {
|
|
409
|
+
timeRemainingString = `${timeRemainingStringBasedOnCount} left`;
|
|
410
|
+
}
|
|
411
|
+
let percentString = this.progresses[PROGRESS_PHASE1_COUNT].getPercentString();
|
|
412
|
+
console.log(`[converted ${percentString}%, ${timeRemainingString}]: ${sourceTile.id}`);
|
|
413
|
+
}
|
|
407
414
|
return newTraversalProps;
|
|
408
415
|
}
|
|
409
416
|
async finalizeTile(conversionResults, currentTraversalProps) {
|