From a6f2d25642a61369c1b939f0f5d1c39e61db2ed3 Mon Sep 17 00:00:00 2001 From: Paul Connelly <22944042+pmconne@users.noreply.github.com> Date: Tue, 5 Mar 2024 11:19:03 -0500 Subject: [PATCH] Add an iterator over the entries of BatchTableProperties (#6488) --- common/api/core-frontend.api.md | 11 ++++++++++- common/api/summary/core-frontend.exports.csv | 2 +- .../pmc-batch-table-iterator_2024-03-05-15-37.json | 10 ++++++++++ core/frontend/src/tile/BatchedTileIdMap.ts | 13 ++++++++++++- core/frontend/src/tile/RealityTileTree.ts | 3 +++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 common/changes/@itwin/core-frontend/pmc-batch-table-iterator_2024-03-05-15-37.json diff --git a/common/api/core-frontend.api.md b/common/api/core-frontend.api.md index c4dea44f26d1..3ec60b89159f 100644 --- a/common/api/core-frontend.api.md +++ b/common/api/core-frontend.api.md @@ -1713,8 +1713,13 @@ export abstract class BaseUnitFormattingSettingsProvider implements UnitFormatti } // @internal -export class BatchedTileIdMap { +export class BatchedTileIdMap implements BatchTableProperties { constructor(iModel: IModelConnection); + // (undocumented) + entries(): Iterable<{ + id: Id64String; + properties: Record; + }>; getBatchId(properties: any): Id64String; // (undocumented) getFeatureProperties(id: Id64String): Record | undefined; @@ -1732,6 +1737,10 @@ export interface BatchOptions { // @beta export interface BatchTableProperties { + entries(): Iterable<{ + id: Id64String; + properties: Record; + }>; getFeatureProperties(id: Id64String): Record | undefined; } diff --git a/common/api/summary/core-frontend.exports.csv b/common/api/summary/core-frontend.exports.csv index 2f6c684961a7..baff49dd1711 100644 --- a/common/api/summary/core-frontend.exports.csv +++ b/common/api/summary/core-frontend.exports.csv @@ -76,7 +76,7 @@ internal;AzureMapsLayerImageryProvider internal;B3dmReader internal;BackgroundMapGeometry beta;class BaseUnitFormattingSettingsProvider -internal;BatchedTileIdMap +internal;BatchedTileIdMap public;BatchOptions beta;BatchTableProperties public;BeButton diff --git a/common/changes/@itwin/core-frontend/pmc-batch-table-iterator_2024-03-05-15-37.json b/common/changes/@itwin/core-frontend/pmc-batch-table-iterator_2024-03-05-15-37.json new file mode 100644 index 000000000000..de3d2e4cc81f --- /dev/null +++ b/common/changes/@itwin/core-frontend/pmc-batch-table-iterator_2024-03-05-15-37.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/core-frontend", + "comment": "Added an iterator over the entries in a BatchTableProperties.", + "type": "none" + } + ], + "packageName": "@itwin/core-frontend" +} \ No newline at end of file diff --git a/core/frontend/src/tile/BatchedTileIdMap.ts b/core/frontend/src/tile/BatchedTileIdMap.ts index 00a1dd9f93b5..c3f49b77d63d 100644 --- a/core/frontend/src/tile/BatchedTileIdMap.ts +++ b/core/frontend/src/tile/BatchedTileIdMap.ts @@ -8,13 +8,14 @@ import { assert, Id64String } from "@itwin/core-bentley"; import { IModelConnection } from "../IModelConnection"; +import { BatchTableProperties } from "./internal"; /** * Mapping between transient IDs assigned to 3D tiles "features" and batch table properties (and visa versa). * these properties may be present in batched tile sets. * @internal */ -export class BatchedTileIdMap { +export class BatchedTileIdMap implements BatchTableProperties { private readonly _iModel: IModelConnection; private _featureMap?: Map; private _idMap?: Map; @@ -47,4 +48,14 @@ export class BatchedTileIdMap { const props = this._idMap?.get(id); return typeof props === "object" ? props : undefined; } + + public * entries(): Iterable<{ id: Id64String, properties: Record }> { + if (this._idMap) { + for (const [id, properties] of this._idMap) { + if (typeof properties === "object") { + yield { id, properties }; + } + } + } + } } diff --git a/core/frontend/src/tile/RealityTileTree.ts b/core/frontend/src/tile/RealityTileTree.ts index 15166006c7a7..8a2599a20700 100644 --- a/core/frontend/src/tile/RealityTileTree.ts +++ b/core/frontend/src/tile/RealityTileTree.ts @@ -152,6 +152,9 @@ export interface BatchTableProperties { * @note Treat the JSON properties as read-only - do not modify them. */ getFeatureProperties(id: Id64String): Record | undefined; + + /** Obtain an iterator over all of the features in the batch table and their properties. */ + entries(): Iterable<{ id: Id64String, properties: Record }>; } /** @internal */