bruce-cesium 3.6.5 → 3.6.6
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.
- package/dist/bruce-cesium.es5.js +136 -64
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +135 -63
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/render-managers/data-source/data-source-static-csv-manager.js +175 -62
- package/dist/lib/rendering/render-managers/data-source/data-source-static-csv-manager.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -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, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate,
|
|
3
|
+
import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, ColorMaterialProperty, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, HeadingPitchRoll, Transforms, Matrix3, IonResource, CesiumInspector, defined, EllipsoidGeodesic, sampleTerrainMostDetailed, Model, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, PolylineGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolygonHierarchy, ScreenSpaceEventHandler, ScreenSpaceEventType, ShadowMode, ClassificationType, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ArcType, CornerType, ColorBlendMode, 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, 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,
|
|
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, utcDate, _b, datePart, timePart, _c, year, month, day, _d, hours, minutes, seconds, milliseconds, convertTo24HourFormat, dateTime24hr, _e, datePart, timePart, _f, day, month, year, _g, hours, minutes, seconds, _h, datePart, timePart, _j, year, month, day, _k, hours, minutes, seconds, vehicleId, czml, czmlAdjusted, curDateTime, source, pHeadingIndex_1, errorsInARow_1, removal_1;
|
|
15352
15352
|
var _this = this;
|
|
15353
|
-
return __generator(this, function (
|
|
15354
|
-
switch (
|
|
15353
|
+
return __generator(this, function (_l) {
|
|
15354
|
+
switch (_l.label) {
|
|
15355
15355
|
case 0:
|
|
15356
15356
|
api = this.apiGetter.getApi();
|
|
15357
15357
|
return [4 /*yield*/, api.Loading];
|
|
15358
15358
|
case 1:
|
|
15359
|
-
|
|
15359
|
+
_l.sent();
|
|
15360
15360
|
fileStrings = [];
|
|
15361
15361
|
files = this.item.CSV;
|
|
15362
15362
|
i = 0;
|
|
15363
|
-
|
|
15363
|
+
_l.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*/, (
|
|
15384
|
+
case 3: return [4 /*yield*/, (_l.sent()).text()];
|
|
15385
15385
|
case 4:
|
|
15386
|
-
fileStr =
|
|
15386
|
+
fileStr = _l.sent();
|
|
15387
15387
|
fileStrings.push(fileStr);
|
|
15388
15388
|
if (this.disposed) {
|
|
15389
15389
|
return [2 /*return*/];
|
|
@@ -15405,7 +15405,7 @@ var DataSourceStaticCsvManager;
|
|
|
15405
15405
|
viaCdn: true
|
|
15406
15406
|
});
|
|
15407
15407
|
}
|
|
15408
|
-
|
|
15408
|
+
_l.label = 5;
|
|
15409
15409
|
case 5:
|
|
15410
15410
|
i++;
|
|
15411
15411
|
return [3 /*break*/, 2];
|
|
@@ -15448,19 +15448,47 @@ var DataSourceStaticCsvManager;
|
|
|
15448
15448
|
}
|
|
15449
15449
|
dateTimeStr = row[pDateTimeIndex];
|
|
15450
15450
|
if (typeof dateTimeStr === "string") {
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
}
|
|
15456
|
-
else {
|
|
15451
|
+
utcDate = void 0;
|
|
15452
|
+
// Dates are assumed to be in UTC.
|
|
15453
|
+
// Check for the format: `2023/12/24 04:15:00.743`.
|
|
15454
|
+
if (dateTimeStr.includes("/") && dateTimeStr.includes(":")) {
|
|
15457
15455
|
_b = dateTimeStr.split(" "), datePart = _b[0], timePart = _b[1];
|
|
15458
15456
|
_c = datePart.split("/").map(Number), year = _c[0], month = _c[1], day = _c[2];
|
|
15459
15457
|
_d = timePart.split(":").map(Number), hours = _d[0], minutes = _d[1], seconds = _d[2];
|
|
15460
15458
|
milliseconds = seconds % 1 * 1000;
|
|
15461
15459
|
utcDate = new Date(Date.UTC(year, month - 1, day, hours, minutes, Math.floor(seconds), milliseconds));
|
|
15462
|
-
row[pDateTimeIndex] = utcDate.toISOString();
|
|
15463
15460
|
}
|
|
15461
|
+
// Check for the format: `24-12-2023 4:15:12 AM`.
|
|
15462
|
+
else if (dateTimeStr.includes("-") && dateTimeStr.includes(":") && (dateTimeStr.includes("AM") || dateTimeStr.includes("PM"))) {
|
|
15463
|
+
convertTo24HourFormat = function (dateTimeStr) {
|
|
15464
|
+
var _a = dateTimeStr.split(/[: ]+/), datePart = _a[0], timePart = _a[1], meridian = _a[2];
|
|
15465
|
+
var _b = timePart.split(":").map(Number), hours = _b[0], minutes = _b[1], seconds = _b[2];
|
|
15466
|
+
if (meridian === 'PM' && hours < 12) {
|
|
15467
|
+
hours += 12;
|
|
15468
|
+
}
|
|
15469
|
+
if (meridian === 'AM' && hours === 12) {
|
|
15470
|
+
hours = 0;
|
|
15471
|
+
}
|
|
15472
|
+
return "".concat(datePart, " ").concat(hours.toString().padStart(2, '0'), ":").concat(minutes.toString().padStart(2, '0'), ":").concat(seconds.toString().padStart(2, '0'));
|
|
15473
|
+
};
|
|
15474
|
+
dateTime24hr = convertTo24HourFormat(dateTimeStr);
|
|
15475
|
+
_e = dateTime24hr.split(" "), datePart = _e[0], timePart = _e[1];
|
|
15476
|
+
_f = datePart.split("-").map(Number), day = _f[0], month = _f[1], year = _f[2];
|
|
15477
|
+
_g = timePart.split(":").map(Number), hours = _g[0], minutes = _g[1], seconds = _g[2];
|
|
15478
|
+
utcDate = new Date(Date.UTC(year, month - 1, day, hours, minutes, seconds));
|
|
15479
|
+
}
|
|
15480
|
+
// Format: `2023-12-24 04:19:17.196`.
|
|
15481
|
+
else if (dateTimeStr.includes("-") && dateTimeStr.includes(":")) {
|
|
15482
|
+
_h = dateTimeStr.split(" "), datePart = _h[0], timePart = _h[1];
|
|
15483
|
+
_j = datePart.split("-").map(Number), year = _j[0], month = _j[1], day = _j[2];
|
|
15484
|
+
_k = timePart.split(":").map(Number), hours = _k[0], minutes = _k[1], seconds = _k[2];
|
|
15485
|
+
utcDate = new Date(Date.UTC(year, month - 1, day, hours, minutes, seconds));
|
|
15486
|
+
}
|
|
15487
|
+
else {
|
|
15488
|
+
// Fallback to parsing in local time.
|
|
15489
|
+
utcDate = new Date(dateTimeStr);
|
|
15490
|
+
}
|
|
15491
|
+
row[pDateTimeIndex] = utcDate.toISOString();
|
|
15464
15492
|
}
|
|
15465
15493
|
}
|
|
15466
15494
|
// Sort by date.
|
|
@@ -15479,19 +15507,20 @@ var DataSourceStaticCsvManager;
|
|
|
15479
15507
|
curDateTime = this.viewer.clock.currentTime;
|
|
15480
15508
|
return [4 /*yield*/, this.viewer.dataSources.add(CzmlDataSource.load(czmlAdjusted))];
|
|
15481
15509
|
case 7:
|
|
15482
|
-
source =
|
|
15510
|
+
source = _l.sent();
|
|
15483
15511
|
this.dataSource = source;
|
|
15484
15512
|
// Reset back to the previous dateTime.
|
|
15485
15513
|
// Adding the czml data source will have changed the clock.
|
|
15486
15514
|
this.viewer.clock.currentTime = curDateTime;
|
|
15487
15515
|
// Listen to update ticks and ensure orientation of moving item is correct.
|
|
15488
15516
|
if (this.viewer.clock) {
|
|
15517
|
+
pHeadingIndex_1 = pHeaders.findIndex(function (x) { return x.toLowerCase().includes("head"); });
|
|
15489
15518
|
errorsInARow_1 = 0;
|
|
15490
15519
|
removal_1 = this.viewer.clock.onTick.addEventListener(function () {
|
|
15491
15520
|
var vehicle = source.entities.getById(vehicleId);
|
|
15492
15521
|
if (vehicle) {
|
|
15493
15522
|
try {
|
|
15494
|
-
updateOrientation(_this.viewer, vehicle);
|
|
15523
|
+
updateOrientation(primary.rows, pHeadingIndex_1, pDateTimeIndex, _this.viewer, vehicle);
|
|
15495
15524
|
errorsInARow_1 = 0;
|
|
15496
15525
|
}
|
|
15497
15526
|
catch (e) {
|
|
@@ -15573,6 +15602,7 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, d
|
|
|
15573
15602
|
}
|
|
15574
15603
|
},
|
|
15575
15604
|
];
|
|
15605
|
+
// Create a polyline for the full path.
|
|
15576
15606
|
// If segmented we'll break it into pieces and display each piece based on relative time to the cesium viewer clock.
|
|
15577
15607
|
{
|
|
15578
15608
|
// Calculate the total duration of the journey in milliseconds.
|
|
@@ -15616,49 +15646,38 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, d
|
|
|
15616
15646
|
});
|
|
15617
15647
|
}
|
|
15618
15648
|
});
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
"
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
|
|
15630
|
-
|
|
15631
|
-
|
|
15632
|
-
|
|
15633
|
-
|
|
15634
|
-
"color": {
|
|
15635
|
-
"rgba": [255, 0, 0, 255]
|
|
15636
|
-
}
|
|
15637
|
-
} : undefined,
|
|
15638
|
-
"billboard": alarmFileUrl ? {
|
|
15639
|
-
"image": alarmFileUrl,
|
|
15640
|
-
"scale": 1,
|
|
15641
|
-
"pixelOffset": {
|
|
15642
|
-
"cartesian2": [0, 0]
|
|
15643
|
-
}
|
|
15644
|
-
} : undefined,
|
|
15645
|
-
/*
|
|
15646
|
-
"label": {
|
|
15647
|
-
"text": row[alarmIndex],
|
|
15648
|
-
"show": true,
|
|
15649
|
-
"font": "11pt monospace",
|
|
15650
|
-
"style": "FILL",
|
|
15651
|
-
"outlineColor": {
|
|
15652
|
-
"rgba": [0, 0, 0, 255]
|
|
15649
|
+
// Alarm points.
|
|
15650
|
+
rows.filter(function (row) { return row[alarmIndex]; }).forEach(function (row, index) {
|
|
15651
|
+
var alarmTime = new Date(row[dateTimeIndex]).getTime();
|
|
15652
|
+
var startTime = new Date(alarmTime - visibilityDuration_1 / 2).toISOString();
|
|
15653
|
+
var endTime = new Date(alarmTime + visibilityDuration_1 / 2).toISOString();
|
|
15654
|
+
czml.push({
|
|
15655
|
+
"id": ObjectUtils.UId(),
|
|
15656
|
+
"name": "Alarm",
|
|
15657
|
+
"availability": startTime + "/" + endTime,
|
|
15658
|
+
"position": {
|
|
15659
|
+
"cartographicDegrees": [
|
|
15660
|
+
Number(row[lonIndex]),
|
|
15661
|
+
Number(row[latIndex]),
|
|
15662
|
+
5
|
|
15663
|
+
]
|
|
15653
15664
|
},
|
|
15654
|
-
"
|
|
15655
|
-
|
|
15656
|
-
"
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15665
|
+
"point": !alarmFileUrl ? {
|
|
15666
|
+
"pixelSize": 10,
|
|
15667
|
+
"color": {
|
|
15668
|
+
"rgba": [255, 0, 0, 255]
|
|
15669
|
+
}
|
|
15670
|
+
} : undefined,
|
|
15671
|
+
"billboard": alarmFileUrl ? {
|
|
15672
|
+
"image": alarmFileUrl,
|
|
15673
|
+
"scale": 1,
|
|
15674
|
+
"pixelOffset": {
|
|
15675
|
+
"cartesian2": [0, 0]
|
|
15676
|
+
}
|
|
15677
|
+
} : undefined
|
|
15678
|
+
});
|
|
15660
15679
|
});
|
|
15661
|
-
}
|
|
15680
|
+
}
|
|
15662
15681
|
// Add animated point for the moving item.
|
|
15663
15682
|
var vehiclePositions = rows.map(function (row) { return [
|
|
15664
15683
|
(new Date(row[dateTimeIndex]).getTime() - new Date(rows[0][dateTimeIndex]).getTime()) / 1000,
|
|
@@ -15692,27 +15711,80 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, d
|
|
|
15692
15711
|
}
|
|
15693
15712
|
/**
|
|
15694
15713
|
* Updates the orientation of the moving item.
|
|
15695
|
-
*
|
|
15714
|
+
* If there is a heading in the file then it will calculate based on the file data,
|
|
15715
|
+
* if there isn't then it will calculate one based on the previous and current position.
|
|
15716
|
+
* @param rows
|
|
15717
|
+
* @param headingIndex
|
|
15718
|
+
* @param dateTimeIndex
|
|
15696
15719
|
* @param viewer
|
|
15697
15720
|
* @param vehicleEntity
|
|
15698
15721
|
* @returns
|
|
15699
15722
|
*/
|
|
15700
|
-
function updateOrientation(viewer, vehicleEntity) {
|
|
15723
|
+
function updateOrientation(rows, headingIndex, dateTimeIndex, viewer, vehicleEntity) {
|
|
15701
15724
|
if (!vehicleEntity || !vehicleEntity.position) {
|
|
15702
15725
|
return;
|
|
15703
15726
|
}
|
|
15704
15727
|
var positionProperty = vehicleEntity.position;
|
|
15705
15728
|
var currentTime = viewer.clock.currentTime;
|
|
15706
|
-
var previousTime = JulianDate.addSeconds(currentTime, -1, new JulianDate());
|
|
15707
15729
|
var currentPosition = positionProperty.getValue(currentTime);
|
|
15730
|
+
if (!currentPosition) {
|
|
15731
|
+
return;
|
|
15732
|
+
}
|
|
15733
|
+
if (headingIndex > -1) {
|
|
15734
|
+
try {
|
|
15735
|
+
var interpolatedHeading = interpolateHeading(dateTimeIndex, rows, currentTime, headingIndex);
|
|
15736
|
+
if (interpolatedHeading !== null) {
|
|
15737
|
+
var radians = Math$1.toRadians(interpolatedHeading - 90);
|
|
15738
|
+
var quaternion = Transforms.headingPitchRollQuaternion(currentPosition, new HeadingPitchRoll(radians, 0, 0));
|
|
15739
|
+
if (!isNaN(quaternion.w) && !isNaN(quaternion.x) && !isNaN(quaternion.y) && !isNaN(quaternion.z)) {
|
|
15740
|
+
vehicleEntity.orientation = quaternion;
|
|
15741
|
+
return;
|
|
15742
|
+
}
|
|
15743
|
+
else {
|
|
15744
|
+
console.error("Invalid quaternion", quaternion);
|
|
15745
|
+
}
|
|
15746
|
+
}
|
|
15747
|
+
}
|
|
15748
|
+
catch (e) {
|
|
15749
|
+
console.error(e);
|
|
15750
|
+
}
|
|
15751
|
+
}
|
|
15752
|
+
var previousTime = JulianDate.addSeconds(currentTime, -1, new JulianDate());
|
|
15708
15753
|
var previousPosition = positionProperty.getValue(previousTime);
|
|
15709
|
-
if (
|
|
15754
|
+
if (previousPosition && !Cartesian3.equals(currentPosition, previousPosition)) {
|
|
15710
15755
|
var direction = Cartesian3.subtract(currentPosition, previousPosition, new Cartesian3());
|
|
15711
15756
|
Cartesian3.normalize(direction, direction);
|
|
15712
15757
|
var rotationMatrix = Transforms.rotationMatrixFromPositionVelocity(previousPosition, direction);
|
|
15713
15758
|
vehicleEntity.orientation = Quaternion.fromRotationMatrix(rotationMatrix);
|
|
15714
15759
|
}
|
|
15715
15760
|
}
|
|
15761
|
+
function interpolateHeading(dateTimeIndex, rows, currentTime, headingIndex) {
|
|
15762
|
+
var currentTimeMs = JulianDate.toDate(currentTime).getTime();
|
|
15763
|
+
var nearestBefore = null;
|
|
15764
|
+
var nearestAfter = null;
|
|
15765
|
+
for (var _i = 0, rows_1 = rows; _i < rows_1.length; _i++) {
|
|
15766
|
+
var row = rows_1[_i];
|
|
15767
|
+
var time = new Date(row[dateTimeIndex]).getTime();
|
|
15768
|
+
var heading = parseFloat(String(row[headingIndex]));
|
|
15769
|
+
if (!isNaN(heading)) {
|
|
15770
|
+
if (time <= currentTimeMs) {
|
|
15771
|
+
nearestBefore = { time: time, heading: heading };
|
|
15772
|
+
}
|
|
15773
|
+
else if (time > currentTimeMs && nearestAfter === null) {
|
|
15774
|
+
nearestAfter = { time: time, heading: heading };
|
|
15775
|
+
break;
|
|
15776
|
+
}
|
|
15777
|
+
}
|
|
15778
|
+
}
|
|
15779
|
+
if (nearestBefore && nearestAfter) {
|
|
15780
|
+
var factor = (currentTimeMs - nearestBefore.time) / (nearestAfter.time - nearestBefore.time);
|
|
15781
|
+
return nearestBefore.heading + factor * (nearestAfter.heading - nearestBefore.heading);
|
|
15782
|
+
}
|
|
15783
|
+
else if (nearestBefore) {
|
|
15784
|
+
return nearestBefore.heading;
|
|
15785
|
+
}
|
|
15786
|
+
return null;
|
|
15787
|
+
}
|
|
15716
15788
|
|
|
15717
15789
|
var TilesetI3sRenderManager;
|
|
15718
15790
|
(function (TilesetI3sRenderManager) {
|
|
@@ -22272,7 +22344,7 @@ var ViewRenderEngine;
|
|
|
22272
22344
|
ViewRenderEngine.Render = Render;
|
|
22273
22345
|
})(ViewRenderEngine || (ViewRenderEngine = {}));
|
|
22274
22346
|
|
|
22275
|
-
var VERSION = "3.6.
|
|
22347
|
+
var VERSION = "3.6.6";
|
|
22276
22348
|
|
|
22277
22349
|
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 };
|
|
22278
22350
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|