@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.
@@ -2892,11 +2892,11 @@ var AirplaneCursor = class {
2892
2892
  setPos(addVec(pose.position, C.Cartesian3.multiplyByScalar(e3, step, new C.Cartesian3())));
2893
2893
  moved = true;
2894
2894
  }
2895
- if (this.keysPressed.has("z")) {
2895
+ if (this.keysPressed.has("c")) {
2896
2896
  setPos(addVec(pose.position, C.Cartesian3.multiplyByScalar(u3, step, new C.Cartesian3())));
2897
2897
  moved = true;
2898
2898
  }
2899
- if (this.keysPressed.has("c")) {
2899
+ if (this.keysPressed.has("z")) {
2900
2900
  setPos(addVec(pose.position, C.Cartesian3.multiplyByScalar(u3, -step, new C.Cartesian3())));
2901
2901
  moved = true;
2902
2902
  }
@@ -4927,6 +4927,10 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
4927
4927
  } catch {
4928
4928
  }
4929
4929
  };
4930
+ const getTotalDistance = () => {
4931
+ if (positions.length < 2) return 0;
4932
+ return calculatePathDistance(CesiumNS, positions, positions.length - 1, hiddenClimbIndex);
4933
+ };
4930
4934
  const vertexInsertionHandler = new VertexInsertionHandler({
4931
4935
  CesiumNS,
4932
4936
  layer,
@@ -4937,6 +4941,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
4937
4941
  if (!cursorStart) cursorStart = positions[hiddenClimbIndex === 1 ? 1 : 0];
4938
4942
  let airplaneCursor;
4939
4943
  const insertVertex = (insertAt, p3, poseOrient) => {
4944
+ console.log("[PathEditing] \u63D2\u5165\u9876\u70B9\u524D positions \u957F\u5EA6:", positions.length, "insertAt:", insertAt);
4940
4945
  const actualIndex = vertexInsertionHandler.insertVertex(
4941
4946
  insertAt,
4942
4947
  p3,
@@ -4952,6 +4957,8 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
4952
4957
  airplaneCursor,
4953
4958
  poseOrient
4954
4959
  );
4960
+ console.log("[PathEditing] \u63D2\u5165\u9876\u70B9\u540E positions \u957F\u5EA6:", positions.length, "actualIndex:", actualIndex);
4961
+ entity.polyline.positions = new C.CallbackProperty(() => positions.slice(), false);
4955
4962
  setActiveIndex(actualIndex);
4956
4963
  createOrUpdateMarkerForIndex(actualIndex);
4957
4964
  };
@@ -4982,6 +4989,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
4982
4989
  } catch {
4983
4990
  }
4984
4991
  }
4992
+ console.log("[PathEditing] \u5220\u9664\u9876\u70B9\u524D positions \u957F\u5EA6:", positions.length, "deleteAt:", deleteAt);
4985
4993
  positions.splice(deleteAt, 1);
4986
4994
  handles.splice(deleteAt, 1);
4987
4995
  headings.splice(deleteAt, 1);
@@ -4989,6 +4997,8 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
4989
4997
  rolls.splice(deleteAt, 1);
4990
4998
  fovs.splice(deleteAt, 1);
4991
4999
  heightMarkers.splice(deleteAt, 1);
5000
+ console.log("[PathEditing] \u5220\u9664\u9876\u70B9\u540E positions \u957F\u5EA6:", positions.length);
5001
+ entity.polyline.positions = new C.CallbackProperty(() => positions.slice(), false);
4992
5002
  const newEditedIndices = /* @__PURE__ */ new Set();
4993
5003
  editedIndices.forEach((idx) => {
4994
5004
  if (idx < deleteAt) {
@@ -5111,7 +5121,9 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5111
5121
  totalVerticesBefore: totalBefore,
5112
5122
  totalVerticesAfter: totalAfter,
5113
5123
  newVertex,
5114
- timestamp: /* @__PURE__ */ new Date()
5124
+ timestamp: /* @__PURE__ */ new Date(),
5125
+ totalDistance: getTotalDistance()
5126
+ // 🆕 航线总里程
5115
5127
  };
5116
5128
  options.onVertexInsertDetail(operationInfo);
5117
5129
  } catch (error) {
@@ -5132,7 +5144,9 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5132
5144
  displayNumber,
5133
5145
  totalVerticesBefore: totalBefore,
5134
5146
  totalVerticesAfter: totalAfter,
5135
- timestamp: /* @__PURE__ */ new Date()
5147
+ timestamp: /* @__PURE__ */ new Date(),
5148
+ totalDistance: getTotalDistance()
5149
+ // 🆕 航线总里程
5136
5150
  };
5137
5151
  options.onVertexDeleteDetail(operationInfo);
5138
5152
  } catch (error) {
@@ -5212,7 +5226,9 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5212
5226
  totalVerticesAfter: positions.length,
5213
5227
  newVertex: vertexInfo,
5214
5228
  newPosition: finalPosition,
5215
- timestamp: /* @__PURE__ */ new Date()
5229
+ timestamp: /* @__PURE__ */ new Date(),
5230
+ totalDistance: getTotalDistance()
5231
+ // 🆕 航线总里程
5216
5232
  };
5217
5233
  options.onVertexDragCompleteDetail(operationInfo);
5218
5234
  } catch (error) {
@@ -5241,6 +5257,18 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5241
5257
  );
