bruce-cesium 7.3.4 → 7.3.6

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.
Files changed (25) hide show
  1. package/dist/bruce-cesium.es5.js +517 -37
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +526 -47
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +1 -1
  6. package/dist/lib/rendering/menu-item-manager.js +6 -2
  7. package/dist/lib/rendering/menu-item-manager.js.map +1 -1
  8. package/dist/lib/rendering/render-managers/common/historic-utils.js +18 -1
  9. package/dist/lib/rendering/render-managers/common/historic-utils.js.map +1 -1
  10. package/dist/lib/rendering/render-managers/common/shared-getters-historic.js +349 -0
  11. package/dist/lib/rendering/render-managers/common/shared-getters-historic.js.map +1 -0
  12. package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js +66 -19
  13. package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js.map +1 -1
  14. package/dist/lib/utils/drawing-utils.js +60 -10
  15. package/dist/lib/utils/drawing-utils.js.map +1 -1
  16. package/dist/lib/widgets/widget-cursorbar.js +20 -2
  17. package/dist/lib/widgets/widget-cursorbar.js.map +1 -1
  18. package/dist/types/bruce-cesium.d.ts +1 -1
  19. package/dist/types/rendering/menu-item-manager.d.ts +1 -0
  20. package/dist/types/rendering/render-managers/common/historic-utils.d.ts +6 -0
  21. package/dist/types/rendering/render-managers/common/shared-getters-historic.d.ts +115 -0
  22. package/dist/types/rendering/render-managers/entities/entities-ids-render-manager.d.ts +5 -0
  23. package/dist/types/utils/drawing-utils.d.ts +4 -0
  24. package/dist/types/widgets/widget-cursorbar.d.ts +5 -2
  25. package/package.json +2 -2
@@ -182,6 +182,37 @@
182
182
  };
183
183
  }
184
184
  DrawingUtils.PointAcrossPolyline = PointAcrossPolyline;
185
+ const _sampledTerrain = new BModels.LRUCache(4000);
186
+ const _samplingTerrain = new Map();
187
+ // How precisely a sample is keyed. Roughly a metre, well under the resolution of any terrain we
188
+ // serve, so a camera that has not really moved asks the same question.
189
+ const SAMPLE_KEY_DECIMALS = 5;
190
+ // Identity for the provider a sample came from. Keyed on the object rather than on the tileset it
191
+ // was built from, so swapping terrain invalidates every height held against the old one.
192
+ const _providerIds = new WeakMap();
193
+ let _nextProviderId = 1;
194
+ /*
195
+ * Returns a stable id for a terrain provider, assigning one on first sight.
196
+ */
197
+ function terrainProviderId(provider) {
198
+ if (!provider) {
199
+ return 0;
200
+ }
201
+ let id = _providerIds.get(provider);
202
+ if (id == null) {
203
+ id = _nextProviderId++;
204
+ _providerIds.set(provider, id);
205
+ }
206
+ return id;
207
+ }
208
+ /**
209
+ * Empties the sampled terrain heights. For a terrain provider swap, or a test.
210
+ */
211
+ function ClearSampledTerrain() {
212
+ _sampledTerrain.Clear();
213
+ _samplingTerrain.clear();
214
+ }
215
+ DrawingUtils.ClearSampledTerrain = ClearSampledTerrain;
185
216
  /**
186
217
  * Returns terrain height from current viewer's provider.
187
218
  * On error or flat terrain, it will return 0.
@@ -205,17 +236,36 @@
205
236
  height: 0
206
237
  };
207
238
  }
208
- const sample = await Cesium.sampleTerrainMostDetailed(viewer.scene.terrainProvider, [Cesium.Cartographic.fromCartesian(pos3d)]);
209
- const height = (sample === null || sample === void 0 ? void 0 : sample.length) ? sample[0].height : null;
210
- if (isNaN(height)) {
211
- return {
212
- height: 0,
213
- error: "NaN"
214
- };
215
- }
216
- return {
217
- height: height
218
- };
239
+ const carto = Cesium.Cartographic.fromCartesian(pos3d);
240
+ const key = `${terrainProviderId(viewer.scene.terrainProvider)}`
241
+ + `_${carto.longitude.toFixed(SAMPLE_KEY_DECIMALS)}`
242
+ + `_${carto.latitude.toFixed(SAMPLE_KEY_DECIMALS)}`;
243
+ const held = _sampledTerrain.Get(key);
244
+ if (held != null) {
245
+ return { height: held };
246
+ }
247
+ // Two callers on the same point wait on the one sample rather than each asking for it.
248
+ const sampling = _samplingTerrain.get(key);
249
+ if (sampling) {
250
+ return sampling;
251
+ }
252
+ const prom = Cesium.sampleTerrainMostDetailed(viewer.scene.terrainProvider, [carto])
253
+ .then((sample) => {
254
+ const height = (sample === null || sample === void 0 ? void 0 : sample.length) ? sample[0].height : null;
255
+ if (height == null || isNaN(height)) {
256
+ return {
257
+ height: 0,
258
+ error: "NaN"
259
+ };
260
+ }
261
+ _sampledTerrain.Set(key, height);
262
+ return { height: height };
263
+ })
264
+ .finally(() => {
265
+ _samplingTerrain.delete(key);
266
+ });
267
+ _samplingTerrain.set(key, prom);
268
+ return prom;
219
269
  }
220
270
  catch (e) {
221
271
  return {
@@ -10993,6 +11043,22 @@
10993
11043
  return Math.round(minMs + ((maxMs - minMs) * progress));
10994
11044
  }
10995
11045
  HistoricFetchOrder.IntervalFor = IntervalFor;
11046
+ /**
11047
+ * Returns the cadence for a set of this size on a clock running at this rate.
11048
+ * @param entityCount
11049
+ * @param multiplier the viewer clock's, ie. scene seconds per real second
11050
+ */
11051
+ function IntervalForClock(entityCount, multiplier) {
11052
+ const bySize = IntervalFor(entityCount);
11053
+ const rate = Math.abs(multiplier);
11054
+ if (!(rate > 0)) {
11055
+ return HistoricFetchOrder.MAX_INTERVAL_MS;
11056
+ }
11057
+ // How long one second of scene time takes to pass, which is how often a record can appear.
11058
+ const perRecord = 1000 / rate;
11059
+ return Math.min(HistoricFetchOrder.MAX_INTERVAL_MS, Math.max(bySize, perRecord));
11060
+ }
11061
+ HistoricFetchOrder.IntervalForClock = IntervalForClock;
10996
11062
  // Upper bounds in metres for the distance bands, nearest first.
