bruce-cesium 4.6.2 → 4.6.4

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.
@@ -8390,16 +8390,16 @@
8390
8390
  min = 0;
8391
8391
  }
8392
8392
  // Adjusting slightly because I distrust our initial calculation vs Cesium's one.
8393
- max = (+max) * 1.2;
8393
+ max = (+max) * 1.8;
8394
8394
  min = +min;
8395
8395
  if (min > 0) {
8396
8396
  min = (+min) * 0.8;
8397
8397
  }
8398
8398
  meterSize = +meterSize;
8399
8399
  if (!isNaN(meterSize) && meterSize > 0) {
8400
- // A 1m thing at 2000m distance is barely visible, so we can cull it.
8400
+ // A 1m thing at 3000m distance is barely visible, so we can cull it.
8401
8401
  // So we'll multiply this magic distance by the size of the thing and determine when it'll be too small to see.
8402
- var METER_DISTANCE_PER_METER = isPolygon ? 100 : 2000;
8402
+ var METER_DISTANCE_PER_METER = isPolygon ? 200 : 3000;
8403
8403
  var newMax = meterSize * METER_DISTANCE_PER_METER;
8404
8404
  // Enforcing a minimum max distance in case something goes wrong we want stuff to always be visible when close.
8405
8405
  var MIN_MAX = 300;
@@ -11827,6 +11827,20 @@
11827
11827
  function colorToCColor$1(color) {
11828
11828
  return new Cesium.Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
11829
11829
  }
11830
+ function getShowDebugBounds() {
11831
+ if (!window) {
11832
+ return false;
11833
+ }
11834
+ var showBounds = window === null || window === void 0 ? void 0 : window.ENTITIES_RENDER_MANAGER_SHOW_BOUNDS;
11835
+ if (showBounds) {
11836
+ return true;
11837
+ }
11838
+ if (window.location.search) {
11839
+ var params = new URLSearchParams(window.location.search);
11840
+ showBounds = params.get("debugScanBounds");
11841
+ }
11842
+ return showBounds == "true" || showBounds == "1" || showBounds == "yes";
11843
+ }
11830
11844
  (function (EntitiesRenderManager) {
11831
11845
  var Manager = /** @class */ (function () {
11832
11846
  function Manager(params) {
@@ -11957,9 +11971,10 @@
11957
11971
  // Unfortunately this searches as an "AND" rather than "OR" which does not meet our needs here.
11958
11972
  // So for multiple tags we'll manually sort on UI end...
11959
11973
  tagIds: (tagsToRender === null || tagsToRender === void 0 ? void 0 : tagsToRender.length) ? tagsToRender : [],
11960
- debugShowBounds: Boolean(window === null || window === void 0 ? void 0 : window.ENTITIES_RENDER_MANAGER_SHOW_BOUNDS),
11974
+ debugShowBounds: getShowDebugBounds(),
11961
11975
  cdn: this.item.cdnEnabled,
11962
11976
  historicAttrKey: this.item.BruceEntity.historicAttrKey,
11977
+ historicInterpolation: this.item.historicInterpolation,
11963
11978
  schemaId: (_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b.schemaId
11964
11979
  });
11965
11980
  var minMax = exports.RenderManager.GetZoomMinMax({
@@ -12187,7 +12202,7 @@
12187
12202
  switch (_b.label) {
12188
12203
  case 0:
12189
12204
  _b.trys.push([0, 8, , 9]);
12190
- if (this.disposed || this.viewer.isDestroyed()) {
12205
+ if (this.disposed || this.viewer.isDestroyed() || !(entities === null || entities === void 0 ? void 0 : entities.length)) {
12191
12206
  return [2 /*return*/];
12192
12207
  }
12193
12208
  typeId_1 = (_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a["EntityType.ID"];
@@ -12583,28 +12598,16 @@
12583
12598
  * @returns
12584
12599
  */
12585
12600
  Manager.prototype.renderAsIndividuals = function (entities, force) {
12586
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
12601
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
12587
12602
  if (force === void 0) { force = false; }
12588
12603
  return __awaiter(this, void 0, void 0, function () {
12589
- var entitiesHistoric, toRemove, i, entity, startTmp, stopTmp, startStr, stopStr, historicData, _m, updated, cEntities, i, entity, id, cEntity, rego, visual, wasClustered, tagIds, rego_1;
12590
- return __generator(this, function (_o) {
12591
- switch (_o.label) {
12604
+ var entitiesHistoric, startTmp, stopTmp, startStr, stopStr, historicData, toRemoveIds_1, i, removeId, toRemoveIds_2, i, removeId, _o, updated, cEntities, i, entity, id, cEntity, rego, visual, wasClustered, tagIds, rego_1;
12605
+ return __generator(this, function (_p) {
12606
+ switch (_p.label) {
12592
12607
  case 0:
12593
12608
  entitiesHistoric = {};
12594
- if (!((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.historicAttrKey)) return [3 /*break*/, 2];
12595
- toRemove = entities.filter(function (x) { var _a; return !((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.HistoricAttrKey); });
12596
- for (i = 0; i < toRemove.length; i++) {
12597
- entity = toRemove[i];
12598
- this.visualsManager.RemoveRegos({
12599
- entityId: entity.Bruce.ID,
12600
- menuItemId: this.item.id,
12601
- requestRender: false
12602
- });
12603
- (_b = this.clustering) === null || _b === void 0 ? void 0 : _b.RemoveEntity(entity.Bruce.ID, false);
12604
- }
12605
- entities = entities.filter(function (x) { var _a; return !!((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.HistoricAttrKey); });
12609
+ if (!(((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.historicAttrKey) && entities.length)) return [3 /*break*/, 3];
12606
12610
  if (!this.item.historicInterpolation) return [3 /*break*/, 2];
12607
- if (!entities.length) return [3 /*break*/, 2];
12608
12611
  startTmp = Cesium.JulianDate.toDate(this.viewer.clock.startTime);
12609
12612
  stopTmp = Cesium.JulianDate.toDate(this.viewer.clock.stopTime);
12610
12613
  startStr = new Date(startTmp.getTime() - 1000).toISOString();
@@ -12617,29 +12620,54 @@
12617
12620
  api: this.apiGetter.getApi()
12618
12621
  })];
12619
12622
  case 1:
12620
- historicData = _o.sent();
12623
+ historicData = _p.sent();
12624
+ entitiesHistoric = historicData.recordsByIds;
12625
+ toRemoveIds_1 = entities.filter(function (x) { var _a; return !((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.HistoricAttrKey) && !entitiesHistoric[x.Bruce.ID]; }).map(function (x) { return x.Bruce.ID; });
12626
+ for (i = 0; i < toRemoveIds_1.length; i++) {
12627
+ removeId = toRemoveIds_1[i];
12628
+ this.visualsManager.RemoveRegos({
12629
+ entityId: removeId,
12630
+ menuItemId: this.item.id,
12631
+ requestRender: false
12632
+ });
12633
+ (_b = this.clustering) === null || _b === void 0 ? void 0 : _b.RemoveEntity(removeId, false);
12634
+ }
12635
+ entities = entities.filter(function (x) { return !toRemoveIds_1.includes(x.Bruce.ID); });
12636
+ return [3 /*break*/, 3];
12637
+ case 2:
12638
+ toRemoveIds_2 = entities.filter(function (x) { var _a; return !((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.HistoricAttrKey); }).map(function (x) { return x.Bruce.ID; });
12639
+ for (i = 0; i < toRemoveIds_2.length; i++) {
12640
+ removeId = toRemoveIds_2[i];
12641
+ this.visualsManager.RemoveRegos({
12642
+ entityId: removeId,
12643
+ menuItemId: this.item.id,
12644
+ requestRender: false
12645
+ });
12646
+ (_c = this.clustering) === null || _c === void 0 ? void 0 : _c.RemoveEntity(removeId, false);
12647
+ }
12648
+ entities = entities.filter(function (x) { return !toRemoveIds_2.includes(x.Bruce.ID); });
12649
+ _p.label = 3;
12650
+ case 3:
12621
12651
  if (this.disposed) {
12622
12652
  this.doDispose();
12623
12653
  return [2 /*return*/];
12624
12654
  }
12625
- entitiesHistoric = historicData.recordsByIds;
12626
- _o.label = 2;
12627
- case 2: return [4 /*yield*/, exports.EntityRenderEngine.Render({
12628
- viewer: this.viewer,
12629
- apiGetter: this.apiGetter,
12630
- entities: entities,
12631
- menuItemId: this.item.id,
12632
- visualRegister: this.visualsManager,
12633
- zoomControl: this.item.CameraZoomSettings,
12634
- entitiesHistoric: entitiesHistoric,
12635
- entityHistoricDrawTrack: this.item.historicDrawTrack,
12636
- force: force,
12637
- optimizeGeometry: this.item.optimizeGeometry,
12638
- optimizeMinPoints: this.item.optimizeMinPoints,
12639
- optimizeTolerance: this.item.optimizeTolerance,
12640
- })];
12641
- case 3:
12642
- _m = _o.sent(), updated = _m.updated, cEntities = _m.entities;
12655
+ return [4 /*yield*/, exports.EntityRenderEngine.Render({
12656
+ viewer: this.viewer,
12657
+ apiGetter: this.apiGetter,
12658
+ entities: entities,
12659
+ menuItemId: this.item.id,
12660
+ visualRegister: this.visualsManager,
12661
+ zoomControl: this.item.CameraZoomSettings,
12662
+ entitiesHistoric: entitiesHistoric,
12663
+ entityHistoricDrawTrack: this.item.historicDrawTrack,
12664
+ force: force,
12665
+ optimizeGeometry: this.item.optimizeGeometry,
12666
+ optimizeMinPoints: this.item.optimizeMinPoints,
12667
+ optimizeTolerance: this.item.optimizeTolerance,
12668
+ })];
12669
+ case 4:
12670
+ _o = _p.sent(), updated = _o.updated, cEntities = _o.entities;
12643
12671
  if (this.disposed) {
12644
12672
  this.doDispose();
12645
12673
  return [2 /*return*/];
@@ -12657,10 +12685,10 @@
12657
12685
  visual = rego === null || rego === void 0 ? void 0 : rego.visual;
12658
12686
  if (!visual || visual != cEntity) {
12659
12687
  wasClustered = this.clustering ? this.clustering.AddEntity(id, cEntity, false) : false;
12660
- tagIds = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c["Layer.ID"];
12688
+ tagIds = (_d = entity.Bruce) === null || _d === void 0 ? void 0 : _d["Layer.ID"];
12661
12689
  rego_1 = {
12662
12690
  entityId: id,
12663
- schemaId: (_d = entity.Bruce) === null || _d === void 0 ? void 0 : _d.SchemaID,
12691
+ schemaId: (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e.SchemaID,
12664
12692
  menuItemId: this.item.id,
12665
12693
  menuItemType: this.item.Type,
12666
12694
  visual: cEntity,
@@ -12671,8 +12699,8 @@
12671
12699
  overrideShow: wasClustered ? false : null,
12672
12700
  name: cEntity.name,
12673
12701
  cdn: this.item.cdnEnabled,
12674
- historicDateTime: (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e.HistoricDateTime,
12675
- historicAttrKey: (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f.HistoricAttrKey
12702
+ historicDateTime: (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f.HistoricDateTime,
12703
+ historicAttrKey: (_g = entity.Bruce) === null || _g === void 0 ? void 0 : _g.HistoricAttrKey
12676
12704
  };
12677
12705
  this.visualsManager.AddRego({
12678
12706
  rego: rego_1,
@@ -12683,11 +12711,11 @@
12683
12711
  rego.name = cEntity.name;
12684
12712
  rego.visual = cEntity;
12685
12713
  rego.entityTypeId = entity.Bruce["EntityType.ID"];
12686
- rego.tagIds = ((_g = entity.Bruce) === null || _g === void 0 ? void 0 : _g["Layer.ID"]) ? [].concat(entity.Bruce["Layer.ID"]) : [];
12687
- rego.historicDateTime = (_h = entity.Bruce) === null || _h === void 0 ? void 0 : _h.HistoricDateTime;
12688
- rego.historicAttrKey = (_j = entity.Bruce) === null || _j === void 0 ? void 0 : _j.HistoricAttrKey;
12714
+ rego.tagIds = ((_h = entity.Bruce) === null || _h === void 0 ? void 0 : _h["Layer.ID"]) ? [].concat(entity.Bruce["Layer.ID"]) : [];
12715
+ rego.historicDateTime = (_j = entity.Bruce) === null || _j === void 0 ? void 0 : _j.HistoricDateTime;
12716
+ rego.historicAttrKey = (_k = entity.Bruce) === null || _k === void 0 ? void 0 : _k.HistoricAttrKey;
12689
12717
  rego.cdn = this.item.cdnEnabled;
12690
- rego.schemaId = (_k = entity.Bruce) === null || _k === void 0 ? void 0 : _k.SchemaID;
12718
+ rego.schemaId = (_l = entity.Bruce) === null || _l === void 0 ? void 0 : _l.SchemaID;
12691
12719
  // Marked as stale meaning some change was performed that requires a refresh.
12692
12720
  // This usually means a new sibling was added that we need to update.
12693
12721
  if (rego.stale) {
@@ -12717,7 +12745,7 @@
12717
12745
  menuItemId: this.item.id,
12718
12746
  requestRender: false
12719
12747
  });
12720
- (_l = this.clustering) === null || _l === void 0 ? void 0 : _l.RemoveEntity(id, false);
12748
+ (_m = this.clustering) === null || _m === void 0 ? void 0 : _m.RemoveEntity(id, false);
12721
12749
  }
12722
12750
  }
12723
12751
  this.viewer.scene.requestRender();
@@ -15944,10 +15972,10 @@
15944
15972
  return range;
15945
15973
  }
15946
15974
  // Add minor decimal as API crashes when giving it whole numbers.
15947
- var maxLon = prepareRangeForBounds(this.Boundaries.maxLongitude) + 0.00001;
15948
- var minLon = prepareRangeForBounds(this.Boundaries.minLongitude) - 0.00001;
15949
- var maxLat = prepareRangeForBounds(this.Boundaries.maxLatitude) + 0.00001;
15950
- var minLat = prepareRangeForBounds(this.Boundaries.minLatitude) - 0.00001;
15975
+ var maxLon = prepareRangeForBounds(this.Boundaries.maxLongitude);
15976
+ var minLon = prepareRangeForBounds(this.Boundaries.minLongitude);
15977
+ var maxLat = prepareRangeForBounds(this.Boundaries.maxLatitude);
15978
+ var minLat = prepareRangeForBounds(this.Boundaries.minLatitude);
15951
15979
  return {
15952
15980
  east: maxLon,
15953
15981
  north: maxLat,
@@ -15970,6 +15998,7 @@
15970
15998
  var maxLon = viewRect.east;
15971
15999
  var MAX_CELLS = 150;
15972
16000
  var cellDegreeSize = getCellSizeFromHeight(viewRect.alt);
16001
+ // console.log("cell size", cellDegreeSize, "height", viewRect.alt);
15973
16002
  var curMinLon = floorValueToCellSize(cellDegreeSize, minLon);
15974
16003
  var curMinLat = floorValueToCellSize(cellDegreeSize, minLat);
15975
16004
  // For larger views we add additional padding because our view-area culling is too strong.
@@ -16026,39 +16055,45 @@
16026
16055
  return 0.01;
16027
16056
  }
16028
16057
  if (height < 5000) {
16029
- return 0.025;
16058
+ return 0.05;
16030
16059
  }
16031
16060
  else if (height < 10000) {
16032
16061
  return 0.05;
16033
16062
  }
16034
16063
  else if (height < 30000) {
16035
- return 0.1;
16064
+ return 0.2;
16036
16065
  }
16037
16066
  else if (height < 70000) {
16038
16067
  return 0.2;
16039
16068
  }
16040
16069
  else if (height < 100000) {
16041
- return 0.3;
16070
+ return 0.5;
16042
16071
  }
16043
16072
  else if (height < 150000) {
16044
- return 0.4;
16073
+ return 0.5;
16045
16074
  }
16046
16075
  else if (height < 200000) {
16047
- return 0.5;
16076
+ return 1.5;
16048
16077
  }
16049
16078
  else if (height < 300000) {
16050
- return 0.6;
16079
+ return 1.5;
16051
16080
  }
16052
16081
  else if (height < 500000) {
16053
- return 1;
16082
+ return 3;
16054
16083
  }
16055
16084
  else if (height < 1000000) {
16056
- return 1.3;
16085
+ return 3;
16057
16086
  }
16058
16087
  else if (height < 1200000) {
16059
- return 1.8;
16088
+ return 4;
16089
+ }
16090
+ else if (height < 2000000) {
16091
+ return 6;
16092
+ }
16093
+ else if (height < 3000000) {
16094
+ return 20;
16060
16095
  }
16061
- return 4;
16096
+ return 35;
16062
16097
  }
16063
16098
  function isCellFetched(cell) {
16064
16099
  if (cell.Fetched) {
@@ -16124,20 +16159,28 @@
16124
16159
  this.onStateUpdate = null;
16125
16160
  this.onScanUpdate = null;
16126
16161
  this.viewPortChangeRemoval = null;
16162
+ this.viewPortDelayQueue = null;
16127
16163
  this.viewerDateTimeChangeRemoval = null;
16128
16164
  this.cells = null;
16129
16165
  this.registeredItems = {};
16130
16166
  this.getterLoopId = 0;
16167
+ this.getterLoopAbortControllers = {};
16131
16168
  this.tagIds = null;
16132
16169
  this.minHeight = 0;
16133
16170
  this.maxHeight = 100000;
16134
16171
  this.viewRect = null;
16135
16172
  this.viewCenter = null;
16136
- var api = params.api, viewer = params.viewer, viewPort = params.viewPort, typeId = params.typeId, schemaId = params.schemaId, batchSize = params.batchSize, attrFilter = params.attrFilter, historicAttrKey = params.historicAttrKey, viaCdn = params.viaCdn;
16173
+ this.historicRefreshAbortController = null;
16174
+ // Entity IDs found for the latest integrity.
16175
+ // We use this for refreshing historic data without having to repeat geographic queries.
16176
+ this.gatheredIntegrity = null;
16177
+ this.gatheredEntityIds = [];
16178
+ var api = params.api, viewer = params.viewer, viewPort = params.viewPort, typeId = params.typeId, schemaId = params.schemaId, batchSize = params.batchSize, attrFilter = params.attrFilter, historicAttrKey = params.historicAttrKey, historicInterpolation = params.historicInterpolation, viaCdn = params.viaCdn;
16137
16179
  this.api = api;
16138
16180
  this.typeId = typeId;
16139
16181
  this.schemaId = schemaId;
16140
16182
  this.historicAttrKey = historicAttrKey;
16183
+ this.historicInterpolation = Boolean(historicInterpolation);
16141
16184
  this.viaCdn = Boolean(viaCdn);
16142
16185
  this.batchSize = isNaN(batchSize) ? 300 : batchSize;
16143
16186
  this.viewPort = viewPort;
@@ -16190,15 +16233,22 @@
16190
16233
  Getter.prototype.viewAreaSub = function () {
16191
16234
  var _this = this;
16192
16235
  this.viewAreaDispose();
16193
- this.viewPortChangeRemoval = this.viewPort.Updated().Subscribe(function () {
16236
+ // We'll avoid restarting the scanner too often.
16237
+ this.viewPortDelayQueue = new BModels.DelayQueue(function () {
16194
16238
  _this.updateBounds();
16195
16239
  _this.startGetterLoop();
16240
+ }, 2000);
16241
+ this.viewPortChangeRemoval = this.viewPort.Updated().Subscribe(function () {
16242
+ var _a;
16243
+ (_a = _this.viewPortDelayQueue) === null || _a === void 0 ? void 0 : _a.Call();
16196
16244
  });
16197
16245
  };
16198
16246
  Getter.prototype.viewAreaDispose = function () {
16199
- var _a;
16247
+ var _a, _b;
16200
16248
  (_a = this.viewPortChangeRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
16201
16249
  this.viewPortChangeRemoval = null;
16250
+ (_b = this.viewPortDelayQueue) === null || _b === void 0 ? void 0 : _b.Dispose();
16251
+ this.viewPortDelayQueue = null;
16202
16252
  };
16203
16253
  /**
16204
16254
  * Monitors the Cesium viewer and updates the historic data filter values.
@@ -16212,6 +16262,11 @@
16212
16262
  // This is multiplied by the speed of animation to figure
16213
16263
  // out how many animation "ticks" before we allow an update.
16214
16264
  var INTERVAL_WHILE_ANIMATING = 2.5 * 1000;
16265
+ var INTERVAL_WHILE_NOT_ANIMATING = 1000;
16266
+ if (this.historicInterpolation) {
16267
+ INTERVAL_WHILE_ANIMATING = 6 * 1000;
16268
+ INTERVAL_WHILE_NOT_ANIMATING = 3.5 * 1000;
16269
+ }
16215
16270
  var lastUpdateTime = null;
16216
16271
  var delayQueue = new BModels.DelayQueue(function () {
16217
16272
  try {
@@ -16221,17 +16276,16 @@
16221
16276
  return;
16222
16277
  }
16223
16278
  }
16224
- lastUpdateTime = new Date().getTime();
16225
16279
  var current = _this.historicAttrDateTime;
16226
16280
  _this.updateHistoricDateTime();
16227
16281
  if (current != _this.historicAttrDateTime) {
16228
- _this.updateState();
16282
+ _this.emitHistoricData();
16229
16283
  }
16230
16284
  }
16231
16285
  catch (e) {
16232
16286
  console.error(e);
16233
16287
  }
16234
- }, 250);
16288
+ }, INTERVAL_WHILE_NOT_ANIMATING);
16235
16289
  var postUpdateRemoval = this.viewer.scene.postUpdate.addEventListener(function () {
16236
16290
  if (delayQueue) {
16237
16291
  delayQueue.Call();
@@ -16350,20 +16404,32 @@
16350
16404
  this.getterLoopId += 1;
16351
16405
  var loopId = this.getterLoopId;
16352
16406
  var loopIntegrity = this.getIntegrityId();
16353
- new Promise(function () { return __awaiter(_this, void 0, void 0, function () {
16354
- var MIN_HEIGHT, MAX_HEIGHT, PAGE_SIZE, retryAttempts, retryDelay, prevFirstId, prevLastId, prevTicks, alt, cells, curCellIndex, postedScanning, postedLoading, total, curCell, entities, integrity, first, last, e_1;
16407
+ // Abort any existing loops that don't match the current loop.
16408
+ // We tried using integrity, however we want to interrupt when user moves camera quickly.
16409
+ // So it's better to use the loop ID.
16410
+ var abortId = String(loopId);
16411
+ {
16412
+ var newAbortControllers = {};
16413
+ for (var key in this.getterLoopAbortControllers) {
16414
+ this.getterLoopAbortControllers[key].abort();
16415
+ }
16416
+ this.getterLoopAbortControllers = newAbortControllers;
16417
+ }
16418
+ var abortController = this.getterLoopAbortControllers[abortId] = new AbortController();
16419
+ (function () { return __awaiter(_this, void 0, void 0, function () {
16420
+ var MIN_HEIGHT, MAX_HEIGHT, PAGE_SIZE, retryAttempts, retryDelay, prevFirstId, prevLastId, prevTicks, alt, cells, curCellIndex, postedScanning, postedLoading, total, curCell, entities, integrity, i, entity, first, last, e_1;
16355
16421
  var _a, _b, _c, _d, _e, _f, _g, _h;
16356
16422
  return __generator(this, function (_j) {
16357
16423
  switch (_j.label) {
16358
16424
  case 0:
16359
- // Minor delay to stop 50 menu items enabling doing their first request all together.
16360
- // This gives it time to recognize only 1 request is needed.
16361
- // Would be better to not use this delay but we're on a clock.
16362
- return [4 /*yield*/, delay(100)];
16425
+ // Larger initial delay for the first loops because terrain is likely loading in.
16426
+ // We also delay because if we enable 50 Menu Items at the same time, common requests we be made if we wait a bit.
16427
+ // Eg: same entity type will be grouped into the same filter getter instance.
16428
+ return [4 /*yield*/, delay(loopId <= 3 ? 800 : 300)];
16363
16429
  case 1:
16364
- // Minor delay to stop 50 menu items enabling doing their first request all together.
16365
- // This gives it time to recognize only 1 request is needed.
16366
- // Would be better to not use this delay but we're on a clock.
16430
+ // Larger initial delay for the first loops because terrain is likely loading in.
16431
+ // We also delay because if we enable 50 Menu Items at the same time, common requests we be made if we wait a bit.
16432
+ // Eg: same entity type will be grouped into the same filter getter instance.
16367
16433
  _j.sent();
16368
16434
  MIN_HEIGHT = this.minHeight;
16369
16435
  MAX_HEIGHT = this.maxHeight;
@@ -16445,7 +16511,10 @@
16445
16511
  viaCdn: this.viaCdn,
16446
16512
  migrated: true,
16447
16513
  req: {
16448
- noCache: true
16514
+ // If we are passing in an abort, we MUST pass in noCache.
16515
+ // Otherwise we will cache an aborted request.
16516
+ noCache: true,
16517
+ abortSignal: abortController.signal
16449
16518
  }
16450
16519
  })];
16451
16520
  case 9:
@@ -16454,6 +16523,20 @@
16454
16523
  if (loopIntegrity == integrity && entities) {
16455
16524
  (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger(entities);
16456
16525
  }
16526
+ if (this.gatheredIntegrity != integrity) {
16527
+ this.gatheredIntegrity = integrity;
16528
+ this.gatheredEntityIds = [];
16529
+ }
16530
+ // Add to the integrity list for any new IDs found.
16531
+ // This lets us keep track of all IDs we've found within the same integrity for historic data.
16532
+ if (this.historicAttrKey) {
16533
+ for (i = 0; i < entities.length; i++) {
16534
+ entity = entities[i];
16535
+ if (!this.gatheredEntityIds.includes(entity.Bruce.ID)) {
16536
+ this.gatheredEntityIds.push(entity.Bruce.ID);
16537
+ }
16538
+ }
16539
+ }
16457
16540
  if (this.getterLoopId != loopId) {
16458
16541
  return [3 /*break*/, 13];
16459
16542
  }
@@ -16496,7 +16579,14 @@
16496
16579
  return [3 /*break*/, 11];
16497
16580
  case 10:
16498
16581
  e_1 = _j.sent();
16582
+ // Ignore abort errors.
16583
+ if (e_1 && typeof e_1 === "object" && e_1.name == "AbortError") {
16584
+ return [3 /*break*/, 13];
16585
+ }
16499
16586
  console.error(e_1);
16587
+ if (this.getterLoopId != loopId) {
16588
+ return [3 /*break*/, 13];
16589
+ }
16500
16590
  // Request failed so let's add a delay and try again soon.
16501
16591
  retryDelay += RETRY_DELAY_INCREMENT;
16502
16592
  retryAttempts -= 1;
@@ -16515,7 +16605,104 @@
16515
16605
  return [2 /*return*/];
16516
16606
  }
16517
16607
  });
16518
- }); });
16608
+ }); })();
16609
+ };
16610
+ /**
16611
+ * Gets the historic state of found Entities for the current date times and emits them.
16612
+ * Since geometry searches are tied to the base Entity, we don't have to re-scan the viewport.
16613
+ */
16614
+ Getter.prototype.emitHistoricData = function () {
16615
+ var _this = this;
16616
+ var integrity = this.getIntegrityId();
16617
+ // Gathered ID does't match current one.
16618
+ if (this.gatheredIntegrity != integrity) {
16619
+ return;
16620
+ }
16621
+ var historicAttrDateTime = this.historicAttrDateTime;
16622
+ var SCAN_BATCH_SIZE = 1000;
16623
+ if (this.historicRefreshAbortController) {
16624
+ this.historicRefreshAbortController.abort();
16625
+ this.historicRefreshAbortController = null;
16626
+ }
16627
+ (function () { return __awaiter(_this, void 0, void 0, function () {
16628
+ var pageIndex, i, batch, controller, entities, e_2;
16629
+ var _a;
16630
+ return __generator(this, function (_b) {
16631
+ switch (_b.label) {
16632
+ case 0:
16633
+ pageIndex = 0;
16634
+ _b.label = 1;
16635
+ case 1:
16636
+ _b.trys.push([1, 6, , 7]);
16637
+ i = 0;
16638
+ _b.label = 2;
16639
+ case 2:
16640
+ if (!(i < this.gatheredEntityIds.length)) return [3 /*break*/, 5];
16641
+ batch = this.gatheredEntityIds.slice(i, i + SCAN_BATCH_SIZE);
16642
+ if (!batch.length) {
16643
+ return [3 /*break*/, 5];
16644
+ }
16645
+ controller = this.historicRefreshAbortController = new AbortController();
16646
+ return [4 /*yield*/, BModels.Entity.GetList({
16647
+ api: this.api,
16648
+ historicKey: this.historicAttrKey,
16649
+ historicPoint: historicAttrDateTime,
16650
+ schemaId: this.schemaId,
16651
+ filter: {
16652
+ pageSize: SCAN_BATCH_SIZE,
16653
+ pageIndex: pageIndex,
16654
+ entityTypeId: this.typeId,
16655
+ layerIds: this.tagIds,
16656
+ layerIdsOperator: "in",
16657
+ sortOrder: BModels.Api.ESortOrder.Asc,
16658
+ entityTypeConditions: {
16659
+ "ID": {
16660
+ "IN": batch
16661
+ }
16662
+ },
16663
+ },
16664
+ viaCdn: this.viaCdn,
16665
+ migrated: true,
16666
+ req: {
16667
+ // If we are passing in an abort, we MUST pass in noCache.
16668
+ // Otherwise we will cache an aborted request.
16669
+ noCache: true,
16670
+ abortSignal: controller.signal
16671
+ }
16672
+ })];
16673
+ case 3:
16674
+ entities = (_b.sent()).entities;
16675
+ // Date changed.
16676
+ if (this.historicAttrDateTime != historicAttrDateTime) {
16677
+ return [3 /*break*/, 5];
16678
+ }
16679
+ // Integrity changed.
16680
+ if (this.gatheredIntegrity != integrity) {
16681
+ return [3 /*break*/, 5];
16682
+ }
16683
+ // No Menu Items.
16684
+ if (!this.GetMenuItems().length) {
16685
+ return [3 /*break*/, 5];
16686
+ }
16687
+ (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(entities);
16688
+ pageIndex += 1;
16689
+ _b.label = 4;
16690
+ case 4:
16691
+ i += SCAN_BATCH_SIZE;
16692
+ return [3 /*break*/, 2];
16693
+ case 5: return [3 /*break*/, 7];
16694
+ case 6:
16695
+ e_2 = _b.sent();
16696
+ // Ignore abort errors.
16697
+ if (e_2 && typeof e_2 === "object" && e_2.name == "AbortError") {
16698
+ return [2 /*return*/];
16699
+ }
16700
+ console.error(e_2);
16701
+ return [3 /*break*/, 7];
16702
+ case 7: return [2 /*return*/];
16703
+ }
16704
+ });
16705
+ }); })();
16519
16706
  };
16520
16707
  return Getter;
16521
16708
  }());
@@ -16531,6 +16718,9 @@
16531
16718
  cacheKey += params.schemaId ? params.schemaId : "";
16532
16719
  cacheKey += JSON.stringify(params.tagIds ? params.tagIds : []);
16533
16720
  cacheKey += params.historicAttrKey ? params.historicAttrKey : "";
16721
+ if (params.historicAttrKey) {
16722
+ cacheKey += params.historicInterpolation ? "true" : "false";
16723
+ }
16534
16724
  // This could potentially crash, but if it crashes here then it would crash during API request anyways.
16535
16725
  cacheKey += JSON.stringify(params.attrFilter ? params.attrFilter : {});
16536
16726
  return cacheKey;
@@ -16554,6 +16744,7 @@
16554
16744
  batchSize: params.batchSize,
16555
16745
  attrFilter: params.attrFilter,
16556
16746
  historicAttrKey: params.historicAttrKey,
16747
+ historicInterpolation: params.historicInterpolation,
16557
16748
  viaCdn: params.cdn
16558
16749
  });
16559
16750
  this.data[cacheKey] = getter;
@@ -16564,6 +16755,7 @@
16564
16755
  if (params.viewer && params.debugShowBounds) {
16565
16756
  // Cell id -> entity.
16566
16757
  var cellCache_1 = {};
16758
+ var cellPrefix_1 = BModels.ObjectUtils.UId(10) + "_";
16567
16759
  getter.OnScanUpdate.Subscribe(function (cells) {
16568
16760
  if (window.ON_SCAN_UPDATE_PAUSED == true) {
16569
16761
  return;
@@ -16574,7 +16766,7 @@
16574
16766
  cells.forEach(function (cell) {
16575
16767
  var _a;
16576
16768
  var bounds = cell.GetBounds();
16577
- var id = bounds.east + "_" + bounds.north + "_" + bounds.south + "_" + bounds.west;
16769
+ var id = cellPrefix_1 + bounds.east + "_" + bounds.north + "_" + bounds.south + "_" + bounds.west;
16578
16770
  curCellIds.push(id);
16579
16771
  fetchedCells[id] = cell.IsFetched();
16580
16772
  fetchingCellId = cell.Fetching ? id : fetchingCellId;
@@ -24033,11 +24225,11 @@
24033
24225
  }
24034
24226
  (function (ViewRenderEngine) {
24035
24227
  function Render(params) {
24036
- var _a;
24228
+ var _a, _b;
24037
24229
  return __awaiter(this, void 0, void 0, function () {
24038
- var iteration, api, view, _b, bookmark, bookmarkId, _c, version, bWidget;
24039
- return __generator(this, function (_d) {
24040
- switch (_d.label) {
24230
+ var iteration, api, view, _c, bookmark, bookmarkId, _d, version, bWidget, lpWidget;
24231
+ return __generator(this, function (_e) {
24232
+ switch (_e.label) {
24041
24233
  case 0:
24042
24234
  if (!params.manager && params.viewer) {
24043
24235
  params.manager = exports.ViewerUtils.GetManager({
@@ -24060,17 +24252,17 @@
24060
24252
  }
24061
24253
  api = params.getters.GetBruceApi();
24062
24254
  if (!params.view) return [3 /*break*/, 1];
24063
- _b = params.view;
24255
+ _c = params.view;
24064
24256
  return [3 /*break*/, 3];
24065
24257
  case 1: return [4 /*yield*/, BModels.ProjectView.Get({
24066
24258
  api: api,
24067
24259
  viewId: params.viewId
24068
24260
  })];
24069
24261
  case 2:
24070
- _b = (_d.sent()).view;
24071
- _d.label = 3;
24262
+ _c = (_e.sent()).view;
24263
+ _e.label = 3;
24072
24264
  case 3:
24073
- view = _b;
24265
+ view = _c;
24074
24266
  bookmark = params.bookmark;
24075
24267
  if (!!bookmark) return [3 /*break*/, 7];
24076
24268
  bookmarkId = params.bookmarkId;
@@ -24084,14 +24276,14 @@
24084
24276
  bookmarkId: bookmarkId
24085
24277
  })];
24086
24278
  case 4:
24087
- _c = (_d.sent()).bookmark;
24279
+ _d = (_e.sent()).bookmark;
24088
24280
  return [3 /*break*/, 6];
24089
24281
  case 5:
24090
- _c = null;
24091
- _d.label = 6;
24282
+ _d = null;
24283
+ _e.label = 6;
24092
24284
  case 6:
24093
- bookmark = _c;
24094
- _d.label = 7;
24285
+ bookmark = _d;
24286
+ _e.label = 7;
24095
24287
  case 7:
24096
24288
  if (!assertIteration$1(params.viewer, iteration)) {
24097
24289
  return [2 /*return*/];
@@ -24100,12 +24292,12 @@
24100
24292
  if (!(version == 1)) return [3 /*break*/, 9];
24101
24293
  return [4 /*yield*/, renderLegacyNavigator(iteration, params, bookmark, view)];
24102
24294
  case 8:
24103
- _d.sent();
24295
+ _e.sent();
24104
24296
  return [3 /*break*/, 11];
24105
24297
  case 9: return [4 /*yield*/, renderNavigator(iteration, params, bookmark, view, params.getters)];
24106
24298
  case 10:
24107
- _d.sent();
24108
- _d.label = 11;
24299
+ _e.sent();
24300
+ _e.label = 11;
24109
24301
  case 11:
24110
24302
  if (!assertIteration$1(params.viewer, iteration)) {
24111
24303
  return [2 /*return*/];
@@ -24115,6 +24307,11 @@
24115
24307
  bWidget.ViewId = params.viewId ? params.viewId : view === null || view === void 0 ? void 0 : view.ID;
24116
24308
  bWidget.LastEnabledBookmarkId = params.bookmarkId ? params.bookmarkId : bookmark === null || bookmark === void 0 ? void 0 : bookmark.ID;
24117
24309
  }
24310
+ lpWidget = (_b = params.viewer) === null || _b === void 0 ? void 0 : _b[VIEWER_LEFT_PANEL_WIDGET_KEY];
24311
+ if (lpWidget) {
24312
+ lpWidget.ViewId = params.viewId ? params.viewId : view === null || view === void 0 ? void 0 : view.ID;
24313
+ lpWidget.LastEnabledBookmarkId = params.bookmarkId ? params.bookmarkId : bookmark === null || bookmark === void 0 ? void 0 : bookmark.ID;
24314
+ }
24118
24315
  return [2 /*return*/];
24119
24316
  }
24120
24317
  });
@@ -24157,6 +24354,8 @@
24157
24354
  var isChanged = this._viewId != value;
24158
24355
  if (isChanged) {
24159
24356
  this._viewId = value;
24357
+ this._updatePanelStyles();
24358
+ this._loading = this.loadBookmarks();
24160
24359
  }
24161
24360
  },
24162
24361
  enumerable: false,
@@ -24208,13 +24407,15 @@
24208
24407
  };
24209
24408
  WidgetLeftPanel.prototype.loadBookmarks = function () {
24210
24409
  return __awaiter(this, void 0, void 0, function () {
24211
- var api, viewId, data, e_1;
24410
+ var viewId, api, data, e_1;
24212
24411
  return __generator(this, function (_a) {
24213
24412
  switch (_a.label) {
24214
24413
  case 0:
24215
- _a.trys.push([0, 2, , 3]);
24216
- api = this._apiGetters.GetBruceApi();
24217
24414
  viewId = this._viewId;
24415
+ _a.label = 1;
24416
+ case 1:
24417
+ _a.trys.push([1, 3, , 4]);
24418
+ api = this._apiGetters.GetBruceApi();
24218
24419
  if (!viewId) {
24219
24420
  this.bookmarks = [];
24220
24421
  return [2 /*return*/];
@@ -24223,16 +24424,22 @@
24223
24424
  viewId: viewId,
24224
24425
  api: api
24225
24426
  })];
24226
- case 1:
24427
+ case 2:
24227
24428
  data = _a.sent();
24429
+ if (this._viewId !== viewId) {
24430
+ return [2 /*return*/];
24431
+ }
24228
24432
  this.bookmarks = data.bookmarks;
24229
- return [3 /*break*/, 3];
24230
- case 2:
24433
+ return [3 /*break*/, 4];
24434
+ case 3:
24231
24435
  e_1 = _a.sent();
24232
24436
  console.error(e_1);
24437
+ if (this._viewId !== viewId) {
24438
+ return [2 /*return*/];
24439
+ }
24233
24440
  this.bookmarks = [];
24234
- return [3 /*break*/, 3];
24235
- case 3: return [2 /*return*/];
24441
+ return [3 /*break*/, 4];
24442
+ case 4: return [2 /*return*/];
24236
24443
  }
24237
24444
  });
24238
24445
  });
@@ -27775,7 +27982,7 @@
27775
27982
  return WidgetViewBar;
27776
27983
  }(exports.Widget.AWidget));
27777
27984
 
27778
- var VERSION = "4.6.2";
27985
+ var VERSION = "4.6.4";
27779
27986
 
27780
27987
  exports.VERSION = VERSION;
27781
27988
  exports.CesiumParabola = CesiumParabola;