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.
@@ -1,6 +1,6 @@
1
- import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, EntityAttribute, EntityAttachment, EntityAttachmentType, Session, AbstractApi } from 'bruce-models';
1
+ import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, AbstractApi, Session, EntityAttribute, EntityAttachment, EntityAttachmentType } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, ColorBlendMode, HeadingPitchRoll, Transforms, Model, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, SceneMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, KmlDataSource, OrthographicFrustum, EasingFunction, NearFarScalar, SceneTransforms, EllipsoidTerrainProvider, CesiumInspector, defined, ClockRange, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, Quaternion, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, SceneMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, PolygonPipeline, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8414,16 +8414,16 @@ var EntityRenderEngine;
8414
8414
  min = 0;
8415
8415
  }
8416
8416
  // Adjusting slightly because I distrust our initial calculation vs Cesium's one.
8417
- max = (+max) * 1.2;
8417
+ max = (+max) * 1.8;
8418
8418
  min = +min;
8419
8419
  if (min > 0) {
8420
8420
  min = (+min) * 0.8;
8421
8421
  }
8422
8422
  meterSize = +meterSize;
8423
8423
  if (!isNaN(meterSize) && meterSize > 0) {
8424
- // A 1m thing at 2000m distance is barely visible, so we can cull it.
8424
+ // A 1m thing at 3000m distance is barely visible, so we can cull it.
8425
8425
  // So we'll multiply this magic distance by the size of the thing and determine when it'll be too small to see.
8426
- var METER_DISTANCE_PER_METER = isPolygon ? 100 : 2000;
8426
+ var METER_DISTANCE_PER_METER = isPolygon ? 200 : 3000;
8427
8427
  var newMax = meterSize * METER_DISTANCE_PER_METER;
8428
8428
  // Enforcing a minimum max distance in case something goes wrong we want stuff to always be visible when close.
8429
8429
  var MIN_MAX = 300;
@@ -11861,6 +11861,20 @@ function getValue$2(viewer, obj) {
11861
11861
  function colorToCColor$1(color) {
11862
11862
  return new Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
11863
11863
  }
11864
+ function getShowDebugBounds() {
11865
+ if (!window) {
11866
+ return false;
11867
+ }
11868
+ var showBounds = window === null || window === void 0 ? void 0 : window.ENTITIES_RENDER_MANAGER_SHOW_BOUNDS;
11869
+ if (showBounds) {
11870
+ return true;
11871
+ }
11872
+ if (window.location.search) {
11873
+ var params = new URLSearchParams(window.location.search);
11874
+ showBounds = params.get("debugScanBounds");
11875
+ }
11876
+ return showBounds == "true" || showBounds == "1" || showBounds == "yes";
11877
+ }
11864
11878
  /**
11865
11879
  * Manager for rendering Bruce entities.
11866
11880
  * This will request entities based on setup menu item filter.
@@ -11996,9 +12010,10 @@ var EntitiesRenderManager;
11996
12010
  // Unfortunately this searches as an "AND" rather than "OR" which does not meet our needs here.
11997
12011
  // So for multiple tags we'll manually sort on UI end...
11998
12012
  tagIds: (tagsToRender === null || tagsToRender === void 0 ? void 0 : tagsToRender.length) ? tagsToRender : [],
11999
- debugShowBounds: Boolean(window === null || window === void 0 ? void 0 : window.ENTITIES_RENDER_MANAGER_SHOW_BOUNDS),
12013
+ debugShowBounds: getShowDebugBounds(),
12000
12014
  cdn: this.item.cdnEnabled,
12001
12015
  historicAttrKey: this.item.BruceEntity.historicAttrKey,
12016
+ historicInterpolation: this.item.historicInterpolation,
12002
12017
  schemaId: (_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b.schemaId
12003
12018
  });
12004
12019
  var minMax = RenderManager.GetZoomMinMax({
@@ -12226,7 +12241,7 @@ var EntitiesRenderManager;
12226
12241
  switch (_b.label) {
12227
12242
  case 0:
12228
12243
  _b.trys.push([0, 8, , 9]);
12229
- if (this.disposed || this.viewer.isDestroyed()) {
12244
+ if (this.disposed || this.viewer.isDestroyed() || !(entities === null || entities === void 0 ? void 0 : entities.length)) {
12230
12245
  return [2 /*return*/];
12231
12246
  }
