@jorgmoritz/gis-manager 0.1.26 → 0.1.27

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.
@@ -74,6 +74,8 @@ interface VertexOperationInfo {
74
74
  newPosition?: Cesium.Cartesian3;
75
75
  /** 时间戳 */
76
76
  timestamp: Date;
77
+ /** 🆕 航线总里程(米) */
78
+ totalDistance?: number;
77
79
  }
78
80
  /**
79
81
  * 🆕 顶点拖动中信息(实时)
@@ -74,6 +74,8 @@ interface VertexOperationInfo {
74
74
  newPosition?: Cesium.Cartesian3;
75
75
  /** 时间戳 */
76
76
  timestamp: Date;
77
+ /** 🆕 航线总里程(米) */
78
+ totalDistance?: number;
77
79
  }
78
80
  /**
79
81
  * 🆕 顶点拖动中信息(实时)
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.25"};
16
+ version: "0.1.26"};
17
17
 
18
18
  // src/utils/version.ts
19
19
  var version = package_default.version;
@@ -2936,11 +2936,11 @@ var AirplaneCursor = class {
2936
2936
  setPos(addVec(pose.position, C.Cartesian3.multiplyByScalar(e3, step, new C.Cartesian3())));
2937
2937
  moved = true;
2938
2938
  }
2939
- if (this.keysPressed.has("z")) {
2939
+ if (this.keysPressed.has("c")) {
2940
2940
  setPos(addVec(pose.position, C.Cartesian3.multiplyByScalar(u3, step, new C.Cartesian3())));
2941
2941
  moved = true;
2942
2942
  }
2943
- if (this.keysPressed.has("c")) {
2943
+ if (this.keysPressed.has("z")) {
2944
2944
  setPos(addVec(pose.position, C.Cartesian3.multiplyByScalar(u3, -step, new C.Cartesian3())));
2945
2945
  moved = true;
2946
2946
  }
@@ -4971,6 +4971,10 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
4971
4971
  } catch {
4972
4972
  }
4973
4973
  };
4974
+ const getTotalDistance = () => {
4975
+ if (positions.length < 2) return 0;
4976
+ return calculatePathDistance(CesiumNS, positions, positions.length - 1, hiddenClimbIndex);
4977
+ };
4974
4978
  const vertexInsertionHandler = new VertexInsertionHandler({
4975
4979
  CesiumNS,
4976
4980
  layer,
@@ -4981,6 +4985,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
4981
4985
  if (!cursorStart) cursorStart = positions[hiddenClimbIndex === 1 ? 1 : 0];
4982
4986
  let airplaneCursor;
4983
4987
  const insertVertex = (insertAt, p3, poseOrient) => {
4988
+ console.log("[PathEditing] \u63D2\u5165\u9876\u70B9\u524D positions \u957F\u5EA6:", positions.length, "insertAt:", insertAt);
4984
4989
  const actualIndex = vertexInsertionHandler.insertVertex(
4985
4990
  insertAt,
4986
4991
  p3,
@@ -4996,6 +5001,8 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
4996
5001
  airplaneCursor,
4997
5002
  poseOrient
4998
5003
  );
5004
+ console.log("[PathEditing] \u63D2\u5165\u9876\u70B9\u540E positions \u957F\u5EA6:", positions.length, "actualIndex:", actualIndex);
5005
+ entity.polyline.positions = new C.CallbackProperty(() => positions.slice(), false);
4999
5006
  setActiveIndex(actualIndex);
5000
5007
  createOrUpdateMarkerForIndex(actualIndex);
5001
5008
  };
@@ -5026,6 +5033,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5026
5033
  } catch {
5027
5034
  }
5028
5035
  }
5036
+ console.log("[PathEditing] \u5220\u9664\u9876\u70B9\u524D positions \u957F\u5EA6:", positions.length, "deleteAt:", deleteAt);
5029
5037
  positions.splice(deleteAt, 1);
5030
5038
  handles.splice(deleteAt, 1);
5031
5039
  headings.splice(deleteAt, 1);
@@ -5033,6 +5041,8 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5033
5041
  rolls.splice(deleteAt, 1);
5034
5042
  fovs.splice(deleteAt, 1);
5035
5043
  heightMarkers.splice(deleteAt, 1);
5044
+ console.log("[PathEditing] \u5220\u9664\u9876\u70B9\u540E positions \u957F\u5EA6:", positions.length);
5045
+ entity.polyline.positions = new C.CallbackProperty(() => positions.slice(), false);
5036
5046
  const newEditedIndices = /* @__PURE__ */ new Set();
