bruce-cesium 7.3.4 → 7.3.5
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.
- package/dist/bruce-cesium.es5.js +498 -36
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +496 -34
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/menu-item-manager.js +6 -2
- package/dist/lib/rendering/menu-item-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/common/historic-utils.js +18 -1
- package/dist/lib/rendering/render-managers/common/historic-utils.js.map +1 -1
- package/dist/lib/rendering/render-managers/common/shared-getters-historic.js +349 -0
- package/dist/lib/rendering/render-managers/common/shared-getters-historic.js.map +1 -0
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js +66 -19
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js.map +1 -1
- package/dist/lib/utils/drawing-utils.js +60 -10
- package/dist/lib/utils/drawing-utils.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/menu-item-manager.d.ts +1 -0
- package/dist/types/rendering/render-managers/common/historic-utils.d.ts +6 -0
- package/dist/types/rendering/render-managers/common/shared-getters-historic.d.ts +115 -0
- package/dist/types/rendering/render-managers/entities/entities-ids-render-manager.d.ts +5 -0
- package/dist/types/utils/drawing-utils.d.ts +4 -0
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -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
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
|
|
13852
|
-
|
|
13853
|
-
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
|
|
13860
|
-
|
|
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:
|
|
@@ -46914,7 +47376,7 @@ void main() {
|
|
|
46914
47376
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
46915
47377
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
46916
47378
|
|
|
46917
|
-
const VERSION = "7.3.
|
|
47379
|
+
const VERSION = "7.3.5";
|
|
46918
47380
|
/**
|
|
46919
47381
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
46920
47382
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|