12232
12247
  typeId_1 = (_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a["EntityType.ID"];
@@ -12622,28 +12637,16 @@ var EntitiesRenderManager;
12622
12637
  * @returns
12623
12638
  */
12624
12639
  Manager.prototype.renderAsIndividuals = function (entities, force) {
12625
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
12640
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
12626
12641
  if (force === void 0) { force = false; }
12627
12642
  return __awaiter(this, void 0, void 0, function () {
12628
- var entitiesHistoric, toRemove, i, entity, startTmp, stopTmp, startStr, stopStr, historicData, _m, updated, cEntities, i, entity, id, cEntity, rego, visual, wasClustered, tagIds, rego_1;
12629
- return __generator(this, function (_o) {
12630
- switch (_o.label) {
12643
+ 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;
12644
+ return __generator(this, function (_p) {
12645
+ switch (_p.label) {
12631
12646
  case 0:
12632
12647
  entitiesHistoric = {};
12633
- if (!((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.historicAttrKey)) return [3 /*break*/, 2];
12634
- toRemove = entities.filter(function (x) { var _a; return !((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.HistoricAttrKey); });
12635
- for (i = 0; i < toRemove.length; i++) {
12636
- entity = toRemove[i];
12637
- this.visualsManager.RemoveRegos({
12638
- entityId: entity.Bruce.ID,
12639
- menuItemId: this.item.id,
12640
- requestRender: false
12641
- });
12642
- (_b = this.clustering) === null || _b === void 0 ? void 0 : _b.RemoveEntity(entity.Bruce.ID, false);
12643
- }
12644
- entities = entities.filter(function (x) { var _a; return !!((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.HistoricAttrKey); });
12648
+ if (!(((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.historicAttrKey) && entities.length)) return [3 /*break*/, 3];
12645
12649
  if (!this.item.historicInterpolation) return [3 /*break*/, 2];
12646
- if (!entities.length) return [3 /*break*/, 2];
12647
12650
  startTmp = JulianDate.toDate(this.viewer.clock.startTime);
12648
12651
  stopTmp = JulianDate.toDate(this.viewer.clock.stopTime);
12649
12652
  startStr = new Date(startTmp.getTime() - 1000).toISOString();
@@ -12656,29 +12659,54 @@ var EntitiesRenderManager;
12656
12659
  api: this.apiGetter.getApi()
12657
12660
  })];
12658
12661
  case 1:
12659
- historicData = _o.sent();
12662
+ historicData = _p.sent();
12663
+ entitiesHistoric = historicData.recordsByIds;
12664
+ 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; });
12665
+ for (i = 0; i < toRemoveIds_1.length; i++) {
12666
+ removeId = toRemoveIds_1[i];
12667
+ this.visualsManager.RemoveRegos({
12668
+ entityId: removeId,
12669
+ menuItemId: this.item.id,
12670
+ requestRender: false
12671
+ });
12672
+ (_b = this.clustering) === null || _b === void 0 ? void 0 : _b.RemoveEntity(removeId, false);
12673
+ }
12674
+ entities = entities.filter(function (x) { return !toRemoveIds_1.includes(x.Bruce.ID); });
12675
+ return [3 /*break*/, 3];
12676
+ case 2:
12677
+ 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; });
12678
+ for (i = 0; i < toRemoveIds_2.length; i++) {
12679
+ removeId = toRemoveIds_2[i];
12680
+ this.visualsManager.RemoveRegos({
12681
+ entityId: removeId,
12682
+ menuItemId: this.item.id,
12683
+ requestRender: false
12684
+ });
12685
+ (_c = this.clustering) === null || _c === void 0 ? void 0 : _c.RemoveEntity(removeId, false);
12686
+ }
12687
+ entities = entities.filter(function (x) { return !toRemoveIds_2.includes(x.Bruce.ID); });
12688
+ _p.label = 3;
12689
+ case 3:
12660
12690
  if (this.disposed) {
12661
12691
  this.doDispose();
12662
12692
  return [2 /*return*/];
12663
12693
  }
12664
- entitiesHistoric = historicData.recordsByIds;
12665
- _o.label = 2;
12666
- case 2: return [4 /*yield*/, EntityRenderEngine.Render({
12667
- viewer: this.viewer,
12668
- apiGetter: this.apiGetter,
12669
- entities: entities,
12670
- menuItemId: this.item.id,
12671
- visualRegister: this.visualsManager,
12672
- zoomControl: this.item.CameraZoomSettings,
12673
- entitiesHistoric: entitiesHistoric,
12674
- entityHistoricDrawTrack: this.item.historicDrawTrack,
12675
- force: force,
12676
- optimizeGeometry: this.item.optimizeGeometry,
12677
- optimizeMinPoints: this.item.optimizeMinPoints,
12678
- optimizeTolerance: this.item.optimizeTolerance,
12679
- })];
12680
- case 3:
12681
- _m = _o.sent(), updated = _m.updated, cEntities = _m.entities;
12694
+ return [4 /*yield*/, EntityRenderEngine.Render({
12695
+ viewer: this.viewer,
12696
+ apiGetter: this.apiGetter,
12697
+ entities: entities,
12698
+ menuItemId: this.item.id,
12699
+ visualRegister: this.visualsManager,
12700
+ zoomControl: this.item.CameraZoomSettings,
12701
+ entitiesHistoric: entitiesHistoric,
12702
+ entityHistoricDrawTrack: this.item.historicDrawTrack,
12703
+ force: force,
12704
+ optimizeGeometry: this.item.optimizeGeometry,
12705
+ optimizeMinPoints: this.item.optimizeMinPoints,
12706
+ optimizeTolerance: this.item.optimizeTolerance,
12707
+ })];
12708
+ case 4:
12709
+ _o = _p.sent(), updated = _o.updated, cEntities = _o.entities;
12682
12710
  if (this.disposed) {
12683
12711
  this.doDispose();
12684
12712
  return [2 /*return*/];
@@ -12696,10 +12724,10 @@ var EntitiesRenderManager;
12696
12724
  visual = rego === null || rego === void 0 ? void 0 : rego.visual;
12697
12725
  if (!visual || visual != cEntity) {
12698
12726
  wasClustered = this.clustering ? this.clustering.AddEntity(id, cEntity, false) : false;
12699
- tagIds = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c["Layer.ID"];
12727
+ tagIds = (_d = entity.Bruce) === null || _d === void 0 ? void 0 : _d["Layer.ID"];
12700
12728
  rego_1 = {
12701
12729
  entityId: id,
12702
- schemaId: (_d = entity.Bruce) === null || _d === void 0 ? void 0 : _d.SchemaID,
12730
+ schemaId: (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e.SchemaID,
12703
12731
  menuItemId: this.item.id,
12704
12732
  menuItemType: this.item.Type,
12705
12733
  visual: cEntity,
@@ -12710,8 +12738,8 @@ var EntitiesRenderManager;
12710
12738
  overrideShow: wasClustered ? false : null,
12711
12739
  name: cEntity.name,
12712
12740
  cdn: this.item.cdnEnabled,
12713
- historicDateTime: (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e.HistoricDateTime,
12714
- historicAttrKey: (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f.HistoricAttrKey
12741
+ historicDateTime: (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f.HistoricDateTime,
12742
+ historicAttrKey: (_g = entity.Bruce) === null || _g === void 0 ? void 0 : _g.HistoricAttrKey
12715
12743
  };
12716
12744
  this.visualsManager.AddRego({
12717
12745
  rego: rego_1,
@@ -12722,11 +12750,11 @@ var EntitiesRenderManager;
12722
12750
  rego.name = cEntity.name;
12723
12751
  rego.visual = cEntity;
12724
12752
  rego.entityTypeId = entity.Bruce["EntityType.ID"];
12725
- rego.tagIds = ((_g = entity.Bruce) === null || _g === void 0 ? void 0 : _g["Layer.ID"]) ? [].concat(entity.Bruce["Layer.ID"]) : [];
12726
- rego.historicDateTime = (_h = entity.Bruce) === null || _h === void 0 ? void 0 : _h.HistoricDateTime;
12727
- rego.historicAttrKey = (_j = entity.Bruce) === null || _j === void 0 ? void 0 : _j.HistoricAttrKey;
12753
+ rego.tagIds = ((_h = entity.Bruce) === null || _h === void 0 ? void 0 : _h["Layer.ID"]) ? [].concat(entity.Bruce["Layer.ID"]) : [];
12754
+ rego.historicDateTime = (_j = entity.Bruce) === null || _j === void 0 ? void 0 : _j.HistoricDateTime;
12755
+ rego.historicAttrKey = (_k = entity.Bruce) === null || _k === void 0 ? void 0 : _k.HistoricAttrKey;
12728
12756
  rego.cdn = this.item.cdnEnabled;
12729
- rego.schemaId = (_k = entity.Bruce) === null || _k === void 0 ? void 0 : _k.SchemaID;
12757
+ rego.schemaId = (_l = entity.Bruce) === null || _l === void 0 ? void 0 : _l.SchemaID;
12730
12758
  // Marked as stale meaning some change was performed that requires a refresh.
12731
12759
  // This usually means a new sibling was added that we need to update.
12732
12760
  if (rego.stale) {
@@ -12756,7 +12784,7 @@ var EntitiesRenderManager;
12756
12784
  menuItemId: this.item.id,
12757
12785
  requestRender: false
12758
12786
  });
12759
- (_l = this.clustering) === null || _l === void 0 ? void 0 : _l.RemoveEntity(id, false);
12787
+ (_m = this.clustering) === null || _m === void 0 ? void 0 : _m.RemoveEntity(id, false);
12760
12788
  }
12761
12789
  }
12762
12790
  this.viewer.scene.requestRender();
@@ -16004,10 +16032,10 @@ var EntityGlobe;
16004
16032
  return range;
16005
16033
  }
16006
16034
  // Add minor decimal as API crashes when giving it whole numbers.
16007
- var maxLon = prepareRangeForBounds(this.Boundaries.maxLongitude) + 0.00001;
16008
- var minLon = prepareRangeForBounds(this.Boundaries.minLongitude) - 0.00001;
16009
- var maxLat = prepareRangeForBounds(this.Boundaries.maxLatitude) + 0.00001;
16010
- var minLat = prepareRangeForBounds(this.Boundaries.minLatitude) - 0.00001;
16035
+ var maxLon = prepareRangeForBounds(this.Boundaries.maxLongitude);
16036
+ var minLon = prepareRangeForBounds(this.Boundaries.minLongitude);
16037
+ var maxLat = prepareRangeForBounds(this.Boundaries.maxLatitude);
16038
+ var minLat = prepareRangeForBounds(this.Boundaries.minLatitude);
16011
16039
  return {
16012
16040
  east: maxLon,
16013
16041
  north: maxLat,
@@ -16030,6 +16058,7 @@ var EntityGlobe;
16030
16058
  var maxLon = viewRect.east;
16031
16059
  var MAX_CELLS = 150;
16032
16060
  var cellDegreeSize = getCellSizeFromHeight(viewRect.alt);
16061
+ // console.log("cell size", cellDegreeSize, "height", viewRect.alt);
16033
16062
  var curMinLon = floorValueToCellSize(cellDegreeSize, minLon);
16034
16063
  var curMinLat = floorValueToCellSize(cellDegreeSize, minLat);
16035
16064
  // For larger views we add additional padding because our view-area culling is too strong.
@@ -16086,39 +16115,45 @@ function getCellSizeFromHeight(height) {
16086
16115
  return 0.01;
16087
16116
  }
16088
16117
  if (height < 5000) {
16089
- return 0.025;
16118
+ return 0.05;
16090
16119
  }
16091
16120
  else if (height < 10000) {
16092
16121
  return 0.05;
16093
16122
  }
16094
16123
  else if (height < 30000) {
16095
- return 0.1;
16124
+ return 0.2;
16096
16125
  }
16097
16126
  else if (height < 70000) {
16098
16127
  return 0.2;
16099
16128
  }
16100
16129
  else if (height < 100000) {
16101
- return 0.3;
16130
+ return 0.5;
16102
16131
  }
16103
16132
  else if (height < 150000) {
16104
- return 0.4;
16133
+ return 0.5;
16105
16134
  }
16106
16135
  else if (height < 200000) {
16107
- return 0.5;
16136
+ return 1.5;
16108
16137
  }
16109
16138
  else if (height < 300000) {
16110
- return 0.6;
16139
+ return 1.5;
16111
16140
  }
16112
16141
  else if (height < 500000) {
16113
- return 1;
16142
+ return 3;
16114
16143
  }
16115
16144
  else if (height < 1000000) {
16116
- return 1.3;
16145
+ return 3;
16117
16146
  }
16118
16147
  else if (height < 1200000) {
16119
- return 1.8;
16148
+ return 4;
16149
+ }
16150
+ else if (height < 2000000) {
16151
+ return 6;
16152
+ }
16153
+ else if (height < 3000000) {
16154
+ return 20;
16120
16155
  }
16121
- return 4;
16156
+ return 35;
16122
16157
  }
16123
16158
  function isCellFetched(cell) {
16124
16159
  if (cell.Fetched) {
@@ -16184,20 +16219,28 @@ var EntityFilterGetter;
16184
16219
  this.onStateUpdate = null;
16185
16220
  this.onScanUpdate = null;
16186
16221
  this.viewPortChangeRemoval = null;
16222
+ this.viewPortDelayQueue = null;
16187
16223
  this.viewerDateTimeChangeRemoval = null;
16188
16224
  this.cells = null;
16189
16225
  this.registeredItems = {};
16190
16226
  this.getterLoopId = 0;
16227
+ this.getterLoopAbortControllers = {};
16191
16228
  this.tagIds = null;
16192
16229
  this.minHeight = 0;
16193
16230
  this.maxHeight = 100000;
16194
16231
  this.viewRect = null;
16195
16232
  this.viewCenter = null;
16196
- 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;
16233
+ this.historicRefreshAbortController = null;
16234
+ // Entity IDs found for the latest integrity.
16235
+ // We use this for refreshing historic data without having to repeat geographic queries.
16236
+ this.gatheredIntegrity = null;
16237
+ this.gatheredEntityIds = [];
16238
+ 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;
16197
16239
  this.api = api;
16198
16240
  this.typeId = typeId;
16199
16241
  this.schemaId = schemaId;
16200
16242
  this.historicAttrKey = historicAttrKey;
16243
+ this.historicInterpolation = Boolean(historicInterpolation);
16201
16244
  this.viaCdn = Boolean(viaCdn);
16202
16245
  this.batchSize = isNaN(batchSize) ? 300 : batchSize;
16203
16246
  this.viewPort = viewPort;
@@ -16250,15 +16293,22 @@ var EntityFilterGetter;
16250
16293
  Getter.prototype.viewAreaSub = function () {
16251
16294
  var _this = this;
16252
16295
  this.viewAreaDispose();
16253
- this.viewPortChangeRemoval = this.viewPort.Updated().Subscribe(function () {
16296
+ // We'll avoid restarting the scanner too often.
16297
+ this.viewPortDelayQueue = new DelayQueue(function () {
16254
16298
  _this.updateBounds();
16255
16299
  _this.startGetterLoop();
16300
+ }, 2000);
16301
+ this.viewPortChangeRemoval = this.viewPort.Updated().Subscribe(function () {
16302
+ var _a;
16303
+ (_a = _this.viewPortDelayQueue) === null || _a === void 0 ? void 0 : _a.Call();
16256
16304
  });
16257
16305
  };
16258
16306
  Getter.prototype.viewAreaDispose = function () {
16259
- var _a;
16307
+ var _a, _b;
16260
16308
  (_a = this.viewPortChangeRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
16261
16309
  this.viewPortChangeRemoval = null;
16310
+ (_b = this.viewPortDelayQueue) === null || _b === void 0 ? void 0 : _b.Dispose();
16311
+ this.viewPortDelayQueue = null;
16262
16312
  };
16263
16313
  /**
16264
16314
  * Monitors the Cesium viewer and updates the historic data filter values.
@@ -16272,6 +16322,11 @@ var EntityFilterGetter;
16272
16322
  // This is multiplied by the speed of animation to figure
16273
16323
  // out how many animation "ticks" before we allow an update.
16274
16324
  var INTERVAL_WHILE_ANIMATING = 2.5 * 1000;
16325
+ var INTERVAL_WHILE_NOT_ANIMATING = 1000;
16326
+ if (this.historicInterpolation) {
16327
+ INTERVAL_WHILE_ANIMATING = 6 * 1000;
16328
+ INTERVAL_WHILE_NOT_ANIMATING = 3.5 * 1000;
16329
+ }
16275
16330
  var lastUpdateTime = null;
16276
16331
  var delayQueue = new DelayQueue(function () {
16277
16332
  try {
@@ -16281,17 +16336,16 @@ var EntityFilterGetter;
16281
16336
  return;
16282
16337
  }
16283
16338
  }
16284
- lastUpdateTime = new Date().getTime();
16285
16339
  var current = _this.historicAttrDateTime;
16286
16340
  _this.updateHistoricDateTime();
16287
16341
  if (current != _this.historicAttrDateTime) {
16288
- _this.updateState();
16342
+ _this.emitHistoricData();
16289
16343
  }
16290
16344
  }
16291
16345
  catch (e) {
16292
16346
  console.error(e);
16293
16347
  }
16294
- }, 250);
16348
+ }, INTERVAL_WHILE_NOT_ANIMATING);
16295
16349
  var postUpdateRemoval = this.viewer.scene.postUpdate.addEventListener(function () {
16296
16350
  if (delayQueue) {
16297
16351
  delayQueue.Call();
@@ -16410,20 +16464,32 @@ var EntityFilterGetter;
16410
16464
  this.getterLoopId += 1;
16411
16465
  var loopId = this.getterLoopId;
16412
16466
  var loopIntegrity = this.getIntegrityId();
16413
- new Promise(function () { return __awaiter(_this, void 0, void 0, function () {
16414
- 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;
16467
+ // Abort any existing loops that don't match the current loop.
16468
+ // We tried using integrity, however we want to interrupt when user moves camera quickly.
16469
+ // So it's better to use the loop ID.
16470
+ var abortId = String(loopId);
16471
+ {
16472
+ var newAbortControllers = {};
16473
+ for (var key in this.getterLoopAbortControllers) {
16474
+ this.getterLoopAbortControllers[key].abort();
16475
+ }
16476
+ this.getterLoopAbortControllers = newAbortControllers;
16477
+ }
16478
+ var abortController = this.getterLoopAbortControllers[abortId] = new AbortController();
16479
+ (function () { return __awaiter(_this, void 0, void 0, function () {
16480
+ 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;
16415
16481
  var _a, _b, _c, _d, _e, _f, _g, _h;
16416
16482
  return __generator(this, function (_j) {
16417
16483
  switch (_j.label) {
16418
16484
  case 0:
16419
- // Minor delay to stop 50 menu items enabling doing their first request all together.
16420
- // This gives it time to recognize only 1 request is needed.
16421
- // Would be better to not use this delay but we're on a clock.
16422
- return [4 /*yield*/, delay(100)];
16485
+ // Larger initial delay for the first loops because terrain is likely loading in.
16486
+ // We also delay because if we enable 50 Menu Items at the same time, common requests we be made if we wait a bit.
16487
+ // Eg: same entity type will be grouped into the same filter getter instance.
16488
+ return [4 /*yield*/, delay(loopId <= 3 ? 800 : 300)];
16423
16489
  case 1:
16424
- // Minor delay to stop 50 menu items enabling doing their first request all together.
16425
- // This gives it time to recognize only 1 request is needed.
16426
- // Would be better to not use this delay but we're on a clock.
16490
+ // Larger initial delay for the first loops because terrain is likely loading in.
16491
+ // We also delay because if we enable 50 Menu Items at the same time, common requests we be made if we wait a bit.
16492
+ // Eg: same entity type will be grouped into the same filter getter instance.
16427
16493
  _j.sent();
16428
16494
  MIN_HEIGHT = this.minHeight;
16429
16495
  MAX_HEIGHT = this.maxHeight;
@@ -16505,7 +16571,10 @@ var EntityFilterGetter;
16505
16571
  viaCdn: this.viaCdn,
16506
16572
  migrated: true,
16507
16573
  req: {
16508
- noCache: true
16574
+ // If we are passing in an abort, we MUST pass in noCache.
16575
+ // Otherwise we will cache an aborted request.
16576
+ noCache: true,
16577
+ abortSignal: abortController.signal
16509
16578
  }
16510
16579
  })];
16511
16580
  case 9:
@@ -16514,6 +16583,20 @@ var EntityFilterGetter;
16514
16583
  if (loopIntegrity == integrity && entities) {
16515
16584
  (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger(entities);
16516
16585
  }
16586
+ if (this.gatheredIntegrity != integrity) {
16587
+ this.gatheredIntegrity = integrity;
16588
+ this.gatheredEntityIds = [];
16589
+ }
16590
+ // Add to the integrity list for any new IDs found.
16591
+ // This lets us keep track of all IDs we've found within the same integrity for historic data.
16592
+ if (this.historicAttrKey) {
16593
+ for (i = 0; i < entities.length; i++) {
16594
+ entity = entities[i];
16595
+ if (!this.gatheredEntityIds.includes(entity.Bruce.ID)) {
16596
+ this.gatheredEntityIds.push(entity.Bruce.ID);
16597
+ }
16598
+ }
16599
+ }
16517
16600
  if (this.getterLoopId != loopId) {
16518
16601
  return [3 /*break*/, 13];
16519
16602
  }
@@ -16556,7 +16639,14 @@ var EntityFilterGetter;
16556
16639
  return [3 /*break*/, 11];
16557
16640
  case 10:
16558
16641
  e_1 = _j.sent();
16642
+ // Ignore abort errors.
16643
+ if (e_1 && typeof e_1 === "object" && e_1.name == "AbortError") {
16644
+ return [3 /*break*/, 13];
16645
+ }
16559
16646
  console.error(e_1);
16647
+ if (this.getterLoopId != loopId) {
16648
+ return [3 /*break*/, 13];
16649
+ }
16560
16650
  // Request failed so let's add a delay and try again soon.
16561
16651
  retryDelay += RETRY_DELAY_INCREMENT;
16562
16652
  retryAttempts -= 1;
@@ -16575,7 +16665,104 @@ var EntityFilterGetter;
16575
16665
  return [2 /*return*/];
16576
16666
  }
16577
16667
  });
16578
- }); });
16668
+ }); })();
16669
+ };
16670
+ /**
16671
+ * Gets the historic state of found Entities for the current date times and emits them.
16672
+ * Since geometry searches are tied to the base Entity, we don't have to re-scan the viewport.
16673
+ */
16674
+ Getter.prototype.emitHistoricData = function () {
16675
+ var _this = this;
16676
+ var integrity = this.getIntegrityId();
16677
+ // Gathered ID does't match current one.
16678
+ if (this.gatheredIntegrity != integrity) {
16679
+ return;
16680
+ }
16681
+ var historicAttrDateTime = this.historicAttrDateTime;
16682
+ var SCAN_BATCH_SIZE = 1000;
16683
+ if (this.historicRefreshAbortController) {
16684
+ this.historicRefreshAbortController.abort();
16685
+ this.historicRefreshAbortController = null;
16686
+ }
16687
+ (function () { return __awaiter(_this, void 0, void 0, function () {
16688
+ var pageIndex, i, batch, controller, entities, e_2;
16689
+ var _a;
16690
+ return __generator(this, function (_b) {
16691
+ switch (_b.label) {
16692
+ case 0:
16693
+ pageIndex = 0;
16694
+ _b.label = 1;
16695
+ case 1:
16696
+ _b.trys.push([1, 6, , 7]);
16697
+ i = 0;
16698
+ _b.label = 2;
16699
+ case 2:
16700
+ if (!(i < this.gatheredEntityIds.length)) return [3 /*break*/, 5];
16701
+ batch = this.gatheredEntityIds.slice(i, i + SCAN_BATCH_SIZE);
16702
+ if (!batch.length) {
16703
+ return [3 /*break*/, 5];
16704
+ }
16705
+ controller = this.historicRefreshAbortController = new AbortController();
16706
+ return [4 /*yield*/, Entity$1.GetList({
16707
+ api: this.api,
16708
+ historicKey: this.historicAttrKey,
16709
+ historicPoint: historicAttrDateTime,
16710
+ schemaId: this.schemaId,
16711
+ filter: {
16712
+ pageSize: SCAN_BATCH_SIZE,
16713
+ pageIndex: pageIndex,
16714
+ entityTypeId: this.typeId,
16715
+ layerIds: this.tagIds,
16716
+ layerIdsOperator: "in",
16717
+ sortOrder: Api.ESortOrder.Asc,
16718
+ entityTypeConditions: {
16719
+ "ID": {
16720
+ "IN": batch
16721
+ }
16722
+ },
16723
+ },
16724
+ viaCdn: this.viaCdn,
16725
+ migrated: true,
16726
+ req: {
16727
+ // If we are passing in an abort, we MUST pass in noCache.
16728
+ // Otherwise we will cache an aborted request.
16729
+ noCache: true,
16730
+ abortSignal: controller.signal
16731
+ }
16732
+ })];
16733
+ case 3:
16734
+ entities = (_b.sent()).entities;
16735
+ // Date changed.
16736
+ if (this.historicAttrDateTime != historicAttrDateTime) {
16737
+ return [3 /*break*/, 5];
16738
+ }
16739
+ // Integrity changed.
16740
+ if (this.gatheredIntegrity != integrity) {
16741
+ return [3 /*break*/, 5];
16742
+ }
16743
+ // No Menu Items.
16744
+ if (!this.GetMenuItems().length) {
16745
+ return [3 /*break*/, 5];
16746
+ }
16747
+ (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(entities);
16748
+ pageIndex += 1;
16749
+ _b.label = 4;
16750
+ case 4:
16751
+ i += SCAN_BATCH_SIZE;
16752
+ return [3 /*break*/, 2];
16753
+ case 5: return [3 /*break*/, 7];
16754
+ case 6:
16755
+ e_2 = _b.sent();
16756
+ // Ignore abort errors.
16757
+ if (e_2 && typeof e_2 === "object" && e_2.name == "AbortError") {
16758
+ return [2 /*return*/];
16759
+ }
16760
+ console.error(e_2);
16761
+ return [3 /*break*/, 7];
16762
+ case 7: return [2 /*return*/];
16763
+ }
16764
+ });
16765
+ }); })();
16579
16766
  };
16580
16767
  return Getter;
16581
16768
  }());
