@loaders.gl/tile-converter 4.0.0-beta.8 → 4.0.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.
Files changed (39) hide show
  1. package/dist/converter.min.cjs +109 -109
  2. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +74 -0
  3. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +1 -0
  4. package/dist/i3s-converter/helpers/attribute-metadata-info.js +157 -0
  5. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +1 -0
  6. package/dist/i3s-converter/helpers/feature-attributes.d.ts +3 -28
  7. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  8. package/dist/i3s-converter/helpers/feature-attributes.js +16 -125
  9. package/dist/i3s-converter/helpers/feature-attributes.js.map +1 -1
  10. package/dist/i3s-converter/i3s-converter.d.ts +11 -5
  11. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  12. package/dist/i3s-converter/i3s-converter.js +31 -44
  13. package/dist/i3s-converter/i3s-converter.js.map +1 -1
  14. package/dist/i3s-converter/types.d.ts +15 -0
  15. package/dist/i3s-converter/types.d.ts.map +1 -1
  16. package/dist/i3s-converter/types.js +6 -0
  17. package/dist/i3s-converter/types.js.map +1 -1
  18. package/dist/i3s-server/app.d.ts.map +1 -1
  19. package/dist/i3s-server/app.js +3 -6
  20. package/dist/i3s-server/app.js.map +1 -1
  21. package/dist/i3s-server/bin/i3s-server.min.cjs +86 -86
  22. package/dist/i3s-server/bin/www.js.map +1 -1
  23. package/dist/i3s-server/routes/index.d.ts +1 -1
  24. package/dist/i3s-server/routes/index.d.ts.map +1 -1
  25. package/dist/i3s-server/routes/index.js +2 -5
  26. package/dist/i3s-server/routes/index.js.map +1 -1
  27. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  28. package/dist/i3s-server/routes/slpk-router.js +3 -3
  29. package/dist/i3s-server/routes/slpk-router.js.map +1 -1
  30. package/dist/index.cjs +269 -173
  31. package/package.json +15 -15
  32. package/src/i3s-converter/helpers/attribute-metadata-info.ts +246 -0
  33. package/src/i3s-converter/helpers/feature-attributes.ts +18 -180
  34. package/src/i3s-converter/i3s-converter.ts +46 -65
  35. package/src/i3s-converter/types.ts +16 -0
  36. package/src/i3s-server/app.ts +9 -4
  37. package/src/i3s-server/bin/www.ts +6 -0
  38. package/src/i3s-server/routes/index.ts +2 -4
  39. package/src/i3s-server/routes/slpk-router.ts +4 -3
