bruce-cesium 4.7.8 → 4.8.0

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
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, DataLab, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, EntityAttribute, EntityAttachment, EntityAttachmentType, AbstractApi, Session } 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, ClassificationType, ArcType, CornerType, ShadowMode, ConstantProperty, ConstantPositionProperty, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, HorizontalOrigin, VerticalOrigin, ColorBlendMode, HeadingPitchRoll, Transforms, Model, SceneMode, GeoJsonDataSource, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, KmlDataSource, OrthographicFrustum, EasingFunction, NearFarScalar, SceneTransforms, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, Cesium3DTileset, PolygonPipeline, Matrix4, Matrix3, IonResource, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, GeometryInstance, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, ClassificationType, ArcType, CornerType, ShadowMode, ConstantProperty, ConstantPositionProperty, HorizontalOrigin, VerticalOrigin, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, SceneMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, 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, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2549,7 +2549,7 @@ var EntityUtils;
2549
2549
  */
2550
2550
  function GetLocation(params) {
2551
2551
  return __awaiter(this, void 0, void 0, function () {
2552
- var api, viewer, samples, visualRegister, minimumAlt, paddingAlt, MAX_DISTANCE_BETWEEN_SAMPLES, MAX_TERRAIN_SAMPLES, terrainSamples, MAX_API_CALLS, apiCalls, MAX_VALID_SAMPLES, validSamples, data, spheres, processPosHeight, ensureHeightRefs, getEntityPositions, allPosses, i, sample, samplePosses, valid, j, samplePos, k, allPos, distance, rect, factor, marginX, marginY, carto, i, pos, radius, sphere, allPointSphere, rectSphere, combinedSphere;
2552
+ var api, viewer, samples, visualRegister, minimumAlt, paddingAlt, MAX_DISTANCE_BETWEEN_SAMPLES, MAX_TERRAIN_SAMPLES, terrainSamples, MAX_VALID_SAMPLES, validSamples, data, spheres, processPosHeight, ensureHeightRefs, getRenderedEntityPositions, getRecordEntityPositions, allPosses, recordSamples, i, sample, samplePosses, added, valid, j, samplePos, k, allPos, distance, toSearchIds, entities, entitiesMap, i, i, sample, e_1, i, sample, samplePosses, valid, j, samplePos, k, allPos, distance, rect, factor, marginX, marginY, carto, i, pos, radius, sphere, allPointSphere, rectSphere, combinedSphere;
2553
2553
  var _this = this;
2554
2554
  return __generator(this, function (_a) {
2555
2555
  switch (_a.label) {
@@ -2564,8 +2564,6 @@ var EntityUtils;
2564
2564
  MAX_DISTANCE_BETWEEN_SAMPLES = 5000;
2565
2565
  MAX_TERRAIN_SAMPLES = 25;
2566
2566
  terrainSamples = 0;
2567
- MAX_API_CALLS = 10;
2568
- apiCalls = 0;
2569
2567
  MAX_VALID_SAMPLES = 20;
2570
2568
  validSamples = 0;
2571
2569
  data = {
@@ -2656,16 +2654,15 @@ var EntityUtils;
2656
2654
  }
2657
2655
  });
2658
2656
  }); };
2659
- getEntityPositions = function (sample) { return __awaiter(_this, void 0, void 0, function () {
2660
- var entityId, entity, disallowRendered, evaluateRendered, evaluateRecord, renderedPosses, e_1, recordPosses, e_2, pos3d, eLocation, geometryRadius, sphere;
2657
+ getRenderedEntityPositions = function (sample) { return __awaiter(_this, void 0, void 0, function () {
2658
+ var entityId, entity, disallowRendered, evaluateRendered, renderedPosses;
2661
2659
  var _this = this;
2662
- var _a, _b;
2663
- return __generator(this, function (_c) {
2664
- switch (_c.label) {
2660
+ return __generator(this, function (_a) {
2661
+ switch (_a.label) {
2665
2662
  case 0:
2666
2663
  entityId = sample.entityId, entity = sample.entity, disallowRendered = sample.disallowRendered;
2667
2664
  evaluateRendered = function () { return __awaiter(_this, void 0, void 0, function () {
2668
- var rego, posses, parts, i, part, visualHeightRef, hierarchy, hPosses, hPossesSample, step, i_1, pPosses, pPossesSample, step, i_2, pPosses, pPossesSample, step, i_3, pos3d_1, toAdjust, modelExt, sphere, semiMajorAxis, semiMinorAxis, height, radius, sphere, data_1, pos3d_2, toAdjust, sphere;
2665
+ var rego, posses, parts, i, part, visualHeightRef, hierarchy, hPosses, hPossesSample, step, i_1, pPosses, pPossesSample, step, i_2, pPosses, pPossesSample, step, i_3, pos3d, toAdjust, modelExt, sphere, semiMajorAxis, semiMinorAxis, height, radius, sphere, data_1, pos3d, toAdjust, sphere;
2669
2666
  return __generator(this, function (_a) {
2670
2667
  switch (_a.label) {
2671
2668
  case 0:
@@ -2754,18 +2751,18 @@ var EntityUtils;
2754
2751
  _a.label = 13;
2755
2752
  case 13:
2756
2753
  if (!(part.point || part.model || part.billboard || part.ellipse)) return [3 /*break*/, 15];
2757
- pos3d_1 = GetValue(viewer, part.position);
2758
- if (!(pos3d_1 === null || pos3d_1 === void 0 ? void 0 : pos3d_1.x)) return [3 /*break*/, 15];
2759
- toAdjust = [pos3d_1];
2754
+ pos3d = GetValue(viewer, part.position);
2755
+ if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) return [3 /*break*/, 15];
2756
+ toAdjust = [pos3d];
2760
2757
  return [4 /*yield*/, ensureHeightRefs(toAdjust, __assign(__assign({}, sample), { heightRef: visualHeightRef }))];
2761
2758
  case 14:
2762
2759
  _a.sent();
2763
- pos3d_1 = toAdjust[0];
2764
- posses.push(pos3d_1);
2760
+ pos3d = toAdjust[0];
2761
+ posses.push(pos3d);
2765
2762
  if (part.model) {
2766
2763
  modelExt = part.model;
2767
2764
  if (modelExt._radius && modelExt._radius > -1) {
2768
- sphere = BoundingSphere.fromPoints([pos3d_1]);
2765
+ sphere = BoundingSphere.fromPoints([pos3d]);
2769
2766
  sphere.radius = modelExt._radius;
2770
2767
  spheres.push(sphere);
2771
2768
  }
@@ -2785,7 +2782,7 @@ var EntityUtils;
2785
2782
  }
2786
2783
  radius = Math.max(semiMajorAxis, semiMinorAxis, height);
2787
2784
  if (radius && radius > 0) {
2788
- sphere = new BoundingSphere(pos3d_1, radius);
2785
+ sphere = new BoundingSphere(pos3d, radius);
2789
2786
  spheres.push(sphere);
2790
2787
  }
2791
2788
  }
@@ -2795,15 +2792,15 @@ var EntityUtils;
2795
2792
  if (!(part instanceof Cesium3DTileFeature)) return [3 /*break*/, 18];
2796
2793
  data_1 = getLocationFromFeature(part);
2797
2794
  if (!(data_1 != null)) return [3 /*break*/, 18];
2798
- pos3d_2 = Cartesian3.fromDegrees(data_1.location.longitude, data_1.location.latitude, data_1.location.altitude);
2799
- toAdjust = [pos3d_2];
2795
+ pos3d = Cartesian3.fromDegrees(data_1.location.longitude, data_1.location.latitude, data_1.location.altitude);
2796
+ toAdjust = [pos3d];
2800
2797
  return [4 /*yield*/, ensureHeightRefs(toAdjust, __assign(__assign({}, sample), { heightRef: data_1.isClamped ? HeightReference.CLAMP_TO_GROUND : HeightReference.NONE }))];
2801
2798
  case 17:
2802
2799
  _a.sent();
2803
- pos3d_2 = toAdjust[0];
2804
- posses.push(pos3d_2);
2800
+ pos3d = toAdjust[0];
2801
+ posses.push(pos3d);
2805
2802
  if (data_1.radius != null && !isNaN(data_1.radius)) {
2806
- sphere = new BoundingSphere(pos3d_2, data_1.radius);
2803
+ sphere = new BoundingSphere(pos3d, data_1.radius);
2807
2804
  spheres.push(sphere);
2808
2805
  }
2809
2806
  _a.label = 18;
@@ -2814,8 +2811,28 @@ var EntityUtils;
2814
2811
  }
2815
2812
  });
2816
2813
  }); };
2814
+ if (!(disallowRendered != true)) return [3 /*break*/, 2];
2815
+ return [4 /*yield*/, evaluateRendered()];
2816
+ case 1:
2817
+ renderedPosses = _a.sent();
2818
+ if (renderedPosses === null || renderedPosses === void 0 ? void 0 : renderedPosses.length) {
2819
+ return [2 /*return*/, renderedPosses];
2820
+ }
2821
+ _a.label = 2;
2822
+ case 2: return [2 /*return*/, []];
2823
+ }
2824
+ });
2825
+ }); };
2826
+ getRecordEntityPositions = function (sample) { return __awaiter(_this, void 0, void 0, function () {
2827
+ var entityId, entity, disallowRendered, evaluateRecord, recordPosses, pos3d, eLocation, geometryRadius, sphere, e_2;
2828
+ var _this = this;
2829
+ var _a;
2830
+ return __generator(this, function (_b) {
2831
+ switch (_b.label) {
2832
+ case 0:
2833
+ entityId = sample.entityId, entity = sample.entity, disallowRendered = sample.disallowRendered;
2817
2834
  evaluateRecord = function () { return __awaiter(_this, void 0, void 0, function () {
2818
- var posses, location, latitude, longitude, pos3d_3, geometry, pointStr, points, point, pos3d_4, lineStr, points, pPosses, pRings, boundary, points, pPosses, boundaries, point, bPosses;
2835
+ var posses, location, latitude, longitude, pos3d, geometry, pointStr, points, point, pos3d, lineStr, points, pPosses, pRings, boundary, points, pPosses, boundaries, point, bPosses;
2819
2836
  return __generator(this, function (_a) {
2820
2837
  switch (_a.label) {
2821
2838
  case 0:
@@ -2829,8 +2846,8 @@ var EntityUtils;
2829
2846
  longitude = EnsureNumber(location.longitude);
2830
2847
  // Disallowing exact 0.
2831
2848
  if (latitude || longitude) {
2832
- pos3d_3 = Cartesian3.fromDegrees(longitude, latitude, EnsureNumber(location.altitude));
2833
- posses.push(pos3d_3);
2849
+ pos3d = Cartesian3.fromDegrees(longitude, latitude, EnsureNumber(location.altitude));
2850
+ posses.push(pos3d);
2834
2851
  }
2835
2852
  }
2836
2853
  geometry = Entity$1.GetValue({
@@ -2845,8 +2862,8 @@ var EntityUtils;
2845
2862
  points = Geometry.ParsePoints(pointStr);
2846
2863
  point = points.length > 0 ? points[0] : null;
2847
2864
  if (point && Carto.ValidateCarto(point)) {
2848
- pos3d_4 = Cartesian3.fromDegrees(EnsureNumber(point.longitude), EnsureNumber(point.latitude), EnsureNumber(point.altitude));
2849
- posses.push(pos3d_4);
2865
+ pos3d = Cartesian3.fromDegrees(EnsureNumber(point.longitude), EnsureNumber(point.latitude), EnsureNumber(point.altitude));
2866
+ posses.push(pos3d);
2850
2867
  }
2851
2868
  }
2852
2869
  lineStr = geometry.LineString;
@@ -2896,78 +2913,26 @@ var EntityUtils;
2896
2913
  }
2897
2914
  });
2898
2915
  }); };
2899
- if (!(disallowRendered != true)) return [3 /*break*/, 2];
2900
- return [4 /*yield*/, evaluateRendered()];
2916
+ return [4 /*yield*/, evaluateRecord()];
2901
2917
  case 1:
2902
- renderedPosses = _c.sent();
2903
- if (renderedPosses === null || renderedPosses === void 0 ? void 0 : renderedPosses.length) {
2904
- return [2 /*return*/, renderedPosses];
2905
- }
2906
- _c.label = 2;
2918
+ recordPosses = _b.sent();
2919
+ if (!(recordPosses === null || recordPosses === void 0 ? void 0 : recordPosses.length)) return [3 /*break*/, 8];
2920
+ _b.label = 2;
2907
2921
  case 2:
2908
- if (!!entity) return [3 /*break*/, 6];
2909
- if (!(apiCalls < MAX_API_CALLS)) return [3 /*break*/, 6];
2910
- apiCalls += 1;
2911
- _c.label = 3;
2912
- case 3:
2913
- _c.trys.push([3, 5, , 6]);
2914
- return [4 /*yield*/, Entity$1.Get({
2915
- api: api,
2916
- entityId: entityId,
2917
- // Not expanding relative positions at first to see if the entity has valid location just by itself.
2918
- expandLocation: false,
2919
- migrated: true
2920
- })];
2921
- case 4:
2922
- entity = (_c.sent()).entity;
2923
- return [3 /*break*/, 6];
2924
- case 5:
2925
- e_1 = _c.sent();
2926
- console.error(e_1);
2927
- return [3 /*break*/, 6];
2928
- case 6:
2929
- if (!entity) {
2930
- return [2 /*return*/, []];
2931
- }
2932
- return [4 /*yield*/, evaluateRecord()];
2933
- case 7:
2934
- recordPosses = _c.sent();
2935
- if (recordPosses === null || recordPosses === void 0 ? void 0 : recordPosses.length) {
2936
- return [2 /*return*/, recordPosses];
2937
- }
2938
- if (!(apiCalls < MAX_API_CALLS && ((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.AssemblyRootLocation) == null)) return [3 /*break*/, 11];
2939
- _c.label = 8;
2940
- case 8:
2941
- _c.trys.push([8, 10, , 11]);
2942
- apiCalls += 1;
2943
- return [4 /*yield*/, Entity$1.Get({
2944
- api: api,
2945
- entityId: entityId,
2946
- // We'll be expanding relative positioning and related assemblies now.
2947
- expandLocation: true,
2948
- migrated: true
2949
- })];
2950
- case 9:
2951
- entity = (_c.sent()).entity;
2952
- return [3 /*break*/, 11];
2953
- case 10:
2954
- e_2 = _c.sent();
2955
- console.warn(e_2);
2956
- return [3 /*break*/, 11];
2957
- case 11:
2922
+ _b.trys.push([2, 6, , 7]);
2958
2923
  pos3d = null;
2959
2924
  eLocation = Entity$1.GetValue({
2960
2925
  entity: entity,
2961
2926
  path: ["Bruce", "Location"]
2962
2927
  });
2963
- if (!((eLocation === null || eLocation === void 0 ? void 0 : eLocation.longitude) && ((_b = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _b === void 0 ? void 0 : _b.AssemblyRootLocation) != null)) return [3 /*break*/, 14];
2928
+ if (!((eLocation === null || eLocation === void 0 ? void 0 : eLocation.longitude) && ((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.AssemblyRootLocation) != null)) return [3 /*break*/, 5];
2964
2929
  pos3d = Cartesian3.fromDegrees(EnsureNumber(eLocation.longitude), EnsureNumber(eLocation.latitude), EnsureNumber(eLocation.altitude));
2965
- if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) return [3 /*break*/, 13];
2930
+ if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) return [3 /*break*/, 4];
2966
2931
  return [4 /*yield*/, processPosHeight(pos3d, HeightReference.NONE)];
2967
- case 12:
2968
- pos3d = _c.sent();
2969
- _c.label = 13;
2970
- case 13:
2932
+ case 3:
2933
+ pos3d = _b.sent();
2934
+ _b.label = 4;
2935
+ case 4:
2971
2936
  geometryRadius = Entity$1.GetValue({
2972
2937
  entity: entity,
2973
2938
  path: ["Bruce", "GeometryRadius"]
@@ -2980,24 +2945,28 @@ var EntityUtils;
2980
2945
  spheres.push(sphere);
2981
2946
  }
2982
2947
  }
2983
- _c.label = 14;
2984
- case 14:
2985
- if (pos3d) {
2986
- return [2 /*return*/, [pos3d]];
2987
- }
2988
- return [2 /*return*/, []];
2948
+ _b.label = 5;
2949
+ case 5: return [3 /*break*/, 7];
2950
+ case 6:
2951
+ e_2 = _b.sent();
2952
+ console.error(e_2);
2953
+ return [3 /*break*/, 7];
2954
+ case 7: return [2 /*return*/, recordPosses];
2955
+ case 8: return [2 /*return*/, []];
2989
2956
  }
2990
2957
  });
2991
2958
  }); };
2992
2959
  allPosses = [];
2960
+ recordSamples = [];
2993
2961
  i = 0;
2994
2962
  _a.label = 1;
2995
2963
  case 1:
2996
2964
  if (!(i < samples.length)) return [3 /*break*/, 4];
2997
2965
  sample = samples[i];
2998
- return [4 /*yield*/, getEntityPositions(sample)];
2966
+ return [4 /*yield*/, getRenderedEntityPositions(sample)];
2999
2967
  case 2:
3000
2968
  samplePosses = _a.sent();
2969
+ added = false;
3001
2970
  if (samplePosses === null || samplePosses === void 0 ? void 0 : samplePosses.length) {
3002
2971
  valid = !(allPosses === null || allPosses === void 0 ? void 0 : allPosses.length);
3003
2972
  if (!valid) {
@@ -3018,17 +2987,91 @@ var EntityUtils;
3018
2987
  }
3019
2988
  if (valid) {
3020
2989
  allPosses = allPosses.concat(samplePosses);
2990
+ added = true;
3021
2991
  validSamples += 1;
3022
2992
  if (validSamples >= MAX_VALID_SAMPLES) {
3023
2993
  return [3 /*break*/, 4];
3024
2994
  }
3025
2995
  }
3026
2996
  }
2997
+ if (!added) {
2998
+ recordSamples.push(sample);
2999
+ }
3027
3000
  _a.label = 3;
3028
3001
  case 3:
3029
3002
  i++;
3030
3003
  return [3 /*break*/, 1];
3031
3004
  case 4:
3005
+ _a.trys.push([4, 7, , 8]);
3006
+ toSearchIds = recordSamples.filter(function (x) { return !x.entity && x.entityId; }).map(function (x) { return x.entityId; });
3007
+ if (!toSearchIds.length) return [3 /*break*/, 6];
3008
+ return [4 /*yield*/, Entity$1.GetListByIds({
3009
+ entityIds: toSearchIds,
3010
+ expandLocation: true,
3011
+ migrated: true,
3012
+ api: api
3013
+ })];
3014
+ case 5:
3015
+ entities = (_a.sent()).entities;
3016
+ entitiesMap = new Map();
3017
+ for (i = 0; i < entities.length; i++) {
3018
+ entitiesMap.set(entities[i].Bruce.ID, entities[i]);
3019
+ }
3020
+ for (i = 0; i < recordSamples.length; i++) {
3021
+ sample = recordSamples[i];
3022
+ if (!sample.entity && sample.entityId) {
3023
+ sample.entity = entitiesMap.get(sample.entityId);
3024
+ }
3025
+ }
3026
+ _a.label = 6;
3027
+ case 6:
3028
+ // Filter out samples that still don't have an entity.
3029
+ recordSamples = recordSamples.filter(function (x) { return !!x.entity; });
3030
+ return [3 /*break*/, 8];
3031
+ case 7:
3032
+ e_1 = _a.sent();
3033
+ console.error(e_1);
3034
+ return [3 /*break*/, 8];
3035
+ case 8:
3036
+ i = 0;
3037
+ _a.label = 9;
3038
+ case 9:
3039
+ if (!(i < recordSamples.length)) return [3 /*break*/, 12];
3040
+ sample = recordSamples[i];
3041
+ return [4 /*yield*/, getRecordEntityPositions(sample)];
3042
+ case 10:
3043
+ samplePosses = _a.sent();
3044
+ if (samplePosses === null || samplePosses === void 0 ? void 0 : samplePosses.length) {
3045
+ valid = !(allPosses === null || allPosses === void 0 ? void 0 : allPosses.length);
3046
+ if (!valid) {
3047
+ for (j = 0; j < samplePosses.length; j++) {
3048
+ samplePos = samplePosses[j];
3049
+ for (k = 0; k < allPosses.length; k++) {
3050
+ allPos = allPosses[k];
3051
+ distance = Cartesian3.distance(samplePos, allPos);
3052
+ if (distance < MAX_DISTANCE_BETWEEN_SAMPLES) {
3053
+ valid = true;
3054
+ break;
3055
+ }
3056
+ }
3057
+ if (valid) {
3058
+ break;
3059
+ }
3060
+ }
3061
+ }
3062
+ if (valid) {
3063
+ allPosses = allPosses.concat(samplePosses);
3064
+ validSamples += 1;
3065
+ if (validSamples >= MAX_VALID_SAMPLES) {
3066
+ return [3 /*break*/, 12];
3067
+ }
3068
+ }
3069
+ }
3070
+ _a.label = 11;
3071
+ case 11:
3072
+ i++;
3073
+ return [3 /*break*/, 9];
3074
+ case 12:
3032
3075
  if (allPosses.length > 1) {
3033
3076
  rect = allPosses.length == 1 ? null : Rectangle.fromCartesianArray(allPosses);
3034
3077
  if (rect.width > 0 && rect.height > 0) {
@@ -3103,9 +3146,9 @@ var EntityUtils;
3103
3146
  if ((rego === null || rego === void 0 ? void 0 : rego.visual) instanceof Entity) {
3104
3147
  var visual = rego.visual;
3105
3148
  if (visual.position) {
3106
- var pos3d_5 = GetValue(viewer, visual.position);
3149
+ var pos3d_1 = GetValue(viewer, visual.position);
3107
3150
  // Fix height reference.
3108
- if (pos3d_5 === null || pos3d_5 === void 0 ? void 0 : pos3d_5.x) {
3151
+ if (pos3d_1 === null || pos3d_1 === void 0 ? void 0 : pos3d_1.x) {
3109
3152
  var visualHeightRef = HeightReference.RELATIVE_TO_GROUND;
3110
3153
  if (visual.model) {
3111
3154
  visualHeightRef = GetValue(viewer, visual.model.heightReference);
@@ -3132,7 +3175,7 @@ var EntityUtils;
3132
3175
  return DrawingUtils.EnsurePosHeight({
3133
3176
  desiredHeightRef: params.returnHeightRef,
3134
3177
  heightRef: visualHeightRef,
3135
- pos3d: pos3d_5,
3178
+ pos3d: pos3d_1,
3136
3179
  viewer: viewer
3137
3180
  });
3138
3181
  }
@@ -8122,11 +8165,11 @@ var EntityRenderEngine;
8122
8165
  }
8123
8166
  EntityRenderEngine.GetRenderGroupId = GetRenderGroupId;
8124
8167
  function Render(params) {
8125
- var _a, _b, _c, _d, _e, _f;
8168
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8126
8169
  return __awaiter(this, void 0, void 0, function () {
8127
8170
  var groupRenderParams, updated, cEntities, models, multiGeometry, polygons, polylines, points, prepareGeometry, i, entity, id, zoomItem, displayType, existingRego, newRenderId, oldRenderId, geometry, mParams, mEntities, i, entity, id, cEntity, _loop_1, i, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity;
8128
- return __generator(this, function (_g) {
8129
- switch (_g.label) {
8171
+ return __generator(this, function (_j) {
8172
+ switch (_j.label) {
8130
8173
  case 0:
8131
8174
  groupRenderParams = {
8132
8175
  apiGetter: params.apiGetter,
@@ -8208,8 +8251,9 @@ var EntityRenderEngine;
8208
8251
  if (!params.force &&
8209
8252
  newRenderId == oldRenderId &&
8210
8253
  !(existingRego === null || existingRego === void 0 ? void 0 : existingRego.stale) &&
8211
- // If historic metadata is different then it's also stale.
8212
- ((existingRego === null || existingRego === void 0 ? void 0 : existingRego.historicDateTime) == ((_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b.HistoricDateTime))) {
8254
+ // If historic/scenario metadata is different then it's also stale.
8255
+ ((existingRego === null || existingRego === void 0 ? void 0 : existingRego.historicDateTime) == ((_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b.HistoricDateTime)) &&
8256
+ ((existingRego === null || existingRego === void 0 ? void 0 : existingRego.scenario) == ((_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c["Scenario.ID"]))) {
8213
8257
  // No sorting category needed. Already rendered the way we want.
8214
8258
  cEntities.set(id, existingRego.visual);
8215
8259
  }
@@ -8220,9 +8264,10 @@ var EntityRenderEngine;
8220
8264
  // Flag as no longer stale as we're unlikely to recreate the rego if we're reusing the graphic.
8221
8265
  existingRego.stale = false;
8222
8266
  // Update metadata for the same reason.
8223
- existingRego.historicDateTime = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c.HistoricDateTime;
8224
- existingRego.historicAttrKey = (_d = entity.Bruce) === null || _d === void 0 ? void 0 : _d.HistoricAttrKey;
8267
+ existingRego.historicDateTime = (_d = entity.Bruce) === null || _d === void 0 ? void 0 : _d.HistoricDateTime;
8268
+ existingRego.historicAttrKey = (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e.HistoricAttrKey;
8225
8269
  existingRego.entityTypeId = entity.Bruce["EntityType.ID"];
8270
+ existingRego.scenario = (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f["Scenario.ID"];
8226
8271
  updated.set(id, true);
8227
8272
  }
8228
8273
  if (displayType == ZoomControl.EDisplayType.Model3D) {
@@ -8235,7 +8280,7 @@ var EntityRenderEngine;
8235
8280
  entity: entity,
8236
8281
  path: ["Bruce", "VectorGeometry"]
8237
8282
  });
8238
- if ((_e = geometry === null || geometry === void 0 ? void 0 : geometry.MultiGeometry) === null || _e === void 0 ? void 0 : _e.length) {
8283
+ if ((_g = geometry === null || geometry === void 0 ? void 0 : geometry.MultiGeometry) === null || _g === void 0 ? void 0 : _g.length) {
8239
8284
  multiGeometry.push(entity);
8240
8285
  }
8241
8286
  else {
@@ -8253,7 +8298,7 @@ var EntityRenderEngine;
8253
8298
  mParams = __assign(__assign({}, groupRenderParams), { rendered: cEntities, entities: models, entitiesHistoric: params.entitiesHistoric, entityHistoricDrawTrack: params.entityHistoricDrawTrack });
8254
8299
  return [4 /*yield*/, Model3d.RenderGroup(mParams)];
8255
8300
  case 1:
8256
- mEntities = _g.sent();
8301
+ mEntities = _j.sent();
8257
8302
  for (i = 0; i < mParams.entities.length; i++) {
8258
8303
  entity = mParams.entities[i];
8259
8304
  id = entity.Bruce.ID;
@@ -8265,20 +8310,20 @@ var EntityRenderEngine;
8265
8310
  multiGeometry.push(entity);
8266
8311
  }
8267
8312
  }
8268
- _g.label = 2;
8313
+ _j.label = 2;
8269
8314
  case 2:
8270
8315
  if (!(multiGeometry.length > 0)) return [3 /*break*/, 6];
8271
8316
  _loop_1 = function (i) {
8272
8317
  var entity, geometry, pParams, zoomItem, j, subEntity, cPoly, rendered, cLines, cPoints, rootEntity_1, firstEntity;
8273
- return __generator(this, function (_h) {
8274
- switch (_h.label) {
8318
+ return __generator(this, function (_k) {
8319
+ switch (_k.label) {
8275
8320
  case 0:
8276
8321
  entity = multiGeometry[i];
8277
8322
  geometry = Entity$1.GetValue({
8278
8323
  entity: entity,
8279
8324
  path: ["Bruce", "VectorGeometry"]
8280
8325
  });
8281
- if (!((_f = geometry === null || geometry === void 0 ? void 0 : geometry.MultiGeometry) === null || _f === void 0 ? void 0 : _f.length)) {
8326
+ if (!((_h = geometry === null || geometry === void 0 ? void 0 : geometry.MultiGeometry) === null || _h === void 0 ? void 0 : _h.length)) {
8282
8327
  polygons.push(entity);
8283
8328
  return [2 /*return*/, "continue"];
8284
8329
  }
@@ -8292,7 +8337,7 @@ var EntityRenderEngine;
8292
8337
  }
8293
8338
  return [4 /*yield*/, Polygon.RenderGroup(pParams)];
8294
8339
  case 1:
8295
- cPoly = _h.sent();
8340
+ cPoly = _k.sent();
8296
8341
  Array.from(cPoly.keys()).forEach(function (key) {
8297
8342
  if (cPoly.get(key)) {
8298
8343
  pParams.entities = pParams.entities.filter(function (e) { return e.Bruce.ID != key; });
@@ -8301,7 +8346,7 @@ var EntityRenderEngine;
8301
8346
  rendered = Array.from(cPoly.values());
8302
8347
  return [4 /*yield*/, Polyline.RenderGroup(pParams)];
8303
8348
  case 2:
8304
- cLines = _h.sent();
8349
+ cLines = _k.sent();
8305
8350
  Array.from(cLines.keys()).forEach(function (key) {
8306
8351
  if (cLines.get(key)) {
8307
8352
  pParams.entities = pParams.entities.filter(function (e) { return e.Bruce.ID != key; });
@@ -8311,9 +8356,9 @@ var EntityRenderEngine;
8311
8356
  if (!!rendered.length) return [3 /*break*/, 4];
8312
8357
  return [4 /*yield*/, Point.RenderGroup(pParams)];
8313
8358
  case 3:
8314
- cPoints = _h.sent();
8359
+ cPoints = _k.sent();
8315
8360
  rendered = rendered.concat(Array.from(cPoints.values()));
8316
- _h.label = 4;
8361
+ _k.label = 4;
8317
8362
  case 4:
8318
8363
  rendered = rendered.filter(function (x) { return x != null; });
8319
8364
  if (rendered.length) {
@@ -8340,13 +8385,13 @@ var EntityRenderEngine;
8340
8385
  });
8341
8386
  };
8342
8387
  i = 0;
8343
- _g.label = 3;
8388
+ _j.label = 3;
8344
8389
  case 3:
8345
8390
  if (!(i < multiGeometry.length)) return [3 /*break*/, 6];
8346
8391
  return [5 /*yield**/, _loop_1(i)];
8347
8392
  case 4:
8348
- _g.sent();
8349
- _g.label = 5;
8393
+ _j.sent();
8394
+ _j.label = 5;
8350
8395
  case 5:
8351
8396
  i++;
8352
8397
  return [3 /*break*/, 3];
@@ -8355,7 +8400,7 @@ var EntityRenderEngine;
8355
8400
  pParams = __assign(__assign({}, groupRenderParams), { entities: polygons, rendered: cEntities });
8356
8401
  return [4 /*yield*/, Polygon.RenderGroup(pParams)];
8357
8402
  case 7:
8358
- pEntities = _g.sent();
8403
+ pEntities = _j.sent();
8359
8404
  for (i = 0; i < pParams.entities.length; i++) {
8360
8405
  entity = pParams.entities[i];
8361
8406
  cEntity = pEntities.get(entity.Bruce.ID);
@@ -8366,13 +8411,13 @@ var EntityRenderEngine;
8366
8411
  polylines.push(entity);
8367
8412
  }
8368
8413
  }
8369
- _g.label = 8;
8414
+ _j.label = 8;
8370
8415
  case 8:
8371
8416
  if (!(polylines.length > 0)) return [3 /*break*/, 10];
8372
8417
  pParams = __assign(__assign({}, groupRenderParams), { entities: polylines, rendered: cEntities });
8373
8418
  return [4 /*yield*/, Polyline.RenderGroup(pParams)];
8374
8419
  case 9:
8375
- pEntities = _g.sent();
8420
+ pEntities = _j.sent();
8376
8421
  for (i = 0; i < pParams.entities.length; i++) {
8377
8422
  entity = pParams.entities[i];
8378
8423
  cEntity = pEntities.get(entity.Bruce.ID);
@@ -8383,13 +8428,13 @@ var EntityRenderEngine;
8383
8428
  points.push(entity);
8384
8429
  }
8385
8430
  }
8386
- _g.label = 10;
8431
+ _j.label = 10;
8387
8432
  case 10:
8388
8433
  if (!(points.length > 0)) return [3 /*break*/, 12];
8389
8434
  pParams = __assign(__assign({}, groupRenderParams), { entities: points, rendered: cEntities, entitiesHistoric: params.entitiesHistoric, entityHistoricDrawTrack: params.entityHistoricDrawTrack });
8390
8435
  return [4 /*yield*/, Point.RenderGroup(pParams)];
8391
8436
  case 11:
8392
- pEntities = _g.sent();
8437
+ pEntities = _j.sent();
8393
8438
  for (i = 0; i < pParams.entities.length; i++) {
8394
8439
  entity = pParams.entities[i];
8395
8440
  cEntity = pEntities.get(entity.Bruce.ID);
@@ -8397,7 +8442,7 @@ var EntityRenderEngine;
8397
8442
  cEntities.set(entity.Bruce.ID, cEntity);
8398
8443
  }
8399
8444
  }
8400
- _g.label = 12;
8445
+ _j.label = 12;
8401
8446
  case 12: return [2 /*return*/, {
8402
8447
  entities: cEntities,
8403
8448
  updated: updated
@@ -12630,7 +12675,7 @@ var EntitiesRenderManager;
12630
12675
  };
12631
12676
  toForceUpdate = [];
12632
12677
  register = function (thing) {
12633
- var _a, _b, _c, _d;
12678
+ var _a, _b, _c, _d, _e, _f;
12634
12679
  // See if the cesium entity already exists in a group.
12635
12680
  var group = groups.find(function (x) { var _a; return ((_a = x.visual) === null || _a === void 0 ? void 0 : _a.id) == thing.id || x.siblings.find(function (x) { return (x === null || x === void 0 ? void 0 : x.id) == thing.id; }); });
12636
12681
  if (group) {
@@ -12671,7 +12716,8 @@ var EntitiesRenderManager;
12671
12716
  defaultToId: false
12672
12717
  })) !== null && _d !== void 0 ? _d : "Unnamed Entity" : "Unnamed Entity",
12673
12718
  cdn: _this.item.cdnEnabled,
12674
- collection: source.entities
12719
+ collection: source.entities,
12720
+ scenario: (_f = (_e = group.data) === null || _e === void 0 ? void 0 : _e.Bruce) === null || _f === void 0 ? void 0 : _f["Scenario.ID"]
12675
12721
  };
12676
12722
  group.rego = rego;
12677
12723
  _this.visualsManager.AddRego({
@@ -17079,6 +17125,9 @@ var EntityFilterGetter;
17079
17125
  */
17080
17126
  Getter.prototype.emitHistoricData = function () {
17081
17127
  var _this = this;
17128
+ if (!this.GetMenuItems().length) {
17129
+ return;
17130
+ }
17082
17131
  var integrity = this.getIntegrityId();
17083
17132
  // Gathered ID does't match current one.
17084
17133
  if (this.gatheredIntegrity != integrity) {
@@ -28632,7 +28681,7 @@ var WidgetViewBar = /** @class */ (function (_super) {
28632
28681
  return WidgetViewBar;
28633
28682
  }(Widget.AWidget));
28634
28683
 
28635
- var VERSION = "4.7.8";
28684
+ var VERSION = "4.8.0";
28636
28685
 
28637
28686
  export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, DataLabRenderManager, 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 };
28638
28687
  //# sourceMappingURL=bruce-cesium.es5.js.map