10997
11063
  HistoricFetchOrder.DEFAULT_BANDS = [500, 2000, 10000, 50000];
10998
11064
  /**
@@ -11375,7 +11441,8 @@
11375
11441
  * Returns how long to wait between refreshes for a set of this size.
11376
11442
  */
11377
11443
  IntervalFor(entityCount) {
11378
- return HistoricFetchOrder.IntervalFor(entityCount);
11444
+ var _a, _b, _c;
11445
+ return HistoricFetchOrder.IntervalForClock(entityCount, (_c = (_b = (_a = this.params.viewer) === null || _a === void 0 ? void 0 : _a.clock) === null || _b === void 0 ? void 0 : _b.multiplier) !== null && _c !== void 0 ? _c : 1);
11379
11446
  }
11380
11447
  /**
11381
11448
  * Fetches whatever the current clock range needs that is not already held.
@@ -13685,6 +13752,7 @@
13685
13752
  this.renderQueueForceFlags = [];
13686
13753
  this.reRenderState = new EntityReRenderMaintainState();
13687
13754
  const { viewer, apiGetter, monitor, item, register: visualsManager } = params;
13755
+ this.sharedHistoric = params.sharedHistoric;
13688
13756
  this.viewer = viewer;
13689
13757
  this.apiGetter = apiGetter;
13690
13758
  this.monitor = monitor;
@@ -13819,6 +13887,51 @@
13819
13887
  this.onGetterUpdate(entityIds);
13820
13888
  }
13821
13889
  }
13890
+ /*
13891
+ * The lane this item reads through, or null when it does not follow the clock.
13892
+ */
13893
+ getHistoricLane() {
13894
+ var _a, _b, _c;
13895
+ if (!this.sharedHistoric ||
13896
+ (!((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.historic) && !((_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b.historicAttrKey))) {
13897
+ return null;
13898
+ }
13899
+ if (!this.historicLane) {
13900
+ const historicKey = (_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historicAttrKey;
13901
+ this.historicLane = this.sharedHistoric.GetOrCreateLane({
13902
+ baseUrl: this.apiGetter.getApi().GetBaseUrl(),
13903
+ attrKey: historicKey,
13904
+ getMinIntervalMs: () => this.historicGatherer.IntervalFor(Object.keys(this.renderedEntities).length),
13905
+ subscribeToChanges: (onChanged) => {
13906
+ var _a;
13907
+ const feed = (_a = this.apiGetter.getApi()) === null || _a === void 0 ? void 0 : _a.RecordChangeFeed;
13908
+ if (!feed) {
13909
+ return null;
13910
+ }
13911
+ return feed.Subscribe({
13912
+ concepts: [BModels.AccountConcept.EConcept.ENTITY],
13913
+ actions: ["C", "U"]
13914
+ }, (event) => {
13915
+ if (typeof event.data === "string" && event.data) {
13916
+ onChanged(event.data);
13917
+ }
13918
+ });
13919
+ },
13920
+ isFeedConnected: () => { var _a, _b; return Boolean((_b = (_a = this.apiGetter.getApi()) === null || _a === void 0 ? void 0 : _a.RecordChangeFeed) === null || _b === void 0 ? void 0 : _b.IsConnected); },
13921
+ read: (entityIds, at) => BModels.Entity.GetListByIds({
13922
+ api: this.apiGetter.getApi(),
13923
+ entityIds: entityIds,
13924
+ historicPoint: new Date(at).toISOString(),
13925
+ historicKey: historicKey,
13926
+ expandSources: true,
13927
+ expandLocation: true,
13928
+ migrated: true,
13929
+ maxSearchTimeSec: 60 * 5,
13930
+ }).then(res => res.entities || [])
13931
+ });
13932
+ }
13933
+ return this.historicLane;
13934
+ }
13822
13935
  async onGetterUpdate(entityIds, force = false) {
13823
13936
  var _a, _b;
13824
13937
  if (this.disposed || this.viewer.isDestroyed() || !(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
@@ -13840,25 +13953,23 @@
13840
13953
  if (!apiIds.length) {
13841
13954
  return;
13842
13955
  }
13843
- const api = this.apiGetter.getApi();
13844
13956
  const revisions = this.reRenderState.captureApiRevisions(apiIds);
13845
- let newDateTime = null;
13846
- if (this.item.BruceEntity.historic || this.item.BruceEntity.historicAttrKey) {
13847
- newDateTime = Cesium.JulianDate.toDate(this.viewer.clock.currentTime).toISOString();
13848
- }
13849
- const { entities } = await BModels.Entity.GetListByIds({
13850
- api,
13851
- entityIds: apiIds,
13852
- historicPoint: newDateTime,
13853
- historicKey: this.item.BruceEntity.historicAttrKey,
13854
- expandSources: true,
13855
- expandLocation: true,
13856
- migrated: true,
13857
- // If we're taking 5+ minutes to make a query, it's a dud.
13858
- // This is a timeout imposed on our DB and not external sources.
13859
- // Honestly could lower down to 30 seconds, but we'll keep it high for now.
13860
- maxSearchTimeSec: 60 * 5,
13861
- });
13957
+ const lane = this.getHistoricLane();
13958
+ const entities = lane
13959
+ ? await lane.Request({
13960
+ subscriberId: this.item.id,
13961
+ entityIds: apiIds,
13962
+ at: Cesium.JulianDate.toDate(this.viewer.clock.currentTime).getTime(),
13963
+ force: force
13964
+ })
13965
+ : (await BModels.Entity.GetListByIds({
13966
+ api: this.apiGetter.getApi(),
13967
+ entityIds: apiIds,
13968
+ expandSources: true,
13969
+ expandLocation: true,
13970
+ migrated: true,
13971
+ maxSearchTimeSec: 60 * 5,
13972
+ })).entities;
13862
13973
  const resolved = this.reRenderState.filterCurrentApiEntities({
13863
13974
  entities,
13864
13975
  revisions
@@ -14074,6 +14185,7 @@
14074
14185
  return;
14075
14186
  }
14076
14187
  prevTick = currentTick;
14188
+ queue.delay = this.historicGatherer.IntervalFor(Object.keys(this.renderedEntities).length);
14077
14189
  queue.Call();
14078
14190
  });
14079
14191
  this.viewerDateTimeChangeRemoval = () => {
@@ -14086,9 +14198,11 @@
14086
14198
  };
14087
14199
  }
14088
14200
  viewerDateTimeDispose() {
14089
- var _a;
14201
+ var _a, _b;
14090
14202
  (_a = this.viewerDateTimeChangeRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
14091
14203
  this.viewerDateTimeChangeRemoval = null;
14204
+ // Whatever this item was waiting on is nobody's answer now.
14205
+ (_b = this.historicLane) === null || _b === void 0 ? void 0 : _b.Drop(this.item.id);
14092
14206
  }
14093
14207
  }
14094
14208
  EntitiesIdsRenderManager.Manager = Manager;
@@ -19498,6 +19612,351 @@
19498
19612
  DataLabRenderManager.Manager = Manager;
19499
19613
  })(exports.DataLabRenderManager || (exports.DataLabRenderManager = {}));
19500
19614
 
19615
+ /**
19616
+ * The shared read path for Entities whose position comes from the clock.
19617
+ */
19618
+ var SharedHistoricGetters;
19619
+ (function (SharedHistoricGetters) {
19620
+ // The floor between two reads on a lane, so a fast server is not read from as fast as it answers.
19621
+ SharedHistoricGetters.DEFAULT_MIN_INTERVAL_MS = 250;
19622
+ // How far from a held answer's instant it still answers a new ask.
19623
+ SharedHistoricGetters.DEFAULT_FRESH_MS = 200;
19624
+ // How slow the idle backoff is allowed to make a lane.
19625
+ SharedHistoricGetters.DEFAULT_MAX_INTERVAL_MS = 3000;
19626
+ // How many unchanged reads it takes to reach that, doubling the wait each time.
19627
+ SharedHistoricGetters.IDLE_DOUBLINGS = 6;
19628
+ // The idle cap while a record change feed is connected.
19629
+ SharedHistoricGetters.FEED_MAX_INTERVAL_MS = 15000;
19630
+ /*
19631
+ * What an Entity looks like to the idle check: where it is, how it is turned, and when it was last written.
19632
+ */
19633
+ function SignatureOf(entity) {
19634
+ const bruce = entity === null || entity === void 0 ? void 0 : entity.Bruce;
19635
+ if (!bruce) {
19636
+ return "";
19637
+ }
19638
+ const location = bruce.Location;
19639
+ const transform = bruce.Transform;
19640
+ return [
19641
+ bruce.Updated || "",
19642
+ location ? `${location.latitude},${location.longitude},${location.altitude}` : "",
19643
+ transform ? `${transform.heading},${transform.pitch},${transform.roll}` : ""
19644
+ ].join("|");
19645
+ }
19646
+ SharedHistoricGetters.SignatureOf = SignatureOf;
19647
+ /**
19648
+ * One read path, shared by every manager reading the same Entities the same way.
19649
+ */
19650
+ class Lane {
19651
+ constructor(params) {
19652
+ this.params = params;
19653
+ // Subscriber to their one outstanding ask.
19654
+ this.pending = new Map();
19655
+ this.inFlight = false;
19656
+ this.lastSentAt = 0;
19657
+ this.pumpTimeout = null;
19658
+ // Set between an ask arriving and the pump running, so asks made in the same turn merge.
19659
+ this.pumpScheduled = false;
19660
+ this.disposed = false;
19661
+ // The last answer, kept so an ask that lands beside it is served rather than sent.
19662
+ this.held = null;
19663
+ // Entity id to what it looked like on the last read, for deciding whether anything moved.
19664
+ this.heldSignatures = {};
19665
+ // How many reads in a row have come back saying the same thing.
19666
+ this.idleReads = 0;
19667
+ // Entity internal id to its id, for matching what the feed reports against what is held.
19668
+ this.heldInternalIds = new Map();
19669
+ this.feedRemoval = null;
19670
+ this.feedWired = false;
19671
+ }
19672
+ /**
19673
+ * Asks for these Entities at this instant, resolving with them however the lane gets there:
19674
+ * from the held answer, from a read already about to happen, or from one this ask starts.
19675
+ */
19676
+ Request(ask) {
19677
+ if (this.disposed) {
19678
+ return Promise.resolve([]);
19679
+ }
19680
+ this.wireFeed();
19681
+ if (ask.force) {
19682
+ this.idleReads = 0;
19683
+ }
19684
+ const fresh = this.freshAnswerFor(ask);
19685
+ if (fresh) {
19686
+ return Promise.resolve(fresh);
19687
+ }
19688
+ return new Promise((resolve, reject) => {
19689
+ // Whoever was waiting on this subscriber's previous ask is answered by this one, so
19690
+ // they are handed the newer read rather than left hanging on a dropped request.
19691
+ const superseded = this.pending.get(ask.subscriberId);
19692
+ this.pending.set(ask.subscriberId, {
19693
+ ask,
19694
+ resolve: (entities) => {
19695
+ superseded === null || superseded === void 0 ? void 0 : superseded.resolve(entities);
19696
+ resolve(entities);
19697
+ },
19698
+ reject: (error) => {
19699
+ superseded === null || superseded === void 0 ? void 0 : superseded.reject(error);
19700
+ reject(error);
19701
+ }
19702
+ });
19703
+ this.schedulePump();
19704
+ });
19705
+ }
19706
+ /**
19707
+ * Forgets a subscriber, for a manager that has been disposed while it was waiting.
19708
+ */
19709
+ Drop(subscriberId) {
19710
+ const waiter = this.pending.get(subscriberId);
19711
+ if (waiter) {
19712
+ this.pending.delete(subscriberId);
19713
+ waiter.resolve([]);
19714
+ }
19715
+ }
19716
+ /**
19717
+ * Tells the lane that records it holds have changed, so its next read happens on the caller's
19718
+ * cadence rather than behind whatever backoff a quiet spell had earned.
19719
+ */
19720
+ NotifyChanged() {
19721
+ if (this.disposed) {
19722
+ return;
19723
+ }
19724
+ this.idleReads = 0;
19725
+ this.schedulePump();
19726
+ }
19727
+ /**
19728
+ * The same, for a feed event naming Entity internal ids as ranges.
19729
+ * @param rangeString as reported by the record change feed.
19730
+ */
19731
+ NotifyChangedRange(rangeString) {
19732
+ if (this.disposed || !rangeString || !this.heldInternalIds.size) {
19733
+ return;
19734
+ }
19735
+ for (const internalId of Array.from(this.heldInternalIds.keys())) {
19736
+ if (BModels.RecordChangeFeed.isEntityInternalIdInRangeString(rangeString, internalId)) {
19737
+ this.NotifyChanged();
19738
+ return;
19739
+ }
19740
+ }
19741
+ }
19742
+ Dispose() {
19743
+ var _a;
19744
+ this.disposed = true;
19745
+ (_a = this.feedRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
19746
+ this.feedRemoval = null;
19747
+ if (this.pumpTimeout != null) {
19748
+ clearTimeout(this.pumpTimeout);
19749
+ this.pumpTimeout = null;
19750
+ }
19751
+ for (const waiter of Array.from(this.pending.values())) {
19752
+ waiter.resolve([]);
19753
+ }
19754
+ this.pending.clear();
19755
+ this.held = null;
19756
+ this.heldSignatures = {};
19757
+ this.heldInternalIds.clear();
19758
+ }
19759
+ /**
19760
+ * How many reads in a row have come back unchanged, which is what the wait is scaled by.
19761
+ */
19762
+ get IdleReads() {
19763
+ return this.idleReads;
19764
+ }
19765
+ /**
19766
+ * The wait the lane would apply before its next read,
19767
+ * ie. the caller's cadence after however far the idle backoff has widened it.
19768
+ */
19769
+ get IntervalMs() {
19770
+ return this.intervalNow();
19771
+ }
19772
+ /**
19773
+ * What the lane is currently holding, for a caller that wants it without asking for a read.
19774
+ */
19775
+ get Held() {
19776
+ return this.held;
19777
+ }
19778
+ /*
19779
+ * The wait before the next read: the caller's cadence, widened while nothing is changing.
19780
+ */
19781
+ intervalNow() {
19782
+ var _a, _b, _c;
19783
+ const base = this.params.getMinIntervalMs
19784
+ ? this.params.getMinIntervalMs() : SharedHistoricGetters.DEFAULT_MIN_INTERVAL_MS;
19785
+ if (!this.idleReads) {
19786
+ return base;
19787
+ }
19788
+ const maxInterval = (_a = this.params.maxIntervalMs) !== null && _a !== void 0 ? _a : (((_c = (_b = this.params).isFeedConnected) === null || _c === void 0 ? void 0 : _c.call(_b)) ? SharedHistoricGetters.FEED_MAX_INTERVAL_MS : SharedHistoricGetters.DEFAULT_MAX_INTERVAL_MS);
19789
+ const widened = base * Math.pow(2, Math.min(this.idleReads, SharedHistoricGetters.IDLE_DOUBLINGS));
19790
+ return Math.min(Math.max(base, maxInterval), widened);
19791
+ }
19792
+ /*
19793
+ * Returns the held answer when it covers this ask, or null when a read is needed.
19794
+ */
19795
+ freshAnswerFor(ask) {
19796
+ var _a;
19797
+ const freshMs = (_a = this.params.freshMs) !== null && _a !== void 0 ? _a : SharedHistoricGetters.DEFAULT_FRESH_MS;
19798
+ if (ask.force || !this.held || Math.abs(ask.at - this.held.at) > freshMs) {
19799
+ return null;
19800
+ }
19801
+ const entities = [];
19802
+ for (const entityId of ask.entityIds) {
19803
+ const entity = this.held.byId[entityId];
19804
+ // A partial answer is not an answer: the Entity may simply never have been asked for.
19805
+ if (!entity) {
19806
+ return null;
19807
+ }
19808
+ entities.push(entity);
19809
+ }
19810
+ return entities;
19811
+ }
19812
+ /*
19813
+ * Subscribes to the record change feed, on the first ask that finds one.
19814
+ */
19815
+ wireFeed() {
19816
+ if (this.feedWired || !this.params.subscribeToChanges) {
19817
+ return;
19818
+ }
19819
+ const removal = this.params.subscribeToChanges((rangeString) => this.NotifyChangedRange(rangeString));
19820
+ if (!removal) {
19821
+ return;
19822
+ }
19823
+ this.feedWired = true;
19824
+ this.feedRemoval = removal;
19825
+ }
19826
+ /*
19827
+ * Runs the pump at the end of this turn rather than during it.
19828
+ */
19829
+ schedulePump() {
19830
+ if (this.pumpScheduled || this.disposed) {
19831
+ return;
19832
+ }
19833
+ this.pumpScheduled = true;
19834
+ Promise.resolve().then(() => {
19835
+ this.pumpScheduled = false;
19836
+ this.pump();
19837
+ });
19838
+ }
19839
+ /*
19840
+ * Sends the next read when there is one to send and the lane is free to send it.
19841
+ */
19842
+ pump() {
19843
+ var _a;
19844
+ if (this.disposed || this.inFlight || !this.pending.size) {
19845
+ return;
19846
+ }
19847
+ const now = ((_a = this.params.now) !== null && _a !== void 0 ? _a : Date.now)();
19848
+ const waitFor = (this.lastSentAt + this.intervalNow()) - now;
19849
+ if (waitFor > 0) {
19850
+ // The pending map keeps absorbing asks meanwhile, so what eventually goes is the
19851
+ // union of everything wanted during the wait rather than the ask that started it.
19852
+ if (this.pumpTimeout == null) {
19853
+ this.pumpTimeout = setTimeout(() => {
19854
+ this.pumpTimeout = null;
19855
+ this.pump();
19856
+ }, waitFor);
19857
+ }
19858
+ return;
19859
+ }
19860
+ // Taken now rather than when each ask arrived, which is what makes an overtaken ask cost
19861
+ // nothing: it is simply part of this read instead of a read of its own.
19862
+ const waiters = Array.from(this.pending.values());
19863
+ this.pending.clear();
19864
+ const entityIds = [];
19865
+ const seen = {};
19866
+ let at = 0;
19867
+ for (const waiter of waiters) {
19868
+ at = Math.max(at, waiter.ask.at);
19869
+ for (const entityId of waiter.ask.entityIds) {
19870
+ if (entityId && !seen[entityId]) {
19871
+ seen[entityId] = true;
19872
+ entityIds.push(entityId);
19873
+ }
19874
+ }
19875
+ }
19876
+ if (!entityIds.length) {
19877
+ for (const waiter of waiters) {
19878
+ waiter.resolve([]);
19879
+ }
19880
+ return;
19881
+ }
19882
+ this.inFlight = true;
19883
+ this.lastSentAt = now;
19884
+ this.params.read(entityIds, at).then((entities) => {
19885
+ var _a, _b, _c;
19886
+ const signatureOf = (_a = this.params.signatureOf) !== null && _a !== void 0 ? _a : SignatureOf;
19887
+ const byId = {};
19888
+ let changed = false;
19889
+ for (const entity of entities || []) {
19890
+ const id = (_b = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _b === void 0 ? void 0 : _b.ID;
19891
+ if (!id) {
19892
+ continue;
19893
+ }
19894
+ byId[id] = entity;
19895
+ const internalId = (_c = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _c === void 0 ? void 0 : _c.InternalID;
19896
+ if (internalId != null) {
19897
+ this.heldInternalIds.set(internalId, id);
19898
+ }
19899
+ const signature = signatureOf(entity);
19900
+ // An Entity read for the first time is not a change: there is nothing it differs
19901
+ // from, and counting it as one would restart the backoff on every widened set.
19902
+ if (this.heldSignatures[id] != null && this.heldSignatures[id] !== signature) {
19903
+ changed = true;
19904
+ }
19905
+ this.heldSignatures[id] = signature;
19906
+ }
19907
+ this.idleReads = changed ? 0 : this.idleReads + 1;
19908
+ this.held = { at, byId };
19909
+ for (const waiter of waiters) {
19910
+ waiter.resolve(waiter.ask.entityIds.map(id => byId[id]).filter(x => !!x));
19911
+ }
19912
+ }).catch((error) => {
19913
+ for (const waiter of waiters) {
19914
+ waiter.reject(error);
19915
+ }
19916
+ }).finally(() => {
19917
+ this.inFlight = false;
19918
+ this.schedulePump();
19919
+ });
19920
+ }
19921
+ }
19922
+ SharedHistoricGetters.Lane = Lane;
19923
+ /**
19924
+ * The lanes in play, keyed so that two managers reading the same Entities the same way land on the same one.
19925
+ */
19926
+ class Cache {
19927
+ constructor() {
19928
+ this.lanes = {};
19929
+ }
19930
+ /**
19931
+ * Returns the lane for this endpoint and attribute key, creating it on first use.
19932
+ * @param params
19933
+ */
19934
+ GetOrCreateLane(params) {
19935
+ const key = `${params.baseUrl}|${params.attrKey || ""}`;
19936
+ let lane = this.lanes[key];
19937
+ if (!lane) {
19938
+ lane = new Lane({
19939
+ read: params.read,
19940
+ getMinIntervalMs: params.getMinIntervalMs,
19941
+ freshMs: params.freshMs,
19942
+ maxIntervalMs: params.maxIntervalMs,
19943
+ subscribeToChanges: params.subscribeToChanges,
19944
+ isFeedConnected: params.isFeedConnected
19945
+ });
19946
+ this.lanes[key] = lane;
19947
+ }
19948
+ return lane;
19949
+ }
19950
+ Dispose() {
19951
+ for (const key of Object.keys(this.lanes)) {
19952
+ this.lanes[key].Dispose();
19953
+ }
19954
+ this.lanes = {};
19955
+ }
19956
+ }
19957
+ SharedHistoricGetters.Cache = Cache;
19958
+ })(SharedHistoricGetters || (SharedHistoricGetters = {}));
19959
+
19501
19960
  const DEFAULT_GROUNDED_HEIGHT = 300;
19502
19961
  const MINIMUM_VIEW_AREA_SIZE_DEGREES = 0.01;
19503
19962
  const NET_STEP_PERCENT = 5;
@@ -24824,6 +25283,7 @@
24824
25283
  }
24825
25284
  this.visualsRegister = visualsRegister;
24826
25285
  this.sharedGetters = new exports.SharedGetters.Cache();
25286
+ this.sharedHistoric = new SharedHistoricGetters.Cache();
24827
25287
  this.sharedMonitor = new exports.CesiumViewMonitor.Monitor(this.viewer);
24828
25288
  this.tilesetInitQueue = new InitQueueTileset(this.getters);
24829
25289
  }
@@ -24832,7 +25292,7 @@
24832
25292
  * This will dispose all render managers and unregister all menu items.
24833
25293
  */
24834
25294
  Dispose(params) {
24835
- var _a, _b;
25295
+ var _a, _b, _c;
24836
25296
  const { disposeRegister } = params !== null && params !== void 0 ? params : {};
24837
25297
  for (let i = 0; i < this.items.length; i++) {
24838
25298
  const item = this.items[i];
@@ -24847,6 +25307,7 @@
24847
25307
  this.FlushPendingHandoffs();
24848
25308
  this.tilesetInitQueue.Dispose();
24849
25309
  (_b = this.sharedMonitor) === null || _b === void 0 ? void 0 : _b.Dispose();
25310
+ (_c = this.sharedHistoric) === null || _c === void 0 ? void 0 : _c.Dispose();
24850
25311
  if (this.visualsRegister && disposeRegister != false) {
24851
25312
  this.visualsRegister.Dispose();
24852
25313
  }
@@ -25054,7 +25515,8 @@
25054
25515
  register: this.visualsRegister,
25055
25516
  apiGetter: params.apiGetter,
25056
25517
  monitor: this.sharedMonitor,
25057
- item: params.item
25518
+ item: params.item,
25519
+ sharedHistoric: this.sharedHistoric
25058
25520
  });
25059
25521
  break;
25060
25522
  case BModels.MenuItem.EType.Entity:
@@ -33005,12 +33467,11 @@
33005
33467
  }
33006
33468
  }
33007
33469
 
33008
- var ECursor;
33009
33470
  (function (ECursor) {
33010
33471
  ECursor["Select"] = "select";
33011
33472
  ECursor["Pan"] = "pan";
33012
33473
  ECursor["Measure"] = "measure";
33013
- })(ECursor || (ECursor = {}));
33474
+ })(exports.ECursor || (exports.ECursor = {}));
33014
33475
  var ESecondaryCursor;
