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.
@@ -1,6 +1,6 @@
1
- import { Cartes, Entity as Entity$1, Calculator, EntityRelationType, EntityType, Style, ENVIRONMENT, ProjectViewTile, DelayQueue, LRUCache, BruceEvent, ObjectUtils, Geometry, EntityHistoricData, EntityLod, ZoomControl, EntityTag, Tileset, Api, EntityCoords, DataLab, EntitySource, ClientFile, MenuItem, EntityRelation, ProgramKey, Bounds, Carto, ProjectView, ProjectViewBookmark, ProjectViewLegacyTile, Camera, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session } from 'bruce-models';
1
+ import { Cartes, Entity as Entity$1, Calculator, EntityRelationType, EntityType, Style, ENVIRONMENT, ProjectViewTile, DelayQueue, LRUCache, BruceEvent, ObjectUtils, Geometry, EntityHistoricData, EntityLod, ZoomControl, EntityTag, Tileset, Api, DataLab, EntityCoords, EntitySource, ClientFile, MenuItem, EntityRelation, ProgramKey, Carto, ProjectView, ProjectViewBookmark, Bounds, ProjectViewLegacyTile, Camera, AbstractApi, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, DistanceDisplayCondition, HeightReference, HorizontalOrigin, VerticalOrigin, ClassificationType, ConstantPositionProperty, PolygonHierarchy, ShadowMode, PolylineGraphics, ArcType, CornerType, ColorBlendMode, Model, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, BoundingSphere, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
3
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, HeightReference, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, ShadowMode, Cartesian3, ClassificationType, Model, ArcType, CornerType, ConstantPositionProperty, JulianDate, Quaternion, Matrix4, HorizontalOrigin, VerticalOrigin, PolygonHierarchy, PolylineGraphics, Cartesian2, SceneTransforms, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Cesium3DTileset, IonResource, Ion, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, BoundingSphere, GeometryInstance, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -12871,6 +12871,23 @@ async function delay(milliseconds) {
12871
12871
  }, milliseconds);
12872
12872
  });
12873
12873
  }