@@ -0,0 +1,74 @@
1
+ import type { Attribute, AttributeStorageInfo, Field, PopupInfo } from '@loaders.gl/i3s';
2
+ export declare class AttributeMetadataInfo {
3
+ private _attributeStorageInfo;
4
+ private _fields;
5
+ private _popupInfo;
6
+ constructor();
7
+ get attributeStorageInfo(): AttributeStorageInfo[];
8
+ get fields(): Field[];
9
+ get popupInfo(): PopupInfo | undefined;
10
+ /**
11
+ * Creates and stores Attribute Storage Info, Fields and PopupInfo objects based on attribute's types.
12
+ * Appends objects that have not been stored yet.
13
+ * @param attributeTypesMap - set of attribute's types
14
+ * @example AttributeStorageInfo, Fields and PopupInfo already contain objects for the following attributes:
15
+ * {
16
+ * color: 'string',
17
+ * name: 'string',
18
+ * opt_uint8: 'Int32'
19
+ * }
20
+ * Then, we call the addMetadataInfo method with the following attributeTypesMap:
21
+ * {
22
+ * // The same attributes
23
+ * color: 'string',
24
+ * name: 'string',
25
+ * opt_uint8: 'Int32',
26
+ * // New attributes
27
+ * opt_uint64: 'string',
28
+ * opt_float32: 'double',
29
+ * }
30
+ * The method creates and stores objects for opt_uint64, opt_float32 attributes.
31
+ */
32
+ addMetadataInfo(attributeTypesMap: Record<string, Attribute>): void;
33
+ /**
34
+ * Generates storage attribute for map segmentation.
35
+ * @param attributeIndex - order index of attribute (f_0, f_1 ...).
36
+ * @param key - attribute key from propertyTable.
37
+ * @param attributeType - attribute type.
38
+ * @return Updated storageAttribute.
39
+ */
40
+ private createStorageAttribute;
41
+ /**
42
+ * Finds and returns attribute type based on key form propertyTable.
43
+ * @param attributeType
44
+ */
45
+ private getFieldAttributeType;
46
+ /**
47
+ * Sets up Id attribute for map segmentation.
48
+ * @param storageAttribute - attribute for map segmentation .
49
+ */
50
+ private setupIdAttribute;
51
+ /**
52
+ * Sets up storage attribute as string.
53
+ * @param storageAttribute - attribute for map segmentation.
54
+ */
55
+ private setupStringAttribute;
56
+ /**
57
+ * Sets up double attribute for map segmentation.
58
+ * @param storageAttribute - attribute for map segmentation .
59
+ */
60
+ private setupDoubleAttribute;
61
+ /**
62
+ * Sets up field attribute for map segmentation.
63
+ * @param key - attribute for map segmentation.
64
+ * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
65
+ */
66
+ private createFieldAttribute;
67
+ /**
68
+ * Generates popup info to show metadata on the map.
69
+ * @param propertyNames - array of property names including OBJECTID.
70
+ * @return data for correct rendering of popup.
71
+ */
72
+ private createPopupInfo;
73
+ }
74
+ //# sourceMappingURL=attribute-metadata-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-metadata-info.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/attribute-metadata-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EAEpB,KAAK,EAEL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAIzB,qBAAa,qBAAqB;IAChC,OAAO,CAAC,qBAAqB,CAAyB;IACtD,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAwB;;IAO1C,IAAI,oBAAoB,IAAI,oBAAoB,EAAE,CAEjD;IAED,IAAI,MAAM,IAAI,KAAK,EAAE,CAEpB;IAED,IAAI,SAAS,IAAI,SAAS,GAAG,SAAS,CAErC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,eAAe,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IA0CnE;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAgC9B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAe7B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAO5B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;;;OAIG;IACH,OAAO,CAAC,eAAe;CA+BxB"}
@@ -0,0 +1,157 @@
1
+ import { AttributeType } from "../types.js";
2
+ export class AttributeMetadataInfo {
3
+ constructor() {
4
+ this._attributeStorageInfo = void 0;
5
+ this._fields = void 0;
6
+ this._popupInfo = void 0;
7
+ this._attributeStorageInfo = [];
8
+ this._fields = [];
9
+ }
10
+ get attributeStorageInfo() {
11
+ return this._attributeStorageInfo;
12
+ }
13
+ get fields() {
14
+ return this._fields;
15
+ }
16
+ get popupInfo() {
17
+ return this._popupInfo;
18
+ }
19
+ addMetadataInfo(attributeTypesMap) {
20
+ if (!Object.keys(attributeTypesMap).length) {
21
+ return;
22
+ }
23
+ const attributeTypes = {
24
+ OBJECTID: AttributeType.OBJECT_ID_TYPE,
25
+ ...attributeTypesMap
26
+ };
27
+ let isUpdated = false;
28
+ let attributeIndex = this._attributeStorageInfo.length;
29
+ for (const key in attributeTypes) {
30
+ const elementFound = this._attributeStorageInfo.find(element => element.name === key);
31
+ if (!elementFound) {
32
+ const attributeType = attributeTypes[key];
33
+ const storageAttribute = this.createStorageAttribute(attributeIndex, key, attributeType);
34
+ const fieldAttributeType = this.getFieldAttributeType(attributeType);
35
+ const fieldAttribute = this.createFieldAttribute(key, fieldAttributeType);
36
+ this._attributeStorageInfo.push(storageAttribute);
37
+ this._fields.push(fieldAttribute);
38
+ attributeIndex += 1;
39
+ isUpdated = true;
40
+ }
41
+ }
42
+ if (isUpdated) {
43
+ const attributeNames = [];
44
+ for (let info of this._attributeStorageInfo) {
45
+ attributeNames.push(info.name);
46
+ }
47
+ this._popupInfo = this.createPopupInfo(attributeNames);
48
+ }
49
+ }
50
+ createStorageAttribute(attributeIndex, key, attributeType) {
51
+ const storageAttribute = {
52
+ key: `f_${attributeIndex}`,
53
+ name: key,
54
+ ordering: ['attributeValues'],
55
+ header: [{
56
+ property: 'count',
57
+ valueType: 'UInt32'
58
+ }],
59
+ attributeValues: {
60
+ valueType: 'Int32',
61
+ valuesPerElement: 1
62
+ }
63
+ };
64
+ switch (attributeType) {
65
+ case AttributeType.OBJECT_ID_TYPE:
66
+ this.setupIdAttribute(storageAttribute);
67
+ break;
68
+ case AttributeType.STRING_TYPE:
69
+ this.setupStringAttribute(storageAttribute);
70
+ break;
71
+ case AttributeType.DOUBLE_TYPE:
72
+ this.setupDoubleAttribute(storageAttribute);
73
+ break;
74
+ case AttributeType.SHORT_INT_TYPE:
75
+ break;
76
+ default:
77
+ this.setupStringAttribute(storageAttribute);
78
+ }
79
+ return storageAttribute;
80
+ }
81
+ getFieldAttributeType(attributeType) {
82
+ switch (attributeType) {
83
+ case AttributeType.OBJECT_ID_TYPE:
84
+ return 'esriFieldTypeOID';
85
+ case AttributeType.STRING_TYPE:
86
+ return 'esriFieldTypeString';
87
+ case AttributeType.SHORT_INT_TYPE:
88
+ return 'esriFieldTypeInteger';
89
+ case AttributeType.DOUBLE_TYPE:
90
+ return 'esriFieldTypeDouble';
91
+ default:
92
+ return 'esriFieldTypeString';
93
+ }
94
+ }
95
+ setupIdAttribute(storageAttribute) {
96
+ storageAttribute.attributeValues = {
97
+ valueType: 'Oid32',
98
+ valuesPerElement: 1
99
+ };
100
+ }
101
+ setupStringAttribute(storageAttribute) {
102
+ storageAttribute.ordering.unshift('attributeByteCounts');
103
+ storageAttribute.header.push({
104
+ property: 'attributeValuesByteCount',
105
+ valueType: 'UInt32'
106
+ });
107
+ storageAttribute.attributeValues = {
108
+ valueType: 'String',
109
+ encoding: 'UTF-8',
110
+ valuesPerElement: 1
111
+ };
112
+ storageAttribute.attributeByteCounts = {
113
+ valueType: 'UInt32',
114
+ valuesPerElement: 1
115
+ };
116
+ }
117
+ setupDoubleAttribute(storageAttribute) {
118
+ storageAttribute.attributeValues = {
119
+ valueType: 'Float64',
120
+ valuesPerElement: 1
121
+ };
122
+ }
123
+ createFieldAttribute(key, fieldAttributeType) {
124
+ return {
125
+ name: key,
126
+ type: fieldAttributeType,
127
+ alias: key
128
+ };
129
+ }
130
+ createPopupInfo(propertyNames) {
131
+ const title = '{OBJECTID}';
132
+ const mediaInfos = [];
133
+ const fieldInfos = [];
134
+ const popupElements = [];
135
+ const expressionInfos = [];
136
+ for (const propertyName of propertyNames) {
137
+ fieldInfos.push({
138
+ fieldName: propertyName,
139
+ visible: true,
140
+ isEditable: false,
141
+ label: propertyName
142
+ });
143
+ }
144
+ popupElements.push({
145
+ fieldInfos,
146
+ type: 'fields'
147
+ });
148
+ return {
149
+ title,
150
+ mediaInfos,
151
+ popupElements,
152
+ fieldInfos,
153
+ expressionInfos
154
+ };
155
+ }
156
+ }
157
+ //# sourceMappingURL=attribute-metadata-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-metadata-info.js","names":["AttributeType","AttributeMetadataInfo","constructor","_attributeStorageInfo","_fields","_popupInfo","attributeStorageInfo","fields","popupInfo","addMetadataInfo","attributeTypesMap","Object","keys","length","attributeTypes","OBJECTID","OBJECT_ID_TYPE","isUpdated","attributeIndex","key","elementFound","find","element","name","attributeType","storageAttribute","createStorageAttribute","fieldAttributeType","getFieldAttributeType","fieldAttribute","createFieldAttribute","push","attributeNames","info","createPopupInfo","ordering","header","property","valueType","attributeValues","valuesPerElement","setupIdAttribute","STRING_TYPE","setupStringAttribute","DOUBLE_TYPE","setupDoubleAttribute","SHORT_INT_TYPE","unshift","encoding","attributeByteCounts","type","alias","propertyNames","title","mediaInfos","fieldInfos","popupElements","expressionInfos","propertyName","fieldName","visible","isEditable","label"],"sources":["../../../src/i3s-converter/helpers/attribute-metadata-info.ts"],"sourcesContent":["import type {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\n\nimport {AttributeType} from '../types';\n\nexport class AttributeMetadataInfo {\n private _attributeStorageInfo: AttributeStorageInfo[];\n private _fields: Field[];\n private _popupInfo: PopupInfo | undefined;\n\n constructor() {\n this._attributeStorageInfo = [];\n this._fields = [];\n }\n\n get attributeStorageInfo(): AttributeStorageInfo[] {\n return this._attributeStorageInfo;\n }\n\n get fields(): Field[] {\n return this._fields;\n }\n\n get popupInfo(): PopupInfo | undefined {\n return this._popupInfo;\n }\n\n /**\n * Creates and stores Attribute Storage Info, Fields and PopupInfo objects based on attribute's types.\n * Appends objects that have not been stored yet.\n * @param attributeTypesMap - set of attribute's types\n * @example AttributeStorageInfo, Fields and PopupInfo already contain objects for the following attributes:\n * {\n * color: 'string',\n * name: 'string',\n * opt_uint8: 'Int32'\n * }\n * Then, we call the addMetadataInfo method with the following attributeTypesMap:\n * {\n * // The same attributes\n * color: 'string',\n * name: 'string',\n * opt_uint8: 'Int32',\n * // New attributes\n * opt_uint64: 'string',\n * opt_float32: 'double',\n * }\n * The method creates and stores objects for opt_uint64, opt_float32 attributes.\n */\n addMetadataInfo(attributeTypesMap: Record<string, Attribute>): void {\n if (!Object.keys(attributeTypesMap).length) {\n return;\n }\n const attributeTypes: Record<string, Attribute> = {\n OBJECTID: AttributeType.OBJECT_ID_TYPE,\n ...attributeTypesMap\n };\n\n let isUpdated = false;\n let attributeIndex = this._attributeStorageInfo.length;\n for (const key in attributeTypes) {\n /*\n We will append a new attribute only in case it has not been added to the attribute storage info yet.\n */\n const elementFound = this._attributeStorageInfo.find((element) => element.name === key);\n if (!elementFound) {\n const attributeType = attributeTypes[key];\n\n const storageAttribute = this.createStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = this.getFieldAttributeType(attributeType);\n const fieldAttribute = this.createFieldAttribute(key, fieldAttributeType);\n\n this._attributeStorageInfo.push(storageAttribute);\n this._fields.push(fieldAttribute);\n attributeIndex += 1;\n isUpdated = true;\n }\n }\n if (isUpdated) {\n /*\n The attributeStorageInfo is updated. So, popupInfo should be recreated.\n Use attributeStorageInfo as a source of attribute names to create the popupInfo.\n */\n const attributeNames: string[] = [];\n for (let info of this._attributeStorageInfo) {\n attributeNames.push(info.name);\n }\n this._popupInfo = this.createPopupInfo(attributeNames);\n }\n }\n\n /**\n * Generates storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\n private createStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n ): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case AttributeType.OBJECT_ID_TYPE:\n this.setupIdAttribute(storageAttribute);\n break;\n case AttributeType.STRING_TYPE:\n this.setupStringAttribute(storageAttribute);\n break;\n case AttributeType.DOUBLE_TYPE:\n this.setupDoubleAttribute(storageAttribute);\n break;\n case AttributeType.SHORT_INT_TYPE:\n break;\n default:\n this.setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n }\n\n /**\n * Finds and returns attribute type based on key form propertyTable.\n * @param attributeType\n */\n private getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case AttributeType.OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case AttributeType.STRING_TYPE:\n return 'esriFieldTypeString';\n case AttributeType.SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case AttributeType.DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n }\n\n /**\n * Sets up Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\n private setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n // @ts-expect-error\n storageAttribute.ordering.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\n private createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n }\n\n /**\n * Generates popup info to show metadata on the map.\n * @param propertyNames - array of property names including OBJECTID.\n * @return data for correct rendering of popup.\n */\n private createPopupInfo(propertyNames: string[]): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const propertyName of propertyNames) {\n fieldInfos.push({\n fieldName: propertyName,\n visible: true,\n isEditable: false,\n label: propertyName\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n }\n}\n"],"mappings":"SASQA,aAAa;AAErB,OAAO,MAAMC,qBAAqB,CAAC;EAKjCC,WAAWA,CAAA,EAAG;IAAA,KAJNC,qBAAqB;IAAA,KACrBC,OAAO;IAAA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,eAAe,GAAG,EAAE;IAE1B,KAAK,MAAMC,YAAY,IAAIN,aAAa,EAAE;MACxCG,UAAU,CAACxB,IAAI,CAAC;QACd4B,SAAS,EAAED,YAAY;QACvBE,OAAO,EAAE,IAAI;QACbC,UAAU,EAAE,KAAK;QACjBC,KAAK,EAAEJ;MACT,CAAC,CAAC;IACJ;IACAF,aAAa,CAACzB,IAAI,CAAC;MACjBwB,UAAU;MACVL,IAAI,EAAE;IACR,CAAC,CAAC;IAEF,OAAO;MACLG,KAAK;MACLC,UAAU;MACVE,aAAa;MACbD,UAAU;MACVE;IACF,CAAC;EACH;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { FeatureTableJson } from '@loaders.gl/3d-tiles';
2
- import type { Attribute, AttributeStorageInfo, ESRIField, Field, PopupInfo } from '@loaders.gl/i3s';
2
+ import type { Attribute } from '@loaders.gl/i3s';
3
3
  import type { GLTFPostprocessed } from '@loaders.gl/gltf';
