bruce-cesium 6.0.8 → 6.1.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, ProjectViewTile, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, DataLab, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, EntityAttachment, EntityAttachmentType, EntityAttribute, 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, HorizontalOrigin, VerticalOrigin, ConstantProperty, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, KmlDataSource, Quaternion, Matrix3, Matrix4, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
3
+ import { Cartographic, JulianDate, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, Entity, DistanceDisplayCondition, ClassificationType, ArcType, CornerType, ShadowMode, ConstantProperty, ConstantPositionProperty, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, HorizontalOrigin, VerticalOrigin, ColorBlendMode, HeadingPitchRoll, Transforms, Model, SceneMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, KmlDataSource, Quaternion, Matrix3, Matrix4, OrthographicFrustum, EasingFunction, NearFarScalar, SceneTransforms, Cesium3DTileset, IonResource, EllipsoidTerrainProvider, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, GeometryInstance, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  const TIME_LAG = 300;
6
6
  const POSITION_CHECK_TIMER = 950;
@@ -1269,16 +1269,21 @@ var CesiumAnimatedProperty;
1269
1269
  return;
1270
1270
  }
1271
1271
  let hasHeading = false;
1272
+ const indicesToUpdate = [];
1272
1273
  for (let i = 0; i < this.positions.length; i++) {
1273
- let pos = this.positions[i];
1274
+ const pos = this.positions[i];
1274
1275
  if (pos.heading !== null && pos.heading !== 0) {
1275
1276
  hasHeading = true;
1276
- break;
1277
+ return;
1278
+ }
1279
+ // Track positions that need updating while we're iterating.
1280
+ if (pos.heading !== null) {
1281
+ indicesToUpdate.push(i);
1277
1282
  }
1278
1283
  }
1279
1284
  if (!hasHeading) {
1280
- for (let i = 0; i < this.positions.length; i++) {
1281
- this.positions[i].heading = null;
1285
+ for (const index of indicesToUpdate) {
1286
+ this.positions[index].heading = null;
1282
1287
  }
1283
1288
  }
1284
1289
  }
@@ -1549,18 +1554,38 @@ var CesiumAnimatedProperty;
1549
1554
  if (!newSeries || newSeries.length === 0) {
1550
1555
  return;
1551
1556
  }
1557
+ const dateTimeIndexes = new Map();
1558
+ for (let i = 0; i < this.positions.length; i++) {
1559
+ const pos = this.positions[i];
1560
+ if (pos && pos.dateTime) {
1561
+ dateTimeIndexes.set(pos.dateTime.getTime(), i);
1562
+ }
1563
+ }
1552
1564
  for (const pos of newSeries) {
1553
1565
  if (!pos || !pos.pos3d || !pos.dateTime) {
1554
1566
  continue;
1555
1567
  }
1556
- const existingIndex = this.positions.findIndex(p => p.dateTime.getTime() === pos.dateTime.getTime());
1568
+ const existingIndex = dateTimeIndexes.get(pos.dateTime.getTime());
1557
1569
  if (existingIndex >= 0) {
1558
1570
  this.positions[existingIndex] = pos;
1559
1571
  }
1560
1572
  else {
1561
- this.AddPosition(pos);
1573
+ const newPoint = {
1574
+ pos: pos.pos3d.clone(),
1575
+ time: pos.dateTime.getTime(),
1576
+ realTime: Date.now()
1577
+ };
1578
+ this.positionHistory.push(newPoint);
1579
+ dateTimeIndexes.set(pos.dateTime.getTime(), this.positions.length);
1562
1580
  }
1563
1581
  }
1582
+ if (this.positionHistory.length > this.maxHistorySize) {
1583
+ this.positionHistory = this.positionHistory.slice(-this.maxHistorySize);
1584
+ }
1585
+ this.analyzeMovementPatterns();
1586
+ this.processHeadings();
1587
+ this.sortPositions();
1588
+ this.invalidateCache();
1564
1589
  }
1565
1590
  UpdatePositionForDateTime(pos3d, dateTime, heading) {
1566
1591
  if (!pos3d || !dateTime) {
@@ -5556,56 +5581,67 @@ var EntityRenderEnginePoint;
5556
5581
  }
5557
5582
  };