12874
+ function createBoundsPolygonGeometry(bounds) {
12875
+ const ring = [
12876
+ `${bounds.west},${bounds.south}`,
12877
+ `${bounds.west},${bounds.north}`,
12878
+ `${bounds.east},${bounds.north}`,
12879
+ `${bounds.east},${bounds.south}`,
12880
+ `${bounds.west},${bounds.south}`
12881
+ ].join(" ");
12882
+ return {
12883
+ Polygon: [
12884
+ {
12885
+ Facing: Geometry.EPolygonRingType.Boundaries,
12886
+ LinearRing: ring
12887
+ }
12888
+ ]
12889
+ };
12890
+ }
12874
12891
  /**
12875
12892
  * This is a batched entity getter.
12876
12893
  * It will scan for entity records in a view-area and emit them in batches.
@@ -12929,7 +12946,7 @@ var EntityFilterGetter;
12929
12946
  // We use this for refreshing historic data without having to repeat geographic queries.
12930
12947
  this.gatheredIntegrity = null;
12931
12948
  this.gatheredEntityIds = [];
12932
- const { api, viewer, viewPort, typeIds, schemaId, batchSize, attrFilter, historicAttrKey, historicInterpolation, historic, viaCdn, scenario } = params;
12949
+ const { api, viewer, viewPort, typeIds, schemaId, batchSize, attrFilter, historicAttrKey, historicInterpolation, historic, viaCdn, scenario, dataLab } = params;
12933
12950
  this.api = api;
12934
12951
  this.typeIds = typeIds;
12935
12952
  this.schemaId = schemaId;
@@ -12940,6 +12957,7 @@ var EntityFilterGetter;
12940
12957
  this.batchSize = isNaN(batchSize) ? 300 : batchSize;
12941
12958
  this.viewPort = viewPort;
12942
12959
  this.attrFilter = attrFilter;
12960
+ this.dataLab = dataLab;
12943
12961
  this.viewer = viewer;
12944
12962
  this.scenario = scenario ? scenario : 0;
12945
12963
  this.updateBounds();
@@ -12964,6 +12982,9 @@ var EntityFilterGetter;
12964
12982
  if (this.typeIds) {
12965
12983
  integrity += this.typeIds.join();
12966
12984
  }
12985
+ if (this.dataLab) {
12986
+ integrity += JSON.stringify(this.dataLab);
12987
+ }
12967
12988
  return integrity;
12968
12989
  }
12969
12990
  viewAreaSub() {
@@ -13070,6 +13091,22 @@ var EntityFilterGetter;
13070
13091
  delete this.registeredItems[menuItemId];
13071
13092
  this.updateState(true);
13072
13093
  }
13094
+ Dispose() {
13095
+ var _a, _b, _c, _d;
13096
+ this.registeredItems = {};
13097
+ this.getterLoopId += 1;
13098
+ for (const key in this.getterLoopAbortControllers) {
13099
+ this.getterLoopAbortControllers[key].abort();
13100
+ }
13101
+ this.getterLoopAbortControllers = {};
13102
+ (_a = this.historicRefreshAbortController) === null || _a === void 0 ? void 0 : _a.abort();
13103
+ this.historicRefreshAbortController = null;
13104
+ this.viewAreaDispose();
13105
+ this.viewerDateTimeDispose();
13106
+ (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Clear();
13107
+ (_c = this.onStateUpdate) === null || _c === void 0 ? void 0 : _c.Clear();
13108
+ (_d = this.onScanUpdate) === null || _d === void 0 ? void 0 : _d.Clear();
13109
+ }
13073
13110
  updateBounds() {
13074
13111
  const viewRect = this.viewPort.GetBounds();
13075
13112
  const poi = this.viewPort.GetTarget();
@@ -13140,6 +13177,68 @@ var EntityFilterGetter;
13140
13177
  this.LastStateUpdates[status.msg] = status;
13141
13178
  (_a = this.onStateUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(status);
13142
13179
  }
13180
+ createDataLabQuery(bounds) {
13181
+ var _a;
13182
+ const dataLab = this.dataLab;
13183
+ const userItems = (dataLab === null || dataLab === void 0 ? void 0 : dataLab.queryItems) ? JSON.parse(JSON.stringify(dataLab.queryItems)) : [];
13184
+ const primaryKey = DataLab.EReqKey.Primary;
13185
+ const baseQuery = (dataLab === null || dataLab === void 0 ? void 0 : dataLab.query) ? JSON.parse(JSON.stringify(dataLab.query)) : {};
13186
+ const basePrimary = (_a = baseQuery === null || baseQuery === void 0 ? void 0 : baseQuery[primaryKey]) !== null && _a !== void 0 ? _a : {};
13187
+ const items = [
13188
+ {
13189
+ LogicOperator: "AND",
13190
+ AttributeValue: {
13191
+ AttributePath: "Bruce/Boundaries",
13192
+ OperandA: createBoundsPolygonGeometry(bounds),
13193
+ Operator: "intersects",
13194
+ ValueOption: "CONST"
13195
+ },
13196
+ key: "attribute"
13197
+ }
13198
+ ];
13199
+ if (userItems.length) {
13200
+ items.push({
13201
+ LogicOperator: "AND",
13202
+ Items: [],
13203
+ key: "subquery",
13204
+ Subquery: {
13205
+ Items: userItems
13206
+ }
13207
+ });
13208
+ }
13209
+ baseQuery[primaryKey] = {
13210
+ ...basePrimary,
13211
+ Items: items
13212
+ };
13213
+ baseQuery.Expand = "location,source";
13214
+ return baseQuery;
13215
+ }
13216
+ async getDataLabResponse(params) {
13217
+ var _a;
13218
+ const { bounds, pageIndex, pageSize, abortSignal } = params;
13219
+ const skip = pageIndex * pageSize;
13220
+ const data = await DataLab.Run({
13221
+ api: this.api,
13222
+ query: this.createDataLabQuery(bounds),
13223
+ skip,
13224
+ load: pageSize,
13225
+ migrated: true,
13226
+ req: {
13227
+ noCache: true,
13228
+ abortSignal
13229
+ }
13230
+ });
13231
+ const entities = (_a = data.entities) !== null && _a !== void 0 ? _a : [];
13232
+ const totalCount = data.totalCount;
13233
+ const nextPage = totalCount != null
13234
+ ? skip + entities.length < totalCount
13235
+ : entities.length >= pageSize;
13236
+ return {
13237
+ entities,
13238
+ nextPage,
13239
+ nextPageUrl: null
13240
+ };
13241
+ }
13143
13242
  startGetterLoop() {
13144
13243
  // Increase id so that existing loops stop.
13145
13244
  this.getterLoopId += 1;
@@ -13218,13 +13317,24 @@ var EntityFilterGetter;
13218
13317
  nextPage: false,
13219
13318
  nextPageUrl: null
13220
13319
  };
13221
- await SharedGetters.Queue.Run("Loading Entities from Menu Item that loads Entity Type: " + this.typeIds, async () => {
13320
+ const queueName = this.dataLab
13321
+ ? "Loading DataLab Entities from Menu Item"
13322
+ : "Loading Entities from Menu Item that loads Entity Type: " + this.typeIds;
13323
+ await SharedGetters.Queue.Run(queueName, async () => {
13222
13324
  var _a;
13223
13325
  if (abortController.signal.aborted || !((_a = this.GetMenuItems()) === null || _a === void 0 ? void 0 : _a.length)) {
13224
13326
  return;
13225
13327
  }
13328
+ if (this.dataLab) {
13329
+ response = await this.getDataLabResponse({
13330
+ bounds: curCell.GetBounds(),
13331
+ pageIndex: curCell.FetchPageIndex,
13332
+ pageSize: PAGE_SIZE,
13333
+ abortSignal: abortController.signal
13334
+ });
13335
+ }
13226
13336
  // API gave us a URL to use.
13227
- if (curCell.FetchURL) {
13337
+ else if (curCell.FetchURL) {
13228
13338
  const tmpResponse = await this.api.get(curCell.FetchURL, {
13229
13339
  abortSignal: abortController.signal,
13230
13340
  noCache: true
@@ -13494,6 +13604,9 @@ function createFilterGetterCacheKey(params) {
13494
13604
  cacheKey += params.historicAttrKey ? params.historicAttrKey : "";
13495
13605
  cacheKey += params.historic ? "true" : "false";
13496
13606
  cacheKey += params.scenario ? params.scenario : 0;
13607
+ if (params.dataLab) {
13608
+ cacheKey += JSON.stringify(params.dataLab);
13609
+ }
13497
13610
  if (params.historicAttrKey) {
13498
13611
  cacheKey += params.historicInterpolation ? "true" : "false";
13499
13612
  }
@@ -13525,6 +13638,7 @@ var SharedGetters;
13525
13638
  historicInterpolation: params.historicInterpolation,
13526
13639
  viaCdn: params.cdn,
13527
13640
  scenario: params.scenario,
13641
+ dataLab: params.dataLab,
13528
13642
  });
13529
13643
  this.data[cacheKey] = getter;
13530
13644
  /**
@@ -14867,6 +14981,8 @@ var TilesetCadRenderManager;
14867
14981
  TilesetCadRenderManager.Manager = Manager;
14868
14982
  })(TilesetCadRenderManager || (TilesetCadRenderManager = {}));
14869
14983
 
14984
+ const BATCH_SIZE$3 = 500;
14985
+ const CHECK_BATCH_SIZE$2 = 250;
14870
14986
  var DataLabRenderManager;
14871
14987
  (function (DataLabRenderManager) {
14872
14988
  class Manager {
@@ -14875,7 +14991,18 @@ var DataLabRenderManager;
14875
14991
  }
14876
14992
  constructor(params) {
14877
14993
  this.getter = null;
14994
+ this.getterSub = null;
14878
14995
  this.disposed = false;
14996
+ this.renderedEntities = {};
14997
+ this.entityCheckQueue = null;
14998
+ this.entityCheckQueueIds = [];
14999
+ this.isRunningCheck = false;
15000
+ this.viewMonitorRemoval = null;
15001
+ this.renderQueue = [];
15002
+ this.renderQueueInterval = null;
15003
+ this.reRenderState = new EntityReRenderMaintainState();
15004
+ this.zoomControl = [];
15005
+ this.queryLoadId = 0;
14879
15006
  const { viewer, item, apiGetter, monitor, visualsRegister } = params;
14880
15007
  this.viewer = viewer;
14881
15008
  this.item = item;
@@ -14883,13 +15010,54 @@ var DataLabRenderManager;
14883
15010
  this.monitor = monitor;
14884
15011
  this.visualsManager = visualsRegister;
14885
15012
  }
14886
- Init() {
15013
+ Init(params) {
14887
15014
  var _a;
14888
15015
  if (this.disposed) {
14889
15016
  throw new Error("This manager has already been disposed.");
14890
15017
  }
14891
- if (!((_a = this.item.CameraZoomSettings) === null || _a === void 0 ? void 0 : _a.length)) {
14892
- this.item.CameraZoomSettings = [
15018
+ if (params === null || params === void 0 ? void 0 : params.item) {
15019
+ this.item = params.item;
15020
+ }
15021
+ this.queryLoadId += 1;
15022
+ const loadId = this.queryLoadId;
15023
+ this.unsetGetter();
15024
+ (_a = this.viewMonitorRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
15025
+ this.viewMonitorRemoval = null;
15026
+ clearInterval(this.renderQueueInterval);
15027
+ this.renderQueueInterval = null;
15028
+ this.renderQueue = [];
15029
+ this.renderedEntities = {};
15030
+ this.ensureSettings();
15031
+ this.visualsManager.RemoveRegos({
15032
+ menuItemId: this.item.id
15033
+ });
15034
+ this.setEntityCheckQueue();
15035
+ (async () => {
15036
+ var _a, _b, _c, _d;
15037
+ try {
15038
+ const { query } = await DataLab.Get({
15039
+ api: this.apiGetter.getApi(),
15040
+ queryId: this.item.DataLabQueryID,
15041
+ req: {
15042
+ noCache: true
15043
+ }
15044
+ });
15045
+ if (this.disposed || loadId != this.queryLoadId) {
15046
+ return;
15047
+ }
15048
+ 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[DataLab.EReqKey.Primary]) === null || _c === void 0 ? void 0 : _c.Items) !== null && _d !== void 0 ? _d : [];
15049
+ this.setGetter(queryItems);
15050
+ }
15051
+ catch (e) {
15052
+ console.error("Failed to initialise DataLab render manager:", e);
15053
+ }
15054
+ })();
15055
+ }
15056
+ ensureSettings() {
15057
+ var _a;
15058
+ this.zoomControl = this.item.CameraZoomSettings;
15059
+ if (!((_a = this.zoomControl) === null || _a === void 0 ? void 0 : _a.length)) {
15060
+ this.zoomControl = [
14893
15061
  {
14894
15062
  MinZoom: 0,
14895
15063
  MaxZoom: 200000,
@@ -14899,17 +15067,74 @@ var DataLabRenderManager;
14899
15067
  StyleID: 0
14900
15068
  }
14901
15069
  ];
15070
+ this.item.CameraZoomSettings = this.zoomControl;
14902
15071
  }
14903
15072
  this.renderPriority = this.item.renderPriority;
14904
15073
  if (this.renderPriority == null) {
14905
15074
  this.renderPriority = 3;
14906
15075
  }
14907
- // Perform the initial query and subscribe to updates
14908
- this.getter = new BatchedDataGetter.Getter([this.item.DataLabQueryID], this.monitor, 1);
14909
- this.getter.OnUpdate.Subscribe((queryIds) => {
14910
- this.onGetterUpdate(queryIds[0]);
15076
+ }
15077
+ setGetter(queryItems) {
15078
+ this.unsetGetter();
15079
+ this.getter = new EntityFilterGetter.Getter({
15080
+ api: this.apiGetter.getApi(),
15081
+ attrFilter: {},
15082
+ batchSize: BATCH_SIZE$3,
15083
+ typeIds: null,
15084
+ viewPort: this.monitor,
15085
+ viewer: this.viewer,
15086
+ dataLab: {
15087
+ queryItems: queryItems !== null && queryItems !== void 0 ? queryItems : []
15088
+ }
14911
15089
  });
14912
- this.getter.Start();
15090
+ const minMax = RenderManager.GetZoomMinMax({
15091
+ zoomControl: this.zoomControl
15092
+ });
15093
+ this.getter.IncludeMenuItem(this.item.id, null, [], minMax[0], minMax[1]);
15094
+ this.getterSub = this.getter.OnUpdate.Subscribe((data) => {
15095
+ var _a;
15096
+ if (!((_a = data === null || data === void 0 ? void 0 : data.entities) === null || _a === void 0 ? void 0 : _a.length)) {
15097
+ return;
15098
+ }
15099
+ this.distributeForRender(data.entities);
15100
+ });
15101
+ }
15102
+ unsetGetter() {
15103
+ var _a, _b, _c;
15104
+ (_a = this.getter) === null || _a === void 0 ? void 0 : _a.ExcludeMenuItem(this.item.id);
15105
+ (_b = this.getterSub) === null || _b === void 0 ? void 0 : _b.call(this);
15106
+ this.getterSub = null;
15107
+ (_c = this.getter) === null || _c === void 0 ? void 0 : _c.Dispose();
15108
+ this.getter = null;
15109
+ }
15110
+ setEntityCheckQueue() {
15111
+ var _a, _b;
15112
+ (_a = this.entityCheckQueue) === null || _a === void 0 ? void 0 : _a.Dispose();
15113
+ this.entityCheckQueue = null;
15114
+ const displayItems = this.zoomControl ? this.zoomControl.filter(x => x.DisplayType != ZoomControl.EDisplayType.Hidden) : [];
15115
+ const shouldCheck = displayItems.length > 1;
15116
+ this.entityCheckQueue = new DelayQueue(() => {
15117
+ this.doEntityCheck(Object.keys(this.renderedEntities));
15118
+ }, shouldCheck ? 3000 : 30000);
15119
+ (_b = this.viewMonitorRemoval) === null || _b === void 0 ? void 0 : _b.call(this);
15120
+ this.viewMonitorRemoval = this.monitor.Updated().Subscribe(() => {
15121
+ var _a;
15122
+ (_a = this.entityCheckQueue) === null || _a === void 0 ? void 0 : _a.Call();
15123
+ });
15124
+ }
15125
+ preventCurrentCheckApiRefresh(entityIds) {
15126
+ var _a;
15127
+ this.reRenderState.markSkipForCurrentRun(entityIds, this.isRunningCheck);
15128
+ if ((_a = this.entityCheckQueueIds) === null || _a === void 0 ? void 0 : _a.length) {
15129
+ const lookup = {};
15130
+ for (let i = 0; i < entityIds.length; i++) {
15131
+ const id = entityIds[i];
15132
+ if (id) {
15133
+ lookup[id] = true;
15134
+ }
15135
+ }
15136
+ this.entityCheckQueueIds = this.entityCheckQueueIds.filter(id => !lookup[id]);
15137
+ }
14913
15138
  }
14914
15139
  Dispose() {
14915
15140
  if (this.disposed) {
@@ -14918,87 +15143,289 @@ var DataLabRenderManager;
14918
15143
  this.doDispose();
14919
15144
  }
14920
15145
  doDispose() {
14921
- var _a;
15146
+ var _a, _b;
14922
15147
  this.disposed = true;
14923
- (_a = this.getter) === null || _a === void 0 ? void 0 : _a.Dispose();
15148
+ this.queryLoadId += 1;
15149
+ this.unsetGetter();
15150
+ (_a = this.entityCheckQueue) === null || _a === void 0 ? void 0 : _a.Dispose();
15151
+ this.entityCheckQueue = null;
15152
+ (_b = this.viewMonitorRemoval) === null || _b === void 0 ? void 0 : _b.call(this);
15153
+ this.viewMonitorRemoval = null;
15154
+ clearInterval(this.renderQueueInterval);
15155
+ this.renderQueueInterval = null;
15156
+ this.renderQueue = [];
15157
+ this.entityCheckQueueIds = [];
14924
15158
  this.visualsManager.RemoveRegos({
14925
15159
  menuItemId: this.item.id
14926
15160
  });
14927
15161
  }
14928
- async onGetterUpdate(queryId) {
14929
- var _a;
14930
- if (this.disposed || this.viewer.isDestroyed()) {
15162
+ async ReRender(params) {
15163
+ let { entityIds, force, entities, maintain } = params;
15164
+ if (this.disposed) {
14931
15165
  return;
14932
15166
  }
15167
+ if (entities && !entityIds) {
15168
+ entityIds = entities.map(x => { var _a; return (_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID; });
15169
+ }
15170
+ if (entityIds == null) {
15171
+ entityIds = Object.keys(this.renderedEntities);
15172
+ }
15173
+ entityIds = entityIds.filter((x, index) => !!x && entityIds.indexOf(x) === index);
15174
+ if (!entityIds.length) {
15175
+ return;
15176
+ }
15177
+ if (entities === null || entities === void 0 ? void 0 : entities.length) {
15178
+ entities = [].concat(entities).filter(x => { var _a; return entityIds.includes((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID); });
15179
+ if (force) {
15180
+ this.reRenderState.bumpApiRevisions(entityIds);
15181
+ this.preventCurrentCheckApiRefresh(entityIds);
15182
+ }
15183
+ }
15184
+ if (maintain === true && (entities === null || entities === void 0 ? void 0 : entities.length)) {
15185
+ this.reRenderState.setMaintainedEntities(entities);
15186
+ }
15187
+ else if (maintain !== true) {
15188
+ this.reRenderState.clearMaintainedEntities(entityIds);
15189
+ }
15190
+ this.visualsManager.MarkStale({
15191
+ entityIds: entityIds,
15192
+ menuItemIds: [this.item.id]
15193
+ });
15194
+ if (entities === null || entities === void 0 ? void 0 : entities.length) {
15195
+ if (force) {
15196
+ await this.renderDataLabEntities(entities, true);
15197
+ }
15198
+ else {
15199
+ this.distributeForRender(entities);
15200
+ }
15201
+ }
15202
+ else {
15203
+ await this.doEntityCheck(entityIds, force);
15204
+ }
15205
+ }
15206
+ UpdateSettings(params) {
15207
+ const { zoomControl, queueRerender } = params;
15208
+ if (this.disposed) {
15209
+ return;
15210
+ }
15211
+ if (zoomControl === null || zoomControl === void 0 ? void 0 : zoomControl.length) {
15212
+ this.zoomControl = zoomControl;
15213
+ this.item.CameraZoomSettings = zoomControl;
15214
+ this.setEntityCheckQueue();
15215
+ }
15216
+ if (queueRerender != false) {
15217
+ const entityIds = Object.keys(this.renderedEntities);
15218
+ this.visualsManager.MarkStale({
15219
+ entityIds,
15220
+ menuItemIds: [this.item.id]
15221
+ });
15222
+ this.doEntityCheck(entityIds);
15223
+ }
15224
+ }
15225
+ async doEntityCheck(ids, force = false) {
15226
+ var _a, _b, _c, _d;
15227
+ if (this.isRunningCheck) {
15228
+ this.entityCheckQueueIds = this.entityCheckQueueIds.concat(ids);
15229
+ (_a = this.entityCheckQueue) === null || _a === void 0 ? void 0 : _a.Call();
15230
+ return;
15231
+ }
15232
+ ids = ids.concat(this.entityCheckQueueIds);
15233
+ this.entityCheckQueueIds = [];
15234
+ ids = ids.filter((id, index) => {
15235
+ return id && ids.indexOf(id) === index;
15236
+ });
15237
+ if (!ids.length) {
15238
+ return;
15239
+ }
15240
+ this.isRunningCheck = true;
15241
+ const runId = this.reRenderState.startCheckRun();
15242
+ const api = this.apiGetter.getApi();
14933
15243
  try {
14934
- const api = this.apiGetter.getApi();
14935
- const result = await DataLab.Get({ api, queryId });
14936
- const query = result.query;
14937
- const queryResult = await DataLab.Run({ api, query: {
14938
- [DataLab.EReqKey.Primary]: {
14939
- Items: ((_a = query === null || query === void 0 ? void 0 : query.PrimarySelectionCriteria) === null || _a === void 0 ? void 0 : _a.Items) || [],
15244
+ if (this.disposed) {
15245
+ return;
15246
+ }
15247
+ const maintained = this.reRenderState.getMaintainedEntities(ids);
15248
+ const maintainedLookup = {};
15249
+ for (let i = 0; i < maintained.length; i++) {
15250
+ const id = (_c = (_b = maintained[i]) === null || _b === void 0 ? void 0 : _b.Bruce) === null || _c === void 0 ? void 0 : _c.ID;
15251
+ if (id) {
15252
+ maintainedLookup[id] = true;
15253
+ }
15254
+ }
15255
+ if (maintained.length) {
15256
+ if (force) {
15257
+ await this.renderDataLabEntities(maintained, true);
15258
+ }
15259
+ else {
15260
+ this.distributeForRender(maintained);
15261
+ }
15262
+ }
15263
+ let apiIds = ids.filter((id) => {
15264
+ return !maintainedLookup[id] && !this.reRenderState.shouldSkipInRun(id, runId);
15265
+ });
15266
+ const checkBatch = async () => {
15267
+ apiIds = this.reRenderState.filterNonSkippedIds(apiIds, runId);
15268
+ const entityIds = apiIds.splice(0, CHECK_BATCH_SIZE$2);
15269
+ if (!entityIds.length) {
15270
+ return;
15271
+ }
15272
+ const revisions = this.reRenderState.captureApiRevisions(entityIds);
15273
+ const { entities } = await Entity$1.GetListByIds({
15274
+ api,
15275
+ entityIds,
15276
+ expandSources: true,
15277
+ expandLocation: true,
15278
+ migrated: true,
15279
+ maxSearchTimeSec: 60 * 2
15280
+ });
15281
+ if (this.disposed) {
15282
+ return;
15283
+ }
15284
+ const resolved = this.reRenderState.filterCurrentApiEntities({
15285
+ entities,
15286
+ revisions,
15287
+ runId
15288
+ });
15289
+ if (resolved.length) {
15290
+ if (force) {
15291
+ await this.renderDataLabEntities(resolved, true);
14940
15292
  }
14941
- } });
14942
- this.renderDataLabEntities(queryResult.entities || []);
15293
+ else {
15294
+ this.distributeForRender(resolved);
15295
+ }
15296
+ }
15297
+ };
15298
+ while (apiIds.length > 0) {
15299
+ await checkBatch();
15300
+ }
15301
+ }
15302
+ catch (e) {
15303
+ console.error(e);
14943
15304
  }
14944
- catch (error) {
14945
- console.error("Failed to perform query or render DataLab entities:", error);
15305
+ finally {
15306
+ this.isRunningCheck = false;
15307
+ if (this.entityCheckQueueIds.length) {
15308
+ (_d = this.entityCheckQueue) === null || _d === void 0 ? void 0 : _d.Call(true);
15309
+ }
14946
15310
  }
14947
15311
  }
14948
- async renderDataLabEntities(entities) {
14949
- if (this.disposed || this.viewer.isDestroyed()) {
15312
+ distributeForRender(entities) {
15313
+ if (this.disposed || !(entities === null || entities === void 0 ? void 0 : entities.length)) {
14950
15314
  return;
14951
15315
  }
14952
- const { updated, entities: cEntities } = await EntityRenderEngine.Render({
14953
- viewer: this.viewer,
14954
- apiGetter: this.apiGetter,
14955
- entities,
14956
- menuItemId: this.item.id,
14957
- visualRegister: this.visualsManager,
14958
- zoomControl: this.item.CameraZoomSettings
14959
- });
15316
+ this.renderQueue = this.renderQueue.concat(entities);
15317
+ if (!this.renderQueueInterval && this.renderQueue.length) {
15318
+ this.renderQueueInterval = setInterval(() => {
15319
+ const batch = this.deduplicateEntities(this.renderQueue.splice(0, BATCH_SIZE$3));
15320
+ this.renderDataLabEntities(batch);
15321
+ if (this.renderQueue.length <= 0) {
15322
+ clearInterval(this.renderQueueInterval);
15323
+ this.renderQueueInterval = null;
15324
+ }
15325
+ }, 50);
15326
+ }
15327
+ }
15328
+ deduplicateEntities(entities) {
15329
+ var _a;
15330
+ const entityMap = new Map();
14960
15331
  for (let i = 0; i < entities.length; i++) {
14961
15332
  const entity = entities[i];
14962
- const id = entity.Bruce.ID;
14963
- const cEntity = cEntities.get(id);
14964
- if (cEntity) {
14965
- const rego = this.visualsManager.GetRego({
14966
- entityId: id,
14967
- menuItemId: this.item.id
14968
- });
14969
- if (!rego) {
14970
- this.visualsManager.AddRego({
14971
- rego: {
14972
- canEdit: true,
15333
+ const id = (_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID;
15334
+ if (id) {
15335
+ entityMap.set(id, entity);
15336
+ }
15337
+ }
15338
+ return Array.from(entityMap.values());
15339
+ }
15340
+ async renderDataLabEntities(entities, force = false) {
15341
+ var _a, _b, _c;
15342
+ if (this.disposed || this.viewer.isDestroyed() || !(entities === null || entities === void 0 ? void 0 : entities.length)) {
15343
+ return;
15344
+ }
15345
+ try {
15346
+ const { updated, entities: cEntities } = await EntityRenderEngine.Render({
15347
+ viewer: this.viewer,
15348
+ apiGetter: this.apiGetter,
15349
+ entities,
15350
+ menuItemId: this.item.id,
15351
+ visualRegister: this.visualsManager,
15352
+ zoomControl: this.zoomControl,
15353
+ force
15354
+ });
15355
+ if (this.disposed) {
15356
+ return;
15357
+ }
15358
+ for (let i = 0; i < entities.length; i++) {
15359
+ const entity = entities[i];
15360
+ const id = entity.Bruce.ID;
15361
+ const cEntity = cEntities.get(id);
15362
+ this.renderedEntities[id] = !!cEntity;
15363
+ if (cEntity) {
15364
+ const rego = this.visualsManager.GetRego({
15365
+ entityId: id,
15366
+ menuItemId: this.item.id
15367
+ });
15368
+ const canEdit = !((_a = entity.Bruce.Outline) === null || _a === void 0 ? void 0 : _a.find(x => x.Baseline && !x.Editable));
15369
+ const visual = rego === null || rego === void 0 ? void 0 : rego.visual;
15370
+ if (!visual || visual != cEntity) {
15371
+ this.visualsManager.AddRego({
15372
+ rego: {
15373
+ canEdit,
15374
+ entityId: id,
15375
+ schema: entity.Bruce.Schema,
15376
+ menuItemId: this.item.id,
15377
+ menuItemType: this.item.Type,
15378
+ visual: cEntity,
15379
+ priority: this.renderPriority,
15380
+ entityTypeId: entity.Bruce["EntityType.ID"],
15381
+ accountId: this.apiGetter.accountId,
15382
+ tagIds: entity.Bruce["Layer.ID"] ? [].concat(entity.Bruce["Layer.ID"]) : [],
15383
+ name: cEntity.name,
15384
+ cdn: this.item.cdnEnabled,
15385
+ outline: entity.Bruce.Outline
15386
+ },
15387
+ requestRender: false
15388
+ });
15389
+ }
15390
+ else if (updated.get(id) && rego) {
15391
+ rego.name = cEntity.name;
15392
+ rego.visual = cEntity;
15393
+ rego.entityTypeId = entity.Bruce["EntityType.ID"];
15394
+ rego.tagIds = entity.Bruce["Layer.ID"] ? [].concat(entity.Bruce["Layer.ID"]) : [];
15395
+ rego.outline = (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b.Outline;
15396
+ rego.cdn = this.item.cdnEnabled;
15397
+ rego.schema = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c.Schema;
15398
+ rego.canEdit = canEdit;
15399
+ if (rego.stale) {
15400
+ this.visualsManager.RefreshMark({
15401
+ rego
15402
+ });
15403
+ this.visualsManager.ForceUpdate({
15404
+ entityIds: [id],
15405
+ refreshColors: true,
15406
+ requestRender: false
15407
+ });
15408
+ }
15409
+ this.visualsManager.OnUpdate.Trigger({
15410
+ type: VisualsRegister.EVisualUpdateType.Update,
14973
15411
  entityId: id,
14974
- menuItemId: this.item.id,
14975
- menuItemType: this.item.Type,
14976
- visual: cEntity,
14977
- priority: this.renderPriority,
14978
- entityTypeId: entity.Bruce["EntityType.ID"],
14979
- accountId: this.apiGetter.accountId,
14980
- name: cEntity.name
14981
- },
15412
+ rego: rego
15413
+ });
15414
+ }
15415
+ }
15416
+ else {
15417
+ this.visualsManager.RemoveRegos({
15418
+ entityId: id,
15419
+ menuItemId: this.item.id,
14982
15420
  requestRender: false
14983
15421
  });
14984
15422
  }
14985
15423
  }
14986
- else {
14987
- this.visualsManager.RemoveRegos({
14988
- entityId: id,
14989
- menuItemId: this.item.id,
14990
- requestRender: false
14991
- });
14992
- }
15424
+ this.viewer.scene.requestRender();
14993
15425
  }
14994
- this.viewer.scene.requestRender();
14995
- }
14996
- async ReRender() {
14997
- if (this.disposed) {
14998
- return;
15426
+ catch (e) {
15427
+ console.error("Failed to render DataLab entities:", e);
14999
15428
  }
15000
- // Re-perform the query and render again
15001
- await this.onGetterUpdate(this.item.DataLabQueryID);
15002
15429
  }
15003
15430
  }
15004
15431
  DataLabRenderManager.Manager = Manager;
@@ -15389,7 +15816,7 @@ var CesiumViewMonitor;
15389
15816
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
15390
15817
 
15391
15818
  const MAX_BATCHES = 2;
15392
- const BATCH_SIZE$3 = 1000;
15819
+ const BATCH_SIZE$4 = 1000;
15393
15820
  const BATCH_DELAY = 200;
15394
15821
  const MAX_RANGE = 3000;
15395
15822
  var TilesetOsmRenderManager;
@@ -15604,7 +16031,7 @@ var TilesetOsmRenderManager;
15604
16031
  const isClose = this.getIsVisualWithinRange(feature, MAX_RANGE);
15605
16032
  if (isClose) {
15606
16033
  batch.push(feature);
15607
- if (batch.length >= BATCH_SIZE$3) {
16034
+ if (batch.length >= BATCH_SIZE$4) {
15608
16035
  return batch;
15609
16036
  }
15610
16037
  }
@@ -15754,7 +16181,7 @@ var TilesetOsmRenderManager;
15754
16181
  delete this._loadedCesiumEntities[key];
15755
16182
  this.totalLoaded -= 1;
15756
16183
  removed += 1;
15757
- if (removed >= BATCH_SIZE$3) {
16184
+ if (removed >= BATCH_SIZE$4) {
15758
16185
  return true;
15759
16186
  }
15760
16187
  }
@@ -35541,7 +35968,7 @@ class WidgetViewBar extends Widget.AWidget {
35541
35968
  }
35542
35969
  }
35543
35970
 
35544
- const VERSION = "6.6.0";
35971
+ const VERSION = "6.6.2";
35545
35972
  /**
35546
35973
  * Updates the environment instance used by bruce-cesium to one specified.
35547
35974
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.