4
4
  /**
5
5
  * Takes attributes from property table based on featureIdsMap.
@@ -28,31 +28,6 @@ export declare function checkPropertiesLength(featureIds: number[], propertyTabl
28
28
  * @param attribute - attribute taken from propertyTable
29
29
  */
30
30
  export declare function getAttributeType(attribute: unknown): string;
31
- /**
32
- * Generate storage attribute for map segmentation.
33
- * @param attributeIndex - order index of attribute (f_0, f_1 ...).
34
- * @param key - attribute key from propertyTable.
35
- * @param attributeType - attribute type.
36
- * @return Updated storageAttribute.
37
- */
38
- export declare function createdStorageAttribute(attributeIndex: number, key: string, attributeType: Attribute): AttributeStorageInfo;
39
- /**
40
- * Find and return attribute type based on key form propertyTable.
41
- * @param attributeType
42
- */
43
- export declare function getFieldAttributeType(attributeType: Attribute): ESRIField;
44
- /**
45
- * Setup field attribute for map segmentation.
46
- * @param key - attribute for map segmentation.
47
- * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
48
- */
49
- export declare function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field;
50
- /**
51
- * Generate popup info to show metadata on the map.
52
- * @param propertyNames - array of property names including OBJECTID.
53
- * @return data for correct rendering of popup.
54
- */
55
- export declare function createPopupInfo(propertyNames: string[]): PopupInfo;
56
31
  /**
57
32
  * Gets attribute's types based on the property table records.
58
33
  * @param propertyTable - Table with layer meta data.
@@ -63,7 +38,7 @@ export declare function createPopupInfo(propertyNames: string[]): PopupInfo;
63
38
  * "opt_uint64": "string"
64
39
  * }
65
40
  */
