bruce-cesium 3.6.5 → 3.6.7
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 +211 -69
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +210 -68
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/menu-item-manager.js +2 -1
- package/dist/lib/rendering/menu-item-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/data-source/data-source-static-csv-manager.js +249 -67
- 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/dist/types/rendering/render-managers/data-source/data-source-static-csv-manager.d.ts +3 -0
- package/package.json +2 -2
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, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode,
|
|
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, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, ColorMaterialProperty, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, 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.
|
|
@@ -15265,10 +15265,11 @@ var DataSourceStaticCsvManager;
|
|
|
15265
15265
|
this.czmlDataInputs = [];
|
|
15266
15266
|
// Array of callbacks to remove from the clock tick event.
|
|
15267
15267
|
this.tickRemovals = [];
|
|
15268
|
-
var viewer = params.viewer, apiGetter = params.apiGetter, item = params.item;
|
|
15268
|
+
var viewer = params.viewer, apiGetter = params.apiGetter, item = params.item, register = params.register;
|
|
15269
15269
|
this.viewer = viewer;
|
|
15270
15270
|
this.apiGetter = apiGetter;
|
|
15271
15271
|
this.item = item;
|
|
15272
|
+
this.register = register;
|
|
15272
15273
|
}
|
|
15273
15274
|
Object.defineProperty(Manager.prototype, "Disposed", {
|
|
15274
15275
|
get: function () {
|
|
@@ -15348,19 +15349,19 @@ var DataSourceStaticCsvManager;
|
|
|
15348
15349
|
Manager.prototype.renderMovingItem = function () {
|
|
15349
15350
|
var _a;
|
|
15350
15351
|
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,
|
|
15352
|
+
var api, vehicleFileUrl, alarmFileUrl, lineColor, vehicleEntityId, 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, vehicleCesiumId, _l, czml, entityMapping, czmlAdjusted, curDateTime, source, pHeadingIndex_1, errorsInARow_1, removal_1, vehicleEntity, cesiumEntityIds, i, cesiumEntityId, entity, nextspaceEntityId;
|
|
15352
15353
|
var _this = this;
|
|
15353
|
-
return __generator(this, function (
|
|
15354
|
-
switch (
|
|
15354
|
+
return __generator(this, function (_m) {
|
|
15355
|
+
switch (_m.label) {
|
|
15355
15356
|
case 0:
|
|
15356
15357
|
api = this.apiGetter.getApi();
|
|
15357
15358
|
return [4 /*yield*/, api.Loading];
|
|
15358
15359
|
case 1:
|
|
15359
|
-
|
|
15360
|
+
_m.sent();
|
|
15360
15361
|
fileStrings = [];
|
|
15361
15362
|
files = this.item.CSV;
|
|
15362
15363
|
i = 0;
|
|
15363
|
-
|
|
15364
|
+
_m.label = 2;
|
|
15364
15365
|
case 2:
|
|
15365
15366
|
if (!(i < files.length)) return [3 /*break*/, 6];
|
|
15366
15367
|
file = files[i];
|
|
@@ -15381,9 +15382,9 @@ var DataSourceStaticCsvManager;
|
|
|
15381
15382
|
fileUrl = externalURL;
|
|
15382
15383
|
}
|
|
15383
15384
|
return [4 /*yield*/, fetch(fileUrl)];
|
|
15384
|
-
case 3: return [4 /*yield*/, (
|
|
15385
|
+
case 3: return [4 /*yield*/, (_m.sent()).text()];
|
|
15385
15386
|
case 4:
|
|
15386
|
-
fileStr =
|
|
15387
|
+
fileStr = _m.sent();
|
|
15387
15388
|
fileStrings.push(fileStr);
|
|
15388
15389
|
if (this.disposed) {
|
|
15389
15390
|
return [2 /*return*/];
|
|
@@ -15405,7 +15406,10 @@ var DataSourceStaticCsvManager;
|
|
|
15405
15406
|
viaCdn: true
|
|
15406
15407
|
});
|
|
15407
15408
|
}
|
|
15408
|
-
|
|
15409
|
+
if (file.vehicleEntityId) {
|
|
15410
|
+
vehicleEntityId = file.vehicleEntityId;
|
|
15411
|
+
}
|
|
15412
|
+
_m.label = 5;
|
|
15409
15413
|
case 5:
|
|
15410
15414
|
i++;
|
|
15411
15415
|
return [3 /*break*/, 2];
|
|
@@ -15448,19 +15452,47 @@ var DataSourceStaticCsvManager;
|
|
|
15448
15452
|
}
|
|
15449
15453
|
dateTimeStr = row[pDateTimeIndex];
|
|
15450
15454
|
if (typeof dateTimeStr === "string") {
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
}
|
|
15456
|
-
else {
|
|
15455
|
+
utcDate = void 0;
|
|
15456
|
+
// Dates are assumed to be in UTC.
|
|
15457
|
+
// Check for the format: `2023/12/24 04:15:00.743`.
|
|
15458
|
+
if (dateTimeStr.includes("/") && dateTimeStr.includes(":")) {
|
|
15457
15459
|
_b = dateTimeStr.split(" "), datePart = _b[0], timePart = _b[1];
|
|
15458
15460
|
_c = datePart.split("/").map(Number), year = _c[0], month = _c[1], day = _c[2];
|
|
15459
15461
|
_d = timePart.split(":").map(Number), hours = _d[0], minutes = _d[1], seconds = _d[2];
|
|
15460
15462
|
milliseconds = seconds % 1 * 1000;
|
|
15461
15463
|
utcDate = new Date(Date.UTC(year, month - 1, day, hours, minutes, Math.floor(seconds), milliseconds));
|
|
15462
|
-
row[pDateTimeIndex] = utcDate.toISOString();
|
|
15463
15464
|
}
|
|
15465
|
+
// Check for the format: `24-12-2023 4:15:12 AM`.
|
|
15466
|
+
else if (dateTimeStr.includes("-") && dateTimeStr.includes(":") && (dateTimeStr.includes("AM") || dateTimeStr.includes("PM"))) {
|
|
15467
|
+
convertTo24HourFormat = function (dateTimeStr) {
|
|
15468
|
+
var _a = dateTimeStr.split(/[: ]+/), datePart = _a[0], timePart = _a[1], meridian = _a[2];
|
|
15469
|
+
var _b = timePart.split(":").map(Number), hours = _b[0], minutes = _b[1], seconds = _b[2];
|
|
15470
|
+
if (meridian === 'PM' && hours < 12) {
|
|
15471
|
+
hours += 12;
|
|
15472
|
+
}
|
|
15473
|
+
if (meridian === 'AM' && hours === 12) {
|
|
15474
|
+
hours = 0;
|
|
15475
|
+
}
|
|
15476
|
+
return "".concat(datePart, " ").concat(hours.toString().padStart(2, '0'), ":").concat(minutes.toString().padStart(2, '0'), ":").concat(seconds.toString().padStart(2, '0'));
|
|
15477
|
+
};
|
|
15478
|
+
dateTime24hr = convertTo24HourFormat(dateTimeStr);
|
|
15479
|
+
_e = dateTime24hr.split(" "), datePart = _e[0], timePart = _e[1];
|
|
15480
|
+
_f = datePart.split("-").map(Number), day = _f[0], month = _f[1], year = _f[2];
|
|
15481
|
+
_g = timePart.split(":").map(Number), hours = _g[0], minutes = _g[1], seconds = _g[2];
|
|
15482
|
+
utcDate = new Date(Date.UTC(year, month - 1, day, hours, minutes, seconds));
|
|
15483
|
+
}
|
|
15484
|
+
// Format: `2023-12-24 04:19:17.196`.
|
|
15485
|
+
else if (dateTimeStr.includes("-") && dateTimeStr.includes(":")) {
|
|
15486
|
+
_h = dateTimeStr.split(" "), datePart = _h[0], timePart = _h[1];
|
|
15487
|
+
_j = datePart.split("-").map(Number), year = _j[0], month = _j[1], day = _j[2];
|
|
15488
|
+
_k = timePart.split(":").map(Number), hours = _k[0], minutes = _k[1], seconds = _k[2];
|
|
15489
|
+
utcDate = new Date(Date.UTC(year, month - 1, day, hours, minutes, seconds));
|
|
15490
|
+
}
|
|
15491
|
+
else {
|
|
15492
|
+
// Fallback to parsing in local time.
|
|
15493
|
+
utcDate = new Date(dateTimeStr);
|
|
15494
|
+
}
|
|
15495
|
+
row[pDateTimeIndex] = utcDate.toISOString();
|
|
15464
15496
|
}
|
|
15465
15497
|
}
|
|
15466
15498
|
// Sort by date.
|
|
@@ -15469,8 +15501,8 @@ var DataSourceStaticCsvManager;
|
|
|
15469
15501
|
var bDate = new Date(b[pDateTimeIndex]);
|
|
15470
15502
|
return aDate.getTime() - bDate.getTime();
|
|
15471
15503
|
});
|
|
15472
|
-
|
|
15473
|
-
|
|
15504
|
+
vehicleCesiumId = ObjectUtils.UId();
|
|
15505
|
+
_l = createJourneyCzml(vehicleCesiumId, vehicleFileUrl, alarmFileUrl, lineColor, primary), czml = _l.czml, entityMapping = _l.entityMapping;
|
|
15474
15506
|
this.czmlDataInputs.push(czml);
|
|
15475
15507
|
czmlAdjusted = JSON.parse(JSON.stringify(czml));
|
|
15476
15508
|
czmlAdjusted.forEach(function (item) {
|
|
@@ -15479,19 +15511,20 @@ var DataSourceStaticCsvManager;
|
|
|
15479
15511
|
curDateTime = this.viewer.clock.currentTime;
|
|
15480
15512
|
return [4 /*yield*/, this.viewer.dataSources.add(CzmlDataSource.load(czmlAdjusted))];
|
|
15481
15513
|
case 7:
|
|
15482
|
-
source =
|
|
15514
|
+
source = _m.sent();
|
|
15483
15515
|
this.dataSource = source;
|
|
15484
15516
|
// Reset back to the previous dateTime.
|
|
15485
15517
|
// Adding the czml data source will have changed the clock.
|
|
15486
15518
|
this.viewer.clock.currentTime = curDateTime;
|
|
15487
15519
|
// Listen to update ticks and ensure orientation of moving item is correct.
|
|
15488
15520
|
if (this.viewer.clock) {
|
|
15521
|
+
pHeadingIndex_1 = pHeaders.findIndex(function (x) { return x.toLowerCase().includes("head"); });
|
|
15489
15522
|
errorsInARow_1 = 0;
|
|
15490
15523
|
removal_1 = this.viewer.clock.onTick.addEventListener(function () {
|
|
15491
|
-
var vehicle = source.entities.getById(
|
|
15524
|
+
var vehicle = source.entities.getById(vehicleCesiumId);
|
|
15492
15525
|
if (vehicle) {
|
|
15493
15526
|
try {
|
|
15494
|
-
updateOrientation(_this.viewer, vehicle);
|
|
15527
|
+
updateOrientation(primary.rows, pHeadingIndex_1, pDateTimeIndex, _this.viewer, vehicle);
|
|
15495
15528
|
errorsInARow_1 = 0;
|
|
15496
15529
|
}
|
|
15497
15530
|
catch (e) {
|
|
@@ -15505,6 +15538,48 @@ var DataSourceStaticCsvManager;
|
|
|
15505
15538
|
}
|
|
15506
15539
|
});
|
|
15507
15540
|
this.tickRemovals.push(removal_1);
|
|
15541
|
+
// Register vehicle rego.
|
|
15542
|
+
if (vehicleEntityId) {
|
|
15543
|
+
vehicleEntity = source.entities.getById(vehicleCesiumId);
|
|
15544
|
+
if (vehicleEntity) {
|
|
15545
|
+
this.register.AddRego({
|
|
15546
|
+
rego: {
|
|
15547
|
+
entityId: vehicleEntityId,
|
|
15548
|
+
menuItemId: this.item.id,
|
|
15549
|
+
priority: 0,
|
|
15550
|
+
visual: vehicleEntity,
|
|
15551
|
+
accountId: this.apiGetter.accountId,
|
|
15552
|
+
cdn: false,
|
|
15553
|
+
overrideShow: true
|
|
15554
|
+
},
|
|
15555
|
+
requestRender: false
|
|
15556
|
+
});
|
|
15557
|
+
}
|
|
15558
|
+
}
|
|
15559
|
+
// Register alarms (and any other Entities that were created).
|
|
15560
|
+
console.log("entityMapping", entityMapping);
|
|
15561
|
+
cesiumEntityIds = Object.keys(entityMapping);
|
|
15562
|
+
for (i = 0; i < cesiumEntityIds.length; i++) {
|
|
15563
|
+
cesiumEntityId = cesiumEntityIds[i];
|
|
15564
|
+
entity = source.entities.getById(cesiumEntityId);
|
|
15565
|
+
if (entity) {
|
|
15566
|
+
nextspaceEntityId = entityMapping[cesiumEntityId];
|
|
15567
|
+
if (nextspaceEntityId) {
|
|
15568
|
+
this.register.AddRego({
|
|
15569
|
+
rego: {
|
|
15570
|
+
entityId: nextspaceEntityId,
|
|
15571
|
+
menuItemId: this.item.id,
|
|
15572
|
+
priority: 0,
|
|
15573
|
+
visual: entity,
|
|
15574
|
+
accountId: this.apiGetter.accountId,
|
|
15575
|
+
cdn: false,
|
|
15576
|
+
overrideShow: true
|
|
15577
|
+
},
|
|
15578
|
+
requestRender: false
|
|
15579
|
+
});
|
|
15580
|
+
}
|
|
15581
|
+
}
|
|
15582
|
+
}
|
|
15508
15583
|
}
|
|
15509
15584
|
return [2 /*return*/];
|
|
15510
15585
|
}
|
|
@@ -15528,6 +15603,11 @@ var DataSourceStaticCsvManager;
|
|
|
15528
15603
|
this.tickRemovals.forEach(function (removal) { return removal(); });
|
|
15529
15604
|
this.tickRemovals = [];
|
|
15530
15605
|
}
|
|
15606
|
+
this.register.RemoveRegos({
|
|
15607
|
+
menuItemId: this.item.id,
|
|
15608
|
+
doUpdate: false,
|
|
15609
|
+
requestRender: false
|
|
15610
|
+
});
|
|
15531
15611
|
};
|
|
15532
15612
|
Manager.prototype.ReRender = function (params) {
|
|
15533
15613
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -15559,6 +15639,16 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, d
|
|
|
15559
15639
|
var lonIndex = headers.findIndex(function (x) { return x.toLowerCase().includes("lon"); });
|
|
15560
15640
|
var dateTimeIndex = headers.findIndex(function (x) { return x.toLowerCase().includes("date"); });
|
|
15561
15641
|
var alarmIndex = headers.findIndex(function (x) { return x.toLowerCase().includes("alarm"); });
|
|
15642
|
+
var entityIdIndex = headers.findIndex(function (x, i) {
|
|
15643
|
+
if (i === latIndex || i === lonIndex || i === dateTimeIndex || i === alarmIndex) {
|
|
15644
|
+
return false;
|
|
15645
|
+
}
|
|
15646
|
+
var lower = x.toLowerCase();
|
|
15647
|
+
return lower.includes("entityid") || lower.includes("bruce") || lower.includes("nextspace");
|
|
15648
|
+
});
|
|
15649
|
+
// Map between Cesium Entity ID and Nextspace Entity ID.
|
|
15650
|
+
// This is returned to the caller so they can map between the two.
|
|
15651
|
+
var entityMapping = {};
|
|
15562
15652
|
var czml = [
|
|
15563
15653
|
{
|
|
15564
15654
|
"id": "document",
|
|
@@ -15573,6 +15663,7 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, d
|
|
|
15573
15663
|
}
|
|
15574
15664
|
},
|
|
15575
15665
|
];
|
|
15666
|
+
// Create a polyline for the full path.
|
|
15576
15667
|
// If segmented we'll break it into pieces and display each piece based on relative time to the cesium viewer clock.
|
|
15577
15668
|
{
|
|
15578
15669
|
// Calculate the total duration of the journey in milliseconds.
|
|
@@ -15616,49 +15707,43 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, d
|
|
|
15616
15707
|
});
|
|
15617
15708
|
}
|
|
15618
15709
|
});
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
"
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
|
|
15630
|
-
|
|
15631
|
-
|
|
15632
|
-
|
|
15633
|
-
|
|
15634
|
-
|
|
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]
|
|
15710
|
+
// Alarm points.
|
|
15711
|
+
rows.filter(function (row) { return row[alarmIndex]; }).forEach(function (row, index) {
|
|
15712
|
+
var alarmTime = new Date(row[dateTimeIndex]).getTime();
|
|
15713
|
+
var startTime = new Date(alarmTime - visibilityDuration_1 / 2).toISOString();
|
|
15714
|
+
var endTime = new Date(alarmTime + visibilityDuration_1 / 2).toISOString();
|
|
15715
|
+
var alarmCesiumId = ObjectUtils.UId();
|
|
15716
|
+
czml.push({
|
|
15717
|
+
"id": alarmCesiumId,
|
|
15718
|
+
"name": "Alarm",
|
|
15719
|
+
"availability": startTime + "/" + endTime,
|
|
15720
|
+
"position": {
|
|
15721
|
+
"cartographicDegrees": [
|
|
15722
|
+
Number(row[lonIndex]),
|
|
15723
|
+
Number(row[latIndex]),
|
|
15724
|
+
5
|
|
15725
|
+
]
|
|
15653
15726
|
},
|
|
15654
|
-
"
|
|
15655
|
-
|
|
15656
|
-
"
|
|
15657
|
-
|
|
15727
|
+
"point": !alarmFileUrl ? {
|
|
15728
|
+
"pixelSize": 10,
|
|
15729
|
+
"color": {
|
|
15730
|
+
"rgba": [255, 0, 0, 255]
|
|
15731
|
+
}
|
|
15732
|
+
} : undefined,
|
|
15733
|
+
"billboard": alarmFileUrl ? {
|
|
15734
|
+
"image": alarmFileUrl,
|
|
15735
|
+
"scale": 1,
|
|
15736
|
+
"pixelOffset": {
|
|
15737
|
+
"cartesian2": [0, 0]
|
|
15738
|
+
}
|
|
15739
|
+
} : undefined
|
|
15740
|
+
});
|
|
15741
|
+
var entityId = entityIdIndex > -1 ? row[entityIdIndex] : null;
|
|
15742
|
+
if (entityId) {
|
|
15743
|
+
entityMapping[alarmCesiumId] = String(entityId);
|
|
15658
15744
|
}
|
|
15659
|
-
*/
|
|
15660
15745
|
});
|
|
15661
|
-
}
|
|
15746
|
+
}
|
|
15662
15747
|
// Add animated point for the moving item.
|
|
15663
15748
|
var vehiclePositions = rows.map(function (row) { return [
|
|
15664
15749
|
(new Date(row[dateTimeIndex]).getTime() - new Date(rows[0][dateTimeIndex]).getTime()) / 1000,
|
|
@@ -15688,31 +15773,87 @@ function createJourneyCzml(vehicleId, vehicleFileUrl, alarmFileUrl, lineColor, d
|
|
|
15688
15773
|
"cartographicDegrees": vehiclePositions
|
|
15689
15774
|
}
|
|
15690
15775
|
});
|
|
15691
|
-
return
|
|
15776
|
+
return {
|
|
15777
|
+
czml: czml,
|
|
15778
|
+
entityMapping: entityMapping
|
|
15779
|
+
};
|
|
15692
15780
|
}
|
|
15693
15781
|
/**
|
|
15694
15782
|
* Updates the orientation of the moving item.
|
|
15695
|
-
*
|
|
15783
|
+
* If there is a heading in the file then it will calculate based on the file data,
|
|
15784
|
+
* if there isn't then it will calculate one based on the previous and current position.
|
|
15785
|
+
* @param rows
|
|
15786
|
+
* @param headingIndex
|
|
15787
|
+
* @param dateTimeIndex
|
|
15696
15788
|
* @param viewer
|
|
15697
15789
|
* @param vehicleEntity
|
|
15698
15790
|
* @returns
|
|
15699
15791
|
*/
|
|
15700
|
-
function updateOrientation(viewer, vehicleEntity) {
|
|
15792
|
+
function updateOrientation(rows, headingIndex, dateTimeIndex, viewer, vehicleEntity) {
|
|
15701
15793
|
if (!vehicleEntity || !vehicleEntity.position) {
|
|
15702
15794
|
return;
|
|
15703
15795
|
}
|
|
15704
15796
|
var positionProperty = vehicleEntity.position;
|
|
15705
15797
|
var currentTime = viewer.clock.currentTime;
|
|
15706
|
-
var previousTime = JulianDate.addSeconds(currentTime, -1, new JulianDate());
|
|
15707
15798
|
var currentPosition = positionProperty.getValue(currentTime);
|
|
15799
|
+
if (!currentPosition) {
|
|
15800
|
+
return;
|
|
15801
|
+
}
|
|
15802
|
+
if (headingIndex > -1) {
|
|
15803
|
+
try {
|
|
15804
|
+
var interpolatedHeading = interpolateHeading(dateTimeIndex, rows, currentTime, headingIndex);
|
|
15805
|
+
if (interpolatedHeading !== null) {
|
|
15806
|
+
var radians = Math$1.toRadians(interpolatedHeading - 90);
|
|
15807
|
+
var quaternion = Transforms.headingPitchRollQuaternion(currentPosition, new HeadingPitchRoll(radians, 0, 0));
|
|
15808
|
+
if (!isNaN(quaternion.w) && !isNaN(quaternion.x) && !isNaN(quaternion.y) && !isNaN(quaternion.z)) {
|
|
15809
|
+
vehicleEntity.orientation = quaternion;
|
|
15810
|
+
return;
|
|
15811
|
+
}
|
|
15812
|
+
else {
|
|
15813
|
+
console.error("Invalid quaternion", quaternion);
|
|
15814
|
+
}
|
|
15815
|
+
}
|
|
15816
|
+
}
|
|
15817
|
+
catch (e) {
|
|
15818
|
+
console.error(e);
|
|
15819
|
+
}
|
|
15820
|
+
}
|
|
15821
|
+
var previousTime = JulianDate.addSeconds(currentTime, -1, new JulianDate());
|
|
15708
15822
|
var previousPosition = positionProperty.getValue(previousTime);
|
|
15709
|
-
if (
|
|
15823
|
+
if (previousPosition && !Cartesian3.equals(currentPosition, previousPosition)) {
|
|
15710
15824
|
var direction = Cartesian3.subtract(currentPosition, previousPosition, new Cartesian3());
|
|
15711
15825
|
Cartesian3.normalize(direction, direction);
|
|
15712
15826
|
var rotationMatrix = Transforms.rotationMatrixFromPositionVelocity(previousPosition, direction);
|
|
15713
15827
|
vehicleEntity.orientation = Quaternion.fromRotationMatrix(rotationMatrix);
|
|
15714
15828
|
}
|
|
15715
15829
|
}
|
|
15830
|
+
function interpolateHeading(dateTimeIndex, rows, currentTime, headingIndex) {
|
|
15831
|
+
var currentTimeMs = JulianDate.toDate(currentTime).getTime();
|
|
15832
|
+
var nearestBefore = null;
|
|
15833
|
+
var nearestAfter = null;
|
|
15834
|
+
for (var _i = 0, rows_1 = rows; _i < rows_1.length; _i++) {
|
|
15835
|
+
var row = rows_1[_i];
|
|
15836
|
+
var time = new Date(row[dateTimeIndex]).getTime();
|
|
15837
|
+
var heading = parseFloat(String(row[headingIndex]));
|
|
15838
|
+
if (!isNaN(heading)) {
|
|
15839
|
+
if (time <= currentTimeMs) {
|
|
15840
|
+
nearestBefore = { time: time, heading: heading };
|
|
15841
|
+
}
|
|
15842
|
+
else if (time > currentTimeMs && nearestAfter === null) {
|
|
15843
|
+
nearestAfter = { time: time, heading: heading };
|
|
15844
|
+
break;
|
|
15845
|
+
}
|
|
15846
|
+
}
|
|
15847
|
+
}
|
|
15848
|
+
if (nearestBefore && nearestAfter) {
|
|
15849
|
+
var factor = (currentTimeMs - nearestBefore.time) / (nearestAfter.time - nearestBefore.time);
|
|
15850
|
+
return nearestBefore.heading + factor * (nearestAfter.heading - nearestBefore.heading);
|
|
15851
|
+
}
|
|
15852
|
+
else if (nearestBefore) {
|
|
15853
|
+
return nearestBefore.heading;
|
|
15854
|
+
}
|
|
15855
|
+
return null;
|
|
15856
|
+
}
|
|
15716
15857
|
|
|
15717
15858
|
var TilesetI3sRenderManager;
|
|
15718
15859
|
(function (TilesetI3sRenderManager) {
|
|
@@ -16056,7 +16197,8 @@ var MenuItemManager;
|
|
|
16056
16197
|
rItem.renderManager = new DataSourceStaticCsvManager.Manager({
|
|
16057
16198
|
viewer: this.viewer,
|
|
16058
16199
|
apiGetter: params.apiGetter,
|
|
16059
|
-
item: params.item
|
|
16200
|
+
item: params.item,
|
|
16201
|
+
register: this.visualsRegister
|
|
16060
16202
|
});
|
|
16061
16203
|
break;
|
|
16062
16204
|
case MenuItem.EType.IonTileset:
|
|
@@ -22272,7 +22414,7 @@ var ViewRenderEngine;
|
|
|
22272
22414
|
ViewRenderEngine.Render = Render;
|
|
22273
22415
|
})(ViewRenderEngine || (ViewRenderEngine = {}));
|
|
22274
22416
|
|
|
22275
|
-
var VERSION = "3.6.
|
|
22417
|
+
var VERSION = "3.6.7";
|
|
22276
22418
|
|
|
22277
22419
|
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
22420
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|