@loaders.gl/tile-converter 4.0.0-beta.3 → 4.0.0-beta.5
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/converter.js +1 -3
- package/bin/i3s-server.js +1 -3
- package/bin/slpk-extractor.js +1 -3
- package/dist/{converter.min.js → converter.min.cjs} +99 -99
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +28 -5
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +96 -8
- package/dist/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +44 -1
- package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +9 -3
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +38 -18
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-converter/types.d.ts +1 -1
- package/dist/i3s-converter/types.js.map +1 -1
- package/dist/{esm/i3s-server/bin/i3s-server.min.js → i3s-server/bin/i3s-server.min.cjs} +70 -70
- package/dist/index.cjs +204 -46
- package/dist/{slpk-extractor.min.js → slpk-extractor.min.cjs} +45 -45
- package/package.json +18 -18
- package/src/i3s-converter/helpers/feature-attributes.ts +164 -11
- package/src/i3s-converter/helpers/geometry-converter.ts +99 -7
- package/src/i3s-converter/helpers/load-3d-tiles.ts +1 -0
- package/src/i3s-converter/i3s-converter.ts +72 -39
- package/src/i3s-converter/types.ts +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FeatureTableJson } from '@loaders.gl/3d-tiles';
|
|
2
|
-
import { Attribute, AttributeStorageInfo, ESRIField, Field, PopupInfo } from '@loaders.gl/i3s';
|
|
2
|
+
import type { Attribute, AttributeStorageInfo, ESRIField, Field, PopupInfo } from '@loaders.gl/i3s';
|
|
3
|
+
import type { GLTFPostprocessed } from '@loaders.gl/gltf';
|
|
3
4
|
/**
|
|
4
5
|
* Takes attributes from property table based on featureIdsMap.
|
|
5
6
|
* If there is no property value for particular featureId (index) the property will be null.
|
|
@@ -24,10 +25,9 @@ export declare function flattenPropertyTableByFeatureIds(featureIdsMap: Record<s
|
|
|
24
25
|
export declare function checkPropertiesLength(featureIds: number[], propertyTable: FeatureTableJson): boolean;
|
|
25
26
|
/**
|
|
26
27
|
* Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
27
|
-
* @param key - attribute's key
|
|
28
28
|
* @param attribute - attribute taken from propertyTable
|
|
29
29
|
*/
|
|
30
|
-
export declare function getAttributeType(
|
|
30
|
+
export declare function getAttributeType(attribute: unknown): string;
|
|
31
31
|
/**
|
|
32
32
|
* Generate storage attribute for map segmentation.
|
|
33
33
|
* @param attributeIndex - order index of attribute (f_0, f_1 ...).
|
|
@@ -49,8 +49,31 @@ export declare function getFieldAttributeType(attributeType: Attribute): ESRIFie
|
|
|
49
49
|
export declare function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field;
|
|
50
50
|
/**
|
|
51
51
|
* Generate popup info to show metadata on the map.
|
|
52
|
-
* @param
|
|
52
|
+
* @param propertyNames - array of property names including OBJECTID.
|
|
53
53
|
* @return data for correct rendering of popup.
|
|
54
54
|
*/
|
|
55
|
-
export declare function createPopupInfo(
|
|
55
|
+
export declare function createPopupInfo(propertyNames: string[]): PopupInfo;
|
|
56
|
+
/**
|
|
57
|
+
* Gets attribute's types based on the property table records.
|
|
58
|
+
* @param propertyTable - Table with layer meta data.
|
|
59
|
+
* @returns set of attribute types
|
|
60
|
+
* @example of returned object:
|
|
61
|
+
* {
|
|
62
|
+
* "opt_uint8": "Int32",
|
|
63
|
+
* "opt_uint64": "string"
|
|
64
|
+
* }
|
|
65
|
+
*/
|
|
66
|
+
export declare function getAttributeTypesFromPropertyTable(propertyTable: FeatureTableJson): Record<string, Attribute>;
|
|
67
|
+
/**
|
|
68
|
+
* Gets attribute's types from the extension schema selected by the class name 'metadataClass'.
|
|
69
|
+
* @param gltfJson - JSON part of GLB content
|
|
70
|
+
* @param metadataClass - name of the schema class
|
|
71
|
+
* @returns set of attribute's types
|
|
72
|
+
* @example of returned object:
|
|
73
|
+
* {
|
|
74
|
+
* "opt_uint8": "Int32",
|
|
75
|
+
* "opt_uint64": "string"
|
|
76
|
+
* }
|
|
77
|
+
*/
|
|
78
|
+
export declare const getAttributeTypesFromSchema: (gltfJson: GLTFPostprocessed, metadataClass: string) => Record<string, Attribute> | null;
|
|
56
79
|
//# 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,
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA } from '@loaders.gl/gltf';
|
|
1
2
|
export function flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable) {
|
|
2
3
|
const resultPropertyTable = {};
|
|
3
4
|
for (const propertyName in propertyTable) {
|
|
@@ -29,10 +30,7 @@ const STRING_TYPE = 'string';
|
|
|
29
30
|
const SHORT_INT_TYPE = 'Int32';
|
|
30
31
|
const DOUBLE_TYPE = 'double';
|
|
31
32
|
const OBJECT_ID_TYPE = 'OBJECTID';
|
|
32
|
-
export function getAttributeType(
|
|
33
|
-
if (key === OBJECT_ID_TYPE) {
|
|
34
|
-
return OBJECT_ID_TYPE;
|
|
35
|
-
}
|
|
33
|
+
export function getAttributeType(attribute) {
|
|
36
34
|
if (typeof attribute === STRING_TYPE || typeof attribute === 'bigint') {
|
|
37
35
|
return STRING_TYPE;
|
|
38
36
|
} else if (typeof attribute === 'number') {
|
|
@@ -92,18 +90,18 @@ export function createFieldAttribute(key, fieldAttributeType) {
|
|
|
92
90
|
alias: key
|
|
93
91
|
};
|
|
94
92
|
}
|
|
95
|
-
export function createPopupInfo(
|
|
93
|
+
export function createPopupInfo(propertyNames) {
|
|
96
94
|
const title = '{OBJECTID}';
|
|
97
95
|
const mediaInfos = [];
|
|
98
96
|
const fieldInfos = [];
|
|
99
97
|
const popupElements = [];
|
|
100
98
|
const expressionInfos = [];
|
|
101
|
-
for (const
|
|
99
|
+
for (const propertyName of propertyNames) {
|
|
102
100
|
fieldInfos.push({
|
|
103
|
-
fieldName:
|
|
101
|
+
fieldName: propertyName,
|
|
104
102
|
visible: true,
|
|
105
103
|
isEditable: false,
|
|
106
|
-
label:
|
|
104
|
+
label: propertyName
|
|
107
105
|
});
|
|
108
106
|
}
|
|
109
107
|
popupElements.push({
|
|
@@ -146,4 +144,94 @@ function setupDoubleAttribute(storageAttribute) {
|
|
|
146
144
|
valuesPerElement: 1
|
|
147
145
|
};
|
|
148
146
|
}
|
|
147
|
+
export function getAttributeTypesFromPropertyTable(propertyTable) {
|
|
148
|
+
const attributeTypesMap = {};
|
|
149
|
+
for (const key in propertyTable) {
|
|
150
|
+
const firstAttribute = propertyTable[key][0];
|
|
151
|
+
const attributeType = getAttributeType(firstAttribute);
|
|
152
|
+
attributeTypesMap[key] = attributeType;
|
|
153
|
+
}
|
|
154
|
+
return attributeTypesMap;
|
|
155
|
+
}
|
|
156
|
+
export const getAttributeTypesFromSchema = (gltfJson, metadataClass) => {
|
|
157
|
+
var _gltfJson$extensions, _gltfJson$extensions$, _gltfJson$extensions$2, _gltfJson$extensions$3, _gltfJson$extensions2, _gltfJson$extensions3, _gltfJson$extensions4, _gltfJson$extensions5;
|
|
158
|
+
const attributeTypesMap = {};
|
|
159
|
+
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];
|
|
160
|
+
if (extFeatureMetadataSchemaClass) {
|
|
161
|
+
for (let propertyName in extFeatureMetadataSchemaClass.properties) {
|
|
162
|
+
const property = extFeatureMetadataSchemaClass.properties[propertyName];
|
|
163
|
+
const attributeProperty = getAttributeTypeFromExtFeatureMetadata(property);
|
|
164
|
+
attributeTypesMap[propertyName] = attributeProperty;
|
|
165
|
+
}
|
|
166
|
+
return attributeTypesMap;
|
|
167
|
+
}
|
|
168
|
+
const extStructuralMetadataSchemaClass = (_gltfJson$extensions2 = gltfJson.extensions) === null || _gltfJson$extensions2 === void 0 ? void 0 : (_gltfJson$extensions3 = _gltfJson$extensions2[EXT_STRUCTURAL_METADATA]) === null || _gltfJson$extensions3 === void 0 ? void 0 : (_gltfJson$extensions4 = _gltfJson$extensions3.schema) === null || _gltfJson$extensions4 === void 0 ? void 0 : (_gltfJson$extensions5 = _gltfJson$extensions4.classes) === null || _gltfJson$extensions5 === void 0 ? void 0 : _gltfJson$extensions5[metadataClass];
|
|
169
|
+
if (extStructuralMetadataSchemaClass) {
|
|
170
|
+
for (let propertyName in extStructuralMetadataSchemaClass.properties) {
|
|
171
|
+
const property = extStructuralMetadataSchemaClass.properties[propertyName];
|
|
172
|
+
const attributeProperty = getAttributeTypeFromExtStructuralMetadata(property);
|
|
173
|
+
attributeTypesMap[propertyName] = attributeProperty;
|
|
174
|
+
}
|
|
175
|
+
return attributeTypesMap;
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
};
|
|
179
|
+
const getAttributeTypeFromExtFeatureMetadata = property => {
|
|
180
|
+
let attributeType;
|
|
181
|
+
switch (property.type) {
|
|
182
|
+
case 'INT8':
|
|
183
|
+
case 'UINT8':
|
|
184
|
+
case 'INT16':
|
|
185
|
+
case 'UINT16':
|
|
186
|
+
case 'INT32':
|
|
187
|
+
case 'UINT32':
|
|
188
|
+
attributeType = SHORT_INT_TYPE;
|
|
189
|
+
break;
|
|
190
|
+
case 'FLOAT32':
|
|
191
|
+
case 'FLOAT64':
|
|
192
|
+
attributeType = DOUBLE_TYPE;
|
|
193
|
+
break;
|
|
194
|
+
case 'INT64':
|
|
195
|
+
case 'UINT64':
|
|
196
|
+
case 'BOOLEAN':
|
|
197
|
+
case 'ENUM':
|
|
198
|
+
case 'STRING':
|
|
199
|
+
case 'ARRAY':
|
|
200
|
+
attributeType = STRING_TYPE;
|
|
201
|
+
break;
|
|
202
|
+
default:
|
|
203
|
+
attributeType = STRING_TYPE;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
return attributeType;
|
|
207
|
+
};
|
|
208
|
+
const getAttributeTypeFromExtStructuralMetadata = property => {
|
|
209
|
+
let attributeType;
|
|
210
|
+
if (property.array) {
|
|
211
|
+
attributeType = STRING_TYPE;
|
|
212
|
+
} else {
|
|
213
|
+
switch (property.componentType) {
|
|
214
|
+
case 'INT8':
|
|
215
|
+
case 'UINT8':
|
|
216
|
+
case 'INT16':
|
|
217
|
+
case 'UINT16':
|
|
218
|
+
case 'INT32':
|
|
219
|
+
case 'UINT32':
|
|
220
|
+
attributeType = SHORT_INT_TYPE;
|
|
221
|
+
break;
|
|
222
|
+
case 'FLOAT32':
|
|
223
|
+
case 'FLOAT64':
|
|
224
|
+
attributeType = DOUBLE_TYPE;
|
|
225
|
+
break;
|
|
226
|
+
case 'INT64':
|
|
227
|
+
case 'UINT64':
|
|
228
|
+
attributeType = STRING_TYPE;
|
|
229
|
+
break;
|
|
230
|
+
default:
|
|
231
|
+
attributeType = STRING_TYPE;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return attributeType;
|
|
236
|
+
};
|
|
149
237
|
//# sourceMappingURL=feature-attributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-attributes.js","names":["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","key","Number","isInteger","createdStorageAttribute","attributeIndex","attributeType","storageAttribute","name","ordering","header","valueType","attributeValues","valuesPerElement","setupIdAttribute","setupStringAttribute","setupDoubleAttribute","getFieldAttributeType","createFieldAttribute","fieldAttributeType","type","alias","createPopupInfo","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","unshift","encoding","attributeByteCounts"],"sources":["../../../src/i3s-converter/helpers/feature-attributes.ts"],"sourcesContent":["import type {FeatureTableJson} from '@loaders.gl/3d-tiles';\nimport {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\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 key - attribute's key\n * @param attribute - attribute taken from propertyTable\n */\nexport function getAttributeType(key: string, attribute: unknown): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\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 propertyTable - table data with OBJECTID.\n * @return data for correct rendering of popup.\n */\nexport function createPopupInfo(propertyTable: FeatureTableJson): 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 key in propertyTable) {\n fieldInfos.push({\n fieldName: key,\n visible: true,\n isEditable: false,\n label: key\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"],"mappings":"AAuBA,OAAO,SAASA,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,aAAa,CAAC;EAC1F;EAEA,OAAOE,mBAAmB;AAC5B;AAOA,SAASG,yBAAyBA,CAChCD,UAAqB,EACrBJ,aAAqC,EAC1B;EACX,MAAMM,gBAA2B,GAAG,EAAE;EAEtC,IAAIF,UA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AAS,EAAE3B,GAAG;MACd4B,OAAO,EAAE,IAAI;MACbC,UAAU,EAAE,KAAK;MACjBC,KAAK,EAAE9B;IACT,CAAC,CAAC;EACJ;EACAyB,aAAa,CAACtC,IAAI,CAAC;IACjBqC,UAAU;IACVL,IAAI,EAAE;EACR,CAAC,CAAC;EAEF,OAAO;IACLG,KAAK;IACLC,UAAU;IACVE,aAAa;IACbD,UAAU;IACVE;EACF,CAAC;AACH;AAMA,SAASZ,oBAAoBA,CAACR,gBAAsC,EAAQ;EAE1EA,gBAAgB,CAACE,QAAQ,CAACuB,OAAO,CAAC,qBAAqB,CAAC;EACxDzB,gBAAgB,CAACG,MAAM,CAACtB,IAAI,CAAC;IAACD,QAAQ,EAAE,0BAA0B;IAAEwB,SAAS,EAAE;EAAQ,CAAC,CAAC;EACzFJ,gBAAgB,CAACK,eAAe,GAAG;IACjCD,SAAS,EAAE,QAAQ;IACnBsB,QAAQ,EAAE,OAAO;IACjBpB,gBAAgB,EAAE;EACpB,CAAC;EACDN,gBAAgB,CAAC2B,mBAAmB,GAAG;IACrCvB,SAAS,EAAE,QAAQ;IACnBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASC,gBAAgBA,CAACP,gBAAsC,EAAQ;EACtEA,gBAAgB,CAACK,eAAe,GAAG;IACjCD,SAAS,EAAE,OAAO;IAClBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASG,oBAAoBA,CAACT,gBAAsC,EAAQ;EAC1EA,gBAAgB,CAACK,eAAe,GAAG;IACjCD,SAAS,EAAE,SAAS;IACpBE,gBAAgB,EAAE;EACpB,CAAC;AACH"}
|
|
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,aAAa,CAAC;EAC1F;EAEA,OAAOE,mBAAmB;AAC5B;AAOA,SAASG,yBAAyBA,CAChCD,UAAqB,EACrBJ,aAAqC,EAC1B;EACX,MAAMM,gBAA2B,GAAG,EAAE;EAEtC,IAAIF,UAAU,EAAE;IACd,KAAK,MA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Q,aAAa,GAAGV,WAAW;QAC3B;MAEF;QACEU,aAAa,GAAGV,WAAW;QAC3B;IACJ;EACF;EACA,OAAOU,aAAa;AACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAgB/E,OAAO,EAAU,OAAO,EAAU,MAAM,eAAe,CAAC;AAUxD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAWrC,OAAO,KAAK,EAAC,kBAAkB,EAAgD,MAAM,UAAU,CAAC;AAEhG,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAyBrE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,kBAAkB,EAC/B,aAAa,EAAE,OAAO,EACtB,kBAAkB,EAAE,mBAAmB,GAAG,cAAc,EACxD,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACxC,aAAa,EAAE,gBAAgB,GAAG,IAAI,EACtC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,EACxD,KAAK,EAAE,OAAO,EACd,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,EAAE,KAAK,EACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CAgEzC;AAoJD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,sBAAsB,EAAE,sBAAsB,EAAE,EAChD,qBAAqB,EAAE,OAAO,EAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,GAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAkD3C;AAmsCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,kBAAkB,GAAG,IAAI,EACtC,aAAa,CAAC,EAAE,MAAM,GACrB,gBAAgB,GAAG,IAAI,CA+BzB"}
|
|
@@ -12,7 +12,7 @@ import { getTextureByMetadataClass, handleBatchIdsExtensions } from "./batch-ids
|
|
|
12
12
|
import { checkPropertiesLength, flattenPropertyTableByFeatureIds } from "./feature-attributes.js";
|
|
13
13
|
import { GL } from '@loaders.gl/math';
|
|
14
14
|
import { generateSyntheticIndices } from "../../lib/utils/geometry-utils.js";
|
|
15
|
-
import { EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA
|
|
15
|
+
import { EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA } from '@loaders.gl/gltf';
|
|
16
16
|
const DEFAULT_ROUGHNESS_FACTOR = 1;
|
|
17
17
|
const DEFAULT_METALLIC_FACTOR = 1;
|
|
18
18
|
const VALUES_PER_VERTEX = 3;
|
|
@@ -872,6 +872,49 @@ export function getPropertyTable(tileContent, metadataClass) {
|
|
|
872
872
|
return null;
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
|
+
function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
|
|
876
|
+
if (extension.propertyTables) {
|
|
877
|
+
for (const propertyTable of extension.propertyTables) {
|
|
878
|
+
if (propertyTable.class === metadataClass || !metadataClass) {
|
|
879
|
+
return getPropertyData(propertyTable);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
if (extension.propertyTextures) {
|
|
884
|
+
for (const propertyTexture of extension.propertyTextures) {
|
|
885
|
+
if (propertyTexture.class === metadataClass || !metadataClass) {
|
|
886
|
+
return getPropertyData(propertyTexture);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return null;
|
|
891
|
+
}
|
|
892
|
+
function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
|
|
893
|
+
if (extension.featureTables) {
|
|
894
|
+
for (const featureTableName in extension.featureTables) {
|
|
895
|
+
const featureTable = extension.featureTables[featureTableName];
|
|
896
|
+
if (featureTable.class === metadataClass || !metadataClass) {
|
|
897
|
+
return getPropertyData(featureTable);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
if (extension.featureTextures) {
|
|
902
|
+
for (const featureTextureName in extension.featureTextures) {
|
|
903
|
+
const featureTexture = extension.featureTextures[featureTextureName];
|
|
904
|
+
if (featureTexture.class === metadataClass || !metadataClass) {
|
|
905
|
+
return getPropertyData(featureTexture);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
return null;
|
|
910
|
+
}
|
|
911
|
+
function getPropertyData(featureObject) {
|
|
912
|
+
const propertyTableWithData = {};
|
|
913
|
+
for (const propertyName in featureObject.properties) {
|
|
914
|
+
propertyTableWithData[propertyName] = featureObject.properties[propertyName].data;
|
|
915
|
+
}
|
|
916
|
+
return propertyTableWithData;
|
|
917
|
+
}
|
|
875
918
|
function getPropertyTableExtension(tileContent) {
|
|
876
919
|
var _tileContent$gltf3, _tileContent$gltf5, _tileContent$gltf5$ex;
|
|
877
920
|
const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA];
|