bruce-cesium 2.9.2 → 2.9.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.
@@ -7435,6 +7435,18 @@
7435
7435
  }
7436
7436
  if (!pos3d) {
7437
7437
  pos3d = getCurPos3d();
7438
+ if (pos3d === null || pos3d === void 0 ? void 0 : pos3d.x) {
7439
+ var carto = Cesium.Cartographic.fromCartesian(pos3d);
7440
+ if (!isNaN(carto === null || carto === void 0 ? void 0 : carto.latitude)) {
7441
+ // We reapply back to the tileset so we can reference this location later.
7442
+ // For example we can reference within editing tools in navigator.
7443
+ position.location = {
7444
+ altitude: carto.height,
7445
+ latitude: Cesium.Math.toDegrees(carto.latitude),
7446
+ longitude: Cesium.Math.toDegrees(carto.longitude)
7447
+ };
7448
+ }
7449
+ }
7438
7450
  }
7439
7451
  var offset = getOffset(pos3d, transform.x, transform.y, transform.z);
7440
7452
  if (bruceModels.Cartes.ValidateCartes3(offset)) {
@@ -9826,6 +9838,41 @@
9826
9838
  relations: this.item.relations
9827
9839
  });
9828
9840
  };
9841
+ /**
9842
+ * Constructs the rendered state of the menu item from the visuals register.
9843
+ * This will let us see the difference between what the menu item should render vs has rendered.
9844
+ */
9845
+ Manager.prototype.getRenderedState = function () {
9846
+ var items = [];
9847
+ var regos = this.register.GetRegos({
9848
+ menuItemId: this.item.id
9849
+ });
9850
+ var _loop_1 = function (i) {
9851
+ var rego = regos[i];
9852
+ if (!(rego === null || rego === void 0 ? void 0 : rego.relation)) {
9853
+ return "continue";
9854
+ }
9855
+ var relationTypeId = rego.relation["Relation.Type.ID"];
9856
+ if (!relationTypeId) {
9857
+ return "continue";
9858
+ }
9859
+ var group = items.find(function (x) { return x.relationTypeId == relationTypeId; });
9860
+ var entityId = rego.relation["Principal.Entity.ID"];
9861
+ if (!group) {
9862
+ items.push({
9863
+ relationTypeId: relationTypeId,
9864
+ entityIds: [entityId]
9865
+ });
9866
+ }
9867
+ else if (!group.entityIds.includes(entityId)) {
9868
+ group.entityIds.push(entityId);
9869
+ }
9870
+ };
9871
+ for (var i = 0; i < regos.length; i++) {
9872
+ _loop_1(i);
9873
+ }
9874
+ return items;
9875
+ };
9829
9876
  Manager.prototype.Dispose = function () {
9830
9877
  if (this.disposed) {
9831
9878
  return;
@@ -9840,22 +9887,162 @@
9840
9887
  * @param params
9841
9888
  */
9842
9889
  Manager.prototype.ReRender = function (params) {
9890
+ var _a;
9843
9891
  return __awaiter(this, void 0, void 0, function () {
9844
- var entityIds, force;
9845
- return __generator(this, function (_a) {
9846
- entityIds = params.entityIds, force = params.force;
9847
- return [2 /*return*/];
9892
+ var entityIds, force, toReRender, toReRenderDataIds, regos, groups, _loop_2, i;
9893
+ return __generator(this, function (_b) {
9894
+ switch (_b.label) {
9895
+ case 0:
9896
+ entityIds = params.entityIds, force = params.force;
9897
+ toReRenderDataIds = [];
9898
+ if (entityIds == null) {
9899
+ toReRender = this.item.relations;
9900
+ }
9901
+ else {
9902
+ toReRender = [];
9903
+ regos = this.register.GetRegos({
9904
+ menuItemId: this.item.id
9905
+ });
9906
+ groups = this.item.relations;
9907
+ _loop_2 = function (i) {
9908
+ var group = groups[i];
9909
+ var toRenderEntityIds = [];
9910
+ if ((_a = group.entityIds) === null || _a === void 0 ? void 0 : _a.length) {
9911
+ for (var i_1 = 0; i_1 < group.entityIds.length; i_1++) {
9912
+ var groupEntityId = group.entityIds[i_1];
9913
+ // Primary ID matches a re-render entity ID.
9914
+ if (entityIds.includes(groupEntityId)) {
9915
+ toRenderEntityIds.push(groupEntityId);
9916
+ }
9917
+ }
9918
+ }
9919
+ var groupRegos = regos.filter(function (x) { var _a; return ((_a = x.relation) === null || _a === void 0 ? void 0 : _a["Relation.Type.ID"]) == group.relationTypeId; });
9920
+ if (groupRegos.length) {
9921
+ for (var i_2 = 0; i_2 < groupRegos.length; i_2++) {
9922
+ var rego = groupRegos[i_2];
9923
+ var dataEntityId = rego.entityId;
9924
+ // Data ID matches a re-render entity ID.
9925
+ if (dataEntityId && entityIds.includes(dataEntityId) && rego.relation) {
9926
+ // toRenderEntityIds.push(rego.relation["Principal.Entity.ID"]);
9927
+ toReRenderDataIds.push(dataEntityId);
9928
+ }
9929
+ }
9930
+ }
9931
+ if (toRenderEntityIds.length) {
9932
+ toReRender.push({
9933
+ relationTypeId: group.relationTypeId,
9934
+ entityIds: toRenderEntityIds
9935
+ });
9936
+ }
9937
+ };
9938
+ for (i = 0; i < groups.length; i++) {
9939
+ _loop_2(i);
9940
+ }
9941
+ }
9942
+ if (!toReRenderDataIds.length) return [3 /*break*/, 2];
9943
+ return [4 /*yield*/, this.queueRenderDataIds({
9944
+ dataEntityIds: toReRenderDataIds
9945
+ })];
9946
+ case 1:
9947
+ _b.sent();
9948
+ _b.label = 2;
9949
+ case 2:
9950
+ if (!toReRender.length) return [3 /*break*/, 4];
9951
+ return [4 /*yield*/, this.queueRenderRelations({
9952
+ relations: toReRender,
9953
+ force: true
9954
+ })];
9955
+ case 3:
9956
+ _b.sent();
9957
+ _b.label = 4;
9958
+ case 4: return [2 /*return*/];
9959
+ }
9848
9960
  });
9849
9961
  });
9850
9962
  };
9851
- Manager.prototype.queueRenderRelations = function (params) {
9963
+ Manager.prototype.queueRenderDataIds = function (params) {
9852
9964
  return __awaiter(this, void 0, void 0, function () {
9853
- var relations, allIds_1, _i, relations_1, relation, entityIds, toRender, i, entityId, data, j, relation, e_1;
9965
+ var dataEntityIds, i, data, e_1;
9854
9966
  return __generator(this, function (_a) {
9855
9967
  switch (_a.label) {
9856
9968
  case 0:
9857
- _a.trys.push([0, 5, , 6]);
9858
- relations = params.relations;
9969
+ dataEntityIds = params.dataEntityIds;
9970
+ i = 0;
9971
+ _a.label = 1;
9972
+ case 1:
9973
+ if (!(i < dataEntityIds.length)) return [3 /*break*/, 6];
9974
+ _a.label = 2;
9975
+ case 2:
9976
+ _a.trys.push([2, 4, , 5]);
9977
+ return [4 /*yield*/, bruceModels.EntityRelation.GetByDataEntityId({
9978
+ entityId: dataEntityIds[i],
9979
+ api: this.apiGetter.getApi()
9980
+ })];
9981
+ case 3:
9982
+ data = _a.sent();
9983
+ if (data.relation) {
9984
+ if (this.shouldRenderRelation(data.relation)) {
9985
+ this.onGetterUpdate([data.relation]);
9986
+ }
9987
+ }
9988
+ return [3 /*break*/, 5];
9989
+ case 4:
9990
+ e_1 = _a.sent();
9991
+ console.error(e_1);
9992
+ return [3 /*break*/, 5];
9993
+ case 5:
9994
+ i++;
9995
+ return [3 /*break*/, 1];
9996
+ case 6: return [2 /*return*/];
9997
+ }
9998
+ });
9999
+ });
10000
+ };
10001
+ Manager.prototype.queueRenderRelations = function (params) {
10002
+ var _a;
10003
+ return __awaiter(this, void 0, void 0, function () {
10004
+ var relations, force, renderedState, toRender, _loop_3, i, allIds_1, _i, relations_1, relation, entityIds, i, entityId, data, toRender, j, relation, rego, e_2;
10005
+ return __generator(this, function (_b) {
10006
+ switch (_b.label) {
10007
+ case 0:
10008
+ _b.trys.push([0, 5, , 6]);
10009
+ relations = params.relations, force = params.force;
10010
+ if (force != true) {
10011
+ renderedState = this.getRenderedState();
10012
+ toRender = [];
10013
+ _loop_3 = function (i) {
10014
+ var typeId = relations[i].relationTypeId;
10015
+ var group = renderedState.find(function (x) { return x.relationTypeId == typeId; });
10016
+ if (!group || !((_a = group.entityIds) === null || _a === void 0 ? void 0 : _a.length)) {
10017
+ toRender.push(relations[i]);
10018
+ return "continue";
10019
+ }
10020
+ var entityIds = relations[i].entityIds;
10021
+ if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
10022
+ return "continue";
10023
+ }
10024
+ var toRenderEntityIds = [];
10025
+ for (var j = 0; j < entityIds.length; j++) {
10026
+ var entityId = entityIds[j];
10027
+ if (!group.entityIds.includes(entityId) && !toRenderEntityIds.includes(entityId)) {
10028
+ toRenderEntityIds.push(entityId);
10029
+ }
10030
+ }
10031
+ if (toRenderEntityIds.length) {
10032
+ toRender.push({
10033
+ relationTypeId: typeId,
10034
+ entityIds: toRenderEntityIds
10035
+ });
10036
+ }
10037
+ };
10038
+ for (i = 0; i < relations.length; i++) {
10039
+ _loop_3(i);
10040
+ }
10041
+ if (!toRender.length) {
10042
+ return [2 /*return*/];
10043
+ }
10044
+ relations = toRender;
10045
+ }
9859
10046
  allIds_1 = [];
9860
10047
  for (_i = 0, relations_1 = relations; _i < relations_1.length; _i++) {
9861
10048
  relation = relations_1[_i];
@@ -9865,9 +10052,8 @@
9865
10052
  allIds_1 = allIds_1.filter(function (id, index) {
9866
10053
  return allIds_1.indexOf(id) === index;
9867
10054
  });
9868
- toRender = [];
9869
10055
  i = 0;
9870
- _a.label = 1;
10056
+ _b.label = 1;
9871
10057
  case 1:
9872
10058
  if (!(i < allIds_1.length)) return [3 /*break*/, 4];
9873
10059
  entityId = allIds_1[i];
@@ -9880,50 +10066,37 @@
9880
10066
  api: this.apiGetter.getApi()
9881
10067
  })];
9882
10068
  case 2:
9883
- data = _a.sent();
9884
- console.log("get relations", data);
10069
+ data = _b.sent();
10070
+ if (this.disposed || this.viewer.isDestroyed()) {
10071
+ return [2 /*return*/];
10072
+ }
10073
+ toRender = [];
9885
10074
  for (j = 0; j < data.relations.length; j++) {
9886
10075
  relation = data.relations[j];
9887
10076
  if (this.shouldRenderRelation(relation)) {
10077
+ if (force != true) {
10078
+ rego = this.register.GetRego({
10079
+ relation: relation,
10080
+ menuItemId: this.item.id
10081
+ });
10082
+ if (rego === null || rego === void 0 ? void 0 : rego.visual) {
10083
+ continue;
10084
+ }
10085
+ }
9888
10086
  toRender.push(relation);
9889
10087
  }
9890
10088
  }
9891
- _a.label = 3;
9892
- case 3:
9893
- i++;
9894
- return [3 /*break*/, 1];
9895
- case 4:
9896
- console.log("all render", toRender);
9897
- // Relations are not being returned??
9898
- // const data = await Entity.GetListByIds({
9899
- // entityIds: allIds,
9900
- // expandRelations: true,
9901
- // api: this.apiGetter.getApi()
9902
- // });
9903
- // for (let i = 0; i < data.entities.length; i++) {
9904
- // const entity = data.entities[i];
9905
- // if (entity?.Bruce?.relations?.length) {
9906
- // const eRelations = entity.Bruce.relations;
9907
- // for (let j = 0; j < eRelations.length; j++) {
9908
- // const eRelation = eRelations[j];
9909
- // const relation: EntityRelation.IRelation = {
9910
- // "Principal.Entity.ID": entity.Bruce.ID,
9911
- // "Related.Entity.ID": eRelation["Other.Entity.ID"],
9912
- // "Relation.Type.ID": eRelation["Relation.Type.ID"]
9913
- // };
9914
- // if (this.shouldRenderRelation(relation)) {
9915
- // toRender.push(relation);
9916
- // }
9917
- // }
9918
- // }
9919
- // }
9920
10089
  if (toRender.length) {
9921
10090
  this.onGetterUpdate(toRender);
9922
10091
  }
9923
- return [3 /*break*/, 6];
10092
+ _b.label = 3;
10093
+ case 3:
10094
+ i++;
10095
+ return [3 /*break*/, 1];
10096
+ case 4: return [3 /*break*/, 6];
9924
10097
  case 5:
9925
- e_1 = _a.sent();
9926
- console.error(e_1);
10098
+ e_2 = _b.sent();
10099
+ console.error(e_2);
9927
10100
  return [3 /*break*/, 6];
9928
10101
  case 6: return [2 /*return*/];
9929
10102
  }
@@ -9951,7 +10124,7 @@
9951
10124
  Manager.prototype.onGetterUpdate = function (relations) {
9952
10125
  var _a, _b;
9953
10126
  return __awaiter(this, void 0, void 0, function () {
9954
- var killCEntity, cEntities, key, i, relation, key, cEntity, visual, e_2;
10127
+ var killCEntity, cEntities, key, i, relation, rego, key, cEntity, visual, e_3;
9955
10128
  var _this = this;
9956
10129
  return __generator(this, function (_c) {
9957
10130
  switch (_c.label) {
@@ -9986,6 +10159,19 @@
9986
10159
  }
9987
10160
  for (i = 0; i < relations.length; i++) {
9988
10161
  relation = relations[i];
10162
+ rego = this.register.GetRego({
10163
+ menuItemId: this.item.id,
10164
+ relation: relation
10165
+ });
10166
+ if (rego) {
10167
+ this.register.RemoveRegos({
10168
+ entityId: rego.entityId,
10169
+ menuItemId: this.item.id,
10170
+ relation: relation,
10171
+ requestRender: false,
10172
+ doUpdate: true
10173
+ });
10174
+ }
9989
10175
  key = RelationRenderEngine.GetRenderGroupId(relation);
9990
10176
  cEntity = cEntities[key];
9991
10177
  if (cEntity && this.shouldRenderRelation(relation)) {
@@ -10020,8 +10206,8 @@
10020
10206
  this.viewer.scene.requestRender();
10021
10207
  return [3 /*break*/, 3];
10022
10208
  case 2:
10023
- e_2 = _c.sent();
10024
- console.error(e_2);
10209
+ e_3 = _c.sent();
10210
+ console.error(e_3);
10025
10211
  return [3 /*break*/, 3];
10026
10212
  case 3: return [2 /*return*/];
10027
10213
  }
@@ -13188,7 +13374,7 @@
13188
13374
  function renderNavigator(iteration, params, bookmark, view) {
13189
13375
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
13190
13376
  return __awaiter(this, void 0, void 0, function () {
13191
- var viewer, scene, vSettings, bSettings, defaults, camera, newLens, shouldBe2d, curIs2d, transition, pos, terrain, hillShades, baseColor, globeHidden, terrainWireframe, globeAlpha, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, selectedIds, hiddenIds, isolatedIds, labelledIds, curLabelledIds, toUnLabel, entityOpacityMap, entityId, opacity, imagery, legacyRelationIds, relations, curEnabled, newItemIds, _i, curEnabled_1, id, menuItem, gOcclusion;
13377
+ var viewer, scene, vSettings, bSettings, defaults, camera, newLens, shouldBe2d, curIs2d, transition, pos, terrain, hillShades, baseColor, globeHidden, terrainWireframe, globeAlpha, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, selectedIds, hiddenIds, isolatedIds, labelledIds, curLabelledIds, toUnLabel, entityOpacityMap, entityId, opacity, imagery, legacyRelationIds, relations, curEnabled, newItemIds, _i, curEnabled_1, id, shouldRemove, rendered, menuItem, menuItem, gOcclusion;
13192
13378
  return __generator(this, function (_7) {
13193
13379
  switch (_7.label) {
13194
13380
  case 0:
@@ -13486,8 +13672,26 @@
13486
13672
  newItemIds = (_5 = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _5 !== void 0 ? _5 : [];
13487
13673
  for (_i = 0, curEnabled_1 = curEnabled; _i < curEnabled_1.length; _i++) {
13488
13674
  id = curEnabled_1[_i];
13489
- if ((newItemIds.indexOf(id) === -1 && id != RELATION_MENU_ITEM_ID) ||
13490
- (id == RELATION_MENU_ITEM_ID && !legacyRelationIds.length && !relations.length)) {
13675
+ shouldRemove = void 0;
13676
+ if (id == RELATION_MENU_ITEM_ID) {
13677
+ rendered = params.manager.GetEnabledItem(id);
13678
+ shouldRemove = false;
13679
+ if (!legacyRelationIds.length && !relations.length) {
13680
+ shouldRemove = true;
13681
+ }
13682
+ // If we're about to render legacy relationships but a non-legacy item is currently enabled then we remove it.
13683
+ else if (legacyRelationIds.length && (rendered === null || rendered === void 0 ? void 0 : rendered.type) != bruceModels.MenuItem.EType.Relations) {
13684
+ shouldRemove = true;
13685
+ }
13686
+ // If we're about to render non-legacy relationships but a legacy item is currently enabled then we remove it.
13687
+ else if (relations.length && (rendered === null || rendered === void 0 ? void 0 : rendered.type) != bruceModels.MenuItem.EType.Relationships) {
13688
+ shouldRemove = true;
13689
+ }
13690
+ }
13691
+ else {
13692
+ shouldRemove = newItemIds.indexOf(id) === -1;
13693
+ }
13694
+ if (shouldRemove) {
13491
13695
  params.manager.RemoveItemById({
13492
13696
  menuItemId: id
13493
13697
  });
@@ -13508,19 +13712,32 @@
13508
13712
  _7.label = 4;
13509
13713
  case 4:
13510
13714
  if (legacyRelationIds.length || relations.length) {
13511
- menuItem = {
13512
- id: RELATION_MENU_ITEM_ID,
13513
- Caption: "Entity relations",
13514
- BruceEntity: {
13515
- EntityIds: legacyRelationIds
13516
- },
13517
- relations: relations,
13518
- Type: bruceModels.MenuItem.EType.Relations
13519
- };
13520
- params.manager.RenderItem({
13521
- getters: params.getters,
13522
- item: menuItem
13523
- });
13715
+ if (relations.length) {
13716
+ menuItem = {
13717
+ id: RELATION_MENU_ITEM_ID,
13718
+ Caption: "Entity relations",
13719
+ relations: relations,
13720
+ Type: bruceModels.MenuItem.EType.Relationships
13721
+ };
13722
+ params.manager.RenderItem({
13723
+ getters: params.getters,
13724
+ item: menuItem
13725
+ });
13726
+ }
13727
+ else if (legacyRelationIds.length) {
13728
+ menuItem = {
13729
+ id: RELATION_MENU_ITEM_ID,
13730
+ Caption: "Entity relations",
13731
+ BruceEntity: {
13732
+ EntityIds: legacyRelationIds
13733
+ },
13734
+ Type: bruceModels.MenuItem.EType.Relations
13735
+ };
13736
+ params.manager.RenderItem({
13737
+ getters: params.getters,
13738
+ item: menuItem
13739
+ });
13740
+ }
13524
13741
  if (!assertIteration$1(params.viewer, iteration)) {
13525
13742
  return [2 /*return*/];
13526
13743
  }
@@ -16436,7 +16653,7 @@
16436
16653
  ViewerUtils.CreateWidgets = CreateWidgets;
16437
16654
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
16438
16655
 
16439
- var VERSION$1 = "2.9.2";
16656
+ var VERSION$1 = "2.9.4";
16440
16657
 
16441
16658
  exports.VERSION = VERSION$1;
16442
16659
  exports.CesiumViewMonitor = CesiumViewMonitor;