Skip to content

Commit

Permalink
Add an iterator over the entries of BatchTableProperties (#6488)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmconne authored Mar 5, 2024
1 parent 7de03ae commit a6f2d25
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
11 changes: 10 additions & 1 deletion common/api/core-frontend.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>;
}>;
getBatchId(properties: any): Id64String;
// (undocumented)
getFeatureProperties(id: Id64String): Record<string, any> | undefined;
Expand All @@ -1732,6 +1737,10 @@ export interface BatchOptions {

// @beta
export interface BatchTableProperties {
entries(): Iterable<{
id: Id64String;
properties: Record<string, any>;
}>;
getFeatureProperties(id: Id64String): Record<string, any> | undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion common/api/summary/core-frontend.exports.csv
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal;AzureMapsLayerImageryProvider
internal;B3dmReader
internal;BackgroundMapGeometry
beta;class BaseUnitFormattingSettingsProvider
internal;BatchedTileIdMap
internal;BatchedTileIdMap
public;BatchOptions
beta;BatchTableProperties
public;BeButton
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
13 changes: 12 additions & 1 deletion core/frontend/src/tile/BatchedTileIdMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, { id: Id64String, properties: any }>;
private _idMap?: Map<Id64String, any>;
Expand Down Expand Up @@ -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<string, any> }> {
if (this._idMap) {
for (const [id, properties] of this._idMap) {
if (typeof properties === "object") {
yield { id, properties };
}
}
}
}
}
3 changes: 3 additions & 0 deletions core/frontend/src/tile/RealityTileTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export interface BatchTableProperties {
* @note Treat the JSON properties as read-only - do not modify them.
*/
getFeatureProperties(id: Id64String): Record<string, any> | undefined;

/** Obtain an iterator over all of the features in the batch table and their properties. */
entries(): Iterable<{ id: Id64String, properties: Record<string, any> }>;
}

/** @internal */
Expand Down

0 comments on commit a6f2d25

Please sign in to comment.