@jorgmoritz/gis-manager 0.1.44 → 0.1.45

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/index.cjs CHANGED
@@ -13,7 +13,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
13
13
  // package.json
14
14
  var package_default = {
15
15
  name: "@jorgmoritz/gis-manager",
16
- version: "0.1.43"};
16
+ version: "0.1.44"};
17
17
 
18
18
  // src/utils/version.ts
19
19
  var version = package_default.version;
@@ -3557,6 +3557,8 @@ var AirplaneCursor = class {
3557
3557
  __publicField(this, "cameraChangedListener");
3558
3558
  /** 飞机游标模型可见性,默认 false */
3559
3559
  __publicField(this, "visible", false);
3560
+ /** 是否显示视锥体,默认 true */
3561
+ __publicField(this, "showFrustum", true);
3560
3562
  const C = this.CesiumNS;
3561
3563
  this.opts = opts;
3562
3564
  this.pose = { position: startPosition, heading: 0, pitch: -10, roll: 0 };
@@ -3565,6 +3567,7 @@ var AirplaneCursor = class {
3565
3567
  this.fastFactor = opts.fastFactor ?? 5;
3566
3568
  this.currentFOV = opts.fovDeg ?? DEFAULT_FOV;
3567
3569
  this.visible = opts.visible ?? false;
3570
+ this.showFrustum = opts.showFrustum ?? true;
3568
3571
  this.ensureEntity(opts.color ?? C.Color.CYAN.withAlpha(0.9));
3569
3572
  this.attachKeyboard(opts);
3570
3573
  this.setupFOVListener();
@@ -3798,6 +3801,7 @@ var AirplaneCursor = class {
3798
3801
  * - 后续只依赖回调读取 pose 与 currentFOV 即可自动更新
3799
3802
  */
3800
3803
  updateFrustum() {
3804
+ if (!this.showFrustum) return;
3801
3805
  try {
3802
3806
  if (!this.frustum) {
3803
3807
  let layer = this.viewer.dataSources?._dataSources?.[0];
@@ -12226,6 +12230,171 @@ var PointCloudPicker = class {
12226
12230
  }
12227
12231
  };
12228
12232
 
12233
+ // src/core/path-manager/RealtimeFlightTracker.ts
12234
+ var RealtimeFlightTracker = class {
12235
+ constructor(CesiumNS, viewer, options) {
12236
+ __publicField(this, "CesiumNS");
12237
+ __publicField(this, "viewer");
12238
+ __publicField(this, "options");
12239
+ __publicField(this, "airplaneCursor");
12240
+ __publicField(this, "trackEntity");
12241
+ __publicField(this, "trackPositions", []);
12242
+ __publicField(this, "isInitialized", false);
12243
+ this.CesiumNS = CesiumNS;
12244
+ this.viewer = viewer;
12245
+ const C = CesiumNS;
12246
+ this.options = {
12247
+ showTrack: options?.showTrack ?? true,
12248
+ fovDeg: options?.fovDeg ?? 50,
12249
+ layer: options?.layer,
12250
+ trackStyle: {
12251
+ color: options?.trackStyle?.color ?? C.Color.CYAN,
12252
+ width: options?.trackStyle?.width ?? 3,
12253
+ clampToGround: options?.trackStyle?.clampToGround ?? false,
12254
+ maxPoints: options?.trackStyle?.maxPoints ?? 1e3
12255
+ }
12256
+ };
12257
+ }
12258
+ /**
12259
+ * 更新飞机位置(接收新航点)
12260
+ * @param waypoint 实时航点数据
12261
+ */
12262
+ updatePosition(waypoint) {
12263
+ const C = this.CesiumNS;
12264
+ const position = C.Cartesian3.fromDegrees(
12265
+ waypoint.longitude,
12266
+ waypoint.latitude,
12267
+ waypoint.altitude
12268
+ );
12269
+ if (!this.isInitialized) {
12270
+ this.initialize(position);
12271
+ this.isInitialized = true;
12272
+ }
12273
+ if (this.airplaneCursor) {
12274
+ this.airplaneCursor.setPose(
12275
+ position,
12276
+ waypoint.heading ?? 0,
12277
+ waypoint.pitch ?? 0,
12278
+ waypoint.roll ?? 0
12279
+ );
12280
+ }
12281
+ if (this.options.showTrack) {
12282
+ this.addTrackPoint(position);
12283
+ }
12284
+ this.viewer.scene.requestRender();
12285
+ }
12286
+ /**
12287
+ * 初始化飞机和轨迹实体
12288
+ */
12289
+ initialize(initialPosition) {
12290
+ this.airplaneCursor = new AirplaneCursor(
12291
+ this.CesiumNS,
12292
+ this.viewer,
12293
+ initialPosition,
12294
+ {
12295
+ stepMeters: 0,
12296
+ // 禁用键盘控制
12297
+ angleStepDeg: 0,
12298
+ fovDeg: this.options.fovDeg,
12299
+ visible: true,
12300
+ showFrustum: false
12301
+ // 实时飞行追踪不显示视锥体
12302
+ }
12303
+ );
12304
+ if (this.options.showTrack) {
12305
+ this.createTrackEntity();
12306
+ }
12307
+ }
12308
+ /**
12309
+ * 创建轨迹实体
12310
+ */
12311
+ createTrackEntity() {
12312
+ const C = this.CesiumNS;
12313
+ const entities = this.options.layer?.entities ?? this.viewer.entities;
12314
+ const style = this.options.trackStyle;
12315
+ this.trackEntity = entities.add({
12316
+ id: `realtime-flight-track-${Date.now()}`,
12317
+ polyline: {
12318
+ // 使用 CallbackProperty 实现动态更新
12319
+ positions: new C.CallbackProperty(() => {
12320
+ return this.trackPositions.slice();
12321
+ }, false),
12322
+ width: style.width,
12323
+ material: style.color,
12324
+ clampToGround: style.clampToGround
12325
+ },
12326
+ properties: {
12327
+ _type: "realtime-flight-track"
12328
+ }
12329
+ });
12330
+ }
12331
+ /**
12332
+ * 添加轨迹点
12333
+ */
12334
+ addTrackPoint(position) {
12335
+ this.trackPositions.push(position);
12336
+ const maxPoints = this.options.trackStyle.maxPoints;
12337
+ if (this.trackPositions.length > maxPoints) {
12338
+ this.trackPositions = this.trackPositions.slice(-maxPoints);
12339
+ }
12340
+ }
12341
+ /**
12342
+ * 清除轨迹
12343
+ */
12344
+ clearTrack() {
12345
+ this.trackPositions = [];
12346
+ this.viewer.scene.requestRender();
12347
+ }
12348
+ /**
12349
+ * 获取当前轨迹点数
12350
+ */
12351
+ getTrackPointCount() {
12352
+ return this.trackPositions.length;
12353
+ }
12354
+ /**
12355
+ * 设置轨迹可见性
12356
+ */
12357
+ setTrackVisible(visible) {
12358
+ if (this.trackEntity) {
12359
+ this.trackEntity.show = visible;
12360
+ this.viewer.scene.requestRender();
12361
+ }
12362
+ }
12363
+ /**
12364
+ * 飞到当前飞机位置
12365
+ */
12366
+ flyToAirplane(options) {
12367
+ if (this.trackPositions.length === 0) return;
12368
+ const C = this.CesiumNS;
12369
+ const lastPosition = this.trackPositions[this.trackPositions.length - 1];
12370
+ const carto = C.Cartographic.fromCartesian(lastPosition);
12371
+ this.viewer.camera.flyTo({
12372
+ destination: C.Cartesian3.fromRadians(
12373
+ carto.longitude,
12374
+ carto.latitude,
12375
+ (options?.height ?? 500) + carto.height
12376
+ ),
12377
+ duration: options?.duration ?? 1.5
12378
+ });
12379
+ }
12380
+ /**
12381
+ * 销毁并清理资源
12382
+ */
12383
+ destroy() {
12384
+ const entities = this.options.layer?.entities ?? this.viewer.entities;
12385
+ if (this.airplaneCursor) {
12386
+ this.airplaneCursor.destroy();
12387
+ this.airplaneCursor = void 0;
12388
+ }
12389
+ if (this.trackEntity) {
12390
+ entities.remove(this.trackEntity);
12391
+ this.trackEntity = void 0;
12392
+ }
12393
+ this.trackPositions = [];
12394
+ this.isInitialized = false;
12395
+ }
12396
+ };
12397
+
12229
12398
  // src/utils/pathToSinoflyAdapter.ts
12230
12399
  function convertCartesian3ToLatLonHeight(CesiumNS, position) {
12231
12400
  const C = CesiumNS;
@@ -12805,6 +12974,7 @@ exports.LayerManager = LayerManager;
12805
12974
  exports.PathSafetyChecker = PathSafetyChecker;
12806
12975
  exports.PointCloudPicker = PointCloudPicker;
12807
12976
  exports.PolygonEditor = PolygonEditor;
12977
+ exports.RealtimeFlightTracker = RealtimeFlightTracker;
12808
12978
  exports.SceneManager = SceneManager;
12809
12979
  exports.Selector = Selector;
12810
12980
  exports.StateManager = StateManager;