33015
33476
  (function (ESecondaryCursor) {
33016
33477
  ESecondaryCursor["None"] = "none";
@@ -33024,15 +33485,33 @@
33024
33485
  constructor(params) {
33025
33486
  super(params);
33026
33487
  this.STYLESHEET_ID = "nextspace-cursorbar-stylesheet";
33027
- this._selectedCursor = ECursor.Select;
33488
+ this._selectedCursor = exports.ECursor.Select;
33028
33489
  this._selectedSecondaryCursor = ESecondaryCursor.None;
33029
33490
  this.OnCursorChange = new BModels.BruceEvent();
33030
33491
  this._generateStyles();
33031
33492
  this._generateElement();
33032
- if (this._selectedCursor == ECursor.Select || this._selectedSecondaryCursor == ESecondaryCursor.Select) {
33493
+ if (this._selectedCursor == exports.ECursor.Select || this._selectedSecondaryCursor == ESecondaryCursor.Select) {
33033
33494
  this._listenSelection();
33034
33495
  }
33035
33496
  }
33497
+ /**
33498
+ * @param cursor
33499
+ */
33500
+ SetCursor(cursor) {
33501
+ if (cursor == this._selectedCursor) {
33502
+ return;
33503
+ }
33504
+ this._disposeMeasureTool();
33505
+ this._disposeCesiumEvent();
33506
+ this._selectedCursor = cursor;
33507
+ this._selectedSecondaryCursor = ESecondaryCursor.None;
33508
+ this._secondary.style.display = "none";
33509
+ if (cursor == exports.ECursor.Select) {
33510
+ this._listenSelection();
33511
+ }
33512
+ this._updateControls();
33513
+ this.OnCursorChange.Trigger(cursor);
33514
+ }
33036
33515
  Dispose() {
33037
33516
  var _a, _b;
33038
33517
  super.Dispose();
@@ -33283,8 +33762,8 @@
33283
33762
  <path d="M11.0706 25L9 7L23 17.8592L15.3135 18.3375L11.0706 25Z" fill="white" stroke="white" strokeLinejoin="round"/>
33284
33763
  </svg>
33285
33764
  `;
33286
- this._generateControl("Select", ECursor.Select, () => {
33287
- this._selectedCursor = ECursor.Select;
33765
+ this._generateControl("Select", exports.ECursor.Select, () => {
33766
+ this._selectedCursor = exports.ECursor.Select;
33288
33767
  this._secondary.style.display = "none";
33289
33768
  this._listenSelection();
33290
33769
  this.OnCursorChange.Trigger(this._selectedCursor);
@@ -33296,10 +33775,10 @@
33296
33775
  <path d="M15.5652 6C14.9172 6 14.3913 6.51692 14.3913 7.15385V14.4615H13.6087V8.69231C13.6087 8.05538 13.0828 7.53846 12.4348 7.53846C11.7868 7.53846 11.2609 8.05538 11.2609 8.69231V14.4615V16.7692V19.6734C11.2609 19.6734 9.0069 18.2402 7.87211 17.7548C7.55594 17.6194 7.22575 17.5385 6.89079 17.5385C5.1401 17.5385 5 19.0769 5 19.0769L8.13043 21.3846L10.6357 24.3398C11.5279 25.3922 12.85 26 14.243 26H19.8696C21.5983 26 23 24.6223 23 22.9231V14.4615V11C23 10.3631 22.4741 9.84615 21.8261 9.84615C21.1781 9.84615 20.6522 10.3631 20.6522 11V14.4615H19.8696V8.69231C19.8696 8.05538 19.3437 7.53846 18.6957 7.53846C18.0477 7.53846 17.5217 8.05538 17.5217 8.69231V14.4615H16.7391V7.15385C16.7391 6.51692 16.2132 6 15.5652 6Z" fill="white"/>
33297
33776
  </svg>
33298
33777
  `;
33299
- this._generateControl("Pan", ECursor.Pan, () => {
33300
- this._selectedCursor = this._selectedCursor == ECursor.Pan ? ECursor.Select : ECursor.Pan;
33778
+ this._generateControl("Pan", exports.ECursor.Pan, () => {
33779
+ this._selectedCursor = this._selectedCursor == exports.ECursor.Pan ? exports.ECursor.Select : exports.ECursor.Pan;
33301
33780
  this._secondary.style.display = "none";
33302
- if (this._selectedCursor == ECursor.Select) {
33781
+ if (this._selectedCursor == exports.ECursor.Select) {
33303
33782
  this._listenSelection();
33304
33783
  }
33305
33784
  this.OnCursorChange.Trigger(this._selectedCursor);
@@ -33311,17 +33790,17 @@
33311
33790
  <path d="M26.5044 8.88032C26.1735 8.54947 23.4505 5.8265 23.1197 5.49564C22.4588 4.83479 21.3876 4.83479 20.7267 5.49564C20.6878 5.53457 20.4449 5.77742 20.0557 6.16666L21.6753 7.78623C22.0061 8.11708 22.0061 8.65186 21.6753 8.98271C21.5103 9.14771 21.2936 9.23064 21.077 9.23064C20.8604 9.23064 20.6438 9.14771 20.4788 8.98271L18.8592 7.36314C18.4581 7.76423 18.0063 8.21608 17.5172 8.70517L18.2906 9.47857C18.6214 9.80942 18.6214 10.3442 18.2906 10.6751C18.1256 10.8401 17.909 10.923 17.6923 10.923C17.4757 10.923 17.2591 10.8401 17.0941 10.6751L16.3207 9.90165C15.8875 10.3349 15.4381 10.7842 14.9787 11.2437L16.5982 12.8632C16.9291 13.1941 16.9291 13.7289 16.5982 14.0597C16.4332 14.2247 16.2166 14.3077 16 14.3077C15.7834 14.3077 15.5668 14.2247 15.4018 14.0597L13.7822 12.4402C13.3363 12.8861 12.8869 13.3354 12.4402 13.7822L13.2136 14.5556C13.5444 14.8864 13.5444 15.4212 13.2136 15.7521C13.0486 15.9171 12.8319 16 12.6153 16C12.3987 16 12.1821 15.9171 12.0171 15.7521L11.2437 14.9787C10.7842 15.4381 10.3349 15.8875 9.90165 16.3207L11.5212 17.9403C11.8521 18.2711 11.8521 18.8059 11.5212 19.1368C11.3562 19.3018 11.1396 19.3847 10.923 19.3847C10.7064 19.3847 10.4897 19.3018 10.3247 19.1368L8.70517 17.5172C8.21608 18.0063 7.76423 18.4581 7.36314 18.8592L8.13654 19.6326C8.46739 19.9635 8.46739 20.4982 8.13654 20.8291C7.97154 20.9941 7.75492 21.077 7.5383 21.077C7.32168 21.077 7.10506 20.9941 6.94006 20.8291L6.16666 20.0557C5.77742 20.4449 5.53457 20.6878 5.49564 20.7267C4.83479 21.3876 4.83479 22.4588 5.49564 23.1197C5.8265 23.4505 8.54947 26.1735 8.88032 26.5044C9.54118 27.1652 10.6124 27.1652 11.2733 26.5044C11.6041 26.1735 26.1735 11.6041 26.5044 11.2733C27.1652 10.6124 27.1652 9.54118 26.5044 8.88032Z" fill="white"/>
33312
33791
  </svg>
33313
33792
  `;
33314
- this._generateControl("Measure", ECursor.Measure, () => {
33793
+ this._generateControl("Measure", exports.ECursor.Measure, () => {
33315
33794
  this._selectedSecondaryCursor = ESecondaryCursor.Pan;
33316
- this._selectedCursor = this._selectedCursor == ECursor.Measure ? ECursor.Select : ECursor.Measure;
33317
- if (this._selectedCursor == ECursor.Measure) {
33795
+ this._selectedCursor = this._selectedCursor == exports.ECursor.Measure ? exports.ECursor.Select : exports.ECursor.Measure;
33796
+ if (this._selectedCursor == exports.ECursor.Measure) {
33318
33797
  this._generateMeasureSecondary();
33319
33798
  this._updateSecondary();
33320
33799
  }
33321
33800
  else {
33322
33801
  this._secondary.style.display = "none";
33323
33802
  }
33324
- if (this._selectedCursor == ECursor.Select) {
33803
+ if (this._selectedCursor == exports.ECursor.Select) {
33325
33804
  this._listenSelection();
33326
33805
  }
33327
33806
  this.OnCursorChange.Trigger(this._selectedCursor);
@@ -46914,7 +47393,7 @@ void main() {
46914
47393
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
46915
47394
  })(exports.StyleUtils || (exports.StyleUtils = {}));
46916
47395
 
46917
- const VERSION = "7.3.4";
47396
+ const VERSION = "7.3.6";
46918
47397
  /**
46919
47398
  * Updates the environment instance used by bruce-cesium to one specified.
46920
47399
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.