bruce-cesium 6.5.1 → 6.5.3

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
- import { Cartes, Entity as Entity$1, Calculator, EntityRelationType, EntityType, Style, ENVIRONMENT, ProjectViewTile, DelayQueue, LRUCache, BruceEvent, ObjectUtils, Geometry, EntityHistoricData, EntityLod, ZoomControl, EntityTag, Tileset, Api, EntityCoords, DataLab, EntitySource, ClientFile, MenuItem, EntityRelation, ProgramKey, Bounds, Carto, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, AbstractApi, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils } from 'bruce-models';
1
+ import { Cartes, Entity as Entity$1, Calculator, EntityRelationType, EntityType, Style, ENVIRONMENT, ProjectViewTile, DelayQueue, LRUCache, BruceEvent, ObjectUtils, Geometry, EntityHistoricData, EntityLod, ZoomControl, EntityTag, Tileset, Api, EntityCoords, DataLab, EntitySource, ClientFile, MenuItem, EntityRelation, ProgramKey, Bounds, Carto, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, HeightReference, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, ShadowMode, Cartesian3, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, JulianDate, Quaternion, Matrix4, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, Cesium3DTileset, IonResource, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, BoundingSphere, GeometryInstance, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
3
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, Cesium3DTileset, IonResource, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, BoundingSphere, GeometryInstance, CesiumInspector, ClockRange, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -10940,6 +10940,14 @@ class EntityGatherer {
10940
10940
  this.viewer = viewer;
10941
10941
  this.emitEntities = emitEntities;
10942
10942
  }
10943
+ createFallbackEntity(entityId) {
10944
+ return {
10945
+ id: entityId,
10946
+ Bruce: {
10947
+ ID: entityId
10948
+ }
10949
+ };
10950
+ }
10943
10951
  SetEntityDataOverride(eId, entity) {
10944
10952
  if (this.disposed) {
10945
10953
  return;
@@ -11084,26 +11092,44 @@ class EntityGatherer {
11084
11092
  this.runningTick = true;
11085
11093
  let rerun = false;
11086
11094
  try {
11087
- const handleResponse = async (entities) => {
11088
- var _a, _b;
11089
- if (!(entities === null || entities === void 0 ? void 0 : entities.length)) {
11090
- return;
11095
+ const handleResponse = async (requestedBatch, entities) => {
11096
+ var _a, _b, _c, _d;
11097
+ const resolvedEntities = [];
11098
+ const foundById = new Map();
11099
+ for (const entity of entities || []) {
11100
+ const entityId = ((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID) || (entity === null || entity === void 0 ? void 0 : entity.id);
11101
+ if (entityId) {
11102
+ foundById.set(entityId, entity);
11103
+ }
11104
+ }
11105
+ for (const entityId of requestedBatch || []) {
11106
+ const override = this.entityDataOverrides.get(entityId);
11107
+ if (override) {
11108
+ resolvedEntities.push(override);
11109
+ continue;
11110
+ }
11111
+ const found = foundById.get(entityId);
11112
+ if (found) {
11113
+ resolvedEntities.push(found);
11114
+ continue;
11115
+ }
11116
+ resolvedEntities.push(this.createFallbackEntity(entityId));
11091
11117
  }
11092
- // Lazy substitution of the entity data overrides.
11093
- if (this.entityDataOverrides.size) {
11094
- for (let i = 0; i < entities.length; i++) {
11095
- const entity = entities[i];
11096
- const eId = entity.Bruce.ID;
11097
- if (this.entityDataOverrides.has(eId)) {
11098
- entities[i] = this.entityDataOverrides.get(eId);
11099
- }
11118
+ for (const entity of entities || []) {
11119
+ const entityId = ((_b = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _b === void 0 ? void 0 : _b.ID) || (entity === null || entity === void 0 ? void 0 : entity.id);
11120
+ if (!entityId || foundById.get(entityId) !== entity || (requestedBatch === null || requestedBatch === void 0 ? void 0 : requestedBatch.includes(entityId))) {
11121
+ continue;
11100
11122
  }
11123
+ resolvedEntities.push(entity);
11124
+ }
11125
+ if (!resolvedEntities.length) {
11126
+ return;
11101
11127
  }
11102
11128
  // Gather all Tag IDs from found Entities.
11103
11129
  let tagIds = new Set();
11104
- for (let i = 0; i < entities.length; i++) {
11105
- const entity = entities[i];
11106
- if ((_b = (_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a["Layer.ID"]) === null || _b === void 0 ? void 0 : _b.length) {
11130
+ for (let i = 0; i < resolvedEntities.length; i++) {
11131
+ const entity = resolvedEntities[i];
11132
+ if ((_d = (_c = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _c === void 0 ? void 0 : _c["Layer.ID"]) === null || _d === void 0 ? void 0 : _d.length) {
11107
11133
  const eTagIds = entity.Bruce["Layer.ID"];
11108
11134
  for (let j = 0; j < eTagIds.length; j++) {
11109
11135
  const tagId = eTagIds[j];
@@ -11132,8 +11158,10 @@ class EntityGatherer {
11132
11158
  if (this.historic) {
11133
11159
  // We can emit Entities if the last resolved time (per Entity) isn't newer than rTime.
11134
11160
  // We compare using the changeDir to determine if we should emit or not.
11135
- toEmit = entities.filter((e) => {
11136
- const lastFoundDateTime = this.lastFoundDateTimes.get(e.id);
11161
+ toEmit = resolvedEntities.filter((e) => {
11162
+ var _a;
11163
+ const entityId = ((_a = e === null || e === void 0 ? void 0 : e.Bruce) === null || _a === void 0 ? void 0 : _a.ID) || (e === null || e === void 0 ? void 0 : e.id);
11164
+ const lastFoundDateTime = this.lastFoundDateTimes.get(entityId);
11137
11165
  if (lastFoundDateTime) {
11138
11166
  if (changeDir === 1) {
11139
11167
  return lastFoundDateTime <= rTime;
@@ -11146,12 +11174,16 @@ class EntityGatherer {
11146
11174
  });
11147
11175
  // Update the last found date times for the filtered Entities.
11148
11176
  toEmit.forEach((e) => {
11149
- this.lastFoundDateTimes.set(e.id, rTime);
11177
+ var _a;
11178
+ const entityId = ((_a = e === null || e === void 0 ? void 0 : e.Bruce) === null || _a === void 0 ? void 0 : _a.ID) || (e === null || e === void 0 ? void 0 : e.id);
11179
+ if (entityId) {
11180
+ this.lastFoundDateTimes.set(entityId, rTime);
11181
+ }
11150
11182
  });
11151
11183
  }
11152
11184
  else {
11153
11185
  // If we're not historic, we can just emit everything.
11154
- toEmit = entities;
11186
+ toEmit = resolvedEntities;
11155
11187
  }
11156
11188
  this.emitEntities(toEmit, tags);
11157
11189
  };
@@ -11173,7 +11205,7 @@ class EntityGatherer {
11173
11205
  api: this.api,
11174
11206
  maxSearchTimeSec: 60 * 2
11175
11207
  });
11176
- handleResponse(entities);
11208
+ handleResponse(batch, entities);
11177
11209
  requestedIds.push(...batch);
11178
11210
  done += batch.length;
11179
11211
  if (this._onQueueProgress) {
@@ -11210,7 +11242,7 @@ class EntityGatherer {
11210
11242
  api: this.api,
11211
11243
  maxSearchTimeSec: 60 * 2
11212
11244
  });
11213
- handleResponse(entities);
11245
+ handleResponse(batch, entities);
11214
11246
  requestedIds.push(...batch);
11215
11247
  }
11216
11248
  }
@@ -14788,23 +14820,13 @@ var DataLabRenderManager;
14788
14820
  DataLabRenderManager.Manager = Manager;
14789
14821
  })(DataLabRenderManager || (DataLabRenderManager = {}));
14790
14822
 
14791
- const TIME_LAG = 300;
14792
- const POSITION_CHECK_TIMER = 950;
14793
14823
  const DEFAULT_GROUNDED_HEIGHT = 300;
14794
14824
  const MINIMUM_VIEW_AREA_SIZE_DEGREES = 0.01;
14795
14825
  const NET_STEP_PERCENT = 5;
14796
14826
  const BORDER_STEPS = 3;
14797
- var ESearchStatus;
14798
- (function (ESearchStatus) {
14799
- ESearchStatus[ESearchStatus["LocationFound"] = 1] = "LocationFound";
14800
- ESearchStatus[ESearchStatus["LocationChanged"] = 2] = "LocationChanged";
14801
- ESearchStatus[ESearchStatus["LocationMissing"] = 3] = "LocationMissing";
14802
- })(ESearchStatus || (ESearchStatus = {}));
14803
- /**
14804
- * @param viewer
14805
- * @param center the previously calculated center of the view area. This is in degrees.
14806
- * @returns
14807
- */
14827
+ function isDefined(value) {
14828
+ return value !== null && value !== undefined;
14829
+ }
14808
14830
  function netScanViewForBoundaries(viewer, center) {
14809
14831
  let maxLong = -2 * Math.PI;
14810
14832
  let minLong = 2 * Math.PI;
@@ -14812,7 +14834,6 @@ function netScanViewForBoundaries(viewer, center) {
14812
14834
  let minLat = 2 * Math.PI;
14813
14835
  let found = 0;
14814
14836
  const updateMinMax = (lon, lat) => {
14815
- // Check to see if given lon/lat (in radians) are within valid range.
14816
14837
  if (lon < -Math.PI || lon > Math.PI || lat < -Math.PI / 2 || lat > Math.PI / 2) {
14817
14838
  return;
14818
14839
  }
@@ -14822,13 +14843,13 @@ function netScanViewForBoundaries(viewer, center) {
14822
14843
  minLat = Math.min(minLat, lat);
14823
14844
  };
14824
14845
  const updateMinMaxForPoint = (stepX, stepY) => {
14825
- const x = Math.round(0 + (viewer.container.clientWidth / 100) * (stepX * NET_STEP_PERCENT));
14826
- const y = Math.round(0 + (viewer.container.clientHeight / 100) * (stepY * NET_STEP_PERCENT));
14846
+ const x = Math.round((viewer.container.clientWidth / 100) * (stepX * NET_STEP_PERCENT));
14847
+ const y = Math.round((viewer.container.clientHeight / 100) * (stepY * NET_STEP_PERCENT));
14827
14848
  const winPos = new Cartesian2(x, y);
14828
14849
  try {
14829
- let intersection = getAdjustedGroundIntersectionOfCameraRay(viewer, winPos);
14850
+ const intersection = getAdjustedGroundIntersectionOfCameraRay(viewer, winPos);
14830
14851
  if (intersection) {
14831
- let point = Cartographic.fromCartesian(intersection, viewer.scene.globe.ellipsoid);
14852
+ const point = Cartographic.fromCartesian(intersection, viewer.scene.globe.ellipsoid);
14832
14853
  updateMinMax(point.longitude, point.latitude);
14833
14854
  found++;
14834
14855
  }
@@ -14837,115 +14858,78 @@ function netScanViewForBoundaries(viewer, center) {
14837
14858
  console.error(e);
14838
14859
  }
14839
14860
  };
14840
- // Outer circle.
14841
14861
  updateMinMaxForPoint(BORDER_STEPS, BORDER_STEPS);
14842
14862
  updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS, BORDER_STEPS);
14843
14863
  updateMinMaxForPoint(BORDER_STEPS, (100 / NET_STEP_PERCENT) - BORDER_STEPS);
14844
14864
  updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS, (100 / NET_STEP_PERCENT) - BORDER_STEPS);
14845
- // Inner circle.
14846
14865
  updateMinMaxForPoint(BORDER_STEPS * 2, BORDER_STEPS * 2);
14847
14866
  updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS * 2, BORDER_STEPS * 2);
14848
14867
  updateMinMaxForPoint(BORDER_STEPS * 2, (100 / NET_STEP_PERCENT) - BORDER_STEPS * 2);
14849
14868
  updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS * 2, (100 / NET_STEP_PERCENT) - BORDER_STEPS * 2);
14850
- // If we failed to find intersections and a center-point was provided, then we can use that to make some guesses.
14851
- // This happens if terrain is hidden, and there's nothing to intersect with.
14852
14869
  if (center && found <= 0) {
14853
14870
  updateMinMax(Math$1.toRadians(center.longitude), Math$1.toRadians(center.latitude));
14854
14871
  found += 1;
14855
- // We'll use the camera height as an indicator on size of the rect.
14856
- let size = viewer.camera.positionCartographic.height;
14872
+ const size = viewer.camera.positionCartographic.height;
14857
14873
  const pitch = viewer.camera.pitch;
14858
14874
  const distance = size / Math.tan(pitch);
14859
- const p1 = _offsetPoint({
14875
+ const p1 = offsetPoint({
14860
14876
  altitude: center.altitude,
14861
14877
  latitude: center.latitude,
14862
14878
  longitude: center.longitude
14863
14879
  }, distance, 45);
14864
- const p2 = _offsetPoint({
14880
+ const p2 = offsetPoint({
14865
14881
  altitude: center.altitude,
14866
14882
  latitude: center.latitude,
14867
14883
  longitude: center.longitude
14868
14884
  }, -distance, 45);
14869
- if (p1 === null || p1 === void 0 ? void 0 : p1.latitude) {
14885
+ if (isDefined(p1 === null || p1 === void 0 ? void 0 : p1.latitude) && isDefined(p1 === null || p1 === void 0 ? void 0 : p1.longitude)) {
14870
14886
  updateMinMax(Math$1.toRadians(p1.longitude), Math$1.toRadians(p1.latitude));
14871
14887
  }
14872
- if (p2 === null || p2 === void 0 ? void 0 : p2.latitude) {
14888
+ if (isDefined(p2 === null || p2 === void 0 ? void 0 : p2.latitude) && isDefined(p2 === null || p2 === void 0 ? void 0 : p2.longitude)) {
14873
14889
  updateMinMax(Math$1.toRadians(p2.longitude), Math$1.toRadians(p2.latitude));
14874
14890
  }
14875
14891
  }
14876
14892
  if (found > 0) {
14877
- const viewRect = {
14893
+ return {
14878
14894
  east: maxLong,
14879
14895
  west: minLong,
14880
14896
  north: maxLat,
14881
14897
  south: minLat
14882
14898
  };
14883
- return viewRect;
14884
14899
  }
14885
14900
  return null;
14886
14901
  }
14887
- /**
14888
- * Moves a given point by a given distance towards a heading.
14889
- * @param point in degrees.
14890
- * @param distance in meters.
14891
- * @param heading in degrees.
14892
- * @returns
14893
- */
14894
- function _offsetPoint(point, distance, heading) {
14895
- // Radius of earth.
14902
+ function offsetPoint(point, distance, heading) {
14896
14903
  const radius = 6371e3;
14897
- const δ = distance / radius;
14898
- const θ = Math$1.toRadians(heading);
14899
- const φ1 = Math$1.toRadians(point.latitude);
14900
- const λ1 = Math$1.toRadians(point.longitude);
14901
- const sinφ2 = Math.sin(φ1) * Math.cos(δ) + Math.cos(φ1) * Math.sin(δ) * Math.cos(θ);
14902
- const φ2 = Math.asin(sinφ2);
14903
- const y = Math.sin(θ) * Math.sin(δ) * Math.cos(φ1);
14904
- const x = Math.cos(δ) - Math.sin(φ1) * sinφ2;
14905
- const λ2 = λ1 + Math.atan2(y, x);
14904
+ const delta = distance / radius;
14905
+ const theta = Math$1.toRadians(heading);
14906
+ const phi1 = Math$1.toRadians(point.latitude);
14907
+ const lambda1 = Math$1.toRadians(point.longitude);
14908
+ const sinPhi2 = Math.sin(phi1) * Math.cos(delta) + Math.cos(phi1) * Math.sin(delta) * Math.cos(theta);
14909
+ const phi2 = Math.asin(sinPhi2);
14910
+ const y = Math.sin(theta) * Math.sin(delta) * Math.cos(phi1);
14911
+ const x = Math.cos(delta) - Math.sin(phi1) * sinPhi2;
14912
+ const lambda2 = lambda1 + Math.atan2(y, x);
14906
14913
  return {
14907
14914
  altitude: point.altitude,
14908
- latitude: Math$1.toDegrees(φ2),
14909
- longitude: Math$1.toDegrees(λ2)
14915
+ latitude: Math$1.toDegrees(phi2),
14916
+ longitude: Math$1.toDegrees(lambda2)
14910
14917
  };
14911
14918
  }
14912
- /**
14913
- * @param pos3d
14914
- * @param distance in meters
14915
- * @param heading in degrees
14916
- * @returns
14917
- */
14918
- function _offsetPos3d(pos3d, distance, heading) {
14919
+ function offsetPos3d(pos3d, distance, heading) {
14919
14920
  const carto = Cartographic.fromCartesian(pos3d);
14920
- const newCarto = _offsetPoint({
14921
+ const newCarto = offsetPoint({
14921
14922
  altitude: carto.height,
14922
14923
  latitude: Math$1.toDegrees(carto.latitude),
14923
14924
  longitude: Math$1.toDegrees(carto.longitude)
14924
14925
  }, distance, heading);
14925
14926
  return Cartesian3.fromDegrees(newCarto.longitude, newCarto.latitude, newCarto.altitude);
14926
14927
  }
14927
- /**
14928
- * Returns the intersection of the camera ray with the ground.
14929
- * @param viewer
14930
- * @param screenPos
14931
- * @returns
14932
- */
14933
14928
  function getAdjustedGroundIntersectionOfCameraRay(viewer, screenPos) {
14934
14929
  const ray = viewer.camera.getPickRay(screenPos);
14935
14930
  const intersection = ray ? viewer.scene.globe.pick(ray, viewer.scene) : null;
14936
- if (intersection) {
14937
- return intersection;
14938
- }
14939
- return null;
14931
+ return intersection || null;
14940
14932
  }
14941
- /**
14942
- * Returns the intersection of the camera ray with the ground.
14943
- * If no intersection is found, then a "guess" is made based on the camera angle and height.
14944
- * The guess is made at the center of the view! It ignores the screenPos.
14945
- * @param viewer
14946
- * @param screenPos
14947
- * @returns
14948
- */
14949
14933
  function getGroundCenterOfCameraRay(viewer, screenPos) {
14950
14934
  var _a, _b;
14951
14935
  const ray = viewer.camera.getPickRay(screenPos);
@@ -14953,19 +14937,114 @@ function getGroundCenterOfCameraRay(viewer, screenPos) {
14953
14937
  if (intersection) {
14954
14938
  return intersection;
14955
14939
  }
14956
- // The fallback will be to "guess" where the intersection might be.
14957
- // This happens if terrain is hidden, and there's nothing to intersect with.
14958
- // We will use the camera angle + camera height.
14959
- // Eg: if camera is looking straight down and is 100 meters above the ground, then the intersection will be 100 meters below the camera.
14960
- let cameraHeight = viewer.camera.positionCartographic.height;
14961
- if (!isNaN(cameraHeight) && cameraHeight != null && ((_b = (_a = viewer.camera) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.clone)) {
14940
+ const cameraHeight = viewer.camera.positionCartographic.height;
14941
+ if (!isNaN(cameraHeight) && isDefined(cameraHeight) && ((_b = (_a = viewer.camera) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.clone)) {
14962
14942
  const cameraPos3d = viewer.camera.position.clone();
14963
14943
  const pitch = viewer.camera.pitch;
14964
14944
  const distance = cameraHeight / Math.tan(pitch);
14965
- return _offsetPos3d(cameraPos3d, -distance, Math$1.toDegrees(viewer.camera.heading));
14945
+ return offsetPos3d(cameraPos3d, -distance, Math$1.toDegrees(viewer.camera.heading));
14966
14946
  }
14967
14947
  return null;
14968
14948
  }
14949
+ var CesiumViewGroundArea;
14950
+ (function (CesiumViewGroundArea) {
14951
+ function ToBboxPolygon(bounds) {
14952
+ return `${bounds.west},${bounds.south} ${bounds.west},${bounds.north} ${bounds.east},${bounds.north} ${bounds.east},${bounds.south}`;
14953
+ }
14954
+ CesiumViewGroundArea.ToBboxPolygon = ToBboxPolygon;
14955
+ async function GetViewArea(viewer) {
14956
+ var _a, _b;
14957
+ if (!viewer || viewer.isDestroyed()) {
14958
+ return null;
14959
+ }
14960
+ if (!viewer.container || ((_a = viewer.container.style) === null || _a === void 0 ? void 0 : _a.display) == "none") {
14961
+ return null;
14962
+ }
14963
+ let viewRect = null;
14964
+ let center = null;
14965
+ const camera = viewer.camera;
14966
+ const terrData = await DrawingUtils.GetTerrainHeight({
14967
+ pos3d: camera.position,
14968
+ viewer
14969
+ });
14970
+ const cameraPosition = viewer.camera.positionCartographic;
14971
+ const terrHeight = terrData.error ? cameraPosition.height + DEFAULT_GROUNDED_HEIGHT : terrData.height;
14972
+ if (terrHeight && ((cameraPosition.height - terrHeight) < DEFAULT_GROUNDED_HEIGHT)) {
14973
+ viewRect = {};
14974
+ const viewRectRad = netScanViewForBoundaries(viewer);
14975
+ if (viewRectRad &&
14976
+ isDefined(viewRectRad.east) &&
14977
+ isDefined(viewRectRad.west) &&
14978
+ isDefined(viewRectRad.north) &&
14979
+ isDefined(viewRectRad.south)) {
14980
+ viewRect.east = Math$1.toDegrees(Math.max(viewRectRad.east, cameraPosition.longitude));
14981
+ viewRect.west = Math$1.toDegrees(Math.min(viewRectRad.west, cameraPosition.longitude));
14982
+ viewRect.south = Math$1.toDegrees(Math.min(viewRectRad.south, cameraPosition.latitude));
14983
+ viewRect.north = Math$1.toDegrees(Math.max(viewRectRad.north, cameraPosition.latitude));
14984
+ }
14985
+ else {
14986
+ viewRect.east = Math$1.toDegrees(cameraPosition.longitude);
14987
+ viewRect.west = Math$1.toDegrees(cameraPosition.longitude);
14988
+ viewRect.south = Math$1.toDegrees(cameraPosition.latitude);
14989
+ viewRect.north = Math$1.toDegrees(cameraPosition.latitude);
14990
+ }
14991
+ center = {
14992
+ altitude: camera.positionCartographic.height,
14993
+ latitude: Math$1.toDegrees(camera.positionCartographic.latitude),
14994
+ longitude: Math$1.toDegrees(camera.positionCartographic.longitude)
14995
+ };
14996
+ }
14997
+ else {
14998
+ const windowPosition = new Cartesian2(viewer.container.clientWidth / 2, viewer.container.clientHeight / 2);
14999
+ const intersection = getGroundCenterOfCameraRay(viewer, windowPosition);
15000
+ let point = null;
15001
+ if (intersection) {
15002
+ point = Cartographic.fromCartesian(intersection, viewer.scene.globe.ellipsoid);
15003
+ }
15004
+ if (point) {
15005
+ center = {
15006
+ altitude: point.height,
15007
+ latitude: Math$1.toDegrees(point.latitude),
15008
+ longitude: Math$1.toDegrees(point.longitude)
15009
+ };
15010
+ const viewRectRad = netScanViewForBoundaries(viewer, center);
15011
+ if (viewRectRad) {
15012
+ viewRect = {};
15013
+ viewRect.east = Math$1.toDegrees(viewRectRad.east);
15014
+ viewRect.west = Math$1.toDegrees(viewRectRad.west);
15015
+ viewRect.south = Math$1.toDegrees(viewRectRad.south);
15016
+ viewRect.north = Math$1.toDegrees(viewRectRad.north);
15017
+ }
15018
+ }
15019
+ }
15020
+ if (viewRect) {
15021
+ const centerLong = (viewRect.east + viewRect.west) / 2;
15022
+ const centerLat = (viewRect.north + viewRect.south) / 2;
15023
+ viewRect.east = Math.max(viewRect.east, centerLong + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15024
+ viewRect.west = Math.min(viewRect.west, centerLong - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15025
+ viewRect.south = Math.min(viewRect.south, centerLat - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15026
+ viewRect.north = Math.max(viewRect.north, centerLat + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15027
+ viewRect.alt = (_b = viewer.scene.camera.positionCartographic) === null || _b === void 0 ? void 0 : _b.height;
15028
+ }
15029
+ if (center && viewRect) {
15030
+ return {
15031
+ bounds: viewRect,
15032
+ target: center
15033
+ };
15034
+ }
15035
+ return null;
15036
+ }
15037
+ CesiumViewGroundArea.GetViewArea = GetViewArea;
15038
+ })(CesiumViewGroundArea || (CesiumViewGroundArea = {}));
15039
+
15040
+ const TIME_LAG = 300;
15041
+ const POSITION_CHECK_TIMER = 950;
15042
+ var ESearchStatus;
15043
+ (function (ESearchStatus) {
15044
+ ESearchStatus[ESearchStatus["LocationFound"] = 1] = "LocationFound";
15045
+ ESearchStatus[ESearchStatus["LocationChanged"] = 2] = "LocationChanged";
15046
+ ESearchStatus[ESearchStatus["LocationMissing"] = 3] = "LocationMissing";
15047
+ })(ESearchStatus || (ESearchStatus = {}));
14969
15048
  function areBoundsEqual(a, b) {
14970
15049
  return a.north == b.north && a.south == b.south && a.east == b.east && a.west == b.west;
14971
15050
  }
@@ -14973,7 +15052,7 @@ function arePosEqual(a, b) {
14973
15052
  return a.latitude == b.latitude && a.longitude == b.longitude;
14974
15053
  }
14975
15054
  var CesiumViewMonitor;
14976
- (function (CesiumViewMonitor$$1) {
15055
+ (function (CesiumViewMonitor) {
14977
15056
  /**
14978
15057
  * Monitors and emits events when the Cesium view changes.
14979
15058
  */
@@ -15047,7 +15126,7 @@ var CesiumViewMonitor;
15047
15126
  this.destroyEntity();
15048
15127
  }
15049
15128
  async tryDoUpdate() {
15050
- var _a, _b;
15129
+ var _a;
15051
15130
  if (!this.viewer || this.viewer.isDestroyed()) {
15052
15131
  this.Dispose();
15053
15132
  return ESearchStatus.LocationMissing;
@@ -15055,73 +15134,10 @@ var CesiumViewMonitor;
15055
15134
  if (!this.viewer.container || ((_a = this.viewer.container.style) === null || _a === void 0 ? void 0 : _a.display) == "none") {
15056
15135
  return ESearchStatus.LocationMissing;
15057
15136
  }
15058
- let viewRect = null;
15059
- let center = null;
15060
- const camera = this.viewer.camera;
15061
- const terrData = await DrawingUtils.GetTerrainHeight({
15062
- pos3d: camera.position,
15063
- viewer: this.viewer
15064
- });
15065
- const cameraPosition = this.viewer.camera.positionCartographic;
15066
- const terrHeight = terrData.error ? cameraPosition.height + DEFAULT_GROUNDED_HEIGHT : terrData.height;
15067
- // We are almost at the ground, screw horizon, just load around.
15068
- if (terrHeight && ((cameraPosition.height - terrHeight) < DEFAULT_GROUNDED_HEIGHT)) {
15069
- // View area calculation.
15070
- viewRect = {};
15071
- const viewRectRad = netScanViewForBoundaries(this.viewer);
15072
- if (viewRectRad &&
15073
- viewRectRad.east &&
15074
- viewRectRad.west &&
15075
- viewRectRad.north &&
15076
- viewRectRad.south) {
15077
- viewRect.east = Math$1.toDegrees(Math.max(viewRectRad.east, cameraPosition.longitude));
15078
- viewRect.west = Math$1.toDegrees(Math.min(viewRectRad.west, cameraPosition.longitude));
15079
- viewRect.south = Math$1.toDegrees(Math.min(viewRectRad.south, cameraPosition.latitude));
15080
- viewRect.north = Math$1.toDegrees(Math.max(viewRectRad.north, cameraPosition.latitude));
15081
- }
15082
- else {
15083
- viewRect.east = cameraPosition.longitude;
15084
- viewRect.west = cameraPosition.longitude;
15085
- viewRect.south = cameraPosition.latitude;
15086
- viewRect.north = cameraPosition.latitude;
15087
- }
15088
- center = {};
15089
- center.latitude = Math$1.toDegrees(camera.positionCartographic.latitude);
15090
- center.longitude = Math$1.toDegrees(camera.positionCartographic.longitude);
15091
- }
15092
- else {
15093
- // View area calculation.
15094
- const windowPosition = new Cartesian2(this.viewer.container.clientWidth / 2, this.viewer.container.clientHeight / 2);
15095
- const intersection = getGroundCenterOfCameraRay(this.viewer, windowPosition);
15096
- let point = null;
15097
- if (intersection) {
15098
- point = Cartographic.fromCartesian(intersection, this.viewer.scene.globe.ellipsoid);
15099
- }
15100
- if (point) {
15101
- center = {};
15102
- center.latitude = Math$1.toDegrees(point.latitude);
15103
- center.longitude = Math$1.toDegrees(point.longitude);
15104
- let viewRectRad = netScanViewForBoundaries(this.viewer, center);
15105
- if (viewRectRad) {
15106
- viewRect = {};
15107
- viewRect.east = Math$1.toDegrees(viewRectRad.east);
15108
- viewRect.west = Math$1.toDegrees(viewRectRad.west);
15109
- viewRect.south = Math$1.toDegrees(viewRectRad.south);
15110
- viewRect.north = Math$1.toDegrees(viewRectRad.north);
15111
- }
15112
- }
15113
- }
15114
- // Minimal field of view.
15115
- if (viewRect) {
15116
- const centerLong = (viewRect.east + viewRect.west) / 2;
15117
- const centerLat = (viewRect.north + viewRect.south) / 2;
15118
- viewRect.east = Math.max(viewRect.east, centerLong + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15119
- viewRect.west = Math.min(viewRect.west, centerLong - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15120
- viewRect.south = Math.min(viewRect.south, centerLat - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15121
- viewRect.north = Math.max(viewRect.north, centerLat + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15122
- viewRect.alt = (_b = this.viewer.scene.camera.positionCartographic) === null || _b === void 0 ? void 0 : _b.height;
15123
- }
15124
- if (center && viewRect) {
15137
+ const viewArea = await CesiumViewGroundArea.GetViewArea(this.viewer);
15138
+ if ((viewArea === null || viewArea === void 0 ? void 0 : viewArea.target) && (viewArea === null || viewArea === void 0 ? void 0 : viewArea.bounds)) {
15139
+ const center = viewArea.target;
15140
+ const viewRect = viewArea.bounds;
15125
15141
  if ((!this.target || (this.target && !arePosEqual(this.target, center))) ||
15126
15142
  (!this.bounds || (this.bounds && !areBoundsEqual(this.bounds, viewRect)))) {
15127
15143
  this.target = center;
@@ -15172,7 +15188,7 @@ var CesiumViewMonitor;
15172
15188
  this.queuePosition(TIME_LAG);
15173
15189
  }
15174
15190
  }
15175
- CesiumViewMonitor$$1.Monitor = Monitor;
15191
+ CesiumViewMonitor.Monitor = Monitor;
15176
15192
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
15177
15193
 
15178
15194
  const MAX_BATCHES = 2;
@@ -26183,7 +26199,7 @@ function doMovementTick(viewer) {
26183
26199
  data.actions.get(EAction.Backward)) {
26184
26200
  const heading = getMovementHeading(viewer);
26185
26201
  const pos = viewer.camera.positionCartographic;
26186
- const newPos = _offsetPoint$1({
26202
+ const newPos = _offsetPoint({
26187
26203
  altitude: pos.height,
26188
26204
  latitude: Math$1.toDegrees(pos.latitude),
26189
26205
  longitude: Math$1.toDegrees(pos.longitude)
@@ -26200,7 +26216,7 @@ function doMovementTick(viewer) {
26200
26216
  * @param heading in degrees.
26201
26217
  * @returns
26202
26218
  */
26203
- function _offsetPoint$1(point, distance, heading) {
26219
+ function _offsetPoint(point, distance, heading) {
26204
26220
  // Radius of earth.
26205
26221
  const radius = 6371e3;
26206
26222
  const δ = distance / radius;
@@ -30153,7 +30169,7 @@ var EntityUtils;
30153
30169
  // This gives a better experience than looking straight down.
30154
30170
  if (!is2d) {
30155
30171
  // Combine the elevation with the sideways offset.
30156
- const finalStartingPosition = _offsetPos3d$1(elevatedPos3d, -range, Math$1.toDegrees(params.viewer.camera.heading));
30172
+ const finalStartingPosition = _offsetPos3d(elevatedPos3d, -range, Math$1.toDegrees(params.viewer.camera.heading));
30157
30173
  // Calculate the direction from the elevated and offset starting position towards the destination.
30158
30174
  const direction = Cartesian3.subtract(destination, finalStartingPosition, new Cartesian3());
30159
30175
  Cartesian3.normalize(direction, direction);
@@ -30209,7 +30225,7 @@ var EntityUtils;
30209
30225
  * @param heading in degrees.
30210
30226
  * @returns
30211
30227
  */
30212
- function _offsetPoint$2(point, distance, heading) {
30228
+ function _offsetPoint$1(point, distance, heading) {
30213
30229
  // Radius of earth.
30214
30230
  const radius = 6371e3;
30215
30231
  const δ = distance / radius;
@@ -30233,9 +30249,9 @@ function _offsetPoint$2(point, distance, heading) {
30233
30249
  * @param heading in degrees
30234
30250
  * @returns
30235
30251
  */
30236
- function _offsetPos3d$1(pos3d, distance, heading) {
30252
+ function _offsetPos3d(pos3d, distance, heading) {
30237
30253
  const carto = Cartographic.fromCartesian(pos3d);
30238
- const newCarto = _offsetPoint$2({
30254
+ const newCarto = _offsetPoint$1({
30239
30255
  altitude: carto.height,
30240
30256
  latitude: Math$1.toDegrees(carto.latitude),
30241
30257
  longitude: Math$1.toDegrees(carto.longitude)
@@ -35297,7 +35313,7 @@ class WidgetViewBar extends Widget.AWidget {
35297
35313
  }
35298
35314
  }
35299
35315
 
35300
- const VERSION = "6.5.1";
35316
+ const VERSION = "6.5.3";
35301
35317
  /**
35302
35318
  * Updates the environment instance used by bruce-cesium to one specified.
35303
35319
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -35314,5 +35330,5 @@ const getENVIRONMENT = () => {
35314
35330
  return ENVIRONMENT;
35315
35331
  };
35316
35332
 
35317
- export { VERSION, setENVIRONMENT, getENVIRONMENT, CesiumAnimatedInOut, CesiumAnimatedProperty, isOutlineChanged$1 as isOutlineChanged, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, EntityRenderEnginePolygon, EntityRenderEnginePolyline, MenuItemCreator, MenuItemManager, CesiumParabola, EntityLabel, LiveCursor, SharedGetters, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, TilesetRenderEngine, ViewRenderEngine, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, DEFAULT_LIVE_PADDING_SECONDS, ViewUtils, CesiumViewMonitor, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
35333
+ export { VERSION, setENVIRONMENT, getENVIRONMENT, CesiumAnimatedInOut, CesiumAnimatedProperty, isOutlineChanged$1 as isOutlineChanged, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, EntityRenderEnginePolygon, EntityRenderEnginePolyline, MenuItemCreator, MenuItemManager, CesiumParabola, EntityLabel, LiveCursor, SharedGetters, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, TilesetRenderEngine, ViewRenderEngine, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, DEFAULT_LIVE_PADDING_SECONDS, ViewUtils, CesiumViewMonitor, CesiumViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
35318
35334
  //# sourceMappingURL=bruce-cesium.es5.js.map