bruce-cesium 6.7.8 → 6.7.9

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.
@@ -30569,25 +30569,27 @@
30569
30569
  var _a;
30570
30570
  const prepareLatitude = (propName, value) => {
30571
30571
  value = +value;
30572
- // Check to see if the lat is in valid degrees, if not, try convert from radians.
30572
+ // Check to see if the lat is in valid degrees, if not, convert from radians.
30573
30573
  if (value < -90 || value > 90) {
30574
- value = Cesium.Math.toDegrees(value);
30574
+ return Cesium.Math.toDegrees(value);
30575
30575
  }
30576
30576
  // If the value is really small we'll assume it's in radians.
30577
30577
  // "cesium#blah" properties are always in degrees. No need to check.
30578
- if (value < 0.9 && !propName.startsWith("cesium#")) {
30578
+ // (Only reached when the value wasn't already converted above, to avoid double-converting.)
30579
+ if (value < 0.9 && value > -0.9 && !propName.startsWith("cesium#")) {
30579
30580
  value = Cesium.Math.toDegrees(value);
30580
30581
  }
30581
30582
  return value;
30582
30583
  };
30583
30584
  const prepareLongitude = (propName, value) => {
30584
30585
  value = +value;
30585
- // Check to see if the lon is in valid degrees, if not, try convert from radians.
30586
+ // Check to see if the lon is in valid degrees, if not, convert from radians.
30586
30587
  if (value < -180 || value > 180) {
30587
- value = Cesium.Math.toDegrees(value);
30588
+ return Cesium.Math.toDegrees(value);
30588
30589
  }
30589
30590
  // If the value is really small we'll assume it's in radians.
30590
30591
  // "cesium#blah" properties are always in degrees. No need to check.
30592
+ // (Only reached when the value wasn't already converted above, to avoid double-converting.)
30591
30593
  if (value < 0.9 && value > -0.9 && !propName.startsWith("cesium#")) {
30592
30594
  value = Cesium.Math.toDegrees(value);
30593
30595
  }
@@ -31268,6 +31270,84 @@
31268
31270
  catch (e) {
31269
31271
  console.error(e);
31270
31272
  }
31273
+ // Some records may still not be expanded.
31274
+ // We have to detect whatever is an Assembly Entity and expand it.
31275
+ try {
31276
+ const needsExpansion = recordSamples.filter(x => {
31277
+ const assemblyPos = BModels.Entity.GetValue({
31278
+ entity: x.entity,
31279
+ path: ["Bruce", "AssemblyPosition"]
31280
+ });
31281
+ if (!assemblyPos) {
31282
+ return false;
31283
+ }
31284
+ const rootPos = BModels.Entity.GetValue({
31285
+ entity: x.entity,
31286
+ path: ["Bruce", "AssemblyRootPosition"]
31287
+ });
31288
+ return !rootPos;
31289
+ });
31290
+ if (needsExpansion.length) {
31291
+ const EXPAND_BATCH_SIZE = 30;
31292
+ const EXPAND_MAX_IDS = 200;
31293
+ // Figure out if any are in the scene.
31294
+ // Helps us sort leaf-nodes away from category nodes thta don't have geometry.
31295
+ const isInScene = (sample) => {
31296
+ var _a;
31297
+ return !!(visualRegister && visualRegister.GetRego({
31298
+ entityId: (_a = sample.entityId) !== null && _a !== void 0 ? _a : sample.entity.Bruce.ID,
31299
+ menuItemId: sample.menuItemId
31300
+ }));
31301
+ };
31302
+ // Trim to max 200 with a preference to those in the scene.
31303
+ const sceneSamples = needsExpansion.filter(isInScene);
31304
+ const offSceneSamples = sceneSamples.length ? needsExpansion.filter(x => !isInScene(x)) : [];
31305
+ if (offSceneSamples.length) {
31306
+ const offSceneIds = new Set(offSceneSamples.map(x => x.entity.Bruce.ID));
31307
+ recordSamples = recordSamples.filter(x => !offSceneIds.has(x.entity.Bruce.ID));
31308
+ }
31309
+ const effectiveSamples = sceneSamples.length ? sceneSamples : needsExpansion;
31310
+ const uniqueIds = Array.from(new Set(effectiveSamples.map(x => x.entity.Bruce.ID)));
31311
+ const expandIds = uniqueIds.slice(0, EXPAND_MAX_IDS);
31312
+ // Anything we didn't expand will taint the overall result so we have to filter them out.
31313
+ const droppedIds = new Set(uniqueIds.slice(EXPAND_MAX_IDS));
31314
+ if (droppedIds.size) {
31315
+ recordSamples = recordSamples.filter(x => !droppedIds.has(x.entity.Bruce.ID));
31316
+ }
31317
+ const expandedMap = new Map();
31318
+ const batches = [];
31319
+ for (let i = 0; i < expandIds.length; i += EXPAND_BATCH_SIZE) {
31320
+ batches.push(expandIds.slice(i, i + EXPAND_BATCH_SIZE));
31321
+ }
31322
+ const batchResults = await Promise.all(batches.map(batchIds => BModels.Entity.GetListByIds({
31323
+ entityIds: batchIds,
31324
+ historicPoint: latestDate,
31325
+ expandLocation: true,
31326
+ expandSources: true,
31327
+ migrated: true,
31328
+ maxSearchTimeSec: 60 * 2,
31329
+ api
31330
+ }).catch(e => {
31331
+ console.error(e);
31332
+ return { entities: [] };
31333
+ })));
31334
+ for (const { entities } of batchResults) {
31335
+ for (let i = 0; i < entities.length; i++) {
31336
+ expandedMap.set(entities[i].Bruce.ID, entities[i]);
31337
+ }
31338
+ }
31339
+ for (let i = 0; i < effectiveSamples.length; i++) {
31340
+ const sample = effectiveSamples[i];
31341
+ const expanded = expandedMap.get(sample.entity.Bruce.ID);
31342
+ if (expanded) {
31343
+ sample.entity = expanded;
31344
+ }
31345
+ }
31346
+ }
31347
+ }
31348
+ catch (e) {
31349
+ console.error(e);
31350
+ }
31271
31351
  for (let i = 0; i < recordSamples.length; i++) {
31272
31352
  const sample = recordSamples[i];
31273
31353
  const samplePosses = await getRecordEntityPositions(sample);
@@ -36394,7 +36474,7 @@
36394
36474
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
36395
36475
  })(exports.StyleUtils || (exports.StyleUtils = {}));
36396
36476
 
36397
- const VERSION = "6.7.8";
36477
+ const VERSION = "6.7.9";
36398
36478
  /**
36399
36479
  * Updates the environment instance used by bruce-cesium to one specified.
36400
36480
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.