5037
5047
  editedIndices.forEach((idx) => {
5038
5048
  if (idx < deleteAt) {
@@ -5155,7 +5165,9 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5155
5165
  totalVerticesBefore: totalBefore,
5156
5166
  totalVerticesAfter: totalAfter,
5157
5167
  newVertex,
5158
- timestamp: /* @__PURE__ */ new Date()
5168
+ timestamp: /* @__PURE__ */ new Date(),
5169
+ totalDistance: getTotalDistance()
5170
+ // 🆕 航线总里程
5159
5171
  };
5160
5172
  options.onVertexInsertDetail(operationInfo);
5161
5173
  } catch (error) {
@@ -5176,7 +5188,9 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5176
5188
  displayNumber,
5177
5189
  totalVerticesBefore: totalBefore,
5178
5190
  totalVerticesAfter: totalAfter,
5179
- timestamp: /* @__PURE__ */ new Date()
5191
+ timestamp: /* @__PURE__ */ new Date(),
5192
+ totalDistance: getTotalDistance()
5193
+ // 🆕 航线总里程
5180
5194
  };
5181
5195
  options.onVertexDeleteDetail(operationInfo);
5182
5196
  } catch (error) {
@@ -5256,7 +5270,9 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5256
5270
  totalVerticesAfter: positions.length,
5257
5271
  newVertex: vertexInfo,
5258
5272
  newPosition: finalPosition,
5259
- timestamp: /* @__PURE__ */ new Date()
5273
+ timestamp: /* @__PURE__ */ new Date(),
5274
+ totalDistance: getTotalDistance()
5275
+ // 🆕 航线总里程
5260
5276
  };
5261
5277
  options.onVertexDragCompleteDetail(operationInfo);
5262
5278
  } catch (error) {
@@ -5285,6 +5301,18 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5285
5301
  );
5286
5302
  const cleanupSession = () => {
5287
5303
  setActiveIndex(void 0);
5304
+ try {
5305
+ handles.forEach((handle) => {
5306
+ if (handle) {
5307
+ try {
5308
+ layer.entities.remove(handle);
5309
+ } catch {
5310
+ }
5311
+ }
5312
+ });
5313
+ handles.length = 0;
5314
+ } catch {
5315
+ }
5288
5316
  try {
5289
5317
  heightMarkers.forEach((m) => m?.destroy());
5290
5318
  } catch {
@@ -5609,7 +5637,55 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5609
5637
  /**
5610
5638
  * 🆕 获取游标当前姿态(包含高度)
5611
5639
  */
5612
- getCursorPose: () => airplaneCursor?.getPose()
5640
+ getCursorPose: () => airplaneCursor?.getPose(),
5641
+ /**
5642
+ * 🆕 动态更新爬升高度(climbHeight)
5643
+ * 更新隐藏爬升点(index 1)的高度,实现安全飞行高度的动态调节
5644
+ * @param climbHeight 新的爬升高度(米)
5645
+ * @returns 是否更新成功
5646
+ */
5647
+ updateClimbHeight: function(climbHeight) {
5648
+ if (hiddenClimbIndex !== 1 || positions.length < 2) {
5649
+ console.warn("[updateClimbHeight] No hidden climb point exists");
5650
+ return false;
5651
+ }
5652
+ try {
5653
+ const startPos = positions[0];
5654
+ const startCarto = C.Cartographic.fromCartesian(startPos);
5655
+ const newAltitude = startCarto.height + climbHeight;
5656
+ const success = this.updateWaypointAltitude(1, newAltitude);
5657
+ if (success) {
5658
+ try {
5659
+ entity.properties._climbHeight = climbHeight;
5660
+ } catch {
5661
+ }
5662
+ console.log("[updateClimbHeight] \u2705 \u722C\u5347\u9AD8\u5EA6\u5DF2\u66F4\u65B0:", climbHeight, "\u7C73");
5663
+ }
5664
+ return success;
5665
+ } catch (error) {
5666
+ console.error("[updateClimbHeight] Error:", error);
5667
+ return false;
5668
+ }
5669
+ },
5670
+ /**
5671
+ * 🆕 获取起飞点信息
5672
+ * @returns 起飞点的经纬度和高度
5673
+ */
5674
+ getStartPoint: () => {
5675
+ if (positions.length < 1) return null;
5676
+ try {
5677
+ const startPos = positions[0];
5678
+ const carto = C.Cartographic.fromCartesian(startPos);
5679
+ return {
5680
+ position: startPos,
5681
+ latitude: C.Math.toDegrees(carto.latitude),
5682
+ longitude: C.Math.toDegrees(carto.longitude),
5683
+ altitude: carto.height
5684
+ };
5685
+ } catch {
5686
+ return null;
5687
+ }
5688
+ }
5613
5689
  };
5614
5690
  }
