UNPKG

@itwin/core-frontend

Version:
55 lines 2.1 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * 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 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.BatchedTileIdMap = void 0; const core_bentley_1 = require("@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. */ 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) { (0, core_bentley_1.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 }; } } } } } exports.BatchedTileIdMap = BatchedTileIdMap; //# sourceMappingURL=BatchedTileIdMap.js.map