66
- export declare function getAttributeTypesFromPropertyTable(propertyTable: FeatureTableJson): Record<string, Attribute>;
41
+ export declare function getAttributeTypesMapFromPropertyTable(propertyTable: FeatureTableJson): Record<string, Attribute>;
67
42
  /**
68
43
  * Gets attribute's types from the extension schema selected by the class name 'metadataClass'.
69
44
  * @param gltfJson - JSON part of GLB content
@@ -75,5 +50,5 @@ export declare function getAttributeTypesFromPropertyTable(propertyTable: Featur
75
50
  * "opt_uint64": "string"
76
51
  * }
77
52
  */
78
- export declare const getAttributeTypesFromSchema: (gltfJson: GLTFPostprocessed, metadataClass: string) => Record<string, Attribute> | null;
53
+ export declare const getAttributeTypesMapFromSchema: (gltfJson: GLTFPostprocessed, metadataClass: string) => Record<string, Attribute> | null;
79
54
  //# sourceMappingURL=feature-attributes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/feature-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,KAAK,EAEL,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAI1B;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,aAAa,EAAE,gBAAgB,GAC9B,gBAAgB,CAQlB;AAuBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAAE,EACpB,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAUT;AAUD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAO3D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,SAAS,GACvB,oBAAoB,CA0BtB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,SAAS,GAAG,SAAS,CAazE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,kBAAkB,EAAE,SAAS,GAAG,KAAK,CAMtF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,SAAS,CA8BlE;AA2CD;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,aAAa,EAAE,gBAAgB,GAC9B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAS3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,aAC5B,iBAAiB,iBACZ,MAAM,KACpB,OAAO,MAAM,EAAE,SAAS,CAAC,GAAG,IA2B9B,CAAC"}
1
+ {"version":3,"file":"feature-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/feature-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EACV,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAM1B;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,aAAa,EAAE,gBAAgB,GAC9B,gBAAgB,CAQlB;AAuBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAAE,EACpB,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAUT;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAO3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,qCAAqC,CACnD,aAAa,EAAE,gBAAgB,GAC9B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAS3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,aAC/B,iBAAiB,iBACZ,MAAM,KACpB,OAAO,MAAM,EAAE,SAAS,CAAC,GAAG,IA2B9B,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { AttributeType } from "../types.js";
1
2
  import { EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA } from '@loaders.gl/gltf';
2
3
  export function flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable) {
3
4
  const resultPropertyTable = {};
@@ -26,125 +27,15 @@ export function checkPropertiesLength(featureIds, propertyTable) {
26
27
  }
27
28
  return needFlatten;
28
29
  }
