@loaders.gl/tile-converter 4.0.0-alpha.8 → 4.0.0-beta.1
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/i3s-server.js +4 -0
- package/bin/slpk-extractor.js +4 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +5 -5
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +10 -5
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +10 -0
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +2 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -1
- package/dist/converter.min.js +172 -103
- package/dist/deps-installer/deps-installer.d.ts +3 -2
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/dist.min.js +32718 -32568
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +97 -117
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +24 -22
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/load-i3s.js +63 -0
- package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/es5/converter-cli.js +25 -65
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +115 -40
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +45 -15
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +8 -18
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +83 -43
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +100 -102
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +70 -4
- package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-index-document.js +3 -2
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +47 -12
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +187 -174
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/types.js +11 -11
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/README.md +46 -2
- package/dist/es5/i3s-server/app.js +23 -15
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/bin/www.js +33 -0
- package/dist/es5/i3s-server/bin/www.js.map +1 -0
- package/dist/es5/i3s-server/controllers/index-controller.js +23 -22
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/controllers/slpk-controller.js +35 -38
- package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +2 -2
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/i3s-server/routes/slpk-router.js +14 -13
- package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -1
- package/dist/es5/i3s-server/utils/create-scene-server.js +7 -4
- package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -1
- package/dist/es5/i3s-server/utils/server-utils.js +49 -0
- package/dist/es5/i3s-server/utils/server-utils.js.map +1 -0
- package/dist/es5/lib/utils/cli-utils.js +57 -0
- package/dist/es5/lib/utils/cli-utils.js.map +1 -0
- package/dist/es5/lib/utils/compress-util.js +1 -1
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +10 -4
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/pgm-loader.js +11 -3
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/es5/slpk-extractor/slpk-extractor.js +171 -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-converter/3d-tiles-converter.js +51 -58
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +12 -11
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/load-i3s.js +32 -0
- package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/esm/converter-cli.js +8 -48
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +40 -13
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +28 -11
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +10 -8
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +77 -34
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +60 -61
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/load-3d-tiles.js +33 -4
- package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js +2 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +37 -12
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +101 -73
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/types.js +9 -9
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/README.md +46 -2
- package/dist/esm/i3s-server/app.js +13 -11
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +516 -0
- package/dist/esm/i3s-server/bin/www.js +30 -0
- package/dist/esm/i3s-server/bin/www.js.map +1 -0
- package/dist/esm/i3s-server/controllers/index-controller.js +4 -7
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/esm/i3s-server/controllers/slpk-controller.js +9 -26
- package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/esm/i3s-server/routes/index.js +1 -1
- package/dist/esm/i3s-server/routes/index.js.map +1 -1
- package/dist/esm/i3s-server/routes/slpk-router.js +5 -11
- package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -1
- package/dist/esm/i3s-server/utils/create-scene-server.js +2 -5
- package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -1
- package/dist/esm/i3s-server/utils/server-utils.js +40 -0
- package/dist/esm/i3s-server/utils/server-utils.js.map +1 -0
- package/dist/esm/lib/utils/cli-utils.js +47 -0
- package/dist/esm/lib/utils/cli-utils.js.map +1 -0
- package/dist/esm/lib/utils/compress-util.js +1 -1
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- package/dist/esm/lib/utils/lod-conversion-utils.js +6 -4
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/pgm-loader.js +7 -4
- package/dist/esm/pgm-loader.js.map +1 -1
- 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/batch-ids-extensions.d.ts +15 -2
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- 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/feature-attributes.d.ts +8 -8
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -9
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +3 -3
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +15 -0
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +4 -5
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +3 -2
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/types.d.ts +48 -7
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/i3s-server/app.d.ts +1 -2
- package/dist/i3s-server/app.d.ts.map +1 -1
- package/dist/i3s-server/bin/www.d.ts +3 -0
- package/dist/i3s-server/bin/www.d.ts.map +1 -0
- package/dist/i3s-server/controllers/index-controller.d.ts +6 -1
- package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -1
- package/dist/i3s-server/controllers/slpk-controller.d.ts +13 -2
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
- package/dist/i3s-server/routes/index.d.ts +1 -2
- package/dist/i3s-server/routes/index.d.ts.map +1 -1
- package/dist/i3s-server/routes/slpk-router.d.ts +2 -2
- package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
- package/dist/i3s-server/utils/create-scene-server.d.ts +11 -5
- package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -1
- package/dist/i3s-server/utils/server-utils.d.ts +24 -0
- package/dist/i3s-server/utils/server-utils.d.ts.map +1 -0
- 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/lod-conversion-utils.d.ts +2 -2
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
- package/dist/pgm-loader.d.ts +9 -2
- package/dist/pgm-loader.d.ts.map +1 -1
- 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-cli.d.ts +17 -0
- package/dist/slpk-extractor-cli.d.ts.map +1 -0
- package/dist/slpk-extractor.min.js +189 -0
- package/package.json +28 -22
- package/src/3d-tiles-converter/3d-tiles-converter.ts +65 -69
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +23 -19
- package/src/3d-tiles-converter/helpers/load-i3s.ts +52 -0
- package/src/3d-tiles-converter/helpers/texture-atlas.ts +6 -2
- package/src/converter-cli.ts +16 -74
- package/src/deps-installer/deps-installer.ts +58 -12
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +77 -32
- package/src/i3s-converter/helpers/coordinate-converter.ts +1 -2
- package/src/i3s-converter/helpers/feature-attributes.ts +23 -18
- package/src/i3s-converter/helpers/geometry-attributes.ts +81 -44
- package/src/i3s-converter/helpers/geometry-converter.ts +149 -126
- package/src/i3s-converter/helpers/gltf-attributes.ts +9 -10
- package/src/i3s-converter/helpers/load-3d-tiles.ts +61 -5
- package/src/i3s-converter/helpers/node-index-document.ts +5 -1
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +70 -21
- package/src/i3s-converter/i3s-converter.ts +145 -73
- package/src/i3s-converter/types.ts +49 -7
- package/src/i3s-server/README.md +46 -2
- package/src/i3s-server/{app.js → app.ts} +11 -9
- package/src/i3s-server/bin/www.ts +38 -0
- package/src/i3s-server/controllers/{index-controller.js → index-controller.ts} +10 -9
- package/src/i3s-server/controllers/slpk-controller.ts +32 -0
- package/src/i3s-server/routes/{index.js → index.ts} +2 -1
- package/src/i3s-server/routes/{slpk-router.js → slpk-router.ts} +5 -10
- package/src/i3s-server/utils/create-scene-server.ts +20 -0
- package/src/i3s-server/utils/server-utils.ts +70 -0
- package/src/lib/utils/cli-utils.ts +78 -0
- package/src/lib/utils/compress-util.ts +1 -1
- package/src/lib/utils/lod-conversion-utils.ts +10 -6
- package/src/pgm-loader.ts +15 -7
- package/src/slpk-extractor/slpk-extractor.ts +101 -0
- package/src/slpk-extractor-cli.ts +128 -0
- package/dist/3d-tiles-attributes-worker.d.ts +0 -28
- package/dist/3d-tiles-attributes-worker.d.ts.map +0 -1
- package/dist/3d-tiles-attributes-worker.js +0 -3
- package/dist/3d-tiles-attributes-worker.js.map +0 -7
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -288
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -269
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -52
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
- package/dist/bundle.js +0 -5
- package/dist/constants.js +0 -4
- package/dist/converter-cli.js +0 -280
- package/dist/deps-installer/deps-installer.js +0 -62
- package/dist/es5/3d-tiles-attributes-worker.js +0 -25
- package/dist/es5/3d-tiles-attributes-worker.js.map +0 -1
- package/dist/es5/i3s-attributes-worker.js +0 -25
- package/dist/es5/i3s-attributes-worker.js.map +0 -1
- package/dist/es5/i3s-server/bin/www +0 -102
- package/dist/es5/workers/3d-tiles-attributes-worker.js +0 -28
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +0 -1
- package/dist/es5/workers/i3s-attributes-worker.js +0 -30
- package/dist/es5/workers/i3s-attributes-worker.js.map +0 -1
- package/dist/esm/3d-tiles-attributes-worker.js +0 -16
- package/dist/esm/3d-tiles-attributes-worker.js.map +0 -1
- package/dist/esm/i3s-attributes-worker.js +0 -16
- package/dist/esm/i3s-attributes-worker.js.map +0 -1
- package/dist/esm/i3s-server/bin/www +0 -102
- package/dist/esm/workers/3d-tiles-attributes-worker.js +0 -8
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +0 -1
- package/dist/esm/workers/i3s-attributes-worker.js +0 -7
- package/dist/esm/workers/i3s-attributes-worker.js.map +0 -1
- package/dist/i3s-attributes-worker.d.ts +0 -45
- package/dist/i3s-attributes-worker.d.ts.map +0 -1
- package/dist/i3s-attributes-worker.js +0 -9
- package/dist/i3s-attributes-worker.js.map +0 -7
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -138
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -123
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -216
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -202
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1225
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -128
- package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -53
- package/dist/i3s-converter/helpers/node-debug.js +0 -120
- package/dist/i3s-converter/helpers/node-index-document.js +0 -268
- package/dist/i3s-converter/helpers/node-pages.js +0 -316
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -76
- package/dist/i3s-converter/helpers/tileset-traversal.js +0 -29
- package/dist/i3s-converter/i3s-converter.js +0 -911
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
- package/dist/i3s-converter/json-templates/layers.js +0 -139
- package/dist/i3s-converter/json-templates/metadata.js +0 -25
- package/dist/i3s-converter/json-templates/node.js +0 -89
- package/dist/i3s-converter/json-templates/scene-server.js +0 -31
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
- package/dist/i3s-converter/json-templates/store.js +0 -103
- package/dist/i3s-converter/types.js +0 -17
- package/dist/i3s-server/app.js +0 -22
- package/dist/i3s-server/controllers/index-controller.js +0 -23
- package/dist/i3s-server/controllers/slpk-controller.js +0 -32
- package/dist/i3s-server/routes/index.js +0 -16
- package/dist/i3s-server/routes/slpk-router.js +0 -33
- package/dist/i3s-server/utils/create-scene-server.js +0 -14
- package/dist/index.js +0 -10
- package/dist/lib/utils/compress-util.js +0 -257
- package/dist/lib/utils/file-utils.js +0 -139
- package/dist/lib/utils/geometry-utils.js +0 -18
- package/dist/lib/utils/lod-conversion-utils.js +0 -76
- package/dist/lib/utils/queue.js +0 -18
- package/dist/lib/utils/statistic-utills.js +0 -64
- package/dist/lib/utils/write-queue.js +0 -80
- package/dist/pgm-loader.js +0 -24
- package/dist/workers/3d-tiles-attributes-worker.d.ts +0 -2
- package/dist/workers/3d-tiles-attributes-worker.d.ts.map +0 -1
- package/dist/workers/3d-tiles-attributes-worker.js +0 -9
- package/dist/workers/i3s-attributes-worker.d.ts +0 -2
- package/dist/workers/i3s-attributes-worker.d.ts.map +0 -1
- package/dist/workers/i3s-attributes-worker.js +0 -5
- package/src/3d-tiles-attributes-worker.ts +0 -43
- package/src/i3s-attributes-worker.ts +0 -59
- package/src/i3s-server/bin/www +0 -102
- package/src/i3s-server/controllers/slpk-controller.js +0 -38
- package/src/i3s-server/utils/create-scene-server.js +0 -15
- package/src/workers/3d-tiles-attributes-worker.ts +0 -6
- package/src/workers/i3s-attributes-worker.ts +0 -7
package/src/converter-cli.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import '@loaders.gl/polyfills';
|
|
3
3
|
import {join} from 'path';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
4
5
|
import {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';
|
|
5
6
|
import {DepsInstaller} from './deps-installer/deps-installer';
|
|
7
|
+
import {
|
|
8
|
+
getBooleanValue,
|
|
9
|
+
getIntegerValue,
|
|
10
|
+
getStringValue,
|
|
11
|
+
getURLValue,
|
|
12
|
+
validateOptionsWithEqual
|
|
13
|
+
} from './lib/utils/cli-utils';
|
|
6
14
|
|
|
7
15
|
type TileConversionOptions = {
|
|
8
16
|
/** "I3S" - for I3S to 3DTiles conversion, "3DTILES" for 3DTiles to I3S conversion */
|
|
@@ -42,6 +50,8 @@ type TileConversionOptions = {
|
|
|
42
50
|
maxDepth?: number;
|
|
43
51
|
/** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */
|
|
44
52
|
slpk: boolean;
|
|
53
|
+
/** Feature metadata class from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA extensions */
|
|
54
|
+
metadataClass?: string;
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
/* During validation we check that particular options are defined so they can't be undefined */
|
|
@@ -125,8 +135,9 @@ function printHelp(): void {
|
|
|
125
135
|
console.log(
|
|
126
136
|
'--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]'
|
|
127
137
|
);
|
|
138
|
+
console.log('--generate-bounding-volumes [Generate obb and mbs bounding volumes from geometry]');
|
|
128
139
|
console.log(
|
|
129
|
-
'--
|
|
140
|
+
'--metadata-class [One of the list of feature metadata classes, detected by converter on "analyze" stage, default: not set]'
|
|
130
141
|
);
|
|
131
142
|
console.log('--validate [Enable validation]');
|
|
132
143
|
process.exit(0); // eslint-disable-line
|
|
@@ -168,7 +179,8 @@ async function convert(options: ValidatedTileConversionOptions) {
|
|
|
168
179
|
generateTextures: options.generateTextures,
|
|
169
180
|
generateBoundingVolumes: options.generateBoundingVolumes,
|
|
170
181
|
validate: options.validate,
|
|
171
|
-
instantNodeWriting: options.instantNodeWriting
|
|
182
|
+
instantNodeWriting: options.instantNodeWriting,
|
|
183
|
+
inquirer
|
|
172
184
|
});
|
|
173
185
|
break;
|
|
174
186
|
default:
|
|
@@ -213,19 +225,6 @@ function validateOptions(options: TileConversionOptions): ValidatedTileConversio
|
|
|
213
225
|
return <ValidatedTileConversionOptions>options;
|
|
214
226
|
}
|
|
215
227
|
|
|
216
|
-
function validateOptionsWithEqual(args: string[]): string[] {
|
|
217
|
-
return args.reduce((acc: string[], curr) => {
|
|
218
|
-
const equalSignIndex = curr.indexOf('=');
|
|
219
|
-
const beforeEqual = curr.slice(0, equalSignIndex);
|
|
220
|
-
const afterEqual = curr.slice(equalSignIndex + 1, curr.length);
|
|
221
|
-
const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;
|
|
222
|
-
if (condition) {
|
|
223
|
-
return acc.concat(beforeEqual, afterEqual);
|
|
224
|
-
}
|
|
225
|
-
return acc.concat(curr);
|
|
226
|
-
}, []);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
228
|
/**
|
|
230
229
|
* Parse option from the cli arguments array
|
|
231
230
|
* @param args
|
|
@@ -298,6 +297,8 @@ function parseOptions(args: string[]): TileConversionOptions {
|
|
|
298
297
|
case '--generate-bounding-volumes':
|
|
299
298
|
opts.generateBoundingVolumes = getBooleanValue(index, args);
|
|
300
299
|
break;
|
|
300
|
+
case '--metadata-class':
|
|
301
|
+
opts.metadataClass = getStringValue(index, args);
|
|
301
302
|
case '--help':
|
|
302
303
|
printHelp();
|
|
303
304
|
break;
|
|
@@ -309,62 +310,3 @@ function parseOptions(args: string[]): TileConversionOptions {
|
|
|
309
310
|
});
|
|
310
311
|
return opts;
|
|
311
312
|
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Get string option value from cli arguments
|
|
315
|
-
* @param index - option's name index in the argument's array.
|
|
316
|
-
* The value of the option should be next to name of the option.
|
|
317
|
-
* @param args - cli arguments array
|
|
318
|
-
* @returns - string value of the option
|
|
319
|
-
*/
|
|
320
|
-
function getStringValue(index: number, args: string[]): string {
|
|
321
|
-
if (index + 1 >= args.length) {
|
|
322
|
-
return '';
|
|
323
|
-
}
|
|
324
|
-
const value = args[index + 1];
|
|
325
|
-
if (value.indexOf('--') === 0) {
|
|
326
|
-
return '';
|
|
327
|
-
}
|
|
328
|
-
return value;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Modyfy URL path to be compatible with fetch
|
|
333
|
-
* @param index - option's name index in the argument's array.
|
|
334
|
-
* The value of the option should be next to name of the option.
|
|
335
|
-
* @param args - cli arguments array
|
|
336
|
-
* @returns - string value of the option
|
|
337
|
-
*/
|
|
338
|
-
function getURLValue(index: number, args: string[]): string {
|
|
339
|
-
const value = getStringValue(index, args);
|
|
340
|
-
console.log(`Input tileset value: ${value}`);
|
|
341
|
-
console.log(`Modified tileset value: ${value.replace(/\\/g, '/')}`);
|
|
342
|
-
return value.replace(/\\/g, '/');
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Get integer option value from cli arguments
|
|
347
|
-
* @param index - option's name index in the argument's array
|
|
348
|
-
* The value of the option should be next to name of the option.
|
|
349
|
-
* @param args - cli arguments array
|
|
350
|
-
* @returns - number value of the option
|
|
351
|
-
*/
|
|
352
|
-
function getIntegerValue(index: number, args: string[]): number {
|
|
353
|
-
const stringValue: string = getStringValue(index, args);
|
|
354
|
-
const result: number = Number.parseInt(stringValue);
|
|
355
|
-
if (isFinite(result)) {
|
|
356
|
-
return result;
|
|
357
|
-
}
|
|
358
|
-
return NaN;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function getBooleanValue(index: number, args: string[]): boolean {
|
|
362
|
-
const stringValue: string = getStringValue(index, args).toLowerCase().trim();
|
|
363
|
-
if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
|
|
364
|
-
return false;
|
|
365
|
-
}
|
|
366
|
-
if (!stringValue || stringValue === 'true') {
|
|
367
|
-
return true;
|
|
368
|
-
}
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
@@ -3,6 +3,8 @@ import {ZipLoader} from '@loaders.gl/zip';
|
|
|
3
3
|
import {writeFile} from '../lib/utils/file-utils';
|
|
4
4
|
import {join} from 'path';
|
|
5
5
|
import {ChildProcessProxy} from '@loaders.gl/worker-utils';
|
|
6
|
+
import {DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS} from '@loaders.gl/draco';
|
|
7
|
+
import {BASIS_EXTERNAL_LIBRARIES} from '@loaders.gl/textures';
|
|
6
8
|
|
|
7
9
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
8
10
|
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
|
|
@@ -23,7 +25,7 @@ export class DepsInstaller {
|
|
|
23
25
|
* This path is '' by default and is not used by tile-converter.
|
|
24
26
|
* It is used in tests to prevent rewriting actual workers during tests running
|
|
25
27
|
*/
|
|
26
|
-
async install(path: string = ''
|
|
28
|
+
async install(path: string = ''): Promise<void> {
|
|
27
29
|
console.log('Installing "EGM2008-5" model...'); // eslint-disable-line no-console
|
|
28
30
|
const fileMap = await load(PGM_LINK, ZipLoader, {});
|
|
29
31
|
|
|
@@ -34,38 +36,82 @@ export class DepsInstaller {
|
|
|
34
36
|
|
|
35
37
|
await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');
|
|
36
38
|
|
|
37
|
-
console.log('Installing "I3S Content Loader worker
|
|
38
|
-
await this.
|
|
39
|
+
console.log('Installing "I3S Content Loader" worker'); // eslint-disable-line no-console
|
|
40
|
+
await this.installFromNpm('i3s', 'i3s-content-worker-node.js');
|
|
39
41
|
|
|
40
|
-
console.log('Installing "Draco Loader worker
|
|
41
|
-
await this.
|
|
42
|
+
console.log('Installing "Draco Loader" worker'); // eslint-disable-line no-console
|
|
43
|
+
await this.installFromNpm('draco', 'draco-worker-node.js');
|
|
42
44
|
|
|
43
|
-
console.log('Installing "
|
|
44
|
-
await this.
|
|
45
|
+
console.log('Installing "Draco Writer" worker'); // eslint-disable-line no-console
|
|
46
|
+
await this.installFromNpm('draco', 'draco-writer-worker-node.js');
|
|
47
|
+
|
|
48
|
+
console.log('Installing "Basis Loader" worker'); // eslint-disable-line no-console
|
|
49
|
+
await this.installFromNpm('textures', 'basis-worker-node.js');
|
|
50
|
+
|
|
51
|
+
console.log('Installing "KTX2 Basis Writer" worker'); // eslint-disable-line no-console
|
|
52
|
+
await this.installFromNpm('textures', 'ktx2-basis-writer-worker-node.js');
|
|
53
|
+
|
|
54
|
+
console.log('Installing "Draco decoder" library'); // eslint-disable-line no-console
|
|
55
|
+
await this.installFromUrl(
|
|
56
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
|
|
57
|
+
'draco',
|
|
58
|
+
DRACO_EXTERNAL_LIBRARIES.DECODER
|
|
59
|
+
);
|
|
60
|
+
await this.installFromUrl(
|
|
61
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
|
|
62
|
+
'draco',
|
|
63
|
+
DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
console.log('Installing "Draco encoder" library'); // eslint-disable-line no-console
|
|
67
|
+
await this.installFromUrl(
|
|
68
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER],
|
|
69
|
+
'draco',
|
|
70
|
+
DRACO_EXTERNAL_LIBRARIES.ENCODER
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
console.log('Installing "Basis transcoder" library'); // eslint-disable-line no-console
|
|
74
|
+
await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'libs');
|
|
75
|
+
await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'libs');
|
|
76
|
+
|
|
77
|
+
console.log('Installing "Basis encoder" library'); // eslint-disable-line no-console
|
|
78
|
+
await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER, 'libs');
|
|
79
|
+
await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'libs');
|
|
45
80
|
|
|
46
81
|
console.log('Installing "join-images" npm package');
|
|
47
82
|
const childProcess = new ChildProcessProxy();
|
|
48
83
|
await childProcess.start({
|
|
49
|
-
command: 'npm',
|
|
84
|
+
command: process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
50
85
|
// `npm install sharp join-images` works unstable. It fails because installed `sharp` version
|
|
51
86
|
// may be different from the version required by `join-images`. Pointing to specific versions
|
|
52
87
|
// resolve this issue
|
|
53
88
|
arguments: ['install', 'sharp@0.30.4', 'join-images@1.1.3'],
|
|
54
|
-
wait: 0
|
|
89
|
+
wait: 0,
|
|
90
|
+
ignoreStderr: true
|
|
55
91
|
});
|
|
56
92
|
|
|
57
93
|
console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console
|
|
58
94
|
}
|
|
59
95
|
|
|
60
|
-
private async
|
|
96
|
+
private async installFromNpm(module: string, name: string, extraPath: string = '') {
|
|
61
97
|
const fileResponse = await fetchFile(
|
|
62
|
-
`https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${name}`
|
|
98
|
+
`https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${extraPath}/${name}`
|
|
63
99
|
);
|
|
64
100
|
const fileData = await fileResponse.arrayBuffer();
|
|
65
101
|
if (!fileData) {
|
|
66
102
|
return;
|
|
67
103
|
}
|
|
68
|
-
const path = join(process.cwd(),
|
|
104
|
+
const path = join(process.cwd(), 'modules', module, 'dist', extraPath);
|
|
105
|
+
await writeFile(path, fileData, name);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private async installFromUrl(url: string, module: string, name: string) {
|
|
109
|
+
const fileResponse = await fetchFile(url);
|
|
110
|
+
const fileData = await fileResponse.arrayBuffer();
|
|
111
|
+
if (!fileData) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const path = join(process.cwd(), 'modules', module, 'dist', 'libs');
|
|
69
115
|
await writeFile(path, fileData, name);
|
|
70
116
|
}
|
|
71
117
|
}
|
|
@@ -1,30 +1,64 @@
|
|
|
1
1
|
import {GLTFAccessorPostprocessed, GLTFMeshPrimitivePostprocessed} from '@loaders.gl/gltf';
|
|
2
2
|
import type {NumericArray} from '@loaders.gl/loader-utils';
|
|
3
3
|
import type {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
GLTF_EXT_feature_metadata_FeatureIdTexture,
|
|
5
|
+
GLTF_EXT_feature_metadata_GLTF,
|
|
6
|
+
GLTF_EXT_feature_metadata_Primitive
|
|
6
7
|
} from '@loaders.gl/gltf';
|
|
8
|
+
|
|
9
|
+
import type {GLTF_EXT_mesh_features} from '@loaders.gl/gltf';
|
|
10
|
+
|
|
7
11
|
import {TypedArray} from '@math.gl/core';
|
|
8
|
-
import {TextureImageProperties} from '
|
|
12
|
+
import {TextureImageProperties} from '../types';
|
|
13
|
+
import {emod} from '@loaders.gl/math';
|
|
14
|
+
import {EXT_MESH_FEATURES, EXT_FEATURE_METADATA} from '@loaders.gl/gltf';
|
|
15
|
+
import {Tiles3DTileContent} from '@loaders.gl/3d-tiles';
|
|
9
16
|
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Get featureTexture by a metadata class.
|
|
19
|
+
* Metadata classes come from a structural metadata extesion (EXT_feature_metadata or EXT_structural_metadata).
|
|
20
|
+
* The glTF might contain multiple texel-level metadata textures related to different classes. Having only one metadata class
|
|
21
|
+
* selected to convert to I3S, we have to pick only one texture to convert to per-vertex property.
|
|
22
|
+
* @param tileContent - 3d tile content
|
|
23
|
+
* @param metadataClass - user selected feature metadata class name
|
|
24
|
+
* @returns featureTexture key
|
|
25
|
+
*/
|
|
26
|
+
export function getTextureByMetadataClass(
|
|
27
|
+
tileContent: Tiles3DTileContent,
|
|
28
|
+
metadataClass?: string
|
|
29
|
+
): string | null {
|
|
30
|
+
const extFeatureMetadata = tileContent.gltf?.extensions?.[
|
|
31
|
+
EXT_FEATURE_METADATA
|
|
32
|
+
] as GLTF_EXT_feature_metadata_GLTF;
|
|
33
|
+
if (!extFeatureMetadata?.featureTextures) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
for (const textureKey in extFeatureMetadata.featureTextures) {
|
|
37
|
+
const texture = extFeatureMetadata.featureTextures[textureKey];
|
|
38
|
+
if (texture.class === metadataClass) {
|
|
39
|
+
return textureKey;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
12
44
|
|
|
13
45
|
/**
|
|
14
46
|
* Getting batchIds from 3DTilesNext extensions.
|
|
15
47
|
* @param attributes - gltf accessors
|
|
16
48
|
* @param primitive - gltf primitive data
|
|
17
49
|
* @param images - gltf texture images
|
|
50
|
+
* @param featureTexture - feature texture key
|
|
51
|
+
* @return array of batch IDs
|
|
18
52
|
*/
|
|
19
53
|
export function handleBatchIdsExtensions(
|
|
20
54
|
attributes: {
|
|
21
55
|
[key: string]: GLTFAccessorPostprocessed;
|
|
22
56
|
},
|
|
23
57
|
primitive: GLTFMeshPrimitivePostprocessed,
|
|
24
|
-
images: (TextureImageProperties | null)[]
|
|
58
|
+
images: (TextureImageProperties | null)[],
|
|
59
|
+
featureTexture: string | null
|
|
25
60
|
): NumericArray {
|
|
26
61
|
const extensions = primitive?.extensions;
|
|
27
|
-
|
|
28
62
|
if (!extensions) {
|
|
29
63
|
return [];
|
|
30
64
|
}
|
|
@@ -34,12 +68,12 @@ export function handleBatchIdsExtensions(
|
|
|
34
68
|
case EXT_FEATURE_METADATA:
|
|
35
69
|
return handleExtFeatureMetadataExtension(
|
|
36
70
|
attributes,
|
|
37
|
-
extensionData as
|
|
38
|
-
images
|
|
71
|
+
extensionData as GLTF_EXT_feature_metadata_Primitive,
|
|
72
|
+
images,
|
|
73
|
+
featureTexture
|
|
39
74
|
);
|
|
40
75
|
case EXT_MESH_FEATURES:
|
|
41
|
-
|
|
42
|
-
return [];
|
|
76
|
+
return handleExtMeshFeaturesExtension(attributes, extensionData as GLTF_EXT_mesh_features);
|
|
43
77
|
default:
|
|
44
78
|
return [];
|
|
45
79
|
}
|
|
@@ -48,19 +82,43 @@ export function handleBatchIdsExtensions(
|
|
|
48
82
|
return [];
|
|
49
83
|
}
|
|
50
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Getting batchIds from EXT_mesh_features extensions.
|
|
87
|
+
* @param attributes - gltf accessors
|
|
88
|
+
* @param extMeshFeatures - EXT_mesh_features extension
|
|
89
|
+
* @returns an array of attribute values
|
|
90
|
+
*/
|
|
91
|
+
function handleExtMeshFeaturesExtension(
|
|
92
|
+
attributes: {
|
|
93
|
+
[key: string]: GLTFAccessorPostprocessed;
|
|
94
|
+
},
|
|
95
|
+
extMeshFeatures: GLTF_EXT_mesh_features
|
|
96
|
+
): NumericArray {
|
|
97
|
+
for (let ids of extMeshFeatures.featureIds) {
|
|
98
|
+
if (typeof ids.propertyTable !== 'undefined') {
|
|
99
|
+
// propertyTable is an index that can be 0
|
|
100
|
+
// return the first featureID set that corresponts to property table.
|
|
101
|
+
return ids.data as NumericArray;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
|
|
51
107
|
/**
|
|
52
108
|
* Get batchIds from EXT_feature_metadata extension.
|
|
53
|
-
*
|
|
54
|
-
* @param attributes
|
|
55
|
-
* @param extFeatureMetadata
|
|
56
|
-
* @param textures
|
|
109
|
+
* @see - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata
|
|
110
|
+
* @param attributes - glTF attributes
|
|
111
|
+
* @param extFeatureMetadata - primitive-level EXT_FEATURE_METADATA extension data
|
|
112
|
+
* @param textures - texture images
|
|
113
|
+
* @param featureTexture - feature texture key
|
|
57
114
|
*/
|
|
58
115
|
function handleExtFeatureMetadataExtension(
|
|
59
116
|
attributes: {
|
|
60
117
|
[key: string]: GLTFAccessorPostprocessed;
|
|
61
118
|
},
|
|
62
|
-
extFeatureMetadata:
|
|
63
|
-
images: (TextureImageProperties | null)[]
|
|
119
|
+
extFeatureMetadata: GLTF_EXT_feature_metadata_Primitive,
|
|
120
|
+
images: (TextureImageProperties | null)[],
|
|
121
|
+
featureTexture: string | null
|
|
64
122
|
): NumericArray {
|
|
65
123
|
// Take only first extension object to get batchIds attribute name.
|
|
66
124
|
const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];
|
|
@@ -93,10 +151,6 @@ function handleExtFeatureMetadataExtension(
|
|
|
93
151
|
return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);
|
|
94
152
|
}
|
|
95
153
|
|
|
96
|
-
// Take only first extension texture to get batchIds from the root EXT_feature_metadata object.
|
|
97
|
-
const featureTexture =
|
|
98
|
-
extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];
|
|
99
|
-
|
|
100
154
|
if (featureTexture) {
|
|
101
155
|
const batchIdsAttribute = attributes[featureTexture];
|
|
102
156
|
return batchIdsAttribute.value;
|
|
@@ -107,7 +161,7 @@ function handleExtFeatureMetadataExtension(
|
|
|
107
161
|
|
|
108
162
|
/**
|
|
109
163
|
* Generates implicit feature ids
|
|
110
|
-
*
|
|
164
|
+
* @see - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids
|
|
111
165
|
* @param featuresCount
|
|
112
166
|
* @param constant
|
|
113
167
|
* @param devisor
|
|
@@ -146,7 +200,7 @@ function generateImplicitFeatureIds(
|
|
|
146
200
|
* @param featureIdTextures
|
|
147
201
|
*/
|
|
148
202
|
function generateBatchIdsFromTexture(
|
|
149
|
-
featureIdTexture:
|
|
203
|
+
featureIdTexture: GLTF_EXT_feature_metadata_FeatureIdTexture,
|
|
150
204
|
textureCoordinates: TypedArray,
|
|
151
205
|
images: (TextureImageProperties | null)[]
|
|
152
206
|
) {
|
|
@@ -191,12 +245,3 @@ function generateBatchIdsFromTexture(
|
|
|
191
245
|
|
|
192
246
|
return batchIds;
|
|
193
247
|
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Handle UVs if they are out of range [0,1].
|
|
197
|
-
* @param n
|
|
198
|
-
* @param m
|
|
199
|
-
*/
|
|
200
|
-
function emod(n: number): number {
|
|
201
|
-
return ((n % 1) + 1) % 1;
|
|
202
|
-
}
|
|
@@ -103,7 +103,6 @@ export function convertPositionsToVectors(positions: Float32Array): Vector3[] {
|
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
|
|
106
|
-
* @param
|
|
107
106
|
* @param boundingVolume
|
|
108
107
|
* @returns - fullExtent object
|
|
109
108
|
*/
|
|
@@ -142,7 +141,7 @@ export function convertBoundingVolumeToI3SFullExtent(
|
|
|
142
141
|
/**
|
|
143
142
|
* Creates oriented boundinb box from mbs.
|
|
144
143
|
* @param mbs - Minimum Bounding Sphere
|
|
145
|
-
* @returns - Oriented
|
|
144
|
+
* @returns - Oriented Bounding Box
|
|
146
145
|
*/
|
|
147
146
|
export function createObbFromMbs(mbs: Mbs): Obb {
|
|
148
147
|
const radius = mbs[3];
|
|
@@ -9,26 +9,26 @@ import {
|
|
|
9
9
|
} from '@loaders.gl/i3s';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Takes attributes from property table based on
|
|
12
|
+
* Takes attributes from property table based on featureIdsMap.
|
|
13
13
|
* If there is no property value for particular featureId (index) the property will be null.
|
|
14
14
|
* Example:
|
|
15
15
|
* Initial data:
|
|
16
|
-
* OBJECTID:
|
|
16
|
+
* OBJECTID: {0: 0, 3: 33, 4: 333}
|
|
17
17
|
* component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']
|
|
18
18
|
* Result:
|
|
19
|
-
* OBJECTID: [0,
|
|
20
|
-
* component: ['Windows', '
|
|
21
|
-
* @param
|
|
19
|
+
* OBJECTID: [0, 33, 333]
|
|
20
|
+
* component: ['Windows', 'Roof', 'Skylight']
|
|
21
|
+
* @param featureIdsMap
|
|
22
22
|
* @param propertyTable
|
|
23
23
|
*/
|
|
24
24
|
export function flattenPropertyTableByFeatureIds(
|
|
25
|
-
|
|
25
|
+
featureIdsMap: Record<string, number>,
|
|
26
26
|
propertyTable: FeatureTableJson
|
|
27
27
|
): FeatureTableJson {
|
|
28
28
|
const resultPropertyTable: FeatureTableJson = {};
|
|
29
29
|
for (const propertyName in propertyTable) {
|
|
30
30
|
const properties = propertyTable[propertyName];
|
|
31
|
-
resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties,
|
|
31
|
+
resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIdsMap);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return resultPropertyTable;
|
|
@@ -37,14 +37,19 @@ export function flattenPropertyTableByFeatureIds(
|
|
|
37
37
|
/**
|
|
38
38
|
* Getting properties by featureId index
|
|
39
39
|
* @param properties
|
|
40
|
-
* @param
|
|
40
|
+
* @param featureIdsMap
|
|
41
41
|
*/
|
|
42
|
-
function getPropertiesByFeatureIds(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
function getPropertiesByFeatureIds(
|
|
43
|
+
properties: unknown[],
|
|
44
|
+
featureIdsMap: Record<string, number>
|
|
45
|
+
): unknown[] {
|
|
46
|
+
const resultProperties: unknown[] = [];
|
|
47
|
+
|
|
48
|
+
if (properties) {
|
|
49
|
+
for (const featureIdKey in featureIdsMap) {
|
|
50
|
+
const property = properties[featureIdKey] || null;
|
|
51
|
+
resultProperties.push(property);
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
return resultProperties;
|
|
@@ -64,7 +69,7 @@ export function checkPropertiesLength(
|
|
|
64
69
|
let needFlatten = false;
|
|
65
70
|
|
|
66
71
|
for (const attribute of Object.values(propertyTable)) {
|
|
67
|
-
if (featureIds.length !== attribute.length) {
|
|
72
|
+
if (!featureIds || !attribute || featureIds.length !== attribute.length) {
|
|
68
73
|
needFlatten = true;
|
|
69
74
|
}
|
|
70
75
|
}
|
|
@@ -83,13 +88,13 @@ const OBJECT_ID_TYPE = 'OBJECTID';
|
|
|
83
88
|
/**
|
|
84
89
|
* Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
85
90
|
* @param key - attribute's key
|
|
86
|
-
* @param attribute - attribute
|
|
91
|
+
* @param attribute - attribute taken from propertyTable
|
|
87
92
|
*/
|
|
88
|
-
export function getAttributeType(key: string, attribute:
|
|
93
|
+
export function getAttributeType(key: string, attribute: unknown): string {
|
|
89
94
|
if (key === OBJECT_ID_TYPE) {
|
|
90
95
|
return OBJECT_ID_TYPE;
|
|
91
96
|
}
|
|
92
|
-
if (typeof attribute === STRING_TYPE) {
|
|
97
|
+
if (typeof attribute === STRING_TYPE || typeof attribute === 'bigint') {
|
|
93
98
|
return STRING_TYPE;
|
|
94
99
|
} else if (typeof attribute === 'number') {
|
|
95
100
|
return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
|