5558
5583
  if (type == Style.EPointType.Icon) {
5559
- // Fixing poor data.
5560
- let iconUrlRows = style.iconUrl == null ? [] : style.iconUrl;
5561
- iconUrlRows.forEach((row) => {
5562
- if (row.type == Calculator.EValueType.Color) {
5563
- row.type = Calculator.EValueType.Input;
5584
+ let image = null;
5585
+ let imageKey = null;
5586
+ // Let's our apps/plugins generate images themselves.
5587
+ // Need a better documented process than this in the future.
5588
+ if (style["imageBillboard"]) {
5589
+ image = style["imageBillboard"];
5590
+ imageKey = image ? image.canvasDataUri : null;
5591
+ }
5592
+ // Typical process.
5593
+ else {
5594
+ // Fixing poor data.
5595
+ let iconUrlRows = style.iconUrl == null ? [] : style.iconUrl;
5596
+ iconUrlRows.forEach((row) => {
5597
+ if (row.type == Calculator.EValueType.Color) {
5598
+ row.type = Calculator.EValueType.Input;
5599
+ }
5600
+ });
5601
+ const icon = Calculator.GetString(iconUrlRows, entity, params.tags);
5602
+ let iconUrl = null;
5603
+ if (typeof icon == "string") {
5604
+ iconUrl = icon;
5605
+ const metadata = extractMetadataFromFileUrl(iconUrl);
5606
+ // If we're able to determine the Nextspace metadata from the url then we can use that to load the file.
5607
+ // Warning, if this is cross-env, eg: UAT -> DEV then it will RIGHTLY fail to load the file.
5608
+ if (metadata) {
5609
+ const api = params.apiGetter.getApi(metadata.accountId);
5610
+ await api.Loading;
5611
+ iconUrl = ClientFile.GetUrl({
5612
+ api: api,
5613
+ fileId: metadata.fileId,
5614
+ viaCdn: true
5615
+ });
5616
+ }
5564
5617
  }
5565
- });
5566
- const icon = Calculator.GetString(iconUrlRows, entity, params.tags);
5567
- let iconUrl = null;
5568
- if (typeof icon == "string") {
5569
- iconUrl = icon;
5570
- const metadata = extractMetadataFromFileUrl(iconUrl);
5571
- // If we're able to determine the Nextspace metadata from the url then we can use that to load the file.
5572
- // Warning, if this is cross-env, eg: UAT -> DEV then it will RIGHTLY fail to load the file.
5573
- if (metadata) {
5574
- const api = params.apiGetter.getApi(metadata.accountId);
5575
- await api.Loading;
5618
+ if (!iconUrl && style.iconId) {
5619
+ await params.api.Loading;
5576
5620
  iconUrl = ClientFile.GetUrl({
5577
- api: api,
5578
- fileId: metadata.fileId,
5621
+ api: params.api,
5622
+ fileId: style.iconId,
5579
5623
  viaCdn: true
5580
5624
  });
5581
5625
  }
5582
- }
5583
- if (!iconUrl && style.iconId) {
5584
- await params.api.Loading;
5585
- iconUrl = ClientFile.GetUrl({
5586
- api: params.api,
5587
- fileId: style.iconId,
5588
- viaCdn: true
5589
- });
5590
- }
5591
- let image = null;
5592
- // ND-1640 - Tags not appearing.
5593
- // Validate file, else user will see nothing.
5594
- // Pray we aren't loading some giant file.
5595
- if (iconUrl) {
5596
- try {
5597
- image = await createImageBillboard(iconUrl);
5598
- }
5599
- catch (e) {
5600
- // Expanding the logging here so we can figure out why this is happening.
5601
- // Most of the time the file is missing but we're getting some strange errors so I am including logging on the API settings as well.
5602
- OneTimeError("ENTITY_RENDER_ENGINE_ICON_URL_ERROR_" + iconUrl, {
5603
- error: e,
5604
- iconUrl,
5605
- apiUrl: (_a = params.api) === null || _a === void 0 ? void 0 : _a.GetBaseUrl(),
5606
- apiAccountId: (_b = params.api) === null || _b === void 0 ? void 0 : _b.AccountId
5607
- });
5626
+ // ND-1640 - Tags not appearing.
5627
+ // Validate file, else user will see nothing.
5628
+ // Pray we aren't loading some giant file.
5629
+ if (iconUrl) {
5630
+ try {
5631
+ image = await createImageBillboard(iconUrl);
5632
+ }
5633
+ catch (e) {
5634
+ // Expanding the logging here so we can figure out why this is happening.
5635
+ // Most of the time the file is missing but we're getting some strange errors so I am including logging on the API settings as well.
5636
+ OneTimeError("ENTITY_RENDER_ENGINE_ICON_URL_ERROR_" + iconUrl, {
5637
+ error: e,
5638
+ iconUrl,
5639
+ apiUrl: (_a = params.api) === null || _a === void 0 ? void 0 : _a.GetBaseUrl(),
5640
+ apiAccountId: (_b = params.api) === null || _b === void 0 ? void 0 : _b.AccountId
5641
+ });
5642
+ }
5608
5643
  }
5644
+ imageKey = image ? iconUrl : null;
5609
5645
  }
5610
5646
  if (image) {
5611
5647
  let iconScale = EnsureNumber(Calculator.GetNumber(style.iconScale, entity, params.tags));
@@ -5681,7 +5717,7 @@ var EntityRenderEnginePoint;
5681
5717
  prepareExistingGraphic(params.rendered, shouldShowTrack ? 1 : 0);
5682
5718
  cEntity = params.rendered;
5683
5719
  const currentImgKey = cEntity.billboard._billboardImgKey;
5684
- if (currentImgKey != iconUrl) {
5720
+ if (currentImgKey != imageKey) {
5685
5721
  cEntity.billboard.image = new ConstantProperty(image.canvasDataUri);
5686
5722
  }
5687
5723
  cEntity.billboard.scale = new ConstantProperty(iconScale);
@@ -5767,7 +5803,7 @@ var EntityRenderEnginePoint;
5767
5803
  cEntity.show = true;
5768
5804
  }
5769
5805
  cEntity.billboard._billboardSize = image.height;
5770
- cEntity.billboard._billboardImgKey = iconUrl;
5806
+ cEntity.billboard._billboardImgKey = imageKey;
5771
5807
  }
5772
5808
  }
5773
5809
  }
@@ -33517,7 +33553,7 @@ class WidgetViewBar extends Widget.AWidget {
33517
33553
  }
33518
33554
  }
33519
33555
 
33520
- const VERSION = "6.0.8";
33556
+ const VERSION = "6.1.0";
33521
33557
 
33522
33558
  export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, isOutlineChanged, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, DataLabRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, AssemblyRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, 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, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, 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 };
33523
33559
  //# sourceMappingURL=bruce-cesium.es5.js.map