bruce-cesium 3.6.4 → 3.6.5

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, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ProjectViewTile, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, Api, EntityRelationType, ENVIRONMENT, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, Camera } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, JulianDate, Color, HeightReference, Cartesian3, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Math as Math$1, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, Cartesian2, SceneMode, GeoJsonDataSource, ColorMaterialProperty, Cesium3DTileColorBlendMode, HeadingPitchRange, CallbackProperty, Rectangle, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Quaternion, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, SceneMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, ColorMaterialProperty, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, PolygonPipeline, CesiumInspector, defined, EllipsoidGeodesic, sampleTerrainMostDetailed, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Quaternion, Intersect } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -15348,19 +15348,19 @@ var DataSourceStaticCsvManager;
15348
15348
  Manager.prototype.renderMovingItem = function () {
15349
15349
  var _a;
15350
15350
  return __awaiter(this, void 0, void 0, function () {
15351
- var api, vehicleFileUrl, lineColor, fileStrings, files, i, file, fileId, externalURL, fileUrl, fileStr, csvData, i, delimiter, fileStr, headers, rows, rowsArr, j, row, rowArr, primary, pHeaders, pLatIndex, pLonIndex, pDateTimeIndex, i, row, lat, lon, dateTime, vehicleId, czml, czmlAdjusted, curDateTime, source, errorsInARow_1, removal_1;
15351
+ var api, vehicleFileUrl, alarmFileUrl, lineColor, fileStrings, files, i, file, fileId, externalURL, fileUrl, fileStr, csvData, i, delimiter, fileStr, headers, rows, rowsArr, j, row, rowArr, primary, pHeaders, pLatIndex, pLonIndex, pDateTimeIndex, i, row, lat, lon, dateTimeStr, dateTime, _b, datePart, timePart, _c, year, month, day, _d, hours, minutes, seconds, milliseconds, utcDate, vehicleId, czml, czmlAdjusted, curDateTime, source, errorsInARow_1, removal_1;
15352
15352
  var _this = this;
15353
- return __generator(this, function (_b) {
15354
- switch (_b.label) {
15353
+ return __generator(this, function (_e) {
15354
+ switch (_e.label) {
15355
15355
  case 0:
15356
15356
  api = this.apiGetter.getApi();
15357
15357
  return [4 /*yield*/, api.Loading];
15358
15358
  case 1:
15359
- _b.sent();
15359
+ _e.sent();
15360
15360
  fileStrings = [];
15361
15361
  files = this.item.CSV;
15362
15362
  i = 0;
15363
- _b.label = 2;
15363
+ _e.label = 2;
15364
15364
  case 2:
15365
15365
  if (!(i < files.length)) return [3 /*break*/, 6];
15366
15366
  file = files[i];
@@ -15381,9 +15381,9 @@ var DataSourceStaticCsvManager;
15381
15381
  fileUrl = externalURL;
15382
15382
  }
15383
15383
  return [4 /*yield*/, fetch(fileUrl)];
15384
- case 3: return [4 /*yield*/, (_b.sent()).text()];
15384
+ case 3: return [4 /*yield*/, (_e.sent()).text()];
15385
15385
  case 4:
15386
- fileStr = _b.sent();
15386
+ fileStr = _e.sent();
15387
15387
  fileStrings.push(fileStr);
15388
15388
  if (this.disposed) {
15389
15389
  return [2 /*return*/];
@@ -15398,7 +15398,14 @@ var DataSourceStaticCsvManager;
15398
15398
  if (file.lineColor) {
15399
15399
  lineColor = file.lineColor;
15400
15400
  }
15401
- _b.label = 5;
15401
+ if (file.alertFileId) {
15402
+ alarmFileUrl = ClientFile.GetUrl({
15403
+ api: api,
15404
+ fileId: file.alertFileId,
15405
+ viaCdn: true
15406
+ });
15407
+ }
15408
+ _e.label = 5;
15402
15409
  case 5:
15403
15410
  i++;
15404
15411
  return [3 /*break*/, 2];
@@ -15439,8 +15446,22 @@ var DataSourceStaticCsvManager;
15439
15446
  if (typeof lon == "string") {
15440
15447
  row[pLonIndex] = parseFloat(lon);
15441
15448
  }
15442
- dateTime = new Date(row[pDateTimeIndex]);
15443
- row[pDateTimeIndex] = dateTime.toISOString();
15449
+ dateTimeStr = row[pDateTimeIndex];
15450
+ if (typeof dateTimeStr === "string") {
15451
+ // Check if format is expected.
15452
+ if (!dateTimeStr.includes("/") || !dateTimeStr.includes(":")) {
15453
+ dateTime = new Date(row[pDateTimeIndex]);
15454
+ row[pDateTimeIndex] = dateTime.toISOString();
15455
+ }
15456
+ else {
15457
+ _b = dateTimeStr.split(" "), datePart = _b[0], timePart = _b[1];
15458
+ _c = datePart.split("/").map(Number), year = _c[0], month = _c[1], day = _c[2];
15459
+ _d = timePart.split(":").map(Number), hours = _d[0], minutes = _d[1], seconds = _d[2];
15460
+ milliseconds = seconds % 1 * 1000;
15461
+ utcDate = new Date(Date.UTC(year, month - 1, day, hours, minutes, Math.floor(seconds), milliseconds));
15462
+ row[pDateTimeIndex] = utcDate.toISOString();
15463
+ }
15464
+ }
15444
15465
  }
15445
15466
  // Sort by date.
15446
15467
  primary.rows.sort(function (a, b) {
@@ -15449,7 +15470,7 @@ var DataSourceStaticCsvManager;
15449
15470
  return aDate.getTime() - bDate.getTime();
15450
15471
  });
15451
15472
  vehicleId = ObjectUtils.UId();
15452
- czml = createJourneyCzml(vehicleId, vehicleFileUrl, lineColor, primary);
15473
+ czml = createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, primary);
15453
15474
  this.czmlDataInputs.push(czml);
15454
15475
  czmlAdjusted = JSON.parse(JSON.stringify(czml));
15455
15476
  czmlAdjusted.forEach(function (item) {
@@ -15458,7 +15479,7 @@ var DataSourceStaticCsvManager;
15458
15479
  curDateTime = this.viewer.clock.currentTime;
15459
15480
  return [4 /*yield*/, this.viewer.dataSources.add(CzmlDataSource.load(czmlAdjusted))];
15460
15481
  case 7:
15461
- source = _b.sent();
15482
+ source = _e.sent();
15462
15483
  this.dataSource = source;
15463
15484
  // Reset back to the previous dateTime.
15464
15485
  // Adding the czml data source will have changed the clock.
@@ -15526,11 +15547,12 @@ var DataSourceStaticCsvManager;
15526
15547
  * This shows a journey taken by a moving object and alarms detected along the way.
15527
15548
  * @param vehicleId
15528
15549
  * @param vehicleFileUrl
15550
+ * @param alarmFileUrl
15529
15551
  * @param lineColor
15530
15552
  * @param data
15531
15553
  * @returns
15532
15554
  */
15533
- function createJourneyCzml(vehicleId, vehicleFileUrl, lineColor, data) {
15555
+ function createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, data) {
15534
15556
  var headers = data.headers;
15535
15557
  var rows = data.rows;
15536
15558
  var latIndex = headers.findIndex(function (x) { return x.toLowerCase().includes("lat"); });
@@ -15551,29 +15573,50 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, lineColor, data) {
15551
15573
  }
15552
15574
  },
15553
15575
  ];
15554
- // Create a polyline for the full path.
15555
- var roadPositions = rows.map(function (row) { return [
15556
- Number(row[lonIndex]),
15557
- Number(row[latIndex]),
15558
- 0
15559
- ]; }).flat();
15560
- czml.push({
15561
- "id": ObjectUtils.UId(),
15562
- "name": "Path",
15563
- "polyline": {
15564
- "positions": {
15565
- "cartographicDegrees": roadPositions
15566
- },
15567
- "material": {
15568
- "solidColor": {
15569
- "color": {
15570
- "rgba": lineColor ? Color.fromCssColorString(lineColor).toBytes() : [0, 255, 0, 100]
15576
+ // If segmented we'll break it into pieces and display each piece based on relative time to the cesium viewer clock.
15577
+ {
15578
+ // Calculate the total duration of the journey in milliseconds.
15579
+ var totalDuration = new Date(rows[rows.length - 1][dateTimeIndex]).getTime() - new Date(rows[0][dateTimeIndex]).getTime();
15580
+ // Percentage of the journey to be visible before and after each point.
15581
+ var visibilityPercentage = 0.05; // 5%
15582
+ var visibilityDuration_1 = totalDuration * visibilityPercentage;
15583
+ rows.forEach(function (row, index) {
15584
+ var time = new Date(row[dateTimeIndex]).getTime();
15585
+ var startTime = new Date(time - visibilityDuration_1 / 2).toISOString();
15586
+ var endTime = new Date(time + visibilityDuration_1 / 2).toISOString();
15587
+ var position = [
15588
+ Number(row[lonIndex]),
15589
+ Number(row[latIndex]),
15590
+ 0
15591
+ ];
15592
+ if (index < rows.length - 1) {
15593
+ var nextRow = rows[index + 1];
15594
+ var nextPosition = [
15595
+ Number(nextRow[lonIndex]),
15596
+ Number(nextRow[latIndex]),
15597
+ 0
15598
+ ];
15599
+ czml.push({
15600
+ "id": "segment-" + ObjectUtils.UId(),
15601
+ "name": "Path Segment",
15602
+ "availability": startTime + "/" + endTime,
15603
+ "polyline": {
15604
+ "positions": {
15605
+ "cartographicDegrees": position.concat(nextPosition)
15606
+ },
15607
+ "material": {
15608
+ "solidColor": {
15609
+ "color": {
15610
+ "rgba": lineColor ? Color.fromCssColorString(lineColor).toBytes() : [0, 255, 0, 100]
15611
+ }
15612
+ }
15613
+ },
15614
+ "width": 5
15571
15615
  }
15572
- }
15573
- },
15574
- "width": 5
15575
- }
15576
- });
15616
+ });
15617
+ }
15618
+ });
15619
+ }
15577
15620
  // Add points for the alarms.
15578
15621
  rows.filter(function (row) { return row[alarmIndex]; }).forEach(function (row, index) {
15579
15622
  czml.push({
@@ -15583,15 +15626,23 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, lineColor, data) {
15583
15626
  "cartographicDegrees": [
15584
15627
  Number(row[lonIndex]),
15585
15628
  Number(row[latIndex]),
15586
- 0
15629
+ 5
15587
15630
  ]
15588
15631
  },
15589
- "point": {
15632
+ "point": !alarmFileUrl ? {
15590
15633
  "pixelSize": 10,
15591
15634
  "color": {
15592
15635
  "rgba": [255, 0, 0, 255]
15593
15636
  }
15594
- },
15637
+ } : undefined,
15638
+ "billboard": alarmFileUrl ? {
15639
+ "image": alarmFileUrl,
15640
+ "scale": 1,
15641
+ "pixelOffset": {
15642
+ "cartesian2": [0, 0]
15643
+ }
15644
+ } : undefined,
15645
+ /*
15595
15646
  "label": {
15596
15647
  "text": row[alarmIndex],
15597
15648
  "show": true,
@@ -15605,9 +15656,16 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, lineColor, data) {
15605
15656
  "cartesian2": [0, -16]
15606
15657
  }
15607
15658
  }
15659
+ */
15608
15660
  });
15609
15661
  });
15610
15662
  // Add animated point for the moving item.
15663
+ var vehiclePositions = rows.map(function (row) { return [
15664
+ (new Date(row[dateTimeIndex]).getTime() - new Date(rows[0][dateTimeIndex]).getTime()) / 1000,
15665
+ Number(row[lonIndex]),
15666
+ Number(row[latIndex]),
15667
+ 0
15668
+ ]; }).flat();
15611
15669
  czml.push({
15612
15670
  "id": vehicleId,
15613
15671
  "name": "Vehicle",
@@ -15627,12 +15685,7 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, lineColor, data) {
15627
15685
  },
15628
15686
  "position": {
15629
15687
  "epoch": rows[0][dateTimeIndex],
15630
- "cartographicDegrees": rows.map(function (row, index) { return [
15631
- index,
15632
- Number(row[lonIndex]),
15633
- Number(row[latIndex]),
15634
- 0
15635
- ]; }).flat()
15688
+ "cartographicDegrees": vehiclePositions
15636
15689
  }
15637
15690
  });
15638
15691
  return czml;
@@ -22219,7 +22272,7 @@ var ViewRenderEngine;
22219
22272
  ViewRenderEngine.Render = Render;
22220
22273
  })(ViewRenderEngine || (ViewRenderEngine = {}));
22221
22274
 
22222
- var VERSION = "3.6.4";
22275
+ var VERSION = "3.6.5";
22223
22276
 
22224
22277
  export { VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, Draw3dPolygon, Draw3dPolyline };
22225
22278
  //# sourceMappingURL=bruce-cesium.es5.js.map