UNPKG

@itwin/core-frontend

Version:
51 lines 1.92 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Tiles */ import { assert } from "@itwin/core-bentley"; /** * 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. */ export class BatchedTileIdMap { _iModel; _featureMap; _idMap; constructor(iModel) { this._iModel = iModel; } /** Obtains or allocates the Id64String corresponding to the supplied set of JSON properties. */ getBatchId(properties) { if (undefined === this._featureMap || undefined === this._idMap) { assert(undefined === this._featureMap && undefined === this._idMap); this._featureMap = new Map(); this._idMap = new Map(); } const key = JSON.stringify(properties); let entry = this._featureMap.get(key); if (undefined === entry) { const id = this._iModel.transientIds.getNext(); entry = { id, properties }; this._featureMap.set(key, entry); this._idMap.set(id, properties); } return entry.id; } getFeatureProperties(id) { const props = this._idMap?.get(id); return typeof props === "object" ? props : undefined; } *entries() { if (this._idMap) { for (const [id, properties] of this._idMap) { if (typeof properties === "object") { yield { id, properties }; } } } } } //# sourceMappingURL=BatchedTileIdMap.js.map