5242
5258
  const cleanupSession = () => {
5243
5259
  setActiveIndex(void 0);
5260
+ try {
5261
+ handles.forEach((handle) => {
5262
+ if (handle) {
5263
+ try {
5264
+ layer.entities.remove(handle);
5265
+ } catch {
5266
+ }
5267
+ }
5268
+ });
5269
+ handles.length = 0;
5270
+ } catch {
5271
+ }
5244
5272
  try {
5245
5273
  heightMarkers.forEach((m) => m?.destroy());
5246
5274
  } catch {
@@ -5565,7 +5593,55 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5565
5593
  /**
5566
5594
  * 🆕 获取游标当前姿态(包含高度)
5567
5595
  */
5568
- getCursorPose: () => airplaneCursor?.getPose()
5596
+ getCursorPose: () => airplaneCursor?.getPose(),
5597
+ /**
5598
+ * 🆕 动态更新爬升高度(climbHeight)
5599
+ * 更新隐藏爬升点(index 1)的高度,实现安全飞行高度的动态调节
5600
+ * @param climbHeight 新的爬升高度(米)
5601
+ * @returns 是否更新成功
5602
+ */
5603
+ updateClimbHeight: function(climbHeight) {
5604
+ if (hiddenClimbIndex !== 1 || positions.length < 2) {
5605
+ console.warn("[updateClimbHeight] No hidden climb point exists");
5606
+ return false;
5607
+ }
5608
+ try {
5609
+ const startPos = positions[0];
5610
+ const startCarto = C.Cartographic.fromCartesian(startPos);
5611
+ const newAltitude = startCarto.height + climbHeight;
5612
+ const success = this.updateWaypointAltitude(1, newAltitude);
5613
+ if (success) {
5614
+ try {
5615
+ entity.properties._climbHeight = climbHeight;
5616
+ } catch {
5617
+ }
5618
+ console.log("[updateClimbHeight] \u2705 \u722C\u5347\u9AD8\u5EA6\u5DF2\u66F4\u65B0:", climbHeight, "\u7C73");
5619
+ }
5620
+ return success;
5621
+ } catch (error) {
5622
+ console.error("[updateClimbHeight] Error:", error);
5623
+ return false;
5624
+ }
5625
+ },
5626
+ /**
5627
+ * 🆕 获取起飞点信息
5628
+ * @returns 起飞点的经纬度和高度
5629
+ */
5630
+ getStartPoint: () => {
5631
+ if (positions.length < 1) return null;
5632
+ try {
5633
+ const startPos = positions[0];
5634
+ const carto = C.Cartographic.fromCartesian(startPos);
5635
+ return {
5636
+ position: startPos,
5637
+ latitude: C.Math.toDegrees(carto.latitude),
5638
+ longitude: C.Math.toDegrees(carto.longitude),
5639
+ altitude: carto.height
5640
+ };
5641
+ } catch {
5642
+ return null;
5643
+ }
5644
+ }
5569
5645
  };
5570
5646
  }
5571
5647
  function fovToFocalLength(fovDeg) {
@@ -5741,6 +5817,7 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
5741
5817
  const DEFAULT_MAIN_WIDTH = options?.width ?? 6;
5742
5818
  let startCartographic;
5743
5819
  let hasStart = false;
5820
+ let createdEntity = void 0;
5744
5821
  const getPositionFromMouse = (movement) => {
5745
5822
  const scene = viewer.scene;
5746
5823
  const winPos = movement?.position ?? movement?.endPosition ?? movement;
@@ -5841,6 +5918,7 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
5841
5918
  _hasHiddenClimb: climbHeight > 0
5842
5919
  }
5843
5920
  });
5921
+ createdEntity = created;
5844
5922
  try {
5845
5923
  tempHandles.forEach((hh, idx) => {
5846
5924
  try {
@@ -5877,8 +5955,21 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
5877
5955
  } else {
5878
5956
  editOptions.preview = { enabled: true };
5879
5957
  }
5880
- if (options?.onVertexSelectDetail) {
5881
- editOptions.onVertexSelectDetail = options.onVertexSelectDetail;
5958
+ const autoOpts = typeof auto === "object" ? auto : {};
5959
+ if (autoOpts.onVertexSelectDetail) {
5960
+ editOptions.onVertexSelectDetail = autoOpts.onVertexSelectDetail;
5961
+ }
5962
+ if (autoOpts.onVertexDragMoveDetail) {
5963
+ editOptions.onVertexDragMoveDetail = autoOpts.onVertexDragMoveDetail;
5964
+ }
5965
+ if (autoOpts.onVertexDragCompleteDetail) {
5966
+ editOptions.onVertexDragCompleteDetail = autoOpts.onVertexDragCompleteDetail;
5967
+ }
5968
+ if (autoOpts.onVertexInsertDetail) {
5969
+ editOptions.onVertexInsertDetail = autoOpts.onVertexInsertDetail;
5970
+ }
5971
+ if (autoOpts.onVertexDeleteDetail) {
5972
+ editOptions.onVertexDeleteDetail = autoOpts.onVertexDeleteDetail;
5882
5973
  }
5883
5974
  const editSession = startPathEditing(CesiumNS, viewer, created, editOptions);
5884
5975
  if (editSession && options?.onEditingStarted) {
@@ -5904,6 +5995,12 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
5904
5995
  handler?.destroy();
5905
5996
  } catch {
5906
5997
  }
5998
+ if (createdEntity) {
5999
+ try {
6000
+ layer.entities.remove(createdEntity);
6001
+ } catch {
6002
+ }
6003
+ }
5907
6004
  }
5908
6005
  };
5909
6006
  }