bruce-cesium 6.6.0 → 6.6.2

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.
@@ -12835,6 +12835,23 @@
12835
12835
  }, milliseconds);
12836
12836
  });
12837
12837
  }
12838
+ function createBoundsPolygonGeometry(bounds) {
12839
+ const ring = [
12840
+ `${bounds.west},${bounds.south}`,
12841
+ `${bounds.west},${bounds.north}`,
12842
+ `${bounds.east},${bounds.north}`,
12843
+ `${bounds.east},${bounds.south}`,
12844
+ `${bounds.west},${bounds.south}`
12845
+ ].join(" ");
12846
+ return {
12847
+ Polygon: [
12848
+ {
12849
+ Facing: BModels.Geometry.EPolygonRingType.Boundaries,
12850
+ LinearRing: ring
12851
+ }
12852
+ ]
12853
+ };
12854
+ }
12838
12855
  /**
12839
12856
  * This is a batched entity getter.
12840
12857
  * It will scan for entity records in a view-area and emit them in batches.
@@ -12893,7 +12910,7 @@
12893
12910
  // We use this for refreshing historic data without having to repeat geographic queries.
12894
12911
  this.gatheredIntegrity = null;
12895
12912
  this.gatheredEntityIds = [];
12896
- const { api, viewer, viewPort, typeIds, schemaId, batchSize, attrFilter, historicAttrKey, historicInterpolation, historic, viaCdn, scenario } = params;
12913
+ const { api, viewer, viewPort, typeIds, schemaId, batchSize, attrFilter, historicAttrKey, historicInterpolation, historic, viaCdn, scenario, dataLab } = params;
12897
12914
  this.api = api;
12898
12915
  this.typeIds = typeIds;
12899
12916
  this.schemaId = schemaId;
@@ -12904,6 +12921,7 @@
12904
12921
  this.batchSize = isNaN(batchSize) ? 300 : batchSize;
12905
12922
  this.viewPort = viewPort;
12906
12923
  this.attrFilter = attrFilter;
12924
+ this.dataLab = dataLab;
12907
12925
  this.viewer = viewer;
12908
12926
  this.scenario = scenario ? scenario : 0;
12909
12927
  this.updateBounds();
@@ -12928,6 +12946,9 @@
12928
12946
  if (this.typeIds) {
12929
12947
  integrity += this.typeIds.join();
12930
12948
  }
12949
+ if (this.dataLab) {
12950
+ integrity += JSON.stringify(this.dataLab);
12951
+ }
12931
12952
  return integrity;
12932
12953
  }
12933
12954
  viewAreaSub() {
@@ -13034,6 +13055,22 @@
13034
13055
  delete this.registeredItems[menuItemId];
13035
13056
  this.updateState(true);
13036
13057
  }
13058
+ Dispose() {
13059
+ var _a, _b, _c, _d;
13060
+ this.registeredItems = {};
13061
+ this.getterLoopId += 1;
13062
+ for (const key in this.getterLoopAbortControllers) {
13063
+ this.getterLoopAbortControllers[key].abort();
13064
+ }
13065
+ this.getterLoopAbortControllers = {};
13066
+ (_a = this.historicRefreshAbortController) === null || _a === void 0 ? void 0 : _a.abort();
13067
+ this.historicRefreshAbortController = null;
13068
+ this.viewAreaDispose();
13069
+ this.viewerDateTimeDispose();
13070
+ (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Clear();
13071
+ (_c = this.onStateUpdate) === null || _c === void 0 ? void 0 : _c.Clear();
13072
+ (_d = this.onScanUpdate) === null || _d === void 0 ? void 0 : _d.Clear();
13073
+ }
13037
13074
  updateBounds() {
13038
13075
  const viewRect = this.viewPort.GetBounds();
13039
13076
  const poi = this.viewPort.GetTarget();
@@ -13104,6 +13141,68 @@
13104
13141
  this.LastStateUpdates[status.msg] = status;
13105
13142
  (_a = this.onStateUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(status);
13106
13143
  }
13144
+ createDataLabQuery(bounds) {
13145
+ var _a;
13146
+ const dataLab = this.dataLab;
13147
+ const userItems = (dataLab === null || dataLab === void 0 ? void 0 : dataLab.queryItems) ? JSON.parse(JSON.stringify(dataLab.queryItems)) : [];
13148
+ const primaryKey = BModels.DataLab.EReqKey.Primary;
13149
+ const baseQuery = (dataLab === null || dataLab === void 0 ? void 0 : dataLab.query) ? JSON.parse(JSON.stringify(dataLab.query)) : {};
13150
+ const basePrimary = (_a = baseQuery === null || baseQuery === void 0 ? void 0 : baseQuery[primaryKey]) !== null && _a !== void 0 ? _a : {};
13151
+ const items = [
13152
+ {
13153
+ LogicOperator: "AND",
13154
+ AttributeValue: {
13155
+ AttributePath: "Bruce/Boundaries",
13156
+ OperandA: createBoundsPolygonGeometry(bounds),
13157
+ Operator: "intersects",
13158
+ ValueOption: "CONST"
13159
+ },
13160
+ key: "attribute"
13161
+ }
13162
+ ];
13163
+ if (userItems.length) {
13164
+ items.push({
13165
+ LogicOperator: "AND",
13166
+ Items: [],
13167
+ key: "subquery",
13168
+ Subquery: {
13169
+ Items: userItems
13170
+ }
13171
+ });
13172
+ }
13173
+ baseQuery[primaryKey] = {
13174
+ ...basePrimary,
13175
+ Items: items
13176
+ };
13177
+ baseQuery.Expand = "location,source";
13178
+ return baseQuery;
13179
+ }
13180
+ async getDataLabResponse(params) {
13181
+ var _a;
13182
+ const { bounds, pageIndex, pageSize, abortSignal } = params;
13183
+ const skip = pageIndex * pageSize;
13184
+ const data = await BModels.DataLab.Run({
13185
+ api: this.api,
13186
+ query: this.createDataLabQuery(bounds),
13187
+ skip,
13188
+ load: pageSize,
13189
+ migrated: true,
13190
+ req: {
13191
+ noCache: true,
13192
+ abortSignal
13193
+ }
13194
+ });
13195
+ const entities = (_a = data.entities) !== null && _a !== void 0 ? _a : [];
13196
+ const totalCount = data.totalCount;
13197
+ const nextPage = totalCount != null
13198
+ ? skip + entities.length < totalCount
13199
+ : entities.length >= pageSize;
13200
+ return {
13201
+ entities,
13202
+ nextPage,
13203
+ nextPageUrl: null
13204
+ };
13205
+ }
13107
13206
  startGetterLoop() {
13108
13207
  // Increase id so that existing loops stop.
13109
13208
  this.getterLoopId += 1;
@@ -13182,13 +13281,24 @@
13182
13281
  nextPage: false,
13183
13282
  nextPageUrl: null
13184
13283
  };
13185
- await exports.SharedGetters.Queue.Run("Loading Entities from Menu Item that loads Entity Type: " + this.typeIds, async () => {
13284
+ const queueName = this.dataLab
13285
+ ? "Loading DataLab Entities from Menu Item"
13286
+ : "Loading Entities from Menu Item that loads Entity Type: " + this.typeIds;
13287
+ await exports.SharedGetters.Queue.Run(queueName, async () => {
13186
13288
  var _a;
13187
13289
  if (abortController.signal.aborted || !((_a = this.GetMenuItems()) === null || _a === void 0 ? void 0 : _a.length)) {
13188
13290
  return;
13189
13291
  }
13292
+ if (this.dataLab) {
13293
+ response = await this.getDataLabResponse({
13294
+ bounds: curCell.GetBounds(),
13295
+ pageIndex: curCell.FetchPageIndex,
13296
+ pageSize: PAGE_SIZE,
13297
+ abortSignal: abortController.signal
13298
+ });
13299
+ }
13190
13300
  // API gave us a URL to use.
13191
- if (curCell.FetchURL) {
13301
+ else if (curCell.FetchURL) {
13192
13302
  const tmpResponse = await this.api.get(curCell.FetchURL, {
13193
13303
  abortSignal: abortController.signal,
13194
13304
  noCache: true
@@ -13458,6 +13568,9 @@
13458
13568
  cacheKey += params.historicAttrKey ? params.historicAttrKey : "";
13459
13569
  cacheKey += params.historic ? "true" : "false";
13460
13570
  cacheKey += params.scenario ? params.scenario : 0;
13571
+ if (params.dataLab) {
13572
+ cacheKey += JSON.stringify(params.dataLab);
13573
+ }
13461
13574
  if (params.historicAttrKey) {
13462
13575
  cacheKey += params.historicInterpolation ? "true" : "false";
13463
13576
  }
@@ -13488,6 +13601,7 @@
13488
13601
  historicInterpolation: params.historicInterpolation,
13489
13602
  viaCdn: params.cdn,
13490
13603
  scenario: params.scenario,
13604
+ dataLab: params.dataLab,
13491
13605
  });
13492
13606
  this.data[cacheKey] = getter;
13493
13607
  /**
@@ -14825,6 +14939,8 @@
14825
14939
  TilesetCadRenderManager.Manager = Manager;
14826
14940
  })(exports.TilesetCadRenderManager || (exports.TilesetCadRenderManager = {}));
14827
14941
 
14942
+ const BATCH_SIZE$3 = 500;
14943
+ const CHECK_BATCH_SIZE$2 = 250;
14828
14944
  (function (DataLabRenderManager) {
14829
14945
  class Manager {
14830
14946
  get Disposed() {
@@ -14832,7 +14948,18 @@
14832
14948
  }
14833
14949
  constructor(params) {
14834
14950
  this.getter = null;
14951
+ this.getterSub = null;
14835
14952
  this.disposed = false;
14953
+ this.renderedEntities = {};
14954
+ this.entityCheckQueue = null;
14955
+ this.entityCheckQueueIds = [];
14956
+ this.isRunningCheck = false;
14957
+ this.viewMonitorRemoval = null;
14958
+ this.renderQueue = [];
14959
+ this.renderQueueInterval = null;
14960
+ this.reRenderState = new EntityReRenderMaintainState();
14961
+ this.zoomControl = [];
14962
+ this.queryLoadId = 0;
14836
14963
  const { viewer, item, apiGetter, monitor, visualsRegister } = params;
14837
14964
  this.viewer = viewer;
14838
14965
  this.item = item;
@@ -14840,13 +14967,54 @@
14840
14967
  this.monitor = monitor;
14841
14968
  this.visualsManager = visualsRegister;
14842
14969
  }
14843
- Init() {
14970
+ Init(params) {
14844
14971
  var _a;
14845
14972
  if (this.disposed) {
14846
14973
  throw new Error("This manager has already been disposed.");
14847
14974
  }
14848
- if (!((_a = this.item.CameraZoomSettings) === null || _a === void 0 ? void 0 : _a.length)) {
14849
- this.item.CameraZoomSettings = [
14975
+ if (params === null || params === void 0 ? void 0 : params.item) {
14976
+ this.item = params.item;
14977
+ }
14978
+ this.queryLoadId += 1;
14979
+ const loadId = this.queryLoadId;
14980
+ this.unsetGetter();
14981
+ (_a = this.viewMonitorRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
14982
+ this.viewMonitorRemoval = null;
14983
+ clearInterval(this.renderQueueInterval);
14984
+ this.renderQueueInterval = null;
14985
+ this.renderQueue = [];
14986
+ this.renderedEntities = {};
14987
+ this.ensureSettings();
14988
+ this.visualsManager.RemoveRegos({
14989
+ menuItemId: this.item.id
14990
+ });
14991
+ this.setEntityCheckQueue();
14992
+ (async () => {
14993
+ var _a, _b, _c, _d;
14994
+ try {
14995
+ const { query } = await BModels.DataLab.Get({
14996
+ api: this.apiGetter.getApi(),
14997
+ queryId: this.item.DataLabQueryID,
14998
+ req: {
14999
+ noCache: true
15000
+ }
15001
+ });
15002
+ if (this.disposed || loadId != this.queryLoadId) {
15003
+ return;
15004
+ }
15005
+ const queryItems = (_d = (_b = (_a = query === null || query === void 0 ? void 0 : query.PrimarySelectionCriteria) === null || _a === void 0 ? void 0 : _a.Items) !== null && _b !== void 0 ? _b : (_c = query === null || query === void 0 ? void 0 : query[BModels.DataLab.EReqKey.Primary]) === null || _c === void 0 ? void 0 : _c.Items) !== null && _d !== void 0 ? _d : [];
15006
+ this.setGetter(queryItems);
15007
+ }
15008
+ catch (e) {
15009
+ console.error("Failed to initialise DataLab render manager:", e);
15010
+ }
15011
+ })();
15012
+ }
15013
+ ensureSettings() {
15014
+ var _a;
15015
+ this.zoomControl = this.item.CameraZoomSettings;
15016
+ if (!((_a = this.zoomControl) === null || _a === void 0 ? void 0 : _a.length)) {
15017
+ this.zoomControl = [
14850
15018
  {
14851
15019
  MinZoom: 0,
14852
15020
  MaxZoom: 200000,
@@ -14856,17 +15024,74 @@
14856
15024
  StyleID: 0
14857
15025
  }
14858
15026
  ];
15027
+ this.item.CameraZoomSettings = this.zoomControl;
14859
15028
  }
14860
15029
  this.renderPriority = this.item.renderPriority;
14861
15030
  if (this.renderPriority == null) {
14862
15031
  this.renderPriority = 3;
14863
15032
  }
14864
- // Perform the initial query and subscribe to updates
14865
- this.getter = new BatchedDataGetter.Getter([this.item.DataLabQueryID], this.monitor, 1);
14866
- this.getter.OnUpdate.Subscribe((queryIds) => {
14867
- this.onGetterUpdate(queryIds[0]);
15033
+ }
15034
+ setGetter(queryItems) {
15035
+ this.unsetGetter();
15036
+ this.getter = new EntityFilterGetter.Getter({
15037
+ api: this.apiGetter.getApi(),
15038
+ attrFilter: {},
15039
+ batchSize: BATCH_SIZE$3,
15040
+ typeIds: null,
15041
+ viewPort: this.monitor,
15042
+ viewer: this.viewer,
15043
+ dataLab: {
15044
+ queryItems: queryItems !== null && queryItems !== void 0 ? queryItems : []
15045
+ }
14868
15046
  });
14869
- this.getter.Start();
15047
+ const minMax = exports.RenderManager.GetZoomMinMax({
15048
+ zoomControl: this.zoomControl
15049
+ });
15050
+ this.getter.IncludeMenuItem(this.item.id, null, [], minMax[0], minMax[1]);
15051
+ this.getterSub = this.getter.OnUpdate.Subscribe((data) => {
15052
+ var _a;
15053
+ if (!((_a = data === null || data === void 0 ? void 0 : data.entities) === null || _a === void 0 ? void 0 : _a.length)) {
15054
+ return;
15055
+ }
15056
+ this.distributeForRender(data.entities);
15057
+ });
15058
+ }
15059
+ unsetGetter() {
15060
+ var _a, _b, _c;
15061
+ (_a = this.getter) === null || _a === void 0 ? void 0 : _a.ExcludeMenuItem(this.item.id);
15062
+ (_b = this.getterSub) === null || _b === void 0 ? void 0 : _b.call(this);
15063
+ this.getterSub = null;
15064
+ (_c = this.getter) === null || _c === void 0 ? void 0 : _c.Dispose();
15065
+ this.getter = null;
15066
+ }
15067
+ setEntityCheckQueue() {
15068
+ var _a, _b;
15069
+ (_a = this.entityCheckQueue) === null || _a === void 0 ? void 0 : _a.Dispose();
15070
+ this.entityCheckQueue = null;
15071
+ const displayItems = this.zoomControl ? this.zoomControl.filter(x => x.DisplayType != BModels.ZoomControl.EDisplayType.Hidden) : [];
15072
+ const shouldCheck = displayItems.length > 1;
15073
+ this.entityCheckQueue = new BModels.DelayQueue(() => {
15074
+ this.doEntityCheck(Object.keys(this.renderedEntities));
15075
+ }, shouldCheck ? 3000 : 30000);
15076
+ (_b = this.viewMonitorRemoval) === null || _b === void 0 ? void 0 : _b.call(this);
15077
+ this.viewMonitorRemoval = this.monitor.Updated().Subscribe(() => {
15078
+ var _a;
15079
+ (_a = this.entityCheckQueue) === null || _a === void 0 ? void 0 : _a.Call();
15080
+ });
15081
+ }
15082
+ preventCurrentCheckApiRefresh(entityIds) {
15083
+ var _a;
15084
+ this.reRenderState.markSkipForCurrentRun(entityIds, this.isRunningCheck);
15085
+ if ((_a = this.entityCheckQueueIds) === null || _a === void 0 ? void 0 : _a.length) {
15086
+ const lookup = {};
15087
+ for (let i = 0; i < entityIds.length; i++) {
15088
+ const id = entityIds[i];
15089
+ if (id) {
15090
+ lookup[id] = true;
15091
+ }
15092
+ }
15093
+ this.entityCheckQueueIds = this.entityCheckQueueIds.filter(id => !lookup[id]);
15094
+ }
14870
15095
  }
14871
15096
  Dispose() {
14872
15097
  if (this.disposed) {
@@ -14875,87 +15100,289 @@
14875
15100
  this.doDispose();
14876
15101
  }
14877
15102
  doDispose() {
14878
- var _a;
15103
+ var _a, _b;
14879
15104
  this.disposed = true;
14880
- (_a = this.getter) === null || _a === void 0 ? void 0 : _a.Dispose();
15105
+ this.queryLoadId += 1;
15106
+ this.unsetGetter();
15107
+ (_a = this.entityCheckQueue) === null || _a === void 0 ? void 0 : _a.Dispose();
15108
+ this.entityCheckQueue = null;
15109
+ (_b = this.viewMonitorRemoval) === null || _b === void 0 ? void 0 : _b.call(this);
15110
+ this.viewMonitorRemoval = null;
15111
+ clearInterval(this.renderQueueInterval);
15112
+ this.renderQueueInterval = null;
15113
+ this.renderQueue = [];
15114
+ this.entityCheckQueueIds = [];
14881
15115
  this.visualsManager.RemoveRegos({
14882
15116
  menuItemId: this.item.id
14883
15117
  });
14884
15118
  }
14885
- async onGetterUpdate(queryId) {
14886
- var _a;
14887
- if (this.disposed || this.viewer.isDestroyed()) {
15119
+ async ReRender(params) {
15120
+ let { entityIds, force, entities, maintain } = params;
15121
+ if (this.disposed) {
14888
15122
  return;
14889
15123
  }
15124
+ if (entities && !entityIds) {
15125
+ entityIds = entities.map(x => { var _a; return (_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID; });
15126
+ }
15127
+ if (entityIds == null) {
15128
+ entityIds = Object.keys(this.renderedEntities);
15129
+ }
15130
+ entityIds = entityIds.filter((x, index) => !!x && entityIds.indexOf(x) === index);
15131
+ if (!entityIds.length) {
15132
+ return;
15133
+ }
15134
+ if (entities === null || entities === void 0 ? void 0 : entities.length) {
15135
+ entities = [].concat(entities).filter(x => { var _a; return entityIds.includes((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID); });
15136
+ if (force) {
15137
+ this.reRenderState.bumpApiRevisions(entityIds);
15138
+ this.preventCurrentCheckApiRefresh(entityIds);
15139
+ }
15140
+ }
15141
+ if (maintain === true && (entities === null || entities === void 0 ? void 0 : entities.length)) {
15142
+ this.reRenderState.setMaintainedEntities(entities);
15143
+ }
15144
+ else if (maintain !== true) {
15145
+ this.reRenderState.clearMaintainedEntities(entityIds);
15146
+ }
15147
+ this.visualsManager.MarkStale({
15148
+ entityIds: entityIds,
15149
+ menuItemIds: [this.item.id]
15150
+ });
15151
+ if (entities === null || entities === void 0 ? void 0 : entities.length) {
15152
+ if (force) {
15153
+ await this.renderDataLabEntities(entities, true);
15154
+ }
15155
+ else {
15156
+ this.distributeForRender(entities);
15157
+ }
15158
+ }
15159
+ else {
15160
+ await this.doEntityCheck(entityIds, force);
15161
+ }
15162
+ }
15163
+ UpdateSettings(params) {
15164
+ const { zoomControl, queueRerender } = params;
15165
+ if (this.disposed) {
15166
+ return;
15167
+ }
15168
+ if (zoomControl === null || zoomControl === void 0 ? void 0 : zoomControl.length) {
15169
+ this.zoomControl = zoomControl;
15170
+ this.item.CameraZoomSettings = zoomControl;
15171
+ this.setEntityCheckQueue();
15172
+ }
15173
+ if (queueRerender != false) {
15174
+ const entityIds = Object.keys(this.renderedEntities);
15175
+ this.visualsManager.MarkStale({
15176
+ entityIds,
15177
+ menuItemIds: [this.item.id]
15178
+ });
15179
+ this.doEntityCheck(entityIds);
15180
+ }
15181
+ }
15182
+ async doEntityCheck(ids, force = false) {
15183
+ var _a, _b, _c, _d;
15184
+ if (this.isRunningCheck) {
15185
+ this.entityCheckQueueIds = this.entityCheckQueueIds.concat(ids);
15186
+ (_a = this.entityCheckQueue) === null || _a === void 0 ? void 0 : _a.Call();
15187
+ return;
15188
+ }
15189
+ ids = ids.concat(this.entityCheckQueueIds);
15190
+ this.entityCheckQueueIds = [];
15191
+ ids = ids.filter((id, index) => {
15192
+ return id && ids.indexOf(id) === index;
15193
+ });
15194
+ if (!ids.length) {
15195
+ return;
15196
+ }
15197
+ this.isRunningCheck = true;
15198
+ const runId = this.reRenderState.startCheckRun();
15199
+ const api = this.apiGetter.getApi();
14890
15200
  try {
14891
- const api = this.apiGetter.getApi();
14892
- const result = await BModels.DataLab.Get({ api, queryId });
14893
- const query = result.query;
14894
- const queryResult = await BModels.DataLab.Run({ api, query: {
14895
- [BModels.DataLab.EReqKey.Primary]: {
14896
- Items: ((_a = query === null || query === void 0 ? void 0 : query.PrimarySelectionCriteria) === null || _a === void 0 ? void 0 : _a.Items) || [],
15201
+ if (this.disposed) {
15202
+ return;
15203
+ }
15204
+ const maintained = this.reRenderState.getMaintainedEntities(ids);
15205
+ const maintainedLookup = {};
15206
+ for (let i = 0; i < maintained.length; i++) {
15207
+ const id = (_c = (_b = maintained[i]) === null || _b === void 0 ? void 0 : _b.Bruce) === null || _c === void 0 ? void 0 : _c.ID;
15208
+ if (id) {
15209
+ maintainedLookup[id] = true;
15210
+ }
15211
+ }
15212
+ if (maintained.length) {
15213
+ if (force) {
15214
+ await this.renderDataLabEntities(maintained, true);
15215
+ }
15216
+ else {
15217
+ this.distributeForRender(maintained);
15218
+ }
15219
+ }
15220
+ let apiIds = ids.filter((id) => {
15221
+ return !maintainedLookup[id] && !this.reRenderState.shouldSkipInRun(id, runId);
15222
+ });
15223
+ const checkBatch = async () => {
15224
+ apiIds = this.reRenderState.filterNonSkippedIds(apiIds, runId);
15225
+ const entityIds = apiIds.splice(0, CHECK_BATCH_SIZE$2);
15226
+ if (!entityIds.length) {
15227
+ return;
15228
+ }
15229
+ const revisions = this.reRenderState.captureApiRevisions(entityIds);
15230
+ const { entities } = await BModels.Entity.GetListByIds({
15231
+ api,
15232
+ entityIds,
15233
+ expandSources: true,
15234
+ expandLocation: true,
15235
+ migrated: true,
15236
+ maxSearchTimeSec: 60 * 2
15237
+ });
15238
+ if (this.disposed) {
15239
+ return;
15240
+ }
15241
+ const resolved = this.reRenderState.filterCurrentApiEntities({
15242
+ entities,
15243
+ revisions,
15244
+ runId
15245
+ });
15246
+ if (resolved.length) {
15247
+ if (force) {
15248
+ await this.renderDataLabEntities(resolved, true);
14897
15249
  }
14898
- } });
14899
- this.renderDataLabEntities(queryResult.entities || []);
15250
+ else {
15251
+ this.distributeForRender(resolved);
15252
+ }
15253
+ }
15254
+ };
15255
+ while (apiIds.length > 0) {
15256
+ await checkBatch();
15257
+ }
15258
+ }
15259
+ catch (e) {
15260
+ console.error(e);
14900
15261
  }
14901
- catch (error) {
14902
- console.error("Failed to perform query or render DataLab entities:", error);
15262
+ finally {
15263
+ this.isRunningCheck = false;
15264
+ if (this.entityCheckQueueIds.length) {
15265
+ (_d = this.entityCheckQueue) === null || _d === void 0 ? void 0 : _d.Call(true);
15266
+ }
14903
15267
  }
14904
15268
  }
14905
- async renderDataLabEntities(entities) {
14906
- if (this.disposed || this.viewer.isDestroyed()) {
15269
+ distributeForRender(entities) {
15270
+ if (this.disposed || !(entities === null || entities === void 0 ? void 0 : entities.length)) {
14907
15271
  return;
14908
15272
  }
14909
- const { updated, entities: cEntities } = await exports.EntityRenderEngine.Render({
14910
- viewer: this.viewer,
14911
- apiGetter: this.apiGetter,
14912
- entities,
14913
- menuItemId: this.item.id,
14914
- visualRegister: this.visualsManager,
14915
- zoomControl: this.item.CameraZoomSettings
14916
- });
15273
+ this.renderQueue = this.renderQueue.concat(entities);
15274
+ if (!this.renderQueueInterval && this.renderQueue.length) {
15275
+ this.renderQueueInterval = setInterval(() => {
15276
+ const batch = this.deduplicateEntities(this.renderQueue.splice(0, BATCH_SIZE$3));
15277
+ this.renderDataLabEntities(batch);
15278
+ if (this.renderQueue.length <= 0) {
15279
+ clearInterval(this.renderQueueInterval);
15280
+ this.renderQueueInterval = null;
15281
+ }
15282
+ }, 50);
15283
+ }
15284
+ }
15285
+ deduplicateEntities(entities) {
15286
+ var _a;
15287
+ const entityMap = new Map();
14917
15288
  for (let i = 0; i < entities.length; i++) {
14918
15289
  const entity = entities[i];
14919
- const id = entity.Bruce.ID;
14920
- const cEntity = cEntities.get(id);
14921
- if (cEntity) {
14922
- const rego = this.visualsManager.GetRego({
14923
- entityId: id,
14924
- menuItemId: this.item.id
14925
- });
14926
- if (!rego) {
14927
- this.visualsManager.AddRego({
14928
- rego: {
14929
- canEdit: true,
15290
+ const id = (_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID;
15291
+ if (id) {
15292
+ entityMap.set(id, entity);
15293
+ }
15294
+ }
15295
+ return Array.from(entityMap.values());
15296
+ }
15297
+ async renderDataLabEntities(entities, force = false) {
15298
+ var _a, _b, _c;
15299
+ if (this.disposed || this.viewer.isDestroyed() || !(entities === null || entities === void 0 ? void 0 : entities.length)) {
15300
+ return;
15301
+ }
15302
+ try {
15303
+ const { updated, entities: cEntities } = await exports.EntityRenderEngine.Render({
15304
+ viewer: this.viewer,
15305
+ apiGetter: this.apiGetter,
15306
+ entities,
15307
+ menuItemId: this.item.id,
15308
+ visualRegister: this.visualsManager,
15309
+ zoomControl: this.zoomControl,
15310
+ force
15311
+ });
15312
+ if (this.disposed) {
15313
+ return;
15314
+ }
15315
+ for (let i = 0; i < entities.length; i++) {
15316
+ const entity = entities[i];
15317
+ const id = entity.Bruce.ID;
15318
+ const cEntity = cEntities.get(id);
15319
+ this.renderedEntities[id] = !!cEntity;
15320
+ if (cEntity) {
15321
+ const rego = this.visualsManager.GetRego({
15322
+ entityId: id,
15323
+ menuItemId: this.item.id
15324
+ });
15325
+ const canEdit = !((_a = entity.Bruce.Outline) === null || _a === void 0 ? void 0 : _a.find(x => x.Baseline && !x.Editable));
15326
+ const visual = rego === null || rego === void 0 ? void 0 : rego.visual;
15327
+ if (!visual || visual != cEntity) {
15328
+ this.visualsManager.AddRego({
15329
+ rego: {
15330
+ canEdit,
15331
+ entityId: id,
15332
+ schema: entity.Bruce.Schema,
15333
+ menuItemId: this.item.id,
15334
+ menuItemType: this.item.Type,
15335
+ visual: cEntity,
15336
+ priority: this.renderPriority,
15337
+ entityTypeId: entity.Bruce["EntityType.ID"],
15338
+ accountId: this.apiGetter.accountId,
15339
+ tagIds: entity.Bruce["Layer.ID"] ? [].concat(entity.Bruce["Layer.ID"]) : [],
15340
+ name: cEntity.name,
15341
+ cdn: this.item.cdnEnabled,
15342
+ outline: entity.Bruce.Outline
15343
+ },
15344
+ requestRender: false
15345
+ });
15346
+ }
15347
+ else if (updated.get(id) && rego) {
15348
+ rego.name = cEntity.name;
15349
+ rego.visual = cEntity;
15350
+ rego.entityTypeId = entity.Bruce["EntityType.ID"];
15351
+ rego.tagIds = entity.Bruce["Layer.ID"] ? [].concat(entity.Bruce["Layer.ID"]) : [];
15352
+ rego.outline = (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b.Outline;
15353
+ rego.cdn = this.item.cdnEnabled;
15354
+ rego.schema = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c.Schema;
15355
+ rego.canEdit = canEdit;
15356
+ if (rego.stale) {
15357
+ this.visualsManager.RefreshMark({
15358
+ rego
15359
+ });
15360
+ this.visualsManager.ForceUpdate({
15361
+ entityIds: [id],
15362
+ refreshColors: true,
15363
+ requestRender: false
15364
+ });
15365
+ }
15366
+ this.visualsManager.OnUpdate.Trigger({
15367
+ type: exports.VisualsRegister.EVisualUpdateType.Update,
14930
15368
  entityId: id,
14931
- menuItemId: this.item.id,
14932
- menuItemType: this.item.Type,
14933
- visual: cEntity,
14934
- priority: this.renderPriority,
14935
- entityTypeId: entity.Bruce["EntityType.ID"],
14936
- accountId: this.apiGetter.accountId,
14937
- name: cEntity.name
14938
- },
15369
+ rego: rego
15370
+ });
15371
+ }
15372
+ }
15373
+ else {
15374
+ this.visualsManager.RemoveRegos({
15375
+ entityId: id,
15376
+ menuItemId: this.item.id,
14939
15377
  requestRender: false
14940
15378
  });
14941
15379
  }
14942
15380
  }
14943
- else {
14944
- this.visualsManager.RemoveRegos({
14945
- entityId: id,
14946
- menuItemId: this.item.id,
14947
- requestRender: false
14948
- });
14949
- }
15381
+ this.viewer.scene.requestRender();
14950
15382
  }
14951
- this.viewer.scene.requestRender();
14952
- }
14953
- async ReRender() {
14954
- if (this.disposed) {
14955
- return;
15383
+ catch (e) {
15384
+ console.error("Failed to render DataLab entities:", e);
14956
15385
  }
14957
- // Re-perform the query and render again
14958
- await this.onGetterUpdate(this.item.DataLabQueryID);
14959
15386
  }
14960
15387
  }
14961
15388
  DataLabRenderManager.Manager = Manager;
@@ -15344,7 +15771,7 @@
15344
15771
  })(exports.CesiumViewMonitor || (exports.CesiumViewMonitor = {}));
15345
15772
 
15346
15773
  const MAX_BATCHES = 2;
15347
- const BATCH_SIZE$3 = 1000;
15774
+ const BATCH_SIZE$4 = 1000;
15348
15775
  const BATCH_DELAY = 200;
15349
15776
  const MAX_RANGE = 3000;
15350
15777
  (function (TilesetOsmRenderManager) {
@@ -15558,7 +15985,7 @@
15558
15985
  const isClose = this.getIsVisualWithinRange(feature, MAX_RANGE);
15559
15986
  if (isClose) {
15560
15987
  batch.push(feature);
15561
- if (batch.length >= BATCH_SIZE$3) {
15988
+ if (batch.length >= BATCH_SIZE$4) {
15562
15989
  return batch;
15563
15990
  }
15564
15991
  }
@@ -15708,7 +16135,7 @@
15708
16135
  delete this._loadedCesiumEntities[key];
15709
16136
  this.totalLoaded -= 1;
15710
16137
  removed += 1;
15711
- if (removed >= BATCH_SIZE$3) {
16138
+ if (removed >= BATCH_SIZE$4) {
15712
16139
  return true;
15713
16140
  }
15714
16141
  }
@@ -35430,7 +35857,7 @@
35430
35857
  }
35431
35858
  }
35432
35859
 
35433
- const VERSION = "6.6.0";
35860
+ const VERSION = "6.6.2";
35434
35861
  /**
35435
35862
  * Updates the environment instance used by bruce-cesium to one specified.
35436
35863
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.