@loaders.gl/tile-converter 3.3.0-alpha.3 → 3.3.0-alpha.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/3d-tiles-attributes-worker.js +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +8 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +57 -43
- package/dist/converter.min.js +21 -21
- package/dist/deps-installer/deps-installer.d.ts +5 -1
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +21 -1
- package/dist/dist.min.js +660 -1016
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +115 -101
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +70 -6
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +4 -0
- 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 +153 -0
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +40 -44
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +55 -36
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +10 -2
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +364 -435
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +59 -44
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +21 -2
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +4 -0
- 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 +138 -0
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +19 -21
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +55 -36
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js +9 -2
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +93 -183
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/i3s-attributes-worker.d.ts +5 -1
- package/dist/i3s-attributes-worker.d.ts.map +1 -1
- package/dist/i3s-attributes-worker.js +3 -3
- package/dist/i3s-attributes-worker.js.map +2 -2
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +2 -3
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +32 -0
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +162 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +5 -4
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +29 -27
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +50 -30
- package/dist/i3s-converter/helpers/node-pages.d.ts +4 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +9 -2
- package/dist/i3s-converter/i3s-converter.d.ts +24 -48
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +88 -186
- package/dist/i3s-converter/types.d.ts +4 -0
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/3d-tiles-converter/3d-tiles-converter.ts +71 -55
- package/src/deps-installer/deps-installer.ts +29 -2
- package/src/i3s-attributes-worker.ts +5 -1
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +13 -6
- package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
- package/src/i3s-converter/helpers/feature-attributes.ts +182 -0
- package/src/i3s-converter/helpers/geometry-converter.ts +45 -36
- package/src/i3s-converter/helpers/gltf-attributes.ts +54 -33
- package/src/i3s-converter/helpers/node-pages.ts +10 -2
- package/src/i3s-converter/i3s-converter.ts +125 -210
- package/src/i3s-converter/types.ts +4 -0
|
@@ -2,19 +2,13 @@ import type {Tile3D, Tileset3DProps} from '@loaders.gl/tiles';
|
|
|
2
2
|
import type {FeatureTableJson} from '@loaders.gl/3d-tiles';
|
|
3
3
|
import type {WriteQueueItem} from '../lib/utils/write-queue';
|
|
4
4
|
import type {
|
|
5
|
-
AttributeStorageInfo,
|
|
6
5
|
SceneLayer3D,
|
|
7
6
|
BoundingVolumes,
|
|
8
7
|
Node3DIndexDocument,
|
|
9
8
|
NodeReference,
|
|
10
9
|
MaxScreenThresholdSQ,
|
|
11
10
|
NodeInPage,
|
|
12
|
-
LodSelection
|
|
13
|
-
Attribute,
|
|
14
|
-
ESRIField,
|
|
15
|
-
Field,
|
|
16
|
-
PopupInfo,
|
|
17
|
-
FieldInfo
|
|
11
|
+
LodSelection
|
|
18
12
|
} from '@loaders.gl/i3s';
|
|
19
13
|
import {load, encode, fetchFile, getLoaderOptions, isBrowser} from '@loaders.gl/core';
|
|
20
14
|
import {Tileset3D} from '@loaders.gl/tiles';
|
|
@@ -59,6 +53,13 @@ import {DracoWriterWorker} from '@loaders.gl/draco';
|
|
|
59
53
|
import WriteQueue from '../lib/utils/write-queue';
|
|
60
54
|
import {I3SAttributesWorker} from '../i3s-attributes-worker';
|
|
61
55
|
import {BROWSER_ERROR_MESSAGE} from '../constants';
|
|
56
|
+
import {
|
|
57
|
+
createdStorageAttribute,
|
|
58
|
+
createFieldAttribute,
|
|
59
|
+
createPopupInfo,
|
|
60
|
+
getAttributeType,
|
|
61
|
+
getFieldAttributeType
|
|
62
|
+
} from './helpers/feature-attributes';
|
|
62
63
|
|
|
63
64
|
const ION_DEFAULT_TOKEN =
|
|
64
65
|
process.env?.IonToken || // eslint-disable-line
|
|
@@ -66,10 +67,6 @@ const ION_DEFAULT_TOKEN =
|
|
|
66
67
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
67
68
|
const _3D_TILES = '3DTILES';
|
|
68
69
|
const _3D_OBJECT_LAYER_TYPE = '3DObject';
|
|
69
|
-
const STRING_TYPE = 'string';
|
|
70
|
-
const SHORT_INT_TYPE = 'Int32';
|
|
71
|
-
const DOUBLE_TYPE = 'double';
|
|
72
|
-
const OBJECT_ID_TYPE = 'OBJECTID';
|
|
73
70
|
const REFRESH_TOKEN_TIMEOUT = 1800; // 30 minutes in seconds
|
|
74
71
|
const CESIUM_DATASET_PREFIX = 'https://';
|
|
75
72
|
// const FS_FILE_TOO_LARGE = 'ERR_FS_FILE_TOO_LARGE';
|
|
@@ -190,7 +187,18 @@ export default class I3SConverter {
|
|
|
190
187
|
|
|
191
188
|
try {
|
|
192
189
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
193
|
-
const tilesetOptions: Tileset3DProps = {
|
|
190
|
+
const tilesetOptions: Tileset3DProps = {
|
|
191
|
+
loadOptions: {
|
|
192
|
+
_nodeWorkers: true,
|
|
193
|
+
reuseWorkers: true,
|
|
194
|
+
basis: {format: 'rgba32'},
|
|
195
|
+
'basis-nodejs': {
|
|
196
|
+
format: 'rgba32',
|
|
197
|
+
workerUrl: './modules/textures/dist/basis-nodejs-worker.js'
|
|
198
|
+
},
|
|
199
|
+
'draco-nodejs': {workerUrl: './modules/draco/dist/draco-nodejs-worker.js'}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
194
202
|
if (preloadOptions.headers) {
|
|
195
203
|
tilesetOptions.loadOptions!.fetch = {headers: preloadOptions.headers};
|
|
196
204
|
}
|
|
@@ -462,6 +470,74 @@ export default class I3SConverter {
|
|
|
462
470
|
await this._addNeighborsAndWriteFile(data.parentNode, childNodes);
|
|
463
471
|
}
|
|
464
472
|
|
|
473
|
+
/**
|
|
474
|
+
* Convert nested subtree of 3DTiles dataset
|
|
475
|
+
* @param param0
|
|
476
|
+
* @param param0.sourceTile - source 3DTile data
|
|
477
|
+
* @param param0.parentNode - parent I3S node
|
|
478
|
+
* @param param0.childNodes - child I3S nodes
|
|
479
|
+
* @param param0.parentId - parent node ID
|
|
480
|
+
* @param param0.level - tree level
|
|
481
|
+
*/
|
|
482
|
+
private async convertNestedTileset({
|
|
483
|
+
sourceTile,
|
|
484
|
+
parentNode,
|
|
485
|
+
childNodes,
|
|
486
|
+
parentId,
|
|
487
|
+
level
|
|
488
|
+
}: {
|
|
489
|
+
childNodes: NodeReference[];
|
|
490
|
+
sourceTile: TileHeader;
|
|
491
|
+
parentNode: Node3DIndexDocument;
|
|
492
|
+
parentId: number;
|
|
493
|
+
level: number;
|
|
494
|
+
}) {
|
|
495
|
+
await this.sourceTileset!._loadTile(sourceTile);
|
|
496
|
+
await this._addChildren({
|
|
497
|
+
parentNode,
|
|
498
|
+
sourceTiles: sourceTile.children,
|
|
499
|
+
childNodes,
|
|
500
|
+
parentId,
|
|
501
|
+
level: level + 1
|
|
502
|
+
});
|
|
503
|
+
await sourceTile.unloadContent();
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Convert 3DTiles tile to I3S node
|
|
508
|
+
* @param param0
|
|
509
|
+
* @param param0.sourceTile - source 3DTile data
|
|
510
|
+
* @param param0.parentNode - parent I3S node
|
|
511
|
+
* @param param0.childNodes - child I3S nodes
|
|
512
|
+
* @param param0.parentId - parent node ID
|
|
513
|
+
* @param param0.level - tree level
|
|
514
|
+
*/
|
|
515
|
+
private async convertNode({
|
|
516
|
+
sourceTile,
|
|
517
|
+
parentNode,
|
|
518
|
+
childNodes,
|
|
519
|
+
parentId,
|
|
520
|
+
level
|
|
521
|
+
}: {
|
|
522
|
+
childNodes: NodeReference[];
|
|
523
|
+
sourceTile: TileHeader;
|
|
524
|
+
parentNode: Node3DIndexDocument;
|
|
525
|
+
parentId: number;
|
|
526
|
+
level: number;
|
|
527
|
+
}) {
|
|
528
|
+
const children = await this._createNode(parentNode, sourceTile, parentId, level);
|
|
529
|
+
parentNode.children = parentNode.children || [];
|
|
530
|
+
for (const child of children) {
|
|
531
|
+
parentNode.children.push({
|
|
532
|
+
id: child.id,
|
|
533
|
+
href: `../${child.path}`,
|
|
534
|
+
obb: child.obb,
|
|
535
|
+
mbs: child.mbs
|
|
536
|
+
});
|
|
537
|
+
childNodes.push(child);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
465
541
|
/**
|
|
466
542
|
* Add child nodes recursively and write them to files
|
|
467
543
|
* @param data - arguments
|
|
@@ -482,30 +558,18 @@ export default class I3SConverter {
|
|
|
482
558
|
if (this.options.maxDepth && level > this.options.maxDepth) {
|
|
483
559
|
return;
|
|
484
560
|
}
|
|
561
|
+
|
|
562
|
+
const promises: Promise<void>[] = [];
|
|
563
|
+
|
|
485
564
|
for (const sourceTile of sourceTiles) {
|
|
486
565
|
if (sourceTile.type === 'json') {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
sourceTiles: sourceTile.children,
|
|
491
|
-
childNodes,
|
|
492
|
-
parentId,
|
|
493
|
-
level: level + 1
|
|
494
|
-
});
|
|
495
|
-
await sourceTile.unloadContent();
|
|
566
|
+
promises.push(
|
|
567
|
+
this.convertNestedTileset({sourceTile, parentNode, childNodes, parentId, level})
|
|
568
|
+
);
|
|
496
569
|
} else {
|
|
497
|
-
|
|
498
|
-
parentNode.children = parentNode.children || [];
|
|
499
|
-
for (const child of children) {
|
|
500
|
-
parentNode.children.push({
|
|
501
|
-
id: child.id,
|
|
502
|
-
href: `../${child.path}`,
|
|
503
|
-
obb: child.obb,
|
|
504
|
-
mbs: child.mbs
|
|
505
|
-
});
|
|
506
|
-
childNodes.push(child);
|
|
507
|
-
}
|
|
570
|
+
promises.push(this.convertNode({sourceTile, parentNode, childNodes, parentId, level}));
|
|
508
571
|
}
|
|
572
|
+
await Promise.all(promises);
|
|
509
573
|
if (sourceTile.id) {
|
|
510
574
|
console.log(sourceTile.id); // eslint-disable-line
|
|
511
575
|
}
|
|
@@ -572,13 +636,13 @@ export default class I3SConverter {
|
|
|
572
636
|
|
|
573
637
|
let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel!);
|
|
574
638
|
|
|
575
|
-
const propertyTable = getPropertyTable(sourceTile);
|
|
639
|
+
const propertyTable = getPropertyTable(sourceTile.content);
|
|
576
640
|
|
|
577
641
|
if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {
|
|
578
642
|
this._convertPropertyTableToNodeAttributes(propertyTable);
|
|
579
643
|
}
|
|
580
644
|
|
|
581
|
-
const resourcesData = await this._convertResources(sourceTile, propertyTable);
|
|
645
|
+
const resourcesData = await this._convertResources(sourceTile, parentId, propertyTable);
|
|
582
646
|
|
|
583
647
|
const nodes: Node3DIndexDocument[] = [];
|
|
584
648
|
const nodesInPage: NodeInPage[] = [];
|
|
@@ -606,7 +670,7 @@ export default class I3SConverter {
|
|
|
606
670
|
(val) => val.metricType === 'maxScreenThresholdSQ'
|
|
607
671
|
) || {maxError: 0};
|
|
608
672
|
|
|
609
|
-
const nodeInPage = this.
|
|
673
|
+
const nodeInPage = this._updateNodeInNodePages(
|
|
610
674
|
maxScreenThresholdSQ,
|
|
611
675
|
boundingVolumes,
|
|
612
676
|
sourceTile,
|
|
@@ -651,6 +715,8 @@ export default class I3SConverter {
|
|
|
651
715
|
/**
|
|
652
716
|
* Convert tile to one or more I3S nodes
|
|
653
717
|
* @param sourceTile - source tile (3DTile)
|
|
718
|
+
* @param parentId - id of parent node in node pages
|
|
719
|
+
* @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA
|
|
654
720
|
* result.geometry - ArrayBuffer with geometry attributes
|
|
655
721
|
* result.compressedGeometry - ArrayBuffer with compressed (draco) geometry
|
|
656
722
|
* result.texture - texture image
|
|
@@ -662,14 +728,20 @@ export default class I3SConverter {
|
|
|
662
728
|
*/
|
|
663
729
|
private async _convertResources(
|
|
664
730
|
sourceTile: TileHeader,
|
|
731
|
+
parentId: number,
|
|
665
732
|
propertyTable: FeatureTableJson | null
|
|
666
733
|
): Promise<I3SConvertedResources[] | null> {
|
|
667
734
|
if (!this.isContentSupported(sourceTile)) {
|
|
668
735
|
return null;
|
|
669
736
|
}
|
|
737
|
+
const draftObb = {
|
|
738
|
+
center: [],
|
|
739
|
+
halfSize: [],
|
|
740
|
+
quaternion: []
|
|
741
|
+
};
|
|
670
742
|
const resourcesData = await convertB3dmToI3sGeometry(
|
|
671
743
|
sourceTile.content,
|
|
672
|
-
|
|
744
|
+
() => this.nodePages.push({index: 0, obb: draftObb}, parentId),
|
|
673
745
|
propertyTable,
|
|
674
746
|
this.featuresHashArray,
|
|
675
747
|
this.layers0?.attributeStorageInfo,
|
|
@@ -682,7 +754,7 @@ export default class I3SConverter {
|
|
|
682
754
|
}
|
|
683
755
|
|
|
684
756
|
/**
|
|
685
|
-
*
|
|
757
|
+
* Update node object (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/node.cmn.md)
|
|
686
758
|
* in node pages (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodePage.cmn.md)
|
|
687
759
|
* @param maxScreenThresholdSQ - Level of Details (LOD) metric
|
|
688
760
|
* @param boundingVolumes - Bounding volumes
|
|
@@ -695,7 +767,7 @@ export default class I3SConverter {
|
|
|
695
767
|
* @param resources.featureCount - number of features
|
|
696
768
|
* @return the node object in node pages
|
|
697
769
|
*/
|
|
698
|
-
private
|
|
770
|
+
private _updateNodeInNodePages(
|
|
699
771
|
maxScreenThresholdSQ: MaxScreenThresholdSQ,
|
|
700
772
|
boundingVolumes: BoundingVolumes,
|
|
701
773
|
sourceTile: TileHeader,
|
|
@@ -723,7 +795,15 @@ export default class I3SConverter {
|
|
|
723
795
|
}
|
|
724
796
|
};
|
|
725
797
|
}
|
|
726
|
-
|
|
798
|
+
|
|
799
|
+
let nodeId = resources.nodeId;
|
|
800
|
+
if (nodeId) {
|
|
801
|
+
this.nodePages.updateAll(nodeId, nodeInPage);
|
|
802
|
+
const node = this.nodePages.getNodeById(nodeId);
|
|
803
|
+
this.nodePages.updateResourceInMesh(node);
|
|
804
|
+
} else {
|
|
805
|
+
nodeId = this.nodePages.push(nodeInPage, parentId);
|
|
806
|
+
}
|
|
727
807
|
|
|
728
808
|
if (meshMaterial) {
|
|
729
809
|
this.nodePages.updateMaterialByNodeId(nodeId, this._findOrCreateMaterial(meshMaterial));
|
|
@@ -743,7 +823,7 @@ export default class I3SConverter {
|
|
|
743
823
|
this.nodePages.updateFeatureCountByNodeId(nodeId, featureCount);
|
|
744
824
|
}
|
|
745
825
|
|
|
746
|
-
return
|
|
826
|
+
return this.nodePages.getNodeById(nodeId);
|
|
747
827
|
}
|
|
748
828
|
|
|
749
829
|
/**
|
|
@@ -1067,115 +1147,6 @@ export default class I3SConverter {
|
|
|
1067
1147
|
return newMaterialId;
|
|
1068
1148
|
}
|
|
1069
1149
|
|
|
1070
|
-
/**
|
|
1071
|
-
* Generate storage attribute for map segmentation.
|
|
1072
|
-
* @param attributeIndex - order index of attribute (f_0, f_1 ...).
|
|
1073
|
-
* @param key - attribute key from propertyTable.
|
|
1074
|
-
* @param attributeType - attribute type.
|
|
1075
|
-
* @return Updated storageAttribute.
|
|
1076
|
-
*/
|
|
1077
|
-
private _createdStorageAttribute(
|
|
1078
|
-
attributeIndex: number,
|
|
1079
|
-
key: string,
|
|
1080
|
-
attributeType: Attribute
|
|
1081
|
-
): AttributeStorageInfo {
|
|
1082
|
-
const storageAttribute = {
|
|
1083
|
-
key: `f_${attributeIndex}`,
|
|
1084
|
-
name: key,
|
|
1085
|
-
ordering: ['attributeValues'],
|
|
1086
|
-
header: [{property: 'count', valueType: 'UInt32'}],
|
|
1087
|
-
attributeValues: {valueType: 'Int32', valuesPerElement: 1}
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
|
-
switch (attributeType) {
|
|
1091
|
-
case OBJECT_ID_TYPE:
|
|
1092
|
-
this._setupIdAttribute(storageAttribute);
|
|
1093
|
-
break;
|
|
1094
|
-
case STRING_TYPE:
|
|
1095
|
-
this._setupStringAttribute(storageAttribute);
|
|
1096
|
-
break;
|
|
1097
|
-
case DOUBLE_TYPE:
|
|
1098
|
-
this._setupDoubleAttribute(storageAttribute);
|
|
1099
|
-
break;
|
|
1100
|
-
case SHORT_INT_TYPE:
|
|
1101
|
-
break;
|
|
1102
|
-
default:
|
|
1103
|
-
this._setupStringAttribute(storageAttribute);
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
return storageAttribute;
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
/**
|
|
1110
|
-
* Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
1111
|
-
* @param key - attribute's key
|
|
1112
|
-
* @param attribute - attribute's type in propertyTable
|
|
1113
|
-
*/
|
|
1114
|
-
private getAttributeType(key: string, attribute: string): string {
|
|
1115
|
-
if (key === OBJECT_ID_TYPE) {
|
|
1116
|
-
return OBJECT_ID_TYPE;
|
|
1117
|
-
}
|
|
1118
|
-
if (typeof attribute === STRING_TYPE) {
|
|
1119
|
-
return STRING_TYPE;
|
|
1120
|
-
} else if (typeof attribute === 'number') {
|
|
1121
|
-
return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
|
|
1122
|
-
}
|
|
1123
|
-
return STRING_TYPE;
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
/**
|
|
1127
|
-
* Setup storage attribute as string.
|
|
1128
|
-
* @param storageAttribute - attribute for map segmentation.
|
|
1129
|
-
*/
|
|
1130
|
-
private _setupStringAttribute(storageAttribute: AttributeStorageInfo): void {
|
|
1131
|
-
storageAttribute.ordering!.unshift('attributeByteCounts');
|
|
1132
|
-
storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});
|
|
1133
|
-
storageAttribute.attributeValues = {
|
|
1134
|
-
valueType: 'String',
|
|
1135
|
-
encoding: 'UTF-8',
|
|
1136
|
-
valuesPerElement: 1
|
|
1137
|
-
};
|
|
1138
|
-
storageAttribute.attributeByteCounts = {
|
|
1139
|
-
valueType: 'UInt32',
|
|
1140
|
-
valuesPerElement: 1
|
|
1141
|
-
};
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
/**
|
|
1145
|
-
* Setup Id attribute for map segmentation.
|
|
1146
|
-
* @param storageAttribute - attribute for map segmentation .
|
|
1147
|
-
*/
|
|
1148
|
-
private _setupIdAttribute(storageAttribute: AttributeStorageInfo): void {
|
|
1149
|
-
storageAttribute.attributeValues = {
|
|
1150
|
-
valueType: 'Oid32',
|
|
1151
|
-
valuesPerElement: 1
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
/**
|
|
1156
|
-
* Setup double attribute for map segmentation.
|
|
1157
|
-
* @param storageAttribute - attribute for map segmentation .
|
|
1158
|
-
*/
|
|
1159
|
-
private _setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {
|
|
1160
|
-
storageAttribute.attributeValues = {
|
|
1161
|
-
valueType: 'Float64',
|
|
1162
|
-
valuesPerElement: 1
|
|
1163
|
-
};
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
/**
|
|
1167
|
-
* Setup field attribute for map segmentation.
|
|
1168
|
-
* @param key - attribute for map segmentation.
|
|
1169
|
-
* @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
|
|
1170
|
-
*/
|
|
1171
|
-
private _createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {
|
|
1172
|
-
return {
|
|
1173
|
-
name: key,
|
|
1174
|
-
type: fieldAttributeType,
|
|
1175
|
-
alias: key
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
1150
|
/**
|
|
1180
1151
|
* Do conversion of 3DTiles property table to I3s node attributes.
|
|
1181
1152
|
* @param propertyTable - Table with layer meta data.
|
|
@@ -1189,12 +1160,12 @@ export default class I3SConverter {
|
|
|
1189
1160
|
|
|
1190
1161
|
for (const key in propertyTableWithObjectId) {
|
|
1191
1162
|
const firstAttribute = propertyTableWithObjectId[key][0];
|
|
1192
|
-
const attributeType =
|
|
1163
|
+
const attributeType = getAttributeType(key, firstAttribute);
|
|
1193
1164
|
|
|
1194
|
-
const storageAttribute =
|
|
1195
|
-
const fieldAttributeType =
|
|
1196
|
-
const fieldAttribute =
|
|
1197
|
-
const popupInfo =
|
|
1165
|
+
const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);
|
|
1166
|
+
const fieldAttributeType = getFieldAttributeType(attributeType);
|
|
1167
|
+
const fieldAttribute = createFieldAttribute(key, fieldAttributeType);
|
|
1168
|
+
const popupInfo = createPopupInfo(propertyTableWithObjectId);
|
|
1198
1169
|
|
|
1199
1170
|
this.layers0!.attributeStorageInfo!.push(storageAttribute);
|
|
1200
1171
|
this.layers0!.fields!.push(fieldAttribute);
|
|
@@ -1205,62 +1176,6 @@ export default class I3SConverter {
|
|
|
1205
1176
|
}
|
|
1206
1177
|
}
|
|
1207
1178
|
|
|
1208
|
-
/**
|
|
1209
|
-
* Find and return attribute type based on key form propertyTable.
|
|
1210
|
-
* @param attributeType
|
|
1211
|
-
*/
|
|
1212
|
-
private _getFieldAttributeType(attributeType: Attribute): ESRIField {
|
|
1213
|
-
switch (attributeType) {
|
|
1214
|
-
case OBJECT_ID_TYPE:
|
|
1215
|
-
return 'esriFieldTypeOID';
|
|
1216
|
-
case STRING_TYPE:
|
|
1217
|
-
return 'esriFieldTypeString';
|
|
1218
|
-
case SHORT_INT_TYPE:
|
|
1219
|
-
return 'esriFieldTypeInteger';
|
|
1220
|
-
case DOUBLE_TYPE:
|
|
1221
|
-
return 'esriFieldTypeDouble';
|
|
1222
|
-
default:
|
|
1223
|
-
return 'esriFieldTypeString';
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
/**
|
|
1228
|
-
* Generate popup info to show metadata on the map.
|
|
1229
|
-
* @param propertyTable - table data with OBJECTID.
|
|
1230
|
-
* @return data for correct rendering of popup.
|
|
1231
|
-
*/
|
|
1232
|
-
private _createPopupInfo(propertyTable: FeatureTableJson): PopupInfo {
|
|
1233
|
-
const title = '{OBJECTID}';
|
|
1234
|
-
const mediaInfos = [];
|
|
1235
|
-
const fieldInfos: FieldInfo[] = [];
|
|
1236
|
-
const popupElements: {
|
|
1237
|
-
fieldInfos: FieldInfo[];
|
|
1238
|
-
type: string;
|
|
1239
|
-
}[] = [];
|
|
1240
|
-
const expressionInfos = [];
|
|
1241
|
-
|
|
1242
|
-
for (const key in propertyTable) {
|
|
1243
|
-
fieldInfos.push({
|
|
1244
|
-
fieldName: key,
|
|
1245
|
-
visible: true,
|
|
1246
|
-
isEditable: false,
|
|
1247
|
-
label: key
|
|
1248
|
-
});
|
|
1249
|
-
}
|
|
1250
|
-
popupElements.push({
|
|
1251
|
-
fieldInfos,
|
|
1252
|
-
type: 'fields'
|
|
1253
|
-
});
|
|
1254
|
-
|
|
1255
|
-
return {
|
|
1256
|
-
title,
|
|
1257
|
-
mediaInfos,
|
|
1258
|
-
popupElements,
|
|
1259
|
-
fieldInfos,
|
|
1260
|
-
expressionInfos
|
|
1261
|
-
};
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
1179
|
/**
|
|
1265
1180
|
* Print statistics in the end of conversion
|
|
1266
1181
|
* @param params - output files data
|
|
@@ -8,6 +8,10 @@ import {ImageDataType} from '@loaders.gl/images';
|
|
|
8
8
|
|
|
9
9
|
/** Converted resources for specific node */
|
|
10
10
|
export type I3SConvertedResources = {
|
|
11
|
+
/**
|
|
12
|
+
* Node id
|
|
13
|
+
*/
|
|
14
|
+
nodeId?: number;
|
|
11
15
|
/** Non-compressed geometry buffer that have structure met
|
|
12
16
|
* https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md
|
|
13
17
|
* (Geometry buffer)
|