5615
5691
  function fovToFocalLength(fovDeg) {
@@ -5785,6 +5861,7 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
5785
5861
  const DEFAULT_MAIN_WIDTH = options?.width ?? 6;
5786
5862
  let startCartographic;
5787
5863
  let hasStart = false;
5864
+ let createdEntity = void 0;
5788
5865
  const getPositionFromMouse = (movement) => {
5789
5866
  const scene = viewer.scene;
5790
5867
  const winPos = movement?.position ?? movement?.endPosition ?? movement;
@@ -5885,6 +5962,7 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
5885
5962
  _hasHiddenClimb: climbHeight > 0
5886
5963
  }
5887
5964
  });
5965
+ createdEntity = created;
5888
5966
  try {
5889
5967
  tempHandles.forEach((hh, idx) => {
5890
5968
  try {
@@ -5921,8 +5999,21 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
5921
5999
  } else {
5922
6000
  editOptions.preview = { enabled: true };
5923
6001
  }
5924
- if (options?.onVertexSelectDetail) {
5925
- editOptions.onVertexSelectDetail = options.onVertexSelectDetail;
6002
+ const autoOpts = typeof auto === "object" ? auto : {};
6003
+ if (autoOpts.onVertexSelectDetail) {
6004
+ editOptions.onVertexSelectDetail = autoOpts.onVertexSelectDetail;
6005
+ }
6006
+ if (autoOpts.onVertexDragMoveDetail) {
6007
+ editOptions.onVertexDragMoveDetail = autoOpts.onVertexDragMoveDetail;
6008
+ }
6009
+ if (autoOpts.onVertexDragCompleteDetail) {
6010
+ editOptions.onVertexDragCompleteDetail = autoOpts.onVertexDragCompleteDetail;
6011
+ }
6012
+ if (autoOpts.onVertexInsertDetail) {
6013
+ editOptions.onVertexInsertDetail = autoOpts.onVertexInsertDetail;
6014
+ }
6015
+ if (autoOpts.onVertexDeleteDetail) {
6016
+ editOptions.onVertexDeleteDetail = autoOpts.onVertexDeleteDetail;
5926
6017
  }
5927
6018
  const editSession = startPathEditing(CesiumNS, viewer, created, editOptions);
5928
6019
  if (editSession && options?.onEditingStarted) {
@@ -5948,6 +6039,12 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
5948
6039
  handler?.destroy();
5949
6040
  } catch {
5950
6041
  }
6042
+ if (createdEntity) {
6043
+ try {
6044
+ layer.entities.remove(createdEntity);
6045
+ } catch {
6046
+ }
6047
+ }
5951
6048
  }
5952
6049
  };
5953
6050
  }