@loaders.gl/tile-converter 4.0.0-alpha.23 → 4.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
- package/dist/converter.min.js +97 -97
- package/dist/dist.min.js +237 -182
- package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +6 -18
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +83 -44
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +9 -7
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/pgm-loader.js +11 -3
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +5 -5
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +76 -34
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +7 -5
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/pgm-loader.js +7 -4
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +6 -6
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/types.d.ts +7 -4
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/pgm-loader.d.ts +9 -2
- package/dist/pgm-loader.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/3d-tiles-converter/helpers/load-i3s.ts +1 -0
- package/src/i3s-converter/helpers/feature-attributes.ts +14 -11
- package/src/i3s-converter/helpers/geometry-attributes.ts +80 -50
- package/src/i3s-converter/helpers/geometry-converter.ts +18 -9
- package/src/i3s-converter/types.ts +8 -4
- package/src/pgm-loader.ts +15 -7
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -279
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -271
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
- package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -42
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -54
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
- package/dist/bundle.js +0 -5
- package/dist/constants.js +0 -4
- package/dist/converter-cli.js +0 -222
- package/dist/deps-installer/deps-installer.js +0 -89
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -179
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -122
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -218
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -203
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1321
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -129
- package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -99
- package/dist/i3s-converter/helpers/node-debug.js +0 -120
- package/dist/i3s-converter/helpers/node-index-document.js +0 -271
- package/dist/i3s-converter/helpers/node-pages.js +0 -316
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -100
- package/dist/i3s-converter/helpers/tileset-traversal.js +0 -29
- package/dist/i3s-converter/i3s-converter.js +0 -964
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
- package/dist/i3s-converter/json-templates/layers.js +0 -139
- package/dist/i3s-converter/json-templates/metadata.js +0 -25
- package/dist/i3s-converter/json-templates/node.js +0 -89
- package/dist/i3s-converter/json-templates/scene-server.js +0 -31
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
- package/dist/i3s-converter/json-templates/store.js +0 -103
- package/dist/i3s-converter/types.js +0 -17
- package/dist/i3s-server/app.js +0 -29
- package/dist/i3s-server/bin/www.js +0 -37
- package/dist/i3s-server/controllers/index-controller.js +0 -31
- package/dist/i3s-server/controllers/slpk-controller.js +0 -33
- package/dist/i3s-server/routes/index.js +0 -20
- package/dist/i3s-server/routes/slpk-router.js +0 -34
- package/dist/i3s-server/utils/create-scene-server.js +0 -22
- package/dist/i3s-server/utils/server-utils.js +0 -66
- package/dist/index.js +0 -10
- package/dist/lib/utils/cli-utils.js +0 -82
- package/dist/lib/utils/compress-util.js +0 -257
- package/dist/lib/utils/file-utils.js +0 -139
- package/dist/lib/utils/geometry-utils.js +0 -18
- package/dist/lib/utils/lod-conversion-utils.js +0 -76
- package/dist/lib/utils/queue.js +0 -18
- package/dist/lib/utils/statistic-utills.js +0 -64
- package/dist/lib/utils/write-queue.js +0 -80
- package/dist/pgm-loader.js +0 -24
- package/dist/slpk-extractor/slpk-extractor.js +0 -75
- package/dist/slpk-extractor-cli.js +0 -102
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["GLTFPrimitiveModeString","exports"],"sources":["../../../src/i3s-converter/types.ts"],"sourcesContent":["import {GLTFImagePostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\nimport {\n BoundingVolumes,\n I3SMaterialDefinition,\n MaterialDefinitionInfo,\n TextureDefinitionInfo\n} from '@loaders.gl/i3s';\nimport {Matrix4, Vector3} from '@math.gl/core';\n\n/** Converted resources for specific node */\nexport type I3SConvertedResources = {\n /**\n * Node id\n */\n nodeId?: number;\n /** Non-compressed geometry buffer that have structure met\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n * (Geometry buffer)\n */\n geometry: ArrayBuffer | null;\n /**\n * Draco compressed geometry\n */\n compressedGeometry?: Promise<ArrayBuffer> | null;\n /**\n * Texture image content\n */\n texture: any | null;\n /**\n * If the resource has uvRegions geometry attribute\n */\n hasUvRegions: boolean;\n /**\n * Shared resources built from GLTF material\n */\n sharedResources: SharedResourcesArrays | null;\n /**\n * Material definition of the node\n */\n meshMaterial?: I3SMaterialDefinition | null;\n /**\n * Number of vertices in the node\n */\n vertexCount: number | null;\n /**\n * Feature attributes contents\n */\n attributes: ArrayBuffer[] | null;\n /**\n * Number of features in the node\n */\n featureCount: number | null;\n /**\n * MBS and/or OBB bounding volumes of the node\n */\n boundingVolumes: BoundingVolumes | null;\n};\n\n/**\n * Geometry and feature attributes converted from GLTF primitives\n */\nexport type ConvertedAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** uvRegion attribute for a texture atlas */\n uvRegions: Uint16Array;\n /** Feature indices grouped by ...\n * converted from \"batch ids\" of GLTF\n */\n featureIndicesGroups?: number[][];\n /** Feature indices converted from \"batch ids\" */\n featureIndices: number[];\n /**\n * MBS and/or OBB bounding volumes of the node\n */\n boundingVolumes: null | BoundingVolumes;\n /** merged materials data */\n mergedMaterials: MergedMaterial[];\n};\n\n/** Postprocessed geometry and feature attributes\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n */\nexport type GeometryAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** uvRegion attribute for a texture atlas */\n uvRegions: Uint16Array;\n /** faceRanges attribute value */\n faceRange: Uint32Array;\n /** feature Ids attribute value */\n featureIds: number[];\n /** number of features in the node */\n featureCount: number;\n};\n\n/** Geometry attributes
|
|
1
|
+
{"version":3,"file":"types.js","names":["GLTFPrimitiveModeString","exports"],"sources":["../../../src/i3s-converter/types.ts"],"sourcesContent":["import {GLTFImagePostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\nimport {\n BoundingVolumes,\n I3SMaterialDefinition,\n MaterialDefinitionInfo,\n TextureDefinitionInfo\n} from '@loaders.gl/i3s';\nimport {Matrix4, Vector3} from '@math.gl/core';\n\n/** Converted resources for specific node */\nexport type I3SConvertedResources = {\n /**\n * Node id\n */\n nodeId?: number;\n /** Non-compressed geometry buffer that have structure met\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n * (Geometry buffer)\n */\n geometry: ArrayBuffer | null;\n /**\n * Draco compressed geometry\n */\n compressedGeometry?: Promise<ArrayBuffer> | null;\n /**\n * Texture image content\n */\n texture: any | null;\n /**\n * If the resource has uvRegions geometry attribute\n */\n hasUvRegions: boolean;\n /**\n * Shared resources built from GLTF material\n */\n sharedResources: SharedResourcesArrays | null;\n /**\n * Material definition of the node\n */\n meshMaterial?: I3SMaterialDefinition | null;\n /**\n * Number of vertices in the node\n */\n vertexCount: number | null;\n /**\n * Feature attributes contents\n */\n attributes: ArrayBuffer[] | null;\n /**\n * Number of features in the node\n */\n featureCount: number | null;\n /**\n * MBS and/or OBB bounding volumes of the node\n */\n boundingVolumes: BoundingVolumes | null;\n};\n\n/**\n * Geometry and feature attributes converted from GLTF primitives\n */\nexport type ConvertedAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** uvRegion attribute for a texture atlas */\n uvRegions: Uint16Array;\n /** Feature indices grouped by ...\n * converted from \"batch ids\" of GLTF\n */\n featureIndicesGroups?: number[][];\n /** Feature indices converted from \"batch ids\" */\n featureIndices: number[];\n /**\n * MBS and/or OBB bounding volumes of the node\n */\n boundingVolumes: null | BoundingVolumes;\n /** merged materials data */\n mergedMaterials: MergedMaterial[];\n};\n\n/** Postprocessed geometry and feature attributes\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n */\nexport type GeometryAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** uvRegion attribute for a texture atlas */\n uvRegions: Uint16Array;\n /** faceRanges attribute value */\n faceRange: Uint32Array;\n /** feature Ids attribute value */\n featureIds: number[];\n /** number of features in the node */\n featureCount: number;\n};\n\n/** Geometry attributes applicable for reordering by featureId */\nexport type GroupedAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** uvRegion attribute for a texture atlas */\n uvRegions: Uint16Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n};\n\n/** Geometry attributes specific for the particular feature */\nexport type GroupedByFeatureIdAttributes = GroupedAttributes & {\n /** Feature Id */\n featureId: number;\n};\n\n/** Shared resources made from GLTF material */\nexport type SharedResourcesArrays = {\n /** material definitions list https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitionInfo.cmn.md */\n materialDefinitionInfos?: MaterialDefinitionInfo[];\n /** texture definitions list https://github.com/Esri/i3s-spec/blob/master/docs/1.8/textureDefinitionInfo.cmn.md*/\n textureDefinitionInfos?: TextureDefinitionInfo[];\n /** node id to make unique SharedResource ids */\n nodePath?: string;\n};\n\n/** I3S material definition and texture content taken from GLTF material */\nexport type I3SMaterialWithTexture = {\n /** Material definition https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitions.cmn.md */\n material: I3SMaterialDefinition;\n /** Texture content (image) */\n texture?: GLTFImagePostprocessed;\n /** Metadata of all merged materials */\n mergedMaterials: MergedMaterial[];\n};\n\n/** Metadata of some original texture */\nexport type MergedMaterial = {\n /** Gltf material Id */\n originalMaterialId: string;\n /** Original texture size */\n textureSize?: {\n width: number;\n height: number;\n };\n /** Uint16Array of 4 elements https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md */\n uvRegion?: Uint16Array;\n};\n\nexport type TypedArrayConstructor =\n | Uint8ArrayConstructor\n | Int8ArrayConstructor\n | Uint16ArrayConstructor\n | Int16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\n/**\n * glTF primitive modes (mesh topology types)\n * @see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode\n */\nexport enum GLTFPrimitiveModeString {\n POINTS = 'POINTS',\n LINES = 'LINES',\n LINE_LOOP = 'LINE_LOOP',\n LINE_STRIP = 'LINE_STRIP',\n TRIANGLES = 'TRIANGLES',\n TRIANGLE_STRIP = 'TRIANGLE_STRIP',\n TRIANGLE_FAN = 'TRIANGLE_FAN'\n}\n\n/** Preprocessed data gathered from child tiles binary content */\nexport type PreprocessData = {\n /** Mesh topology types used in gltf primitives of the tileset */\n meshTopologyTypes: Set<GLTFPrimitiveModeString>;\n /** Featrue metadata classes found in glTF extensions */\n metadataClasses: Set<string>;\n};\n\n/** Texture image properties required for conversion */\nexport type TextureImageProperties = {\n /** Array with image data */\n data: Uint8Array;\n /** Is the texture compressed */\n compressed?: boolean;\n /** Height of the texture's image */\n height?: number;\n /** Width of the texture's image */\n width?: number;\n /** Number of components (3 for RGB, 4 for RGBA) */\n components?: number;\n /** Mime type of the texture's image */\n mimeType?: string;\n};\n\n/** glTF attributes data, prepared for conversion */\nexport type GLTFAttributesData = {\n /** glTF PBR materials (only id is required) */\n gltfMaterials?: {id: string}[];\n /** glTF geometry nodes */\n nodes: GLTFNodePostprocessed[];\n /** glTF texture images (set to null for compressed textures) */\n images: (null | TextureImageProperties)[];\n /** Source tile origin coordinates in cartographic coordinate system */\n cartographicOrigin: Vector3;\n /** Model matrix to convert coordinate system of POSITION and NORMAL attributes from METER_OFFSETS to CARTESIAN */\n cartesianModelMatrix: Matrix4;\n};\n"],"mappings":";;;;;;IA+KYA,uBAAuB,aAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAA,OAAvBA,uBAAuB;AAAA;AAAAC,OAAA,CAAAD,uBAAA,GAAAA,uBAAA"}
|
package/dist/es5/pgm-loader.js
CHANGED
|
@@ -4,11 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "Geoid", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _geoid.Geoid;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
exports.PGMLoader = void 0;
|
|
8
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
16
|
var _geoid = require("@math.gl/geoid");
|
|
11
|
-
var VERSION = typeof "4.0.0-alpha.
|
|
17
|
+
var VERSION = typeof "4.0.0-alpha.24" !== 'undefined' ? "4.0.0-alpha.24" : 'latest';
|
|
12
18
|
var PGMLoader = {
|
|
13
19
|
name: 'PGM - Netpbm grayscale image format',
|
|
14
20
|
id: 'pgm',
|
|
@@ -20,7 +26,7 @@ var PGMLoader = {
|
|
|
20
26
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
21
27
|
while (1) switch (_context.prev = _context.next) {
|
|
22
28
|
case 0:
|
|
23
|
-
return _context.abrupt("return", (0, _geoid.parsePGM)(new Uint8Array(arrayBuffer), options));
|
|
29
|
+
return _context.abrupt("return", (0, _geoid.parsePGM)(new Uint8Array(arrayBuffer), (options === null || options === void 0 ? void 0 : options.pgm) || {}));
|
|
24
30
|
case 1:
|
|
25
31
|
case "end":
|
|
26
32
|
return _context.stop();
|
|
@@ -34,7 +40,9 @@ var PGMLoader = {
|
|
|
34
40
|
}(),
|
|
35
41
|
extensions: ['pgm'],
|
|
36
42
|
options: {
|
|
37
|
-
|
|
43
|
+
pgm: {
|
|
44
|
+
cubic: false
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
};
|
|
40
48
|
exports.PGMLoader = PGMLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pgm-loader.js","names":["_geoid","require","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","_parse","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","options","wrap","_callee$","_context","prev","next","abrupt","parsePGM","Uint8Array","stop","_x","_x2","apply","arguments","extensions","cubic","exports"],"sources":["../../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {parsePGM} from '@math.gl/geoid';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n
|
|
1
|
+
{"version":3,"file":"pgm-loader.js","names":["_geoid","require","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","_parse","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","options","wrap","_callee$","_context","prev","next","abrupt","parsePGM","Uint8Array","pgm","stop","_x","_x2","apply","arguments","extensions","cubic","exports"],"sources":["../../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {Geoid, parsePGM} from '@math.gl/geoid';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport {Geoid};\n\nexport type PGMLoaderOptions = LoaderOptions & {\n pgm?: {\n cubic?: boolean;\n };\n};\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser<Geoid, never, PGMLoaderOptions> = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options?.pgm || {}),\n extensions: ['pgm'],\n options: {\n pgm: {\n cubic: false\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAMC,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,QAAQ;AAapE,IAAMC,SAA2D,GAAG;EACzEC,IAAI,EAAE,qCAAqC;EAC3CC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,0BAA0B,CAAC;EACvCC,KAAK;IAAA,IAAAC,MAAA,OAAAC,kBAAA,CAAAC,OAAA,EAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAAE,SAAAC,QAAOC,WAAW,EAAEC,OAAO;MAAA,OAAAJ,YAAA,CAAAD,OAAA,CAAAM,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAA,OAAAF,QAAA,CAAAG,MAAA,WAAK,IAAAC,eAAQ,EAAC,IAAIC,UAAU,CAACT,WAAW,CAAC,EAAE,CAAAC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAES,GAAG,KAAI,CAAC,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAN,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAZ,OAAA;IAAA;IAAA,SAAAN,MAAAmB,EAAA,EAAAC,GAAA;MAAA,OAAAnB,MAAA,CAAAoB,KAAA,OAAAC,SAAA;IAAA;IAAA,OAAAtB,KAAA;EAAA;EAChGuB,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBf,OAAO,EAAE;IACPS,GAAG,EAAE;MACHO,KAAK,EAAE;IACT;EACF;AACF,CAAC;AAACC,OAAA,CAAA/B,SAAA,GAAAA,SAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-i3s.js","names":["load","I3SLoader","loadI3SContent","sourceTileset","sourceTile","tilesetLoadOptions","contentUrl","loadOptions","i3s","isTileset","isTileHeader","_tileOptions","attributeUrls","textureUrl","textureFormat","textureLoaderOptions","materialDefinition","isDracoGeometry","mbs","_tilesetOptions","store","attributeStorageInfo","fields","tileContent"],"sources":["../../../../src/3d-tiles-converter/helpers/load-i3s.ts"],"sourcesContent":["import {load} from '@loaders.gl/core';\nimport {\n I3STileContent,\n I3STileHeader,\n I3STilesetHeader,\n I3SLoader,\n I3SLoaderOptions\n} from '@loaders.gl/i3s';\n\n/**\n * Load I3S node content\n * @param sourceTileset - source layer JSON\n * @param sourceTile - source I3S node metadata\n * @param tilesetLoadOptions - load options for Tiles3DLoader\n * @returns - 3DTiles tile content or null\n */\nexport const loadI3SContent = async (\n sourceTileset: I3STilesetHeader | null,\n sourceTile: I3STileHeader,\n tilesetLoadOptions: I3SLoaderOptions\n): Promise<I3STileContent | null> => {\n if (!sourceTileset || !sourceTile.contentUrl) {\n return null;\n }\n\n const loadOptions = {\n ...tilesetLoadOptions,\n i3s: {\n ...tilesetLoadOptions.i3s,\n isTileset: false,\n isTileHeader: false,\n _tileOptions: {\n attributeUrls: sourceTile.attributeUrls,\n textureUrl: sourceTile.textureUrl,\n textureFormat: sourceTile.textureFormat,\n textureLoaderOptions: sourceTile.textureLoaderOptions,\n materialDefinition: sourceTile.materialDefinition,\n isDracoGeometry: sourceTile.isDracoGeometry,\n mbs: sourceTile.mbs\n },\n _tilesetOptions: {\n store: sourceTileset.store,\n attributeStorageInfo: sourceTileset.attributeStorageInfo,\n fields: sourceTileset.fields\n }\n }\n };\n const tileContent = await load(sourceTile.contentUrl, I3SLoader, loadOptions);\n\n return tileContent;\n};\n"],"mappings":"AAAA,SAAQA,IAAI,QAAO,kBAAkB;AACrC,SAIEC,SAAS,QAEJ,iBAAiB;AASxB,OAAO,MAAMC,cAAc,GAAG,MAAAA,CAC5BC,aAAsC,EACtCC,UAAyB,EACzBC,kBAAoC,KACD;EACnC,IAAI,CAACF,aAAa,IAAI,CAACC,UAAU,CAACE,UAAU,EAAE;IAC5C,OAAO,IAAI;EACb;EAEA,MAAMC,WAAW,GAAG;IAClB,GAAGF,kBAAkB;IACrBG,GAAG,EAAE;MACH,GAAGH,kBAAkB,CAACG,GAAG;MACzBC,SAAS,EAAE,KAAK;MAChBC,YAAY,EAAE,KAAK;MACnBC,YAAY,EAAE;QACZC,aAAa,EAAER,UAAU,CAACQ,aAAa;QACvCC,UAAU,EAAET,UAAU,CAACS,UAAU;QACjCC,aAAa,EAAEV,UAAU,CAACU,aAAa;QACvCC,oBAAoB,EAAEX,UAAU,CAACW,oBAAoB;QACrDC,kBAAkB,EAAEZ,UAAU,CAACY,kBAAkB;QACjDC,eAAe,EAAEb,UAAU,CAACa,eAAe;QAC3CC,GAAG,EAAEd,UAAU,CAACc;MAClB,CAAC;MACDC,eAAe,EAAE;QACfC,KAAK,EAAEjB,aAAa,CAACiB,KAAK;QAC1BC,oBAAoB,EAAElB,aAAa,CAACkB,oBAAoB;QACxDC,MAAM,EAAEnB,aAAa,CAACmB;MACxB;IACF;EACF,CAAC;EACD,MAAMC,WAAW,GAAG,MAAMvB,IAAI,CAACI,UAAU,CAACE,UAAU,EAAEL,SAAS,EAAEM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"load-i3s.js","names":["load","I3SLoader","loadI3SContent","sourceTileset","sourceTile","tilesetLoadOptions","contentUrl","loadOptions","i3s","isTileset","isTileHeader","_tileOptions","attributeUrls","textureUrl","textureFormat","textureLoaderOptions","materialDefinition","isDracoGeometry","mbs","_tilesetOptions","store","attributeStorageInfo","fields","tileContent"],"sources":["../../../../src/3d-tiles-converter/helpers/load-i3s.ts"],"sourcesContent":["import {load} from '@loaders.gl/core';\nimport {\n I3STileContent,\n I3STileHeader,\n I3STilesetHeader,\n I3SLoader,\n I3SLoaderOptions\n} from '@loaders.gl/i3s';\n\n/**\n * Load I3S node content\n * @param sourceTileset - source layer JSON\n * @param sourceTile - source I3S node metadata\n * @param tilesetLoadOptions - load options for Tiles3DLoader\n * @returns - 3DTiles tile content or null\n */\nexport const loadI3SContent = async (\n sourceTileset: I3STilesetHeader | null,\n sourceTile: I3STileHeader,\n tilesetLoadOptions: I3SLoaderOptions\n): Promise<I3STileContent | null> => {\n if (!sourceTileset || !sourceTile.contentUrl) {\n return null;\n }\n\n const loadOptions = {\n ...tilesetLoadOptions,\n i3s: {\n ...tilesetLoadOptions.i3s,\n isTileset: false,\n isTileHeader: false,\n _tileOptions: {\n attributeUrls: sourceTile.attributeUrls,\n textureUrl: sourceTile.textureUrl,\n textureFormat: sourceTile.textureFormat,\n textureLoaderOptions: sourceTile.textureLoaderOptions,\n materialDefinition: sourceTile.materialDefinition,\n isDracoGeometry: sourceTile.isDracoGeometry,\n mbs: sourceTile.mbs\n },\n _tilesetOptions: {\n store: sourceTileset.store,\n attributeStorageInfo: sourceTileset.attributeStorageInfo,\n fields: sourceTileset.fields\n }\n }\n };\n const tileContent = await load(sourceTile.contentUrl, I3SLoader, loadOptions);\n\n // @ts-expect-error\n return tileContent;\n};\n"],"mappings":"AAAA,SAAQA,IAAI,QAAO,kBAAkB;AACrC,SAIEC,SAAS,QAEJ,iBAAiB;AASxB,OAAO,MAAMC,cAAc,GAAG,MAAAA,CAC5BC,aAAsC,EACtCC,UAAyB,EACzBC,kBAAoC,KACD;EACnC,IAAI,CAACF,aAAa,IAAI,CAACC,UAAU,CAACE,UAAU,EAAE;IAC5C,OAAO,IAAI;EACb;EAEA,MAAMC,WAAW,GAAG;IAClB,GAAGF,kBAAkB;IACrBG,GAAG,EAAE;MACH,GAAGH,kBAAkB,CAACG,GAAG;MACzBC,SAAS,EAAE,KAAK;MAChBC,YAAY,EAAE,KAAK;MACnBC,YAAY,EAAE;QACZC,aAAa,EAAER,UAAU,CAACQ,aAAa;QACvCC,UAAU,EAAET,UAAU,CAACS,UAAU;QACjCC,aAAa,EAAEV,UAAU,CAACU,aAAa;QACvCC,oBAAoB,EAAEX,UAAU,CAACW,oBAAoB;QACrDC,kBAAkB,EAAEZ,UAAU,CAACY,kBAAkB;QACjDC,eAAe,EAAEb,UAAU,CAACa,eAAe;QAC3CC,GAAG,EAAEd,UAAU,CAACc;MAClB,CAAC;MACDC,eAAe,EAAE;QACfC,KAAK,EAAEjB,aAAa,CAACiB,KAAK;QAC1BC,oBAAoB,EAAElB,aAAa,CAACkB,oBAAoB;QACxDC,MAAM,EAAEnB,aAAa,CAACmB;MACxB;IACF;EACF,CAAC;EACD,MAAMC,WAAW,GAAG,MAAMvB,IAAI,CAACI,UAAU,CAACE,UAAU,EAAEL,SAAS,EAAEM,WAAW,CAAC;EAG7E,OAAOgB,WAAW;AACpB,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { join } from 'path';
|
|
|
5
5
|
import { ChildProcessProxy } from '@loaders.gl/worker-utils';
|
|
6
6
|
import { DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS } from '@loaders.gl/draco';
|
|
7
7
|
import { BASIS_EXTERNAL_LIBRARIES } from '@loaders.gl/textures';
|
|
8
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
8
|
+
const VERSION = typeof "4.0.0-alpha.24" !== 'undefined' ? "4.0.0-alpha.24" : 'beta';
|
|
9
9
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
10
10
|
export class DepsInstaller {
|
|
11
11
|
async install() {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export function flattenPropertyTableByFeatureIds(
|
|
1
|
+
export function flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable) {
|
|
2
2
|
const resultPropertyTable = {};
|
|
3
3
|
for (const propertyName in propertyTable) {
|
|
4
4
|
const properties = propertyTable[propertyName];
|
|
5
|
-
resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties,
|
|
5
|
+
resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIdsMap);
|
|
6
6
|
}
|
|
7
7
|
return resultPropertyTable;
|
|
8
8
|
}
|
|
9
|
-
function getPropertiesByFeatureIds(properties,
|
|
9
|
+
function getPropertiesByFeatureIds(properties, featureIdsMap) {
|
|
10
10
|
const resultProperties = [];
|
|
11
11
|
if (properties) {
|
|
12
|
-
for (const
|
|
13
|
-
const property = properties[
|
|
12
|
+
for (const featureIdKey in featureIdsMap) {
|
|
13
|
+
const property = properties[featureIdKey] || null;
|
|
14
14
|
resultProperties.push(property);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-attributes.js","names":["flattenPropertyTableByFeatureIds","featureIds","propertyTable","resultPropertyTable","propertyName","properties","getPropertiesByFeatureIds","resultProperties","featureId","property","push","checkPropertiesLength","needFlatten","attribute","Object","values","length","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","getAttributeType","key","Number","isInteger","createdStorageAttribute","attributeIndex","attributeType","storageAttribute","concat","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 featureIds.\n * If there is no property value for particular featureId (index) the property will be null.\n * Example:\n * Initial data:\n * OBJECTID: [0, 1, 5]\n * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']\n * Result:\n * OBJECTID: [0, 1, 5]\n * component: ['Windows', 'Frames', 'null']\n * @param featureIds\n * @param propertyTable\n */\nexport function flattenPropertyTableByFeatureIds(\n featureIds: 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, featureIds);\n }\n\n return resultPropertyTable;\n}\n\n/**\n * Getting properties by featureId index\n * @param properties\n * @param featureIds\n */\nfunction getPropertiesByFeatureIds(properties: unknown[], featureIds: number[]): unknown[] {\n const resultProperties: unknown[] = [];\n\n if (properties) {\n for (const featureId of featureIds) {\n const property = properties[featureId] || 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's type in propertyTable\n */\nexport function getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\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,UAAoB,EACpBC,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,UAAU,CAAC;EACvF;EAEA,OAAOE,mBAAmB;AAC5B;AAOA,SAASG,yBAAyBA,CAACD,UAAqB,EAAEJ,UAAoB,EAAa;EACzF,MAAMM,gBAA2B,GAAG,EAAE;EAEtC,IAAIF,UAAU,EAAE;IACd,KAAK,MAAMG,SAAS,IAAIP,UAAU,EAAE;MAClC,MAAMQ,QAAQ,GAAGJ,UAAU,CAACG,SAAS,CAAC,IAAI,IAAI;MAC9CD,gBAAgB,CAACG,IAAI,CAACD,QAAQ,CAAC;IACjC;EACF;EAEA,OAAOF,gBAAgB;AACzB;AASA,OAAO,SAASI,qBAAqBA,CACnCV,UAAoB,EACpBC,aAA+B,EACtB;EACT,IAAIU,WAAW,GAAG,KAAK;EAEvB,KAAK,MAAMC,SAAS,IAAIC,MAAM,CAACC,MAAM,CAACb,aAAa,CAAC,EAAE;IACpD,IAAI,CAACD,UAAU,IAAI,CAACY,SAAS,IAAIZ,UAAU,CAACe,MAAM,KAAKH,SAAS,CAACG,MAAM,EAAE;MACvEJ,WAAW,GAAG,IAAI;IACpB;EACF;EAEA,OAAOA,WAAW;AACpB;AAGA,MAAMK,WAAW,GAAG,QAAQ;AAE5B,MAAMC,cAAc,GAAG,OAAO;AAE9B,MAAMC,WAAW,GAAG,Q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GAAG;IACrCvB,SAAS,EAAE,QAAQ;IACnBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASC,gBAAgBA,CAACR,gBAAsC,EAAQ;EACtEA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,OAAO;IAClBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASG,oBAAoBA,CAACV,gBAAsC,EAAQ;EAC1EA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,SAAS;IACpBE,gBAAgB,EAAE;EACpB,CAAC;AACH"}
|
|
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","concat","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's type in propertyTable\n */\nexport function getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\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,CACh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AAa,EAAE;IAC/B8C,UAAU,CAACtC,IAAI,CAAC;MACdyC,SAAS,EAAE5B,GAAG;MACd6B,OAAO,EAAE,IAAI;MACbC,UAAU,EAAE,KAAK;MACjBC,KAAK,EAAE/B;IACT,CAAC,CAAC;EACJ;EACA0B,aAAa,CAACvC,IAAI,CAAC;IACjBsC,UAAU;IACVL,IAAI,EAAE;EACR,CAAC,CAAC;EAEF,OAAO;IACLG,KAAK;IACLC,UAAU;IACVE,aAAa;IACbD,UAAU;IACVE;EACF,CAAC;AACH;AAMA,SAASZ,oBAAoBA,CAACT,gBAAsC,EAAQ;EAE1EA,gBAAgB,CAACG,QAAQ,CAACuB,OAAO,CAAC,qBAAqB,CAAC;EACxD1B,gBAAgB,CAACI,MAAM,CAACvB,IAAI,CAAC;IAACD,QAAQ,EAAE,0BAA0B;IAAEyB,SAAS,EAAE;EAAQ,CAAC,CAAC;EACzFL,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,QAAQ;IACnBsB,QAAQ,EAAE,OAAO;IACjBpB,gBAAgB,EAAE;EACpB,CAAC;EACDP,gBAAgB,CAAC4B,mBAAmB,GAAG;IACrCvB,SAAS,EAAE,QAAQ;IACnBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASC,gBAAgBA,CAACR,gBAAsC,EAAQ;EACtEA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,OAAO;IAClBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASG,oBAAoBA,CAACV,gBAAsC,EAAQ;EAC1EA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,SAAS;IACpBE,gBAAgB,EAAE;EACpB,CAAC;AACH"}
|
|
@@ -91,6 +91,11 @@ function makeAttributeObjects(attributes) {
|
|
|
91
91
|
let colorsList = new Uint8Array(colors);
|
|
92
92
|
let texCoordsList = new Float32Array(texCoords);
|
|
93
93
|
let uvRegionsList = new Uint16Array(uvRegions);
|
|
94
|
+
let positionsOffset = 0;
|
|
95
|
+
let normalsOffset = 0;
|
|
96
|
+
let colorsOffset = 0;
|
|
97
|
+
let uvRegionsOffset = 0;
|
|
98
|
+
let texCoordsOffset = 0;
|
|
94
99
|
for (let index = 0; index < featureIds.length; index++) {
|
|
95
100
|
const startIndex = faceRange[index * 2];
|
|
96
101
|
const endIndex = faceRange[index * 2 + 1];
|
|
@@ -101,19 +106,19 @@ function makeAttributeObjects(attributes) {
|
|
|
101
106
|
const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
|
|
102
107
|
groupedData.push({
|
|
103
108
|
featureId: featureIds[index],
|
|
104
|
-
positions: positionsList.
|
|
105
|
-
normals: normalsList.
|
|
106
|
-
colors: colorsList.
|
|
107
|
-
uvRegions: uvRegionsList.
|
|
108
|
-
texCoords: texCoordsList.
|
|
109
|
+
positions: positionsList.subarray(positionsOffset, positionsOffset + positionsCount),
|
|
110
|
+
normals: normalsList.subarray(normalsOffset, normalsOffset + normalsCount),
|
|
111
|
+
colors: colorsList.subarray(colorsOffset, colorsOffset + colorsCount),
|
|
112
|
+
uvRegions: uvRegionsList.subarray(uvRegionsOffset, uvRegionsOffset + uvRegionsCount),
|
|
113
|
+
texCoords: texCoordsList.subarray(texCoordsOffset, texCoordsOffset + texCoordsCount)
|
|
109
114
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
positionsOffset += positionsCount;
|
|
116
|
+
normalsOffset += normalsCount;
|
|
117
|
+
colorsOffset += colorsCount;
|
|
118
|
+
uvRegionsOffset += uvRegionsCount;
|
|
119
|
+
texCoordsOffset += texCoordsCount;
|
|
115
120
|
}
|
|
116
|
-
return groupedData
|
|
121
|
+
return groupedData;
|
|
117
122
|
}
|
|
118
123
|
function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
119
124
|
const itemsPerVertex4 = 4;
|
|
@@ -134,58 +139,95 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
function unifyObjectsByFeatureId(sortedData) {
|
|
137
|
-
const
|
|
138
|
-
for (
|
|
139
|
-
const
|
|
140
|
-
const existingObject = uniqueObjects.find(obj => obj.featureId === currentObject.featureId);
|
|
142
|
+
const groupedMetadata = [];
|
|
143
|
+
for (const data of sortedData) {
|
|
144
|
+
const existingObject = groupedMetadata.find(obj => obj.featureId === data.featureId);
|
|
141
145
|
if (existingObject) {
|
|
142
|
-
existingObject.
|
|
143
|
-
existingObject.normals = concatenateTypedArrays(existingObject.normals, currentObject.normals);
|
|
144
|
-
existingObject.colors = concatenateTypedArrays(existingObject.colors, currentObject.colors);
|
|
145
|
-
existingObject.texCoords = concatenateTypedArrays(existingObject.texCoords, currentObject.texCoords);
|
|
146
|
-
existingObject.uvRegions = concatenateTypedArrays(existingObject.uvRegions, currentObject.uvRegions);
|
|
146
|
+
existingObject.attributes.push(data);
|
|
147
147
|
} else {
|
|
148
|
-
|
|
148
|
+
groupedMetadata.push({
|
|
149
|
+
featureId: data.featureId,
|
|
150
|
+
attributes: [data]
|
|
151
|
+
});
|
|
149
152
|
}
|
|
150
153
|
}
|
|
154
|
+
const uniqueObjects = [];
|
|
155
|
+
for (const metatada of groupedMetadata) {
|
|
156
|
+
const attributes = concatenateAttributes(metatada.attributes);
|
|
157
|
+
uniqueObjects.push({
|
|
158
|
+
featureId: metatada.featureId,
|
|
159
|
+
...attributes
|
|
160
|
+
});
|
|
161
|
+
}
|
|
151
162
|
return uniqueObjects;
|
|
152
163
|
}
|
|
153
164
|
function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
154
165
|
const firstAttributeObject = unifiedObjects[0];
|
|
155
166
|
const featureIds = [firstAttributeObject.featureId || 0];
|
|
156
|
-
let positions = new Float32Array(firstAttributeObject.positions);
|
|
157
|
-
let normals = new Float32Array(firstAttributeObject.normals);
|
|
158
|
-
let colors = new Uint8Array(firstAttributeObject.colors);
|
|
159
|
-
let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);
|
|
160
|
-
let texCoords = new Float32Array(firstAttributeObject.texCoords);
|
|
161
167
|
const range = [0];
|
|
162
168
|
let objIndex = 0;
|
|
163
169
|
let sum = 0;
|
|
164
170
|
for (let index = 1; index < unifiedObjects.length; index++) {
|
|
165
171
|
const currentAttributesObject = unifiedObjects[index];
|
|
166
172
|
featureIds.push(currentAttributesObject.featureId || 0);
|
|
167
|
-
positions = concatenateTypedArrays(positions, currentAttributesObject.positions);
|
|
168
|
-
normals = concatenateTypedArrays(normals, currentAttributesObject.normals);
|
|
169
|
-
colors = concatenateTypedArrays(colors, currentAttributesObject.colors);
|
|
170
|
-
uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);
|
|
171
|
-
texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);
|
|
172
173
|
const groupedObject = unifiedObjects[objIndex];
|
|
173
174
|
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
|
|
174
175
|
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
|
|
175
176
|
sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
176
177
|
objIndex += 1;
|
|
177
178
|
}
|
|
178
|
-
|
|
179
|
+
const attributes = concatenateAttributes(unifiedObjects);
|
|
180
|
+
range.push(attributes.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
|
|
179
181
|
const faceRange = new Uint32Array(range);
|
|
180
182
|
return {
|
|
181
183
|
faceRange,
|
|
182
184
|
featureIds,
|
|
185
|
+
featureCount,
|
|
186
|
+
...attributes
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function concatenateAttributes(attributes) {
|
|
190
|
+
const positionGroups = attributes.map(_ref => {
|
|
191
|
+
let {
|
|
192
|
+
positions
|
|
193
|
+
} = _ref;
|
|
194
|
+
return positions;
|
|
195
|
+
});
|
|
196
|
+
const positions = positionGroups.length > 1 ? concatenateTypedArrays(...positionGroups) : positionGroups[0];
|
|
197
|
+
const normalGroups = attributes.map(_ref2 => {
|
|
198
|
+
let {
|
|
199
|
+
normals
|
|
200
|
+
} = _ref2;
|
|
201
|
+
return normals;
|
|
202
|
+
});
|
|
203
|
+
const normals = normalGroups.length > 1 ? concatenateTypedArrays(...normalGroups) : normalGroups[0];
|
|
204
|
+
const colorGroups = attributes.map(_ref3 => {
|
|
205
|
+
let {
|
|
206
|
+
colors
|
|
207
|
+
} = _ref3;
|
|
208
|
+
return colors;
|
|
209
|
+
});
|
|
210
|
+
const colors = colorGroups.length > 1 ? concatenateTypedArrays(...colorGroups) : colorGroups[0];
|
|
211
|
+
const texCoordGroups = attributes.map(_ref4 => {
|
|
212
|
+
let {
|
|
213
|
+
texCoords
|
|
214
|
+
} = _ref4;
|
|
215
|
+
return texCoords;
|
|
216
|
+
});
|
|
217
|
+
const texCoords = texCoordGroups.length > 1 ? concatenateTypedArrays(...texCoordGroups) : texCoordGroups[0];
|
|
218
|
+
const uvRegionGroups = attributes.map(_ref5 => {
|
|
219
|
+
let {
|
|
220
|
+
uvRegions
|
|
221
|
+
} = _ref5;
|
|
222
|
+
return uvRegions;
|
|
223
|
+
});
|
|
224
|
+
const uvRegions = uvRegionGroups.length > 1 ? concatenateTypedArrays(...uvRegionGroups) : uvRegionGroups[0];
|
|
225
|
+
return {
|
|
183
226
|
positions,
|
|
184
227
|
normals,
|
|
185
228
|
colors,
|
|
186
|
-
uvRegions,
|
|
187
229
|
texCoords,
|
|
188
|
-
|
|
230
|
+
uvRegions
|
|
189
231
|
};
|
|
190
232
|
}
|
|
191
233
|
//# sourceMappingURL=geometry-attributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-attributes.js","names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","uvRegions","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","data","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","getFrequentValue","slice","faceRangeList","uniqueFeatureIds","index","newFeatureId","includes","push","values","map","mostFrequentValue","maxCount","value","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","uvRegionsList","Uint16Array","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","uvRegionsCount","texCoordsCount","featureId","sort","first","second","attributeName","itemsPerVertex4","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existingObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"sourcesContent":["import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';\nimport {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param attributes\n * @returns attirbutes with featureCount, featureIds and changed faceRange.\n */\nexport function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {\n const {positions, normals, texCoords, colors, uvRegions, featureIndices} = attributes;\n const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors,\n uvRegions\n };\n }\n\n const data = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({...data, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds,\n data.featureCount\n );\n return groupedAttributes;\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param featureIndices\n * @returns Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {\n faceRange: Uint32Array;\n featureCount: number;\n featureIds: number[];\n} {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {\n const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));\n if (currentFeatureId !== newFeatureId) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = newFeatureId;\n\n if (!uniqueFeatureIds.includes(newFeatureId)) {\n uniqueFeatureIds.push(newFeatureId);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = newFeatureId;\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).\n * @param values\n */\nfunction getFrequentValue(values: number[]): number {\n const map: {[key: number]: number} = {};\n\n let mostFrequentValue = values[0];\n let maxCount = 1;\n\n for (const value of values) {\n // Save item and it's frequency count to the map.\n map[value] = (map[value] || 0) + 1;\n // Find max count of frequency.\n maxCount = maxCount > map[value] ? maxCount : map[value];\n // Find the most frequent value.\n mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;\n }\n\n return mostFrequentValue;\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param attributes\n * @returns sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {\n const {\n featureIds,\n positions,\n normals,\n colors,\n uvRegions,\n texCoords,\n faceRange = new Uint32Array(0)\n } = attributes;\n const groupedData: GroupedByFeatureIdAttributes[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n let uvRegionsList = new Uint16Array(uvRegions);\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index * 2];\n const endIndex = faceRange[index * 2 + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n uvRegions: uvRegionsList.slice(0, uvRegionsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n uvRegionsList = uvRegionsList.slice(uvRegionsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param attributeName\n * @param startIndex\n * @param endIndex\n * @returns sliced count\n */\nfunction getSliceAttributeCount(\n attributeName: string,\n startIndex: number,\n endIndex: number\n): number {\n const itemsPerVertex4 = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n case 'uvRegions':\n return vertexCount * itemsPerVertex4;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param sortedData\n * @returns unique list of objects\n */\nfunction unifyObjectsByFeatureId(\n sortedData: GroupedByFeatureIdAttributes[]\n): GroupedByFeatureIdAttributes[] {\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existingObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existingObject) {\n existingObject.positions = concatenateTypedArrays(\n existingObject.positions,\n currentObject.positions\n );\n existingObject.normals = concatenateTypedArrays(\n existingObject.normals,\n currentObject.normals\n );\n existingObject.colors = concatenateTypedArrays(existingObject.colors, currentObject.colors);\n existingObject.texCoords = concatenateTypedArrays(\n existingObject.texCoords,\n currentObject.texCoords\n );\n existingObject.uvRegions = concatenateTypedArrays(\n existingObject.uvRegions,\n currentObject.uvRegions\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param unifiedObjects\n * @returns generated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(\n unifiedObjects: GroupedByFeatureIdAttributes[],\n featureCount: number\n): GeometryAttributes {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId || 0];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId || 0);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount};\n}\n"],"mappings":"AACA,SAAQA,sBAAsB,QAAO,0BAA0B;AAE/D,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kCAAkC,GAAG,CAAC;AAO5C,OAAO,SAASC,kBAAkBA,CAACC,UAA+B,EAAsB;EACtF,MAAM;IAACC,SAAS;IAAEC,OAAO;IAAEC,SAAS;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGN,UAAU;EACrF,MAAMO,aAAa,GAAGN,SAAS,CAACO,MAAM,GAAGV,kCAAkC;EAE3E,IAAI,CAACQ,cAAc,CAACE,MAAM,EAAE;IAC1B,OAAO;MACLC,SAAS,EAAE,IAAIC,WAAW,CAAC,CAAC,CAAC,EAAEH,aAAa,GAAG,CAAC,CAAC,CAAC;MAClDI,UAAU,EAAE,CAAC,CAAC,CAAC;MACfC,YAAY,EAAE,CAAC;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AAa,CAAC1E,SAAS,CAACO,MAAM,GAAGV,kCAAkC,GAAG2E,GAAG,CAAC;IAErFA,GAAG,IAAIE,aAAa,CAAC1E,SAAS,CAACO,MAAM,GAAGV,kCAAkC;IAC1E0E,QAAQ,IAAI,CAAC;EACf;EAEAD,KAAK,CAACxC,IAAI,CAAC9B,SAAS,CAACO,MAAM,GAAGV,kCAAkC,GAAG,CAAC,CAAC;EAErE,MAAMW,SAAS,GAAG,IAAIC,WAAW,CAAC6D,KAAK,CAAC;EACxC,OAAO;IAAC9D,SAAS;IAAEE,UAAU;IAAEV,SAAS;IAAEC,OAAO;IAAEE,MAAM;IAAEC,SAAS;IAAEF,SAAS;IAAES;EAAY,CAAC;AAChG"}
|
|
1
|
+
{"version":3,"file":"geometry-attributes.js","names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","uvRegions","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","data","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","getFrequentValue","slice","faceRangeList","uniqueFeatureIds","index","newFeatureId","includes","push","values","map","mostFrequentValue","maxCount","value","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","uvRegionsList","Uint16Array","positionsOffset","normalsOffset","colorsOffset","uvRegionsOffset","texCoordsOffset","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","uvRegionsCount","texCoordsCount","featureId","subarray","attributeName","itemsPerVertex4","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","groupedMetadata","existingObject","find","obj","uniqueObjects","metatada","concatenateAttributes","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject","positionGroups","_ref","normalGroups","_ref2","colorGroups","_ref3","texCoordGroups","_ref4","uvRegionGroups","_ref5"],"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"sourcesContent":["import type {\n GeometryAttributes,\n ConvertedAttributes,\n GroupedByFeatureIdAttributes,\n GroupedAttributes\n} from '../types';\nimport {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param attributes\n * @returns attirbutes with featureCount, featureIds and changed faceRange.\n */\nexport function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {\n const {positions, normals, texCoords, colors, uvRegions, featureIndices} = attributes;\n const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors,\n uvRegions\n };\n }\n\n const data = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({...data, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds,\n data.featureCount\n );\n return groupedAttributes;\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param featureIndices\n * @returns Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {\n faceRange: Uint32Array;\n featureCount: number;\n featureIds: number[];\n} {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {\n const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));\n if (currentFeatureId !== newFeatureId) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = newFeatureId;\n\n if (!uniqueFeatureIds.includes(newFeatureId)) {\n uniqueFeatureIds.push(newFeatureId);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = newFeatureId;\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).\n * @param values\n */\nfunction getFrequentValue(values: number[]): number {\n const map: {[key: number]: number} = {};\n\n let mostFrequentValue = values[0];\n let maxCount = 1;\n\n for (const value of values) {\n // Save item and it's frequency count to the map.\n map[value] = (map[value] || 0) + 1;\n // Find max count of frequency.\n maxCount = maxCount > map[value] ? maxCount : map[value];\n // Find the most frequent value.\n mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;\n }\n\n return mostFrequentValue;\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param attributes\n * @returns sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {\n const {\n featureIds,\n positions,\n normals,\n colors,\n uvRegions,\n texCoords,\n faceRange = new Uint32Array(0)\n } = attributes;\n const groupedData: GroupedByFeatureIdAttributes[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n let uvRegionsList = new Uint16Array(uvRegions);\n let positionsOffset = 0;\n let normalsOffset = 0;\n let colorsOffset = 0;\n let uvRegionsOffset = 0;\n let texCoordsOffset = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index * 2];\n const endIndex = faceRange[index * 2 + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.subarray(positionsOffset, positionsOffset + positionsCount),\n normals: normalsList.subarray(normalsOffset, normalsOffset + normalsCount),\n colors: colorsList.subarray(colorsOffset, colorsOffset + colorsCount),\n uvRegions: uvRegionsList.subarray(uvRegionsOffset, uvRegionsOffset + uvRegionsCount),\n texCoords: texCoordsList.subarray(texCoordsOffset, texCoordsOffset + texCoordsCount)\n });\n\n positionsOffset += positionsCount;\n normalsOffset += normalsCount;\n colorsOffset += colorsCount;\n uvRegionsOffset += uvRegionsCount;\n texCoordsOffset += texCoordsCount;\n }\n\n return groupedData;\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param attributeName\n * @param startIndex\n * @param endIndex\n * @returns sliced count\n */\nfunction getSliceAttributeCount(\n attributeName: string,\n startIndex: number,\n endIndex: number\n): number {\n const itemsPerVertex4 = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n case 'uvRegions':\n return vertexCount * itemsPerVertex4;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param sortedData\n * @returns unique list of objects\n */\nfunction unifyObjectsByFeatureId(\n sortedData: GroupedByFeatureIdAttributes[]\n): GroupedByFeatureIdAttributes[] {\n const groupedMetadata: {\n featureId: number;\n attributes: GroupedByFeatureIdAttributes[];\n }[] = [];\n for (const data of sortedData) {\n const existingObject = groupedMetadata.find((obj) => obj.featureId === data.featureId);\n if (existingObject) {\n existingObject.attributes.push(data);\n } else {\n groupedMetadata.push({\n featureId: data.featureId,\n attributes: [data]\n });\n }\n }\n\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n for (const metatada of groupedMetadata) {\n const attributes = concatenateAttributes(metatada.attributes);\n\n uniqueObjects.push({\n featureId: metatada.featureId,\n ...attributes\n });\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param unifiedObjects\n * @returns generated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(\n unifiedObjects: GroupedByFeatureIdAttributes[],\n featureCount: number\n): GeometryAttributes {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId || 0];\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId || 0);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n const attributes = concatenateAttributes(unifiedObjects);\n\n range.push(attributes.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, featureCount, ...attributes};\n}\n\n/**\n * Concatenate attributes typed arrays\n * @param attributes - grouped by featureId typed arrays\n * @returns - concatenated typed array list\n */\nfunction concatenateAttributes(attributes: GroupedByFeatureIdAttributes[]): GroupedAttributes {\n const positionGroups = attributes.map(({positions}) => positions);\n const positions =\n positionGroups.length > 1 ? concatenateTypedArrays(...positionGroups) : positionGroups[0];\n\n const normalGroups = attributes.map(({normals}) => normals);\n const normals =\n normalGroups.length > 1 ? concatenateTypedArrays(...normalGroups) : normalGroups[0];\n\n const colorGroups = attributes.map(({colors}) => colors);\n const colors = colorGroups.length > 1 ? concatenateTypedArrays(...colorGroups) : colorGroups[0];\n\n const texCoordGroups = attributes.map(({texCoords}) => texCoords);\n const texCoords =\n texCoordGroups.length > 1 ? concatenateTypedArrays(...texCoordGroups) : texCoordGroups[0];\n\n const uvRegionGroups = attributes.map(({uvRegions}) => uvRegions);\n const uvRegions =\n uvRegionGroups.length > 1 ? concatenateTypedArrays(...uvRegionGroups) : uvRegionGroups[0];\n return {\n positions,\n normals,\n colors,\n texCoords,\n uvRegions\n };\n}\n"],"mappings":"AAMA,SAAQA,sBAAsB,QAAO,0BAA0B;AAE/D,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kCAAkC,GAAG,CAAC;AAO5C,OAAO,SAASC,kBAAkBA,CAACC,UAA+B,EAAsB;EACtF,MAAM;IAACC,SAAS;IAAEC,OAAO;IAAEC,SAAS;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGN,UAAU;EACrF,MAAMO,aAAa,GAAGN,SAAS,CAACO,MAAM,GAAGV,kCAAkC;EAE3E,IAAI,CAACQ,cAAc,CAACE,MAAM,EAAE;IAC1B,OAAO;MACLC,SAAS,EAAE,IAAIC,WAAW,CAAC,CAAC,CAAC,EAAEH,aAAa,GAAG,CAAC,CAAC,CAAC;MAClDI,UAAU,EAAE,CAAC,CAAC,CAAC;MACfC,YAAY,EAAE,CAAC;MACfX,SAAS;MACTC,OAAO;MACPC,SAAS;MACTC,MAAM;MACNC;IACF,CAAC;EACH;EAEA,MAAMQ,IAAI,GAAGC,mCAAmC,CAACR,cAAc,CAAC;EAChE,MAAMS,gBAAgB,GAAGC,oBAAoB,CAAC;IAAC,GAAGH,I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WAAW,CAAC7E,MAAM,GAAG,CAAC,GAAGZ,sBAAsB,CAAC,GAAGyF,WAAW,CAAC,GAAGA,WAAW,CAAC,CAAC,CAAC;EAE/F,MAAME,cAAc,GAAGvF,UAAU,CAACiC,GAAG,CAACuD,KAAA;IAAA,IAAC;MAACrF;IAAS,CAAC,GAAAqF,KAAA;IAAA,OAAKrF,SAAS;EAAA,EAAC;EACjE,MAAMA,SAAS,GACboF,cAAc,CAAC/E,MAAM,GAAG,CAAC,GAAGZ,sBAAsB,CAAC,GAAG2F,cAAc,CAAC,GAAGA,cAAc,CAAC,CAAC,CAAC;EAE3F,MAAME,cAAc,GAAGzF,UAAU,CAACiC,GAAG,CAACyD,KAAA;IAAA,IAAC;MAACrF;IAAS,CAAC,GAAAqF,KAAA;IAAA,OAAKrF,SAAS;EAAA,EAAC;EACjE,MAAMA,SAAS,GACboF,cAAc,CAACjF,MAAM,GAAG,CAAC,GAAGZ,sBAAsB,CAAC,GAAG6F,cAAc,CAAC,GAAGA,cAAc,CAAC,CAAC,CAAC;EAC3F,OAAO;IACLxF,SAAS;IACTC,OAAO;IACPE,MAAM;IACND,SAAS;IACTE;EACF,CAAC;AACH"}
|
|
@@ -107,8 +107,9 @@ async function _makeNodeResources(_ref) {
|
|
|
107
107
|
texCoords,
|
|
108
108
|
featureCount
|
|
109
109
|
} = generateAttributes(convertedAttributes);
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
let featureIdsMap = {};
|
|
111
|
+
if (propertyTable) {
|
|
112
|
+
featureIdsMap = makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, propertyTable);
|
|
112
113
|
}
|
|
113
114
|
const header = new Uint32Array(2);
|
|
114
115
|
const typedFeatureIds = generateBigUint64Array(featureIds);
|
|
@@ -125,7 +126,7 @@ async function _makeNodeResources(_ref) {
|
|
|
125
126
|
}, libraries) : null;
|
|
126
127
|
let attributes = [];
|
|
127
128
|
if (attributeStorageInfo && propertyTable) {
|
|
128
|
-
attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
|
|
129
|
+
attributes = convertPropertyTableToAttributeBuffers(featureIds, featureIdsMap, propertyTable, attributeStorageInfo);
|
|
129
130
|
}
|
|
130
131
|
return {
|
|
131
132
|
nodeId,
|
|
@@ -663,6 +664,7 @@ function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, bat
|
|
|
663
664
|
const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
|
|
664
665
|
replaceIndicesByUnique(featureIndices, replaceMap);
|
|
665
666
|
replaceIndicesByUnique(featureIds, replaceMap);
|
|
667
|
+
return replaceMap;
|
|
666
668
|
}
|
|
667
669
|
function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
|
|
668
670
|
const featureMap = {};
|
|
@@ -693,10 +695,10 @@ function replaceIndicesByUnique(indicesArray, featureMap) {
|
|
|
693
695
|
indicesArray[index] = featureMap[indicesArray[index]];
|
|
694
696
|
}
|
|
695
697
|
}
|
|
696
|
-
function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo) {
|
|
698
|
+
function convertPropertyTableToAttributeBuffers(featureIds, featureIdsMap, propertyTable, attributeStorageInfo) {
|
|
697
699
|
const attributeBuffers = [];
|
|
698
700
|
const needFlattenPropertyTable = checkPropertiesLength(featureIds, propertyTable);
|
|
699
|
-
const properties = needFlattenPropertyTable ? flattenPropertyTableByFeatureIds(
|
|
701
|
+
const properties = needFlattenPropertyTable ? flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable) : propertyTable;
|
|
700
702
|
const propertyTableWithObjectIds = {
|
|
701
703
|
OBJECTID: featureIds,
|
|
702
704
|
...properties
|