@@ -16591,6 +16778,9 @@ function createFilterGetterCacheKey(params) {
16591
16778
  cacheKey += params.schemaId ? params.schemaId : "";
16592
16779
  cacheKey += JSON.stringify(params.tagIds ? params.tagIds : []);
16593
16780
  cacheKey += params.historicAttrKey ? params.historicAttrKey : "";
16781
+ if (params.historicAttrKey) {
16782
+ cacheKey += params.historicInterpolation ? "true" : "false";
16783
+ }
16594
16784
  // This could potentially crash, but if it crashes here then it would crash during API request anyways.
16595
16785
  cacheKey += JSON.stringify(params.attrFilter ? params.attrFilter : {});
16596
16786
  return cacheKey;
@@ -16615,6 +16805,7 @@ var SharedGetters;
16615
16805
  batchSize: params.batchSize,
16616
16806
  attrFilter: params.attrFilter,
16617
16807
  historicAttrKey: params.historicAttrKey,
16808
+ historicInterpolation: params.historicInterpolation,
16618
16809
  viaCdn: params.cdn
16619
16810
  });
16620
16811
  this.data[cacheKey] = getter;
@@ -16625,6 +16816,7 @@ var SharedGetters;
16625
16816
  if (params.viewer && params.debugShowBounds) {
16626
16817
  // Cell id -> entity.
16627
16818
  var cellCache_1 = {};
16819
+ var cellPrefix_1 = ObjectUtils.UId(10) + "_";
16628
16820
  getter.OnScanUpdate.Subscribe(function (cells) {
16629
16821
  if (window.ON_SCAN_UPDATE_PAUSED == true) {
16630
16822
  return;
@@ -16635,7 +16827,7 @@ var SharedGetters;
16635
16827
  cells.forEach(function (cell) {
16636
16828
  var _a;
16637
16829
  var bounds = cell.GetBounds();
16638
- var id = bounds.east + "_" + bounds.north + "_" + bounds.south + "_" + bounds.west;
16830
+ var id = cellPrefix_1 + bounds.east + "_" + bounds.north + "_" + bounds.south + "_" + bounds.west;
16639
16831
  curCellIds.push(id);
16640
16832
  fetchedCells[id] = cell.IsFetched();
16641
16833
  fetchingCellId = cell.Fetching ? id : fetchingCellId;
@@ -24122,11 +24314,11 @@ function renderNavigator(iteration, params, bookmark, view, getters) {
24122
24314
  var ViewRenderEngine;
24123
24315
  (function (ViewRenderEngine) {
24124
24316
  function Render(params) {
24125
- var _a;
24317
+ var _a, _b;
24126
24318
  return __awaiter(this, void 0, void 0, function () {
24127
- var iteration, api, view, _b, bookmark, bookmarkId, _c, version, bWidget;
24128
- return __generator(this, function (_d) {
24129
- switch (_d.label) {
24319
+ var iteration, api, view, _c, bookmark, bookmarkId, _d, version, bWidget, lpWidget;
24320
+ return __generator(this, function (_e) {
24321
+ switch (_e.label) {
24130
24322
  case 0:
24131
24323
  if (!params.manager && params.viewer) {
24132
24324
  params.manager = ViewerUtils.GetManager({
@@ -24149,17 +24341,17 @@ var ViewRenderEngine;
24149
24341
  }
24150
24342
  api = params.getters.GetBruceApi();
24151
24343
  if (!params.view) return [3 /*break*/, 1];
24152
- _b = params.view;
24344
+ _c = params.view;
24153
24345
  return [3 /*break*/, 3];
24154
24346
  case 1: return [4 /*yield*/, ProjectView.Get({
24155
24347
  api: api,
24156
24348
  viewId: params.viewId
24157
24349
  })];
24158
24350
  case 2:
24159
- _b = (_d.sent()).view;
24160
- _d.label = 3;
24351
+ _c = (_e.sent()).view;
24352
+ _e.label = 3;
24161
24353
  case 3:
24162
- view = _b;
24354
+ view = _c;
24163
24355
  bookmark = params.bookmark;
24164
24356
  if (!!bookmark) return [3 /*break*/, 7];
24165
24357
  bookmarkId = params.bookmarkId;
@@ -24173,14 +24365,14 @@ var ViewRenderEngine;
24173
24365
  bookmarkId: bookmarkId
24174
24366
  })];
24175
24367
  case 4:
24176
- _c = (_d.sent()).bookmark;
24368
+ _d = (_e.sent()).bookmark;
24177
24369
  return [3 /*break*/, 6];
24178
24370
  case 5:
24179
- _c = null;
24180
- _d.label = 6;
24371
+ _d = null;
24372
+ _e.label = 6;
24181
24373
  case 6:
24182
- bookmark = _c;
24183
- _d.label = 7;
24374
+ bookmark = _d;
24375
+ _e.label = 7;
24184
24376
  case 7:
24185
24377
  if (!assertIteration$1(params.viewer, iteration)) {
24186
24378
  return [2 /*return*/];
@@ -24189,12 +24381,12 @@ var ViewRenderEngine;
24189
24381
  if (!(version == 1)) return [3 /*break*/, 9];
24190
24382
  return [4 /*yield*/, renderLegacyNavigator(iteration, params, bookmark, view)];
24191
24383
  case 8:
24192
- _d.sent();
24384
+ _e.sent();
24193
24385
  return [3 /*break*/, 11];
24194
24386
  case 9: return [4 /*yield*/, renderNavigator(iteration, params, bookmark, view, params.getters)];
24195
24387
  case 10:
24196
- _d.sent();
24197
- _d.label = 11;
24388
+ _e.sent();
24389
+ _e.label = 11;
24198
24390
  case 11:
24199
24391
  if (!assertIteration$1(params.viewer, iteration)) {
24200
24392
  return [2 /*return*/];
@@ -24204,6 +24396,11 @@ var ViewRenderEngine;
24204
24396
  bWidget.ViewId = params.viewId ? params.viewId : view === null || view === void 0 ? void 0 : view.ID;
24205
24397
  bWidget.LastEnabledBookmarkId = params.bookmarkId ? params.bookmarkId : bookmark === null || bookmark === void 0 ? void 0 : bookmark.ID;
24206
24398
  }
24399
+ lpWidget = (_b = params.viewer) === null || _b === void 0 ? void 0 : _b[VIEWER_LEFT_PANEL_WIDGET_KEY];
24400
+ if (lpWidget) {
24401
+ lpWidget.ViewId = params.viewId ? params.viewId : view === null || view === void 0 ? void 0 : view.ID;
24402
+ lpWidget.LastEnabledBookmarkId = params.bookmarkId ? params.bookmarkId : bookmark === null || bookmark === void 0 ? void 0 : bookmark.ID;
24403
+ }
24207
24404
  return [2 /*return*/];
24208
24405
  }
24209
24406
  });
@@ -24246,6 +24443,8 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
24246
24443
  var isChanged = this._viewId != value;
24247
24444
  if (isChanged) {
24248
24445
  this._viewId = value;
24446
+ this._updatePanelStyles();
24447
+ this._loading = this.loadBookmarks();
24249
24448
  }
24250
24449
  },
24251
24450
  enumerable: false,
@@ -24297,13 +24496,15 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
24297
24496
  };
24298
24497
  WidgetLeftPanel.prototype.loadBookmarks = function () {
24299
24498
  return __awaiter(this, void 0, void 0, function () {
24300
- var api, viewId, data, e_1;
24499
+ var viewId, api, data, e_1;
24301
24500
  return __generator(this, function (_a) {
24302
24501
  switch (_a.label) {
24303
24502
  case 0:
24304
- _a.trys.push([0, 2, , 3]);
24305
- api = this._apiGetters.GetBruceApi();
24306
24503
  viewId = this._viewId;
24504
+ _a.label = 1;
24505
+ case 1:
24506
+ _a.trys.push([1, 3, , 4]);
24507
+ api = this._apiGetters.GetBruceApi();
24307
24508
  if (!viewId) {
24308
24509
  this.bookmarks = [];
24309
24510
  return [2 /*return*/];
@@ -24312,16 +24513,22 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
24312
24513
  viewId: viewId,
24313
24514
  api: api
24314
24515
  })];
24315
- case 1:
24516
+ case 2:
24316
24517
  data = _a.sent();
24518
+ if (this._viewId !== viewId) {
24519
+ return [2 /*return*/];
24520
+ }
24317
24521
  this.bookmarks = data.bookmarks;
24318
- return [3 /*break*/, 3];
24319
- case 2:
24522
+ return [3 /*break*/, 4];
24523
+ case 3:
24320
24524
  e_1 = _a.sent();
24321
24525
  console.error(e_1);
24526
+ if (this._viewId !== viewId) {
24527
+ return [2 /*return*/];
24528
+ }
24322
24529
  this.bookmarks = [];
24323
- return [3 /*break*/, 3];
24324
- case 3: return [2 /*return*/];
24530
+ return [3 /*break*/, 4];
24531
+ case 4: return [2 /*return*/];
24325
24532
  }
24326
24533
  });
24327
24534
  });
@@ -27871,7 +28078,7 @@ var WidgetViewBar = /** @class */ (function (_super) {
27871
28078
  return WidgetViewBar;
27872
28079
  }(Widget.AWidget));
27873
28080
 
27874
- var VERSION = "4.6.2";
28081
+ var VERSION = "4.6.4";
27875
28082
 
27876
28083
  export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar, WidgetControlViewBar, WidgetControlViewBarSearch, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
27877
28084
  //# sourceMappingURL=bruce-cesium.es5.js.map