29
- const STRING_TYPE = 'string';
30
- const SHORT_INT_TYPE = 'Int32';
31
- const DOUBLE_TYPE = 'double';
32
- const OBJECT_ID_TYPE = 'OBJECTID';
33
30
  export function getAttributeType(attribute) {
34
- if (typeof attribute === STRING_TYPE || typeof attribute === 'bigint') {
35
- return STRING_TYPE;
31
+ if (typeof attribute === 'string' || typeof attribute === 'bigint') {
32
+ return AttributeType.STRING_TYPE;
36
33
  } else if (typeof attribute === 'number') {
37
- return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
34
+ return Number.isInteger(attribute) ? AttributeType.SHORT_INT_TYPE : AttributeType.DOUBLE_TYPE;
38
35
  }
39
- return STRING_TYPE;
36
+ return AttributeType.STRING_TYPE;
40
37
  }
41
- export function createdStorageAttribute(attributeIndex, key, attributeType) {
42
- const storageAttribute = {
43
- key: `f_${attributeIndex}`,
44
- name: key,
45
- ordering: ['attributeValues'],
46
- header: [{
47
- property: 'count',
48
- valueType: 'UInt32'
49
- }],
50
- attributeValues: {
51
- valueType: 'Int32',
52
- valuesPerElement: 1
53
- }
54
- };
55
- switch (attributeType) {
56
- case OBJECT_ID_TYPE:
57
- setupIdAttribute(storageAttribute);
58
- break;
59
- case STRING_TYPE:
60
- setupStringAttribute(storageAttribute);
61
- break;
62
- case DOUBLE_TYPE:
63
- setupDoubleAttribute(storageAttribute);
64
- break;
65
- case SHORT_INT_TYPE:
66
- break;
67
- default:
68
- setupStringAttribute(storageAttribute);
69
- }
70
- return storageAttribute;
71
- }
72
- export function getFieldAttributeType(attributeType) {
73
- switch (attributeType) {
74
- case OBJECT_ID_TYPE:
75
- return 'esriFieldTypeOID';
76
- case STRING_TYPE:
77
- return 'esriFieldTypeString';
78
- case SHORT_INT_TYPE:
79
- return 'esriFieldTypeInteger';
80
- case DOUBLE_TYPE:
81
- return 'esriFieldTypeDouble';
82
- default:
83
- return 'esriFieldTypeString';
84
- }
85
- }
86
- export function createFieldAttribute(key, fieldAttributeType) {
87
- return {
88
- name: key,
89
- type: fieldAttributeType,
90
- alias: key
91
- };
92
- }
93
- export function createPopupInfo(propertyNames) {
94
- const title = '{OBJECTID}';
95
- const mediaInfos = [];
96
- const fieldInfos = [];
97
- const popupElements = [];
98
- const expressionInfos = [];
99
- for (const propertyName of propertyNames) {
100
- fieldInfos.push({
101
- fieldName: propertyName,
102
- visible: true,
103
- isEditable: false,
104
- label: propertyName
105
- });
106
- }
107
- popupElements.push({
108
- fieldInfos,
109
- type: 'fields'
110
- });
111
- return {
112
- title,
113
- mediaInfos,
114
- popupElements,
115
- fieldInfos,
116
- expressionInfos
117
- };
118
- }
119
- function setupStringAttribute(storageAttribute) {
120
- storageAttribute.ordering.unshift('attributeByteCounts');
121
- storageAttribute.header.push({
122
- property: 'attributeValuesByteCount',
123
- valueType: 'UInt32'
124
- });
125
- storageAttribute.attributeValues = {
126
- valueType: 'String',
127
- encoding: 'UTF-8',
128
- valuesPerElement: 1
129
- };
130
- storageAttribute.attributeByteCounts = {
131
- valueType: 'UInt32',
132
- valuesPerElement: 1
133
- };
134
- }
135
- function setupIdAttribute(storageAttribute) {
136
- storageAttribute.attributeValues = {
137
- valueType: 'Oid32',
138
- valuesPerElement: 1
139
- };
140
- }
141
- function setupDoubleAttribute(storageAttribute) {
142
- storageAttribute.attributeValues = {
143
- valueType: 'Float64',
144
- valuesPerElement: 1
145
- };
146
- }
147
- export function getAttributeTypesFromPropertyTable(propertyTable) {
38
+ export function getAttributeTypesMapFromPropertyTable(propertyTable) {
148
39
  const attributeTypesMap = {};
149
40
  for (const key in propertyTable) {
150
41
  const firstAttribute = propertyTable[key][0];
@@ -153,7 +44,7 @@ export function getAttributeTypesFromPropertyTable(propertyTable) {
153
44
  }
154
45
  return attributeTypesMap;
155
46
  }
156
- export const getAttributeTypesFromSchema = (gltfJson, metadataClass) => {
47
+ export const getAttributeTypesMapFromSchema = (gltfJson, metadataClass) => {
157
48
  var _gltfJson$extensions, _gltfJson$extensions$, _gltfJson$extensions$2, _gltfJson$extensions$3, _gltfJson$extensions2, _gltfJson$extensions3, _gltfJson$extensions4, _gltfJson$extensions5;
158
49
  const attributeTypesMap = {};
159
50
  const extFeatureMetadataSchemaClass = (_gltfJson$extensions = gltfJson.extensions) === null || _gltfJson$extensions === void 0 ? void 0 : (_gltfJson$extensions$ = _gltfJson$extensions[EXT_FEATURE_METADATA]) === null || _gltfJson$extensions$ === void 0 ? void 0 : (_gltfJson$extensions$2 = _gltfJson$extensions$.schema) === null || _gltfJson$extensions$2 === void 0 ? void 0 : (_gltfJson$extensions$3 = _gltfJson$extensions$2.classes) === null || _gltfJson$extensions$3 === void 0 ? void 0 : _gltfJson$extensions$3[metadataClass];
@@ -185,11 +76,11 @@ const getAttributeTypeFromExtFeatureMetadata = property => {
185
76
  case 'UINT16':
186
77
  case 'INT32':
187
78
  case 'UINT32':
188
- attributeType = SHORT_INT_TYPE;
79
+ attributeType = AttributeType.SHORT_INT_TYPE;
189
80
  break;
190
81
  case 'FLOAT32':
191
82
  case 'FLOAT64':
192
- attributeType = DOUBLE_TYPE;
83
+ attributeType = AttributeType.DOUBLE_TYPE;
193
84
  break;
194
85
  case 'INT64':
195
86
  case 'UINT64':
@@ -197,10 +88,10 @@ const getAttributeTypeFromExtFeatureMetadata = property => {
197
88
  case 'ENUM':
198
89
  case 'STRING':
199
90
  case 'ARRAY':
200
- attributeType = STRING_TYPE;
91
+ attributeType = AttributeType.STRING_TYPE;
201
92
  break;
202
93
  default:
203
- attributeType = STRING_TYPE;
94
+ attributeType = AttributeType.STRING_TYPE;
204
95
  break;
205
96
  }
206
97
  return attributeType;
@@ -208,7 +99,7 @@ const getAttributeTypeFromExtFeatureMetadata = property => {
208
99
  const getAttributeTypeFromExtStructuralMetadata = property => {
209
100
  let attributeType;
210
101
  if (property.array) {
211
- attributeType = STRING_TYPE;
102
+ attributeType = AttributeType.STRING_TYPE;
212
103
  } else {
213
104
  switch (property.componentType) {
214
105
  case 'INT8':
@@ -217,18 +108,18 @@ const getAttributeTypeFromExtStructuralMetadata = property => {
217
108
  case 'UINT16':
218
109
  case 'INT32':
219
110
  case 'UINT32':
220
- attributeType = SHORT_INT_TYPE;
111
+ attributeType = AttributeType.SHORT_INT_TYPE;
221
112
  break;
222
113
  case 'FLOAT32':
223
114
  case 'FLOAT64':
224
- attributeType = DOUBLE_TYPE;
115
+ attributeType = AttributeType.DOUBLE_TYPE;
225
116
  break;
226
117
  case 'INT64':
227
118
  case 'UINT64':
228
- attributeType = STRING_TYPE;
119
+ attributeType = AttributeType.STRING_TYPE;
229
120
  break;
230
121
  default:
231
- attributeType = STRING_TYPE;
122
+ attributeType = AttributeType.STRING_TYPE;
232
123
  break;
233
124
  }
234
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"feature-attributes.js","names":["EXT_FEATURE_METADATA","EXT_STRUCTURAL_METADATA","flattenPropertyTableByFeatureIds","featureIdsMap","propertyTable","resultPropertyTable","propertyName","properties","getPropertiesByFeatureIds","resultProperties","featureIdKey","property","push","checkPropertiesLength","featureIds","needFlatten","attribute","Object","values","length","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","getAttributeType","Number","isInteger","createdStorageAttribute","attributeIndex","key","attributeType","storageAttribute","name","ordering","header","valueType","attributeValues","valuesPerElement","setupIdAttribute","setupStringAttribute","setupDoubleAttribute","getFieldAttributeType","createFieldAttribute","fieldAttributeType","type","alias","createPopupInfo","propertyNames","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","unshift","encoding","attributeByteCounts","getAttributeTypesFromPropertyTable","attributeTypesMap","firstAttribute","getAttributeTypesFromSchema","gltfJson","metadataClass","_gltfJson$extensions","_gltfJson$extensions$","_gltfJson$extensions$2","_gltfJson$extensions$3","_gltfJson$extensions2","_gltfJson$extensions3","_gltfJson$extensions4","_gltfJson$extensions5","extFeatureMetadataSchemaClass","extensions","schema","classes","attributeProperty","getAttributeTypeFromExtFeatureMetadata","extStructuralMetadataSchemaClass","getAttributeTypeFromExtStructuralMetadata","array","componentType"],"sources":["../../../src/i3s-converter/helpers/feature-attributes.ts"],"sourcesContent":["import type {FeatureTableJson} from '@loaders.gl/3d-tiles';\nimport type {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\nimport type {\n GLTFPostprocessed,\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_ClassProperty,\n GLTF_EXT_structural_metadata_GLTF,\n GLTF_EXT_structural_metadata_ClassProperty\n} from '@loaders.gl/gltf';\n\nimport {EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA} from '@loaders.gl/gltf';\n\n/**\n * Takes attributes from property table based on featureIdsMap.\n * If there is no property value for particular featureId (index) the property will be null.\n * Example:\n * Initial data:\n * OBJECTID: {0: 0, 3: 33, 4: 333}\n * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']\n * Result:\n * OBJECTID: [0, 33, 333]\n * component: ['Windows', 'Roof', 'Skylight']\n * @param featureIdsMap\n * @param propertyTable\n */\nexport function flattenPropertyTableByFeatureIds(\n featureIdsMap: Record<string, number>,\n propertyTable: FeatureTableJson\n): FeatureTableJson {\n const resultPropertyTable: FeatureTableJson = {};\n for (const propertyName in propertyTable) {\n const properties = propertyTable[propertyName];\n resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIdsMap);\n }\n\n return resultPropertyTable;\n}\n\n/**\n * Getting properties by featureId index\n * @param properties\n * @param featureIdsMap\n */\nfunction getPropertiesByFeatureIds(\n properties: unknown[],\n featureIdsMap: Record<string, number>\n): unknown[] {\n const resultProperties: unknown[] = [];\n\n if (properties) {\n for (const featureIdKey in featureIdsMap) {\n const property = properties[featureIdKey] || null;\n resultProperties.push(property);\n }\n }\n\n return resultProperties;\n}\n\n/**\n * Check that all attributes in propertyTable have the same length as FeatureIds.\n * If there are differencies between lengths we should flatten property table based on exiesting featureIds.\n * @param featureIds\n * @param propertyTable\n * @returns\n */\nexport function checkPropertiesLength(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): boolean {\n let needFlatten = false;\n\n for (const attribute of Object.values(propertyTable)) {\n if (!featureIds || !attribute || featureIds.length !== attribute.length) {\n needFlatten = true;\n }\n }\n\n return needFlatten;\n}\n\n/** String data type name for feature attributes */\nconst STRING_TYPE = 'string';\n/** Integer data type name for feature attributes */\nconst SHORT_INT_TYPE = 'Int32';\n/** Double data type name for feature attributes */\nconst DOUBLE_TYPE = 'double';\n/** Type of attribute that is linked with feature ids */\nconst OBJECT_ID_TYPE = 'OBJECTID';\n/**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param attribute - attribute taken from propertyTable\n */\nexport function getAttributeType(attribute: unknown): string {\n if (typeof attribute === STRING_TYPE || typeof attribute === 'bigint') {\n return STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;\n }\n return STRING_TYPE;\n}\n\n/**\n * Generate storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\nexport function createdStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n setupIdAttribute(storageAttribute);\n break;\n case STRING_TYPE:\n setupStringAttribute(storageAttribute);\n break;\n case DOUBLE_TYPE:\n setupDoubleAttribute(storageAttribute);\n break;\n case SHORT_INT_TYPE:\n break;\n default:\n setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n}\n\n/**\n * Find and return attribute type based on key form propertyTable.\n * @param attributeType\n */\nexport function getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case STRING_TYPE:\n return 'esriFieldTypeString';\n case SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n}\n\n/**\n * Setup field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\nexport function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n}\n\n/**\n * Generate popup info to show metadata on the map.\n * @param propertyNames - array of property names including OBJECTID.\n * @return data for correct rendering of popup.\n */\nexport function createPopupInfo(propertyNames: string[]): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const propertyName of propertyNames) {\n fieldInfos.push({\n fieldName: propertyName,\n visible: true,\n isEditable: false,\n label: propertyName\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n}\n\n/**\n * Setup storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\nfunction setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n // @ts-expect-error\n storageAttribute.ordering.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n}\n\n/**\n * Gets attribute's types based on the property table records.\n * @param propertyTable - Table with layer meta data.\n * @returns set of attribute types\n * @example of returned object:\n * {\n * \"opt_uint8\": \"Int32\",\n * \"opt_uint64\": \"string\"\n * }\n */\nexport function getAttributeTypesFromPropertyTable(\n propertyTable: FeatureTableJson\n): Record<string, Attribute> {\n const attributeTypesMap: Record<string, Attribute> = {};\n for (const key in propertyTable) {\n // Get attribute type based on the first element of each property.\n const firstAttribute = propertyTable[key][0];\n const attributeType = getAttributeType(firstAttribute);\n attributeTypesMap[key] = attributeType;\n }\n return attributeTypesMap;\n}\n\n/**\n * Gets attribute's types from the extension schema selected by the class name 'metadataClass'.\n * @param gltfJson - JSON part of GLB content\n * @param metadataClass - name of the schema class\n * @returns set of attribute's types\n * @example of returned object:\n * {\n * \"opt_uint8\": \"Int32\",\n * \"opt_uint64\": \"string\"\n * }\n */\nexport const getAttributeTypesFromSchema = (\n gltfJson: GLTFPostprocessed,\n metadataClass: string\n): Record<string, Attribute> | null => {\n const attributeTypesMap: Record<string, Attribute> = {};\n const extFeatureMetadataSchemaClass = (\n gltfJson.extensions?.[EXT_FEATURE_METADATA] as GLTF_EXT_feature_metadata_GLTF\n )?.schema?.classes?.[metadataClass];\n if (extFeatureMetadataSchemaClass) {\n for (let propertyName in extFeatureMetadataSchemaClass.properties) {\n const property = extFeatureMetadataSchemaClass.properties[propertyName];\n const attributeProperty = getAttributeTypeFromExtFeatureMetadata(property);\n attributeTypesMap[propertyName] = attributeProperty;\n }\n return attributeTypesMap;\n }\n\n const extStructuralMetadataSchemaClass = (\n gltfJson.extensions?.[EXT_STRUCTURAL_METADATA] as GLTF_EXT_structural_metadata_GLTF\n )?.schema?.classes?.[metadataClass];\n if (extStructuralMetadataSchemaClass) {\n for (let propertyName in extStructuralMetadataSchemaClass.properties) {\n const property = extStructuralMetadataSchemaClass.properties[propertyName];\n const attributeProperty = getAttributeTypeFromExtStructuralMetadata(property);\n attributeTypesMap[propertyName] = attributeProperty;\n }\n return attributeTypesMap;\n }\n\n return null;\n};\n\n/**\n * Gets the attribute type according to the Ext_feature_metadata extension class schema\n * @see https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param property - schema of the class property for Ext_feature_metadata\n * @returns attribute's type\n */\nconst getAttributeTypeFromExtFeatureMetadata = (\n property: GLTF_EXT_feature_metadata_ClassProperty\n): Attribute => {\n let attributeType: Attribute;\n switch (property.type) {\n case 'INT8':\n case 'UINT8':\n case 'INT16':\n case 'UINT16':\n case 'INT32':\n case 'UINT32':\n attributeType = SHORT_INT_TYPE;\n break;\n\n case 'FLOAT32':\n case 'FLOAT64':\n attributeType = DOUBLE_TYPE;\n break;\n\n case 'INT64':\n case 'UINT64':\n case 'BOOLEAN':\n case 'ENUM':\n case 'STRING':\n case 'ARRAY':\n attributeType = STRING_TYPE;\n break;\n\n default:\n attributeType = STRING_TYPE;\n break;\n }\n return attributeType;\n};\n\n/**\n * Gets the attribute type according to the Ext_structural_metadata extension class schema\n * @see https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param property - schema of the class property for Ext_structural_metadata\n * @returns attribute's type\n */\nconst getAttributeTypeFromExtStructuralMetadata = (\n property: GLTF_EXT_structural_metadata_ClassProperty\n): Attribute => {\n let attributeType: Attribute;\n if (property.array) {\n attributeType = STRING_TYPE;\n } else {\n switch (property.componentType) {\n case 'INT8':\n case 'UINT8':\n case 'INT16':\n case 'UINT16':\n case 'INT32':\n case 'UINT32':\n attributeType = SHORT_INT_TYPE;\n break;\n\n case 'FLOAT32':\n case 'FLOAT64':\n attributeType = DOUBLE_TYPE;\n break;\n\n case 'INT64':\n case 'UINT64':\n attributeType = STRING_TYPE;\n break;\n\n default:\n attributeType = STRING_TYPE;\n break;\n }\n }\n return attributeType;\n};\n"],"mappings":"AAiBA,SAAQA,oBAAoB,EAAEC,uBAAuB,QAAO,kBAAkB;AAe9E,OAAO,SAASC,gCAAgCA,CAC9CC,aAAqC,EACrCC,aAA+B,EACb;EAClB,MAAMC,mBAAqC,GAAG,CAAC,CAAC;EAChD,KAAK,MAAMC,YAAY,IAAIF,aAAa,EAAE;IACxC,MAAMG,UAAU,GAAGH,aAAa,CAACE,YAAY,CAAC;IAC9CD,mBAAmB,CAACC,YAAY,CAAC,GAAGE,yBAAyB,CAACD,UAAU,EAAEJ,aA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ACb,KAAK,OAAO;MACZ,KAAK,QAAQ;QACXrD,aAAa,GAAGT,cAAc;QAC9B;MAEF,KAAK,SAAS;MACd,KAAK,SAAS;QACZS,aAAa,GAAGR,WAAW;QAC3B;MAEF,KAAK,OAAO;MACZ,KAAK,QAAQ;QACXQ,aAAa,GAAGV,WAAW;QAC3B;MAEF;QACEU,aAAa,GAAGV,WAAW;QAC3B;IACJ;EACF;EACA,OAAOU,aAAa;AACtB,CAAC"}
1
+ {"version":3,"file":"feature-attributes.js","names":["AttributeType","EXT_FEATURE_METADATA","EXT_STRUCTURAL_METADATA","flattenPropertyTableByFeatureIds","featureIdsMap","propertyTable","resultPropertyTable","propertyName","properties","getPropertiesByFeatureIds","resultProperties","featureIdKey","property","push","checkPropertiesLength","featureIds","needFlatten","attribute","Object","values","length","getAttributeType","STRING_TYPE","Number","isInteger","SHORT_INT_TYPE","DOUBLE_TYPE","getAttributeTypesMapFromPropertyTable","attributeTypesMap","key","firstAttribute","attributeType","getAttributeTypesMapFromSchema","gltfJson","metadataClass","_gltfJson$extensions","_gltfJson$extensions$","_gltfJson$extensions$2","_gltfJson$extensions$3","_gltfJson$extensions2","_gltfJson$extensions3","_gltfJson$extensions4","_gltfJson$extensions5","extFeatureMetadataSchemaClass","extensions","schema","classes","attributeProperty","getAttributeTypeFromExtFeatureMetadata","extStructuralMetadataSchemaClass","getAttributeTypeFromExtStructuralMetadata","type","array","componentType"],"sources":["../../../src/i3s-converter/helpers/feature-attributes.ts"],"sourcesContent":["import type {FeatureTableJson} from '@loaders.gl/3d-tiles';\nimport type {Attribute} from '@loaders.gl/i3s';\nimport type {\n GLTFPostprocessed,\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_ClassProperty,\n GLTF_EXT_structural_metadata_GLTF,\n GLTF_EXT_structural_metadata_ClassProperty\n} from '@loaders.gl/gltf';\n\nimport {AttributeType} from '../types';\n\nimport {EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA} from '@loaders.gl/gltf';\n\n/**\n * Takes attributes from property table based on featureIdsMap.\n * If there is no property value for particular featureId (index) the property will be null.\n * Example:\n * Initial data:\n * OBJECTID: {0: 0, 3: 33, 4: 333}\n * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']\n * Result:\n * OBJECTID: [0, 33, 333]\n * component: ['Windows', 'Roof', 'Skylight']\n * @param featureIdsMap\n * @param propertyTable\n */\nexport function flattenPropertyTableByFeatureIds(\n featureIdsMap: Record<string, number>,\n propertyTable: FeatureTableJson\n): FeatureTableJson {\n const resultPropertyTable: FeatureTableJson = {};\n for (const propertyName in propertyTable) {\n const properties = propertyTable[propertyName];\n resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIdsMap);\n }\n\n return resultPropertyTable;\n}\n\n/**\n * Getting properties by featureId index\n * @param properties\n * @param featureIdsMap\n */\nfunction getPropertiesByFeatureIds(\n properties: unknown[],\n featureIdsMap: Record<string, number>\n): unknown[] {\n const resultProperties: unknown[] = [];\n\n if (properties) {\n for (const featureIdKey in featureIdsMap) {\n const property = properties[featureIdKey] || null;\n resultProperties.push(property);\n }\n }\n\n return resultProperties;\n}\n\n/**\n * Check that all attributes in propertyTable have the same length as FeatureIds.\n * If there are differencies between lengths we should flatten property table based on exiesting featureIds.\n * @param featureIds\n * @param propertyTable\n * @returns\n */\nexport function checkPropertiesLength(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): boolean {\n let needFlatten = false;\n\n for (const attribute of Object.values(propertyTable)) {\n if (!featureIds || !attribute || featureIds.length !== attribute.length) {\n needFlatten = true;\n }\n }\n\n return needFlatten;\n}\n\n/**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param attribute - attribute taken from propertyTable\n */\nexport function getAttributeType(attribute: unknown): string {\n if (typeof attribute === 'string' || typeof attribute === 'bigint') {\n return AttributeType.STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? AttributeType.SHORT_INT_TYPE : AttributeType.DOUBLE_TYPE;\n }\n return AttributeType.STRING_TYPE;\n}\n\n/**\n * Gets attribute's types based on the property table records.\n * @param propertyTable - Table with layer meta data.\n * @returns set of attribute types\n * @example of returned object:\n * {\n * \"opt_uint8\": \"Int32\",\n * \"opt_uint64\": \"string\"\n * }\n */\nexport function getAttributeTypesMapFromPropertyTable(\n propertyTable: FeatureTableJson\n): Record<string, Attribute> {\n const attributeTypesMap: Record<string, Attribute> = {};\n for (const key in propertyTable) {\n // Get attribute type based on the first element of each property.\n const firstAttribute = propertyTable[key][0];\n const attributeType = getAttributeType(firstAttribute);\n attributeTypesMap[key] = attributeType;\n }\n return attributeTypesMap;\n}\n\n/**\n * Gets attribute's types from the extension schema selected by the class name 'metadataClass'.\n * @param gltfJson - JSON part of GLB content\n * @param metadataClass - name of the schema class\n * @returns set of attribute's types\n * @example of returned object:\n * {\n * \"opt_uint8\": \"Int32\",\n * \"opt_uint64\": \"string\"\n * }\n */\nexport const getAttributeTypesMapFromSchema = (\n gltfJson: GLTFPostprocessed,\n metadataClass: string\n): Record<string, Attribute> | null => {\n const attributeTypesMap: Record<string, Attribute> = {};\n const extFeatureMetadataSchemaClass = (\n gltfJson.extensions?.[EXT_FEATURE_METADATA] as GLTF_EXT_feature_metadata_GLTF\n )?.schema?.classes?.[metadataClass];\n if (extFeatureMetadataSchemaClass) {\n for (let propertyName in extFeatureMetadataSchemaClass.properties) {\n const property = extFeatureMetadataSchemaClass.properties[propertyName];\n const attributeProperty = getAttributeTypeFromExtFeatureMetadata(property);\n attributeTypesMap[propertyName] = attributeProperty;\n }\n return attributeTypesMap;\n }\n\n const extStructuralMetadataSchemaClass = (\n gltfJson.extensions?.[EXT_STRUCTURAL_METADATA] as GLTF_EXT_structural_metadata_GLTF\n )?.schema?.classes?.[metadataClass];\n if (extStructuralMetadataSchemaClass) {\n for (let propertyName in extStructuralMetadataSchemaClass.properties) {\n const property = extStructuralMetadataSchemaClass.properties[propertyName];\n const attributeProperty = getAttributeTypeFromExtStructuralMetadata(property);\n attributeTypesMap[propertyName] = attributeProperty;\n }\n return attributeTypesMap;\n }\n\n return null;\n};\n\n/**\n * Gets the attribute type according to the Ext_feature_metadata extension class schema\n * @see https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param property - schema of the class property for Ext_feature_metadata\n * @returns attribute's type\n */\nconst getAttributeTypeFromExtFeatureMetadata = (\n property: GLTF_EXT_feature_metadata_ClassProperty\n): Attribute => {\n let attributeType: Attribute;\n switch (property.type) {\n case 'INT8':\n case 'UINT8':\n case 'INT16':\n case 'UINT16':\n case 'INT32':\n case 'UINT32':\n attributeType = AttributeType.SHORT_INT_TYPE;\n break;\n\n case 'FLOAT32':\n case 'FLOAT64':\n attributeType = AttributeType.DOUBLE_TYPE;\n break;\n\n case 'INT64':\n case 'UINT64':\n case 'BOOLEAN':\n case 'ENUM':\n case 'STRING':\n case 'ARRAY':\n attributeType = AttributeType.STRING_TYPE;\n break;\n\n default:\n attributeType = AttributeType.STRING_TYPE;\n break;\n }\n return attributeType;\n};\n\n/**\n * Gets the attribute type according to the Ext_structural_metadata extension class schema\n * @see https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param property - schema of the class property for Ext_structural_metadata\n * @returns attribute's type\n */\nconst getAttributeTypeFromExtStructuralMetadata = (\n property: GLTF_EXT_structural_metadata_ClassProperty\n): Attribute => {\n let attributeType: Attribute;\n if (property.array) {\n attributeType = AttributeType.STRING_TYPE;\n } else {\n switch (property.componentType) {\n case 'INT8':\n case 'UINT8':\n case 'INT16':\n case 'UINT16':\n case 'INT32':\n case 'UINT32':\n attributeType = AttributeType.SHORT_INT_TYPE;\n break;\n\n case 'FLOAT32':\n case 'FLOAT64':\n attributeType = AttributeType.DOUBLE_TYPE;\n break;\n\n case 'INT64':\n case 'UINT64':\n attributeType = AttributeType.STRING_TYPE;\n break;\n\n default:\n attributeType = AttributeType.ST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Q;IACb,KAAK,OAAO;MACVK,aAAa,GAAG/B,aAAa,CAACsB,WAAW;MACzC;IAEF;MACES,aAAa,GAAG/B,aAAa,CAACsB,WAAW;MACzC;EACJ;EACA,OAAOS,aAAa;AACtB,CAAC;AAQD,MAAMmB,yCAAyC,GAC7CtC,QAAoD,IACtC;EACd,IAAImB,aAAwB;EAC5B,IAAInB,QAAQ,CAACwC,KAAK,EAAE;IAClBrB,aAAa,GAAG/B,aAAa,CAACsB,WAAW;EAC3C,CAAC,MAAM;IACL,QAAQV,QAAQ,CAACyC,aAAa;MAC5B,KAAK,MAAM;MACX,KAAK,OAAO;MACZ,KAAK,OAAO;MACZ,KAAK,QAAQ;MACb,KAAK,OAAO;MACZ,KAAK,QAAQ;QACXtB,aAAa,GAAG/B,aAAa,CAACyB,cAAc;QAC5C;MAEF,KAAK,SAAS;MACd,KAAK,SAAS;QACZM,aAAa,GAAG/B,aAAa,CAAC0B,WAAW;QACzC;MAEF,KAAK,OAAO;MACZ,KAAK,QAAQ;QACXK,aAAa,GAAG/B,aAAa,CAACsB,WAAW;QACzC;MAEF;QACES,aAAa,GAAG/B,aAAa,CAACsB,WAAW;QACzC;IACJ;EACF;EACA,OAAOS,aAAa;AACtB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { AttributeMetadataInfo } from './helpers/attribute-metadata-info';
1
2
  import type { Tiles3DLoaderOptions, Tiles3DTilesetJSONPostprocessed } from '@loaders.gl/3d-tiles';
2
3
  import type { WriteQueueItem } from '../lib/utils/write-queue';
3
4
  import type { SceneLayer3D } from '@loaders.gl/i3s';
@@ -11,6 +12,7 @@ import WriteQueue from '../lib/utils/write-queue';
11
12
  * Converter from 3d-tiles tileset to i3s layer
12
13
  */
13
14
  export default class I3SConverter {
15
+ attributeMetadataInfo: AttributeMetadataInfo;
14
16
  nodePages: NodePages;
15
17
  options: any;
16
18
  layers0Path: string;
@@ -45,6 +47,15 @@ export default class I3SConverter {
45
47
  writeQueue: WriteQueue<WriteQueueItem>;
46
48
  compressList: string[] | null;
47
49
  preprocessData: PreprocessData;
50
+ /** Total count of tiles in tileset */
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;
48
59
  constructor();
49
60
  /**
50
61
  * Convert a 3d tileset
@@ -248,11 +259,6 @@ export default class I3SConverter {
248
259
  * @param propertyTable - feature properties from EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA
249
260
  */
250
261
  private createAttributeStorageInfo;
251
- /**
252
- * Creates Attribute Storage Info objects based on attribute's types
253
- * @param attributeTypesMap - set of attribute's types
254
- */
255
- private createStorageAttributes;
256
262
  /**
257
263
  * Print statistics in the end of conversion
258
264
  * @param params - output files data