bruce-cesium 2.6.5 → 2.6.7

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.
@@ -1713,7 +1713,7 @@
1713
1713
  }
1714
1714
  function getName(api, entity) {
1715
1715
  return __awaiter(this, void 0, void 0, function () {
1716
- var typeId, type, name_1, e_1;
1716
+ var typeId, type, name_1, e_1, hideError, error, code;
1717
1717
  return __generator(this, function (_a) {
1718
1718
  switch (_a.label) {
1719
1719
  case 0:
@@ -1740,7 +1740,18 @@
1740
1740
  return [3 /*break*/, 4];
1741
1741
  case 3:
1742
1742
  e_1 = _a.sent();
1743
- console.error(e_1);
1743
+ hideError = false;
1744
+ // TODO: we need a util for extracting code + message rather than writing all this every time.
1745
+ if (e_1 && typeof e_1 == "object" && e_1.ERROR) {
1746
+ error = e_1.ERROR;
1747
+ code = error && typeof error == "object" ? error.Code : "";
1748
+ // Avoiding logging a common error.
1749
+ // This happens when rendering entities that don't have records.
1750
+ hideError = String(code).toLowerCase() == "notfound";
1751
+ }
1752
+ if (!hideError) {
1753
+ console.error(e_1);
1754
+ }
1744
1755
  return [3 /*break*/, 4];
1745
1756
  case 4: return [2 /*return*/, "Unknown entity"];
1746
1757
  }
@@ -5431,6 +5442,12 @@
5431
5442
  var _this = this;
5432
5443
  var _a;
5433
5444
  this.unsetGetter();
5445
+ var isTagItem = Boolean(this.item.BruceEntity.ExpandLayers);
5446
+ var tagsToRender = isTagItem ? this.item.BruceEntity.SelectedExpandLayers : null;
5447
+ if (!tagsToRender) {
5448
+ tagsToRender = [];
5449
+ }
5450
+ tagsToRender = [].concat(tagsToRender);
5434
5451
  this.getter = this.sharedGetters.GetOrCreateFilterGetter({
5435
5452
  api: this.apiGetter.getApi(),
5436
5453
  attrFilter: (_a = this.item.BruceEntity.Filter) !== null && _a !== void 0 ? _a : {},
@@ -5438,19 +5455,18 @@
5438
5455
  typeId: this.item.BruceEntity["EntityType.ID"],
5439
5456
  monitor: this.monitor,
5440
5457
  viewer: this.viewer,
5458
+ // Unfortunately this searches as an "AND" rather than "OR" which does not meet our needs here.
5459
+ // So for multiple tags we'll manually sort on UI end...
5460
+ tagIds: tagsToRender.length == 1 ? tagsToRender : [],
5441
5461
  debugShowBounds: Boolean(window === null || window === void 0 ? void 0 : window.ENTITIES_RENDER_MANAGER_SHOW_BOUNDS),
5442
5462
  cdn: this.item.cdnEnabled
5443
5463
  });
5444
5464
  var minMax = exports.RenderManager.GetZoomMinMax({
5445
5465
  zoomControl: this.item.CameraZoomSettings
5446
5466
  });
5447
- this.getter.IncludeMenuItem(this.item.id, [], minMax[0], minMax[1]);
5448
- var isTagItem = Boolean(this.item.BruceEntity.ExpandLayers);
5449
- var tagsToRender = isTagItem ? this.item.BruceEntity.SelectedExpandLayers : null;
5450
- if (!tagsToRender) {
5451
- tagsToRender = [];
5452
- }
5453
- tagsToRender = [].concat(tagsToRender);
5467
+ // Unfortunately this searches as an "AND" rather than "OR" which does not meet our needs here.
5468
+ // So for multiple tags we'll manually sort on UI end...
5469
+ this.getter.IncludeMenuItem(this.item.id, tagsToRender.length == 1 ? tagsToRender : [], minMax[0], minMax[1]);
5454
5470
  this.getterSub = this.getter.OnUpdate.Subscribe(function (entities) {
5455
5471
  if (isTagItem) {
5456
5472
  _this.distributeForRender(entities.filter(function (entity) {
@@ -5738,17 +5754,20 @@
5738
5754
  (function (EntitiesLoadedRenderManager) {
5739
5755
  var Manager = /** @class */ (function () {
5740
5756
  function Manager(params) {
5757
+ var _a;
5741
5758
  this.getter = null;
5742
5759
  this.getterSub = null;
5743
5760
  this.disposed = false;
5744
5761
  this.renderedEntities = {};
5745
- this.updatedEntities = {};
5746
5762
  var viewer = params.viewer, apiGetter = params.apiGetter, monitor = params.monitor, item = params.item, visualsManager = params.register;
5747
5763
  this.viewer = viewer;
5748
5764
  this.apiGetter = apiGetter;
5749
5765
  this.monitor = monitor;
5750
5766
  this.item = item;
5751
5767
  this.visualsManager = visualsManager;
5768
+ if (!((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.Entities)) {
5769
+ this.item.BruceEntity = __assign(__assign({}, this.item.BruceEntity), { Entities: [] });
5770
+ }
5752
5771
  }
5753
5772
  Object.defineProperty(Manager.prototype, "Disposed", {
5754
5773
  get: function () {
@@ -5764,13 +5783,9 @@
5764
5783
  */
5765
5784
  Manager.prototype.AddEntities = function (params) {
5766
5785
  var _this = this;
5767
- var _a;
5768
5786
  if (this.disposed) {
5769
5787
  throw (new Error("This item is disposed."));
5770
5788
  }
5771
- if (!((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.Entities)) {
5772
- this.item.BruceEntity = __assign(__assign({}, this.item.BruceEntity), { Entities: [] });
5773
- }
5774
5789
  var entities = params.entities;
5775
5790
  entities.forEach(function (x) {
5776
5791
  var _a;
@@ -5797,13 +5812,9 @@
5797
5812
  */
5798
5813
  Manager.prototype.RemoveEntities = function (params) {
5799
5814
  var _this = this;
5800
- var _a;
5801
5815
  if (this.disposed) {
5802
5816
  throw (new Error("This item is disposed."));
5803
5817
  }
5804
- if (!((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.Entities)) {
5805
- this.item.BruceEntity = __assign(__assign({}, this.item.BruceEntity), { Entities: [] });
5806
- }
5807
5818
  var entityIds = params.entityIds;
5808
5819
  entityIds.forEach(function (x) {
5809
5820
  var index = _this.item.BruceEntity.Entities.findIndex(function (y) { var _a; return ((_a = y === null || y === void 0 ? void 0 : y.Bruce) === null || _a === void 0 ? void 0 : _a.ID) == x; });
@@ -5814,9 +5825,25 @@
5814
5825
  entityId: x,
5815
5826
  menuItemId: _this.item.id
5816
5827
  });
5828
+ _this.renderedEntities[x] = false;
5817
5829
  });
5818
5830
  this.recreateGetter();
5819
5831
  };
5832
+ /**
5833
+ * Clears all entities from the menu item.
5834
+ * Any visuals will be removed as well.
5835
+ */
5836
+ Manager.prototype.ClearEntities = function () {
5837
+ if (this.disposed) {
5838
+ throw (new Error("This item is disposed."));
5839
+ }
5840
+ this.item.BruceEntity.Entities = [];
5841
+ this.visualsManager.RemoveRegos({
5842
+ menuItemId: this.item.id
5843
+ });
5844
+ this.renderedEntities = {};
5845
+ this.recreateGetter();
5846
+ };
5820
5847
  Manager.prototype.Init = function () {
5821
5848
  var _a;
5822
5849
  if (this.disposed) {
@@ -5891,10 +5918,6 @@
5891
5918
  }
5892
5919
  if (entities === null || entities === void 0 ? void 0 : entities.length) {
5893
5920
  entities = [].concat(entities).filter(function (x) { var _a; return entityIds.includes((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID); });
5894
- entities.forEach(function (x) {
5895
- var _a;
5896
- _this.updatedEntities[(_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID] = x;
5897
- });
5898
5921
  }
5899
5922
  this.visualsManager.MarkStale({
5900
5923
  entityIds: entityIds,
@@ -5945,7 +5968,6 @@
5945
5968
  if (!(ids.length > 0)) return [3 /*break*/, 4];
5946
5969
  checkBatch = function () { return __awaiter(_this, void 0, void 0, function () {
5947
5970
  var entityIds, entities;
5948
- var _this = this;
5949
5971
  return __generator(this, function (_a) {
5950
5972
  switch (_a.label) {
5951
5973
  case 0:
@@ -5959,10 +5981,6 @@
5959
5981
  if (this.disposed) {
5960
5982
  return [2 /*return*/];
5961
5983
  }
5962
- entities.forEach(function (x) {
5963
- var _a;
5964
- _this.updatedEntities[(_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID] = x;
5965
- });
5966
5984
  this.onGetterUpdate(entities, force);
5967
5985
  return [2 /*return*/];
5968
5986
  }
@@ -5989,7 +6007,8 @@
5989
6007
  var _a;
5990
6008
  if (force === void 0) { force = false; }
5991
6009
  return __awaiter(this, void 0, void 0, function () {
5992
- var cEntities, i, entity, id, cEntity, visual, e_2;
6010
+ var isEntityInItem_1, cEntities, i, entity, id, cEntity, visual, e_2;
6011
+ var _this = this;
5993
6012
  return __generator(this, function (_b) {
5994
6013
  switch (_b.label) {
5995
6014
  case 0:
@@ -5997,6 +6016,16 @@
5997
6016
  if (this.disposed || this.viewer.isDestroyed()) {
5998
6017
  return [2 /*return*/];
5999
6018
  }
6019
+ isEntityInItem_1 = function (entityId) {
6020
+ var _a, _b;
6021
+ return (_b = (_a = _this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.Entities) === null || _b === void 0 ? void 0 : _b.find(function (y) { var _a; return ((_a = y === null || y === void 0 ? void 0 : y.Bruce) === null || _a === void 0 ? void 0 : _a.ID) == entityId; });
6022
+ };
6023
+ // Filter out entities that aren't in the menu item.
6024
+ // This can happen if the menu item is updated while the getter is running.
6025
+ entities = entities.filter(function (x) {
6026
+ var _a;
6027
+ return isEntityInItem_1((_a = x === null || x === void 0 ? void 0 : x.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
6028
+ });
6000
6029
  return [4 /*yield*/, exports.EntityRenderEngine.Render({
6001
6030
  viewer: this.viewer,
6002
6031
  apiGetter: this.apiGetter,
@@ -6013,7 +6042,7 @@
6013
6042
  id = entity.Bruce.ID;
6014
6043
  cEntity = cEntities[id];
6015
6044
  this.renderedEntities[id] = !!cEntity;
6016
- if (cEntity) {
6045
+ if (cEntity && isEntityInItem_1(id)) {
6017
6046
  visual = (_a = this.visualsManager.GetRego({
6018
6047
  entityId: id,
6019
6048
  menuItemId: this.item.id
@@ -7710,6 +7739,7 @@
7710
7739
  cacheKey += params.typeId;
7711
7740
  cacheKey += params.batchSize;
7712
7741
  cacheKey += String(params.cdn);
7742
+ cacheKey += JSON.stringify(params.tagIds ? params.tagIds : []);
7713
7743
  // This could potentially crash, but if it crashes here then it would crash during API request anyways.
7714
7744
  cacheKey += JSON.stringify(params.attrFilter ? params.attrFilter : {});
7715
7745
  return cacheKey;
@@ -15092,7 +15122,7 @@
15092
15122
  ViewerUtils.CreateWidgets = CreateWidgets;
15093
15123
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
15094
15124
 
15095
- var VERSION$1 = "2.6.5";
15125
+ var VERSION$1 = "2.6.7";
15096
15126
 
15097
15127
  exports.VERSION = VERSION$1;
15098
15128
  exports.CesiumViewMonitor = CesiumViewMonitor;