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.
@@ -30661,25 +30661,27 @@ const getLocationFromFeature = (feature) => {
30661
30661
  var _a;
30662
30662
  const prepareLatitude = (propName, value) => {
30663
30663
  value = +value;
30664
- // Check to see if the lat is in valid degrees, if not, try convert from radians.
30664
+ // Check to see if the lat is in valid degrees, if not, convert from radians.
30665
30665
  if (value < -90 || value > 90) {
30666
- value = Math$1.toDegrees(value);
30666
+ return Math$1.toDegrees(value);
30667
30667
  }
30668
30668
  // If the value is really small we'll assume it's in radians.
30669
30669
  // "cesium#blah" properties are always in degrees. No need to check.
30670
- if (value < 0.9 && !propName.startsWith("cesium#")) {
30670
+ // (Only reached when the value wasn't already converted above, to avoid double-converting.)
30671
+ if (value < 0.9 && value > -0.9 && !propName.startsWith("cesium#")) {
30671
30672
  value = Math$1.toDegrees(value);
30672
30673
  }
30673
30674
  return value;
30674
30675
  };
30675
30676
  const prepareLongitude = (propName, value) => {
30676
30677
  value = +value;
30677
- // Check to see if the lon is in valid degrees, if not, try convert from radians.
30678
+ // Check to see if the lon is in valid degrees, if not, convert from radians.
30678
30679
  if (value < -180 || value > 180) {
30679
- value = Math$1.toDegrees(value);
30680
+ return Math$1.toDegrees(value);
30680
30681
  }
30681
30682
  // If the value is really small we'll assume it's in radians.
30682
30683
  // "cesium#blah" properties are always in degrees. No need to check.
30684
+ // (Only reached when the value wasn't already converted above, to avoid double-converting.)
30683
30685
  if (value < 0.9 && value > -0.9 && !propName.startsWith("cesium#")) {
30684
30686
  value = Math$1.toDegrees(value);
30685
30687
  }
@@ -31361,6 +31363,84 @@ var EntityUtils;
31361
31363
  catch (e) {
31362
31364
  console.error(e);
31363
31365
  }
31366
+ // Some records may still not be expanded.
31367
+ // We have to detect whatever is an Assembly Entity and expand it.
31368
+ try {
31369
+ const needsExpansion = recordSamples.filter(x => {
31370
+ const assemblyPos = Entity$1.GetValue({
31371
+ entity: x.entity,
31372
+ path: ["Bruce", "AssemblyPosition"]
31373
+ });
31374
+ if (!assemblyPos) {
31375
+ return false;
31376
+ }
31377
+ const rootPos = Entity$1.GetValue({
31378
+ entity: x.entity,
31379
+ path: ["Bruce", "AssemblyRootPosition"]
31380
+ });
31381
+ return !rootPos;
31382
+ });
31383
+ if (needsExpansion.length) {
31384
+ const EXPAND_BATCH_SIZE = 30;
31385
+ const EXPAND_MAX_IDS = 200;
31386
+ // Figure out if any are in the scene.
31387
+ // Helps us sort leaf-nodes away from category nodes thta don't have geometry.
31388
+ const isInScene = (sample) => {
31389
+ var _a;
31390
+ return !!(visualRegister && visualRegister.GetRego({
31391
+ entityId: (_a = sample.entityId) !== null && _a !== void 0 ? _a : sample.entity.Bruce.ID,
31392
+ menuItemId: sample.menuItemId
31393
+ }));
31394
+ };
31395
+ // Trim to max 200 with a preference to those in the scene.
31396
+ const sceneSamples = needsExpansion.filter(isInScene);
31397
+ const offSceneSamples = sceneSamples.length ? needsExpansion.filter(x => !isInScene(x)) : [];
31398
+ if (offSceneSamples.length) {
31399
+ const offSceneIds = new Set(offSceneSamples.map(x => x.entity.Bruce.ID));
31400
+ recordSamples = recordSamples.filter(x => !offSceneIds.has(x.entity.Bruce.ID));
31401
+ }
31402
+ const effectiveSamples = sceneSamples.length ? sceneSamples : needsExpansion;
31403
+ const uniqueIds = Array.from(new Set(effectiveSamples.map(x => x.entity.Bruce.ID)));
31404
+ const expandIds = uniqueIds.slice(0, EXPAND_MAX_IDS);
31405
+ // Anything we didn't expand will taint the overall result so we have to filter them out.
31406
+ const droppedIds = new Set(uniqueIds.slice(EXPAND_MAX_IDS));
31407
+ if (droppedIds.size) {
31408
+ recordSamples = recordSamples.filter(x => !droppedIds.has(x.entity.Bruce.ID));
31409
+ }
31410
+ const expandedMap = new Map();
31411
+ const batches = [];
31412
+ for (let i = 0; i < expandIds.length; i += EXPAND_BATCH_SIZE) {
31413
+ batches.push(expandIds.slice(i, i + EXPAND_BATCH_SIZE));
31414
+ }
31415
+ const batchResults = await Promise.all(batches.map(batchIds => Entity$1.GetListByIds({
31416
+ entityIds: batchIds,
31417
+ historicPoint: latestDate,
31418
+ expandLocation: true,
31419
+ expandSources: true,
31420
+ migrated: true,
31421
+ maxSearchTimeSec: 60 * 2,
31422
+ api
31423
+ }).catch(e => {
31424
+ console.error(e);
31425
+ return { entities: [] };
31426
+ })));
31427
+ for (const { entities } of batchResults) {
31428
+ for (let i = 0; i < entities.length; i++) {
31429
+ expandedMap.set(entities[i].Bruce.ID, entities[i]);
31430
+ }
31431
+ }
31432
+ for (let i = 0; i < effectiveSamples.length; i++) {
31433
+ const sample = effectiveSamples[i];
31434
+ const expanded = expandedMap.get(sample.entity.Bruce.ID);
31435
+ if (expanded) {
31436
+ sample.entity = expanded;
31437
+ }
31438
+ }
31439
+ }
31440
+ }
31441
+ catch (e) {
31442
+ console.error(e);
31443
+ }
31364
31444
  for (let i = 0; i < recordSamples.length; i++) {
31365
31445
  const sample = recordSamples[i];
31366
31446
  const samplePosses = await getRecordEntityPositions(sample);
@@ -36516,7 +36596,7 @@ var StyleUtils;
36516
36596
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
36517
36597
  })(StyleUtils || (StyleUtils = {}));
36518
36598
 
36519
- const VERSION = "6.7.8";
36599
+ const VERSION = "6.7.9";
36520
36600
  /**
36521
36601
  * Updates the environment instance used by bruce-cesium to one specified.
36522
36602
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.