@jorgmoritz/gis-manager 0.1.42 → 0.1.44
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 +354 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +351 -59
- package/dist/index.js.map +1 -1
- package/dist/vue/index.cjs +337 -55
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +337 -55
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/vue/index.js
CHANGED
|
@@ -1909,14 +1909,15 @@ var HeightMarker = class {
|
|
|
1909
1909
|
polyline: {
|
|
1910
1910
|
positions: [C.Cartesian3.ZERO, C.Cartesian3.ZERO],
|
|
1911
1911
|
width: this.opts.width ?? 2,
|
|
1912
|
-
material:
|
|
1912
|
+
material: C.Color.YELLOW.withAlpha(0.4),
|
|
1913
|
+
// 黄色半透明垂直线
|
|
1913
1914
|
clampToGround: false
|
|
1914
1915
|
// vertical line in 3D space
|
|
1915
1916
|
},
|
|
1916
1917
|
ellipse: {
|
|
1917
|
-
semiMajorAxis: this.opts.circleRadius ??
|
|
1918
|
-
semiMinorAxis: this.opts.circleRadius ??
|
|
1919
|
-
material: color.withAlpha ? color.withAlpha(0.
|
|
1918
|
+
semiMajorAxis: this.opts.circleRadius ?? 3,
|
|
1919
|
+
semiMinorAxis: this.opts.circleRadius ?? 3,
|
|
1920
|
+
material: color.withAlpha ? color.withAlpha(0.45) : color,
|
|
1920
1921
|
outline: true,
|
|
1921
1922
|
outlineColor: color,
|
|
1922
1923
|
heightReference: C.HeightReference.CLAMP_TO_GROUND
|
|
@@ -1927,12 +1928,13 @@ var HeightMarker = class {
|
|
|
1927
1928
|
position: C.Cartesian3.ZERO,
|
|
1928
1929
|
label: {
|
|
1929
1930
|
text: "",
|
|
1930
|
-
font: "
|
|
1931
|
+
font: "10px sans-serif",
|
|
1932
|
+
// 字体改小
|
|
1931
1933
|
style: C.LabelStyle.FILL_AND_OUTLINE,
|
|
1932
1934
|
fillColor: C.Color.BLACK,
|
|
1933
1935
|
outlineColor: C.Color.WHITE,
|
|
1934
|
-
outlineWidth:
|
|
1935
|
-
pixelOffset: new C.Cartesian2(0, -
|
|
1936
|
+
outlineWidth: 2,
|
|
1937
|
+
pixelOffset: new C.Cartesian2(0, -4),
|
|
1936
1938
|
showBackground: false,
|
|
1937
1939
|
horizontalOrigin: C.HorizontalOrigin.CENTER,
|
|
1938
1940
|
verticalOrigin: C.VerticalOrigin.BOTTOM,
|
|
@@ -3458,6 +3460,8 @@ var AirplaneCursor = class {
|
|
|
3458
3460
|
__publicField(this, "cachedScaleFactor", 1);
|
|
3459
3461
|
// 相机变化事件监听器
|
|
3460
3462
|
__publicField(this, "cameraChangedListener");
|
|
3463
|
+
/** 飞机游标模型可见性,默认 false */
|
|
3464
|
+
__publicField(this, "visible", false);
|
|
3461
3465
|
const C = this.CesiumNS;
|
|
3462
3466
|
this.opts = opts;
|
|
3463
3467
|
this.pose = { position: startPosition, heading: 0, pitch: -10, roll: 0 };
|
|
@@ -3465,6 +3469,7 @@ var AirplaneCursor = class {
|
|
|
3465
3469
|
this.angleStep = opts.angleStepDeg ?? 1;
|
|
3466
3470
|
this.fastFactor = opts.fastFactor ?? 5;
|
|
3467
3471
|
this.currentFOV = opts.fovDeg ?? DEFAULT_FOV;
|
|
3472
|
+
this.visible = opts.visible ?? false;
|
|
3468
3473
|
this.ensureEntity(opts.color ?? C.Color.CYAN.withAlpha(0.9));
|
|
3469
3474
|
this.attachKeyboard(opts);
|
|
3470
3475
|
this.setupFOVListener();
|
|
@@ -3519,6 +3524,8 @@ var AirplaneCursor = class {
|
|
|
3519
3524
|
runAnimations: true,
|
|
3520
3525
|
clampAnimations: false
|
|
3521
3526
|
},
|
|
3527
|
+
show: this.visible,
|
|
3528
|
+
// 根据 visible 设置初始显示状态
|
|
3522
3529
|
properties: { _type: "airplane-cursor" }
|
|
3523
3530
|
});
|
|
3524
3531
|
this.entity = this.modelEntity;
|
|
@@ -3746,6 +3753,18 @@ var AirplaneCursor = class {
|
|
|
3746
3753
|
altitude
|
|
3747
3754
|
};
|
|
3748
3755
|
}
|
|
3756
|
+
/** 设置飞机游标可见性 */
|
|
3757
|
+
setVisible(visible) {
|
|
3758
|
+
this.visible = visible;
|
|
3759
|
+
if (this.modelEntity) {
|
|
3760
|
+
this.modelEntity.show = visible;
|
|
3761
|
+
}
|
|
3762
|
+
this.viewer.scene?.requestRender?.();
|
|
3763
|
+
}
|
|
3764
|
+
/** 获取当前可见性状态 */
|
|
3765
|
+
isVisible() {
|
|
3766
|
+
return this.visible;
|
|
3767
|
+
}
|
|
3749
3768
|
/** 获取内部实体(用于拾取识别) */
|
|
3750
3769
|
getEntity() {
|
|
3751
3770
|
return this.entity;
|
|
@@ -4936,6 +4955,34 @@ function calculateRelativeHeight(altitudeMode, absoluteHeight, startPointAltitud
|
|
|
4936
4955
|
}
|
|
4937
4956
|
}
|
|
4938
4957
|
|
|
4958
|
+
// src/utils/geometryUtils.ts
|
|
4959
|
+
function calculateDistanceAndMidpoint(CesiumNS, point1, point2) {
|
|
4960
|
+
const C = CesiumNS;
|
|
4961
|
+
const distance = C.Cartesian3.distance(point1, point2);
|
|
4962
|
+
const midpoint = new C.Cartesian3();
|
|
4963
|
+
C.Cartesian3.midpoint(point1, point2, midpoint);
|
|
4964
|
+
return { distance, midpoint };
|
|
4965
|
+
}
|
|
4966
|
+
function calculateHeadingBetweenPoints(CesiumNS, point1, point2) {
|
|
4967
|
+
const C = CesiumNS;
|
|
4968
|
+
try {
|
|
4969
|
+
const fromCarto = C.Cartographic.fromCartesian(point1);
|
|
4970
|
+
const toCarto = C.Cartographic.fromCartesian(point2);
|
|
4971
|
+
const deltaLon = toCarto.longitude - fromCarto.longitude;
|
|
4972
|
+
let heading = Math.atan2(
|
|
4973
|
+
Math.sin(deltaLon) * Math.cos(toCarto.latitude),
|
|
4974
|
+
Math.cos(fromCarto.latitude) * Math.sin(toCarto.latitude) - Math.sin(fromCarto.latitude) * Math.cos(toCarto.latitude) * Math.cos(deltaLon)
|
|
4975
|
+
);
|
|
4976
|
+
heading = C.Math.toDegrees(heading);
|
|
4977
|
+
if (heading > 180) heading -= 360;
|
|
4978
|
+
if (heading < -180) heading += 360;
|
|
4979
|
+
return heading;
|
|
4980
|
+
} catch (error) {
|
|
4981
|
+
console.error("[calculateHeadingBetweenPoints] Error:", error);
|
|
4982
|
+
return 0;
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
4985
|
+
|
|
4939
4986
|
// src/core/path-manager/editing/PathEditingEventHandler.ts
|
|
4940
4987
|
var PathEditingEventHandler = class {
|
|
4941
4988
|
constructor(options, callbacks) {
|
|
@@ -4996,36 +5043,14 @@ var PathEditingEventHandler = class {
|
|
|
4996
5043
|
if (typeof index === "number") {
|
|
4997
5044
|
if (currentActiveIndex === index) {
|
|
4998
5045
|
this.vertexDragHandler.startDrag(index, movement.position);
|
|
4999
|
-
} else {
|
|
5000
|
-
if (this.callbacks.onVertexSelect) {
|
|
5001
|
-
this.callbacks.onVertexSelect(index);
|
|
5002
|
-
}
|
|
5003
|
-
console.log("[PathEditingEventHandler] \u9876\u70B9\u88AB\u70B9\u51FB\uFF0C\u7D22\u5F15:", index, "\u56DE\u8C03\u5B58\u5728:", !!this.callbacks.onVertexSelectDetail);
|
|
5004
|
-
if (this.callbacks.onVertexSelectDetail) {
|
|
5005
|
-
try {
|
|
5006
|
-
const detailInfo = this.buildVertexDetailInfo(index);
|
|
5007
|
-
console.log("[PathEditingEventHandler] \u8C03\u7528 onVertexSelectDetail \u56DE\u8C03");
|
|
5008
|
-
this.callbacks.onVertexSelectDetail(detailInfo);
|
|
5009
|
-
} catch (error) {
|
|
5010
|
-
console.error("[PathEditingEventHandler] Error building vertex detail info:", error);
|
|
5011
|
-
}
|
|
5012
|
-
}
|
|
5013
5046
|
}
|
|
5014
5047
|
return;
|
|
5015
5048
|
}
|
|
5016
5049
|
}
|
|
5017
5050
|
const idx = pickVertexIndex(this.viewer, movement.position, this.hiddenClimbIndex);
|
|
5018
5051
|
if (typeof idx === "number") {
|
|
5019
|
-
if (
|
|
5020
|
-
this.
|
|
5021
|
-
}
|
|
5022
|
-
if (this.callbacks.onVertexSelectDetail) {
|
|
5023
|
-
try {
|
|
5024
|
-
const detailInfo = this.buildVertexDetailInfo(idx);
|
|
5025
|
-
this.callbacks.onVertexSelectDetail(detailInfo);
|
|
5026
|
-
} catch (error) {
|
|
5027
|
-
console.error("Error building vertex detail info:", error);
|
|
5028
|
-
}
|
|
5052
|
+
if (currentActiveIndex === idx) {
|
|
5053
|
+
this.vertexDragHandler.startDrag(idx, movement.position);
|
|
5029
5054
|
}
|
|
5030
5055
|
}
|
|
5031
5056
|
}, C.ScreenSpaceEventType.LEFT_DOWN);
|
|
@@ -5044,6 +5069,26 @@ var PathEditingEventHandler = class {
|
|
|
5044
5069
|
if (this.vertexDragHandler.isDragging()) {
|
|
5045
5070
|
return;
|
|
5046
5071
|
}
|
|
5072
|
+
const scene = this.viewer.scene;
|
|
5073
|
+
const picked = scene.pick?.(movement.position);
|
|
5074
|
+
const entity = picked?.id;
|
|
5075
|
+
if (entity?.properties?._type?.getValue?.() === "vertex-label") {
|
|
5076
|
+
const labelIndex = entity.properties._vertexIndex?.getValue?.();
|
|
5077
|
+
if (typeof labelIndex === "number") {
|
|
5078
|
+
if (this.callbacks.onVertexSelect) {
|
|
5079
|
+
this.callbacks.onVertexSelect(labelIndex);
|
|
5080
|
+
}
|
|
5081
|
+
if (this.callbacks.onVertexSelectDetail) {
|
|
5082
|
+
try {
|
|
5083
|
+
const detailInfo = this.buildVertexDetailInfo(labelIndex);
|
|
5084
|
+
this.callbacks.onVertexSelectDetail(detailInfo);
|
|
5085
|
+
} catch (error) {
|
|
5086
|
+
console.error("Error building vertex detail info:", error);
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
return;
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5047
5092
|
const idx = pickVertexIndex(this.viewer, movement.position, this.hiddenClimbIndex);
|
|
5048
5093
|
if (typeof idx === "number") {
|
|
5049
5094
|
if (this.callbacks.onVertexSelect) {
|
|
@@ -5059,6 +5104,45 @@ var PathEditingEventHandler = class {
|
|
|
5059
5104
|
}
|
|
5060
5105
|
return;
|
|
5061
5106
|
}
|
|
5107
|
+
const CLICK_THRESHOLD_PIXELS = 25;
|
|
5108
|
+
const positions = this.callbacks.getPositions?.() || [];
|
|
5109
|
+
if (positions.length > 0) {
|
|
5110
|
+
const clickPos = movement.position;
|
|
5111
|
+
let minDistance = Infinity;
|
|
5112
|
+
let nearestIndex = -1;
|
|
5113
|
+
for (let i = 0; i < positions.length; i++) {
|
|
5114
|
+
try {
|
|
5115
|
+
const screenPos = C.SceneTransforms.wgs84ToWindowCoordinates(
|
|
5116
|
+
scene,
|
|
5117
|
+
positions[i]
|
|
5118
|
+
);
|
|
5119
|
+
if (screenPos) {
|
|
5120
|
+
const dx = screenPos.x - clickPos.x;
|
|
5121
|
+
const dy = screenPos.y - clickPos.y;
|
|
5122
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
5123
|
+
if (distance < minDistance) {
|
|
5124
|
+
minDistance = distance;
|
|
5125
|
+
nearestIndex = i;
|
|
5126
|
+
}
|
|
5127
|
+
}
|
|
5128
|
+
} catch {
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
if (minDistance < CLICK_THRESHOLD_PIXELS && nearestIndex >= 0) {
|
|
5132
|
+
if (this.callbacks.onVertexSelect) {
|
|
5133
|
+
this.callbacks.onVertexSelect(nearestIndex);
|
|
5134
|
+
}
|
|
5135
|
+
if (this.callbacks.onVertexSelectDetail) {
|
|
5136
|
+
try {
|
|
5137
|
+
const detailInfo = this.buildVertexDetailInfo(nearestIndex);
|
|
5138
|
+
this.callbacks.onVertexSelectDetail(detailInfo);
|
|
5139
|
+
} catch (error) {
|
|
5140
|
+
console.error("Error building vertex detail info:", error);
|
|
5141
|
+
}
|
|
5142
|
+
}
|
|
5143
|
+
return;
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5062
5146
|
const quickEditEnabled = this.callbacks.getQuickEditEnabled?.();
|
|
5063
5147
|
if (quickEditEnabled) {
|
|
5064
5148
|
this.handleQuickEditClick(movement);
|
|
@@ -5162,6 +5246,14 @@ var PathEditingEventHandler = class {
|
|
|
5162
5246
|
this.handleInsertVertex(activeIndex + 1, pose, "after");
|
|
5163
5247
|
}
|
|
5164
5248
|
});
|
|
5249
|
+
if (activeIndex < positions.length - 1) {
|
|
5250
|
+
menuItems.push({
|
|
5251
|
+
label: "\u5728\u4E2D\u95F4\u63D2\u5165\u822A\u70B9",
|
|
5252
|
+
action: () => {
|
|
5253
|
+
this.handleInsertMidpoint(activeIndex);
|
|
5254
|
+
}
|
|
5255
|
+
});
|
|
5256
|
+
}
|
|
5165
5257
|
} else if (pose && visibleVertexCount <= 1) {
|
|
5166
5258
|
menuItems.push({
|
|
5167
5259
|
label: "\u6DFB\u52A0\u7B2C\u4E00\u4E2A\u822A\u70B9",
|
|
@@ -5308,6 +5400,27 @@ var PathEditingEventHandler = class {
|
|
|
5308
5400
|
});
|
|
5309
5401
|
}
|
|
5310
5402
|
}
|
|
5403
|
+
/**
|
|
5404
|
+
* 🆕 在选中航点和下一个航点中间插入新航点
|
|
5405
|
+
*/
|
|
5406
|
+
handleInsertMidpoint(activeIndex) {
|
|
5407
|
+
const positions = this.callbacks.getPositions?.() || [];
|
|
5408
|
+
const poseData = this.callbacks.getPoseData?.();
|
|
5409
|
+
if (activeIndex >= positions.length - 1) {
|
|
5410
|
+
console.warn("[handleInsertMidpoint] \u9009\u4E2D\u822A\u70B9\u662F\u6700\u540E\u4E00\u4E2A\uFF0C\u65E0\u6CD5\u63D2\u5165\u4E2D\u70B9");
|
|
5411
|
+
return;
|
|
5412
|
+
}
|
|
5413
|
+
const point1 = positions[activeIndex];
|
|
5414
|
+
const point2 = positions[activeIndex + 1];
|
|
5415
|
+
const { midpoint } = calculateDistanceAndMidpoint(this.CesiumNS, point1, point2);
|
|
5416
|
+
const heading = calculateHeadingBetweenPoints(this.CesiumNS, point1, point2);
|
|
5417
|
+
const pitch = poseData?.pitches[activeIndex] ?? -10;
|
|
5418
|
+
const roll = poseData?.rolls[activeIndex] ?? 0;
|
|
5419
|
+
console.log("[handleInsertMidpoint] \u5728\u7D22\u5F15", activeIndex, "\u548C", activeIndex + 1, "\u4E4B\u95F4\u63D2\u5165\u4E2D\u70B9");
|
|
5420
|
+
if (this.callbacks.onInsertVertex) {
|
|
5421
|
+
this.callbacks.onInsertVertex(activeIndex + 1, midpoint, { heading, pitch, roll });
|
|
5422
|
+
}
|
|
5423
|
+
}
|
|
5311
5424
|
/**
|
|
5312
5425
|
* 处理删除顶点
|
|
5313
5426
|
*/
|
|
@@ -5756,23 +5869,37 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
5756
5869
|
while (useGlobalHeightFlags.length < positions.length) {
|
|
5757
5870
|
useGlobalHeightFlags.push(false);
|
|
5758
5871
|
}
|
|
5759
|
-
|
|
5872
|
+
const waypointIds = [];
|
|
5873
|
+
if (options?.waypointIds && Array.isArray(options.waypointIds)) {
|
|
5874
|
+
const offset = 0;
|
|
5875
|
+
for (let i = 0; i < offset; i++) {
|
|
5876
|
+
waypointIds[i] = void 0;
|
|
5877
|
+
}
|
|
5878
|
+
options.waypointIds.forEach((id, idx) => {
|
|
5879
|
+
waypointIds[offset + idx] = id;
|
|
5880
|
+
});
|
|
5881
|
+
}
|
|
5882
|
+
while (waypointIds.length < positions.length) {
|
|
5883
|
+
waypointIds.push(void 0);
|
|
5884
|
+
}
|
|
5885
|
+
let quickEditEnabled = true;
|
|
5760
5886
|
let quickEditOptions = {
|
|
5761
|
-
enabled:
|
|
5887
|
+
enabled: true,
|
|
5762
5888
|
climbHeight: currentDefaultAltitude,
|
|
5763
5889
|
// 使用当前默认高度
|
|
5764
5890
|
altitudeMode: currentAltitudeMode
|
|
5765
5891
|
// 使用当前高度模式
|
|
5766
5892
|
};
|
|
5767
|
-
if (options?.quickEdit) {
|
|
5893
|
+
if (options?.quickEdit !== void 0) {
|
|
5768
5894
|
if (typeof options.quickEdit === "boolean") {
|
|
5769
5895
|
quickEditEnabled = options.quickEdit;
|
|
5770
5896
|
quickEditOptions.enabled = options.quickEdit;
|
|
5771
5897
|
} else {
|
|
5772
|
-
quickEditEnabled = options.quickEdit.enabled ??
|
|
5898
|
+
quickEditEnabled = options.quickEdit.enabled ?? true;
|
|
5773
5899
|
quickEditOptions = {
|
|
5774
5900
|
...quickEditOptions,
|
|
5775
|
-
...options.quickEdit
|
|
5901
|
+
...options.quickEdit,
|
|
5902
|
+
enabled: options.quickEdit.enabled ?? true
|
|
5776
5903
|
};
|
|
5777
5904
|
}
|
|
5778
5905
|
}
|
|
@@ -5867,6 +5994,8 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
5867
5994
|
const stateManager = new PathStateManager(entity, positions, headings, pitches, rolls, fovs);
|
|
5868
5995
|
let activeIndex;
|
|
5869
5996
|
let editedIndices = /* @__PURE__ */ new Set();
|
|
5997
|
+
let isUpdatingFromCursor = false;
|
|
5998
|
+
let isUpdatingFromDrag = false;
|
|
5870
5999
|
const handleStyleManager = new VertexHandleStyleManager(CesiumNS);
|
|
5871
6000
|
const setActiveIndex = (idx) => {
|
|
5872
6001
|
if (activeIndex !== void 0 && handles[activeIndex]) {
|
|
@@ -5972,6 +6101,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
5972
6101
|
useGlobalHeightFlags
|
|
5973
6102
|
// 🆕 传递 useGlobalHeightFlags
|
|
5974
6103
|
);
|
|
6104
|
+
waypointIds.splice(actualIndex, 0, void 0);
|
|
5975
6105
|
console.log("[PathEditing] \u63D2\u5165\u9876\u70B9\u540E positions \u957F\u5EA6:", positions.length, "actualIndex:", actualIndex);
|
|
5976
6106
|
entity.polyline.positions = new C.CallbackProperty(() => positions.slice(), false);
|
|
5977
6107
|
setActiveIndex(actualIndex);
|
|
@@ -6004,6 +6134,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
6004
6134
|
fovs.splice(deleteAt, 1);
|
|
6005
6135
|
heightMarkers.splice(deleteAt, 1);
|
|
6006
6136
|
useGlobalHeightFlags.splice(deleteAt, 1);
|
|
6137
|
+
waypointIds.splice(deleteAt, 1);
|
|
6007
6138
|
console.log("[PathEditing] \u5220\u9664\u9876\u70B9\u540E positions \u957F\u5EA6:", positions.length);
|
|
6008
6139
|
entity.polyline.positions = new C.CallbackProperty(() => positions.slice(), false);
|
|
6009
6140
|
const newEditedIndices = /* @__PURE__ */ new Set();
|
|
@@ -6090,12 +6221,36 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
6090
6221
|
}
|
|
6091
6222
|
airplaneCursor.updateOptions({
|
|
6092
6223
|
onPose: (pose) => {
|
|
6224
|
+
if (isUpdatingFromDrag) return;
|
|
6093
6225
|
try {
|
|
6094
6226
|
if (preview) {
|
|
6095
6227
|
preview.setPose(pose.position, pose.heading, pose.pitch, pose.roll, 50);
|
|
6096
6228
|
}
|
|
6097
6229
|
} catch {
|
|
6098
6230
|
}
|
|
6231
|
+
if (activeIndex !== void 0 && !isUpdatingFromCursor) {
|
|
6232
|
+
isUpdatingFromCursor = true;
|
|
6233
|
+
try {
|
|
6234
|
+
positions[activeIndex] = pose.position;
|
|
6235
|
+
headings[activeIndex] = pose.heading;
|
|
6236
|
+
pitches[activeIndex] = pose.pitch;
|
|
6237
|
+
rolls[activeIndex] = pose.roll;
|
|
6238
|
+
if (handles[activeIndex]) {
|
|
6239
|
+
handles[activeIndex].position = pose.position;
|
|
6240
|
+
}
|
|
6241
|
+
vertexLabelManager.updateLabelPosition(activeIndex, pose.position);
|
|
6242
|
+
createOrUpdateMarkerForIndex(activeIndex);
|
|
6243
|
+
editedIndices.add(activeIndex);
|
|
6244
|
+
useGlobalHeightFlags[activeIndex] = false;
|
|
6245
|
+
try {
|
|
6246
|
+
entity.polyline.positions = positions.slice();
|
|
6247
|
+
} catch {
|
|
6248
|
+
}
|
|
6249
|
+
viewer.scene?.requestRender?.();
|
|
6250
|
+
} finally {
|
|
6251
|
+
isUpdatingFromCursor = false;
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6099
6254
|
}
|
|
6100
6255
|
});
|
|
6101
6256
|
}
|
|
@@ -6171,24 +6326,38 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
6171
6326
|
},
|
|
6172
6327
|
onVertexDragMove: (index, newPosition) => {
|
|
6173
6328
|
console.log("[PathEditing] onVertexDragMove \u88AB\u8C03\u7528, index:", index);
|
|
6174
|
-
|
|
6175
|
-
|
|
6329
|
+
if (isUpdatingFromCursor) return;
|
|
6330
|
+
isUpdatingFromDrag = true;
|
|
6331
|
+
try {
|
|
6332
|
+
positions[index] = newPosition;
|
|
6333
|
+
if (handles[index]) {
|
|
6334
|
+
try {
|
|
6335
|
+
handles[index].position = newPosition;
|
|
6336
|
+
} catch {
|
|
6337
|
+
}
|
|
6338
|
+
}
|
|
6176
6339
|
try {
|
|
6177
|
-
|
|
6340
|
+
vertexLabelManager.updateLabelPosition(index, newPosition);
|
|
6178
6341
|
} catch {
|
|
6179
6342
|
}
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6343
|
+
try {
|
|
6344
|
+
entity.polyline.positions = positions.slice();
|
|
6345
|
+
} catch {
|
|
6346
|
+
}
|
|
6347
|
+
try {
|
|
6348
|
+
viewer.scene.requestRender();
|
|
6349
|
+
} catch {
|
|
6350
|
+
}
|
|
6351
|
+
if (airplaneCursor && index === activeIndex) {
|
|
6352
|
+
airplaneCursor.setPose(
|
|
6353
|
+
newPosition,
|
|
6354
|
+
headings[index] ?? 0,
|
|
6355
|
+
pitches[index] ?? -10,
|
|
6356
|
+
rolls[index] ?? 0
|
|
6357
|
+
);
|
|
6358
|
+
}
|
|
6359
|
+
} finally {
|
|
6360
|
+
isUpdatingFromDrag = false;
|
|
6192
6361
|
}
|
|
6193
6362
|
if (options?.onVertexDragMoveDetail) {
|
|
6194
6363
|
try {
|
|
@@ -6392,6 +6561,55 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
6392
6561
|
// 🆕 添加相对高度
|
|
6393
6562
|
};
|
|
6394
6563
|
};
|
|
6564
|
+
if (options?.initialClickPosition && positions.length === 0) {
|
|
6565
|
+
console.log("[PathEditing] \u5904\u7406\u521D\u59CB\u70B9\u51FB\u4F4D\u7F6E\uFF0C\u7ACB\u5373\u6DFB\u52A0\u7B2C\u4E00\u4E2A\u822A\u70B9");
|
|
6566
|
+
let finalPosition = options.initialClickPosition;
|
|
6567
|
+
try {
|
|
6568
|
+
const cartographic = C.Cartographic.fromCartesian(options.initialClickPosition);
|
|
6569
|
+
const lon = C.Math.toDegrees(cartographic.longitude);
|
|
6570
|
+
const lat = C.Math.toDegrees(cartographic.latitude);
|
|
6571
|
+
let finalHeight;
|
|
6572
|
+
if (currentAltitudeMode === "absolute") {
|
|
6573
|
+
finalHeight = currentDefaultAltitude;
|
|
6574
|
+
} else if (currentAltitudeMode === "relativeToGround") {
|
|
6575
|
+
const terrainHeight = queryTerrainHeightSync(CesiumNS, viewer, options.initialClickPosition);
|
|
6576
|
+
finalHeight = terrainHeight + currentDefaultAltitude;
|
|
6577
|
+
} else if (currentAltitudeMode === "relativeToStart") {
|
|
6578
|
+
finalHeight = currentDefaultAltitude;
|
|
6579
|
+
} else {
|
|
6580
|
+
finalHeight = currentDefaultAltitude;
|
|
6581
|
+
}
|
|
6582
|
+
finalPosition = C.Cartesian3.fromDegrees(lon, lat, finalHeight);
|
|
6583
|
+
console.log("[PathEditing] \u521D\u59CB\u822A\u70B9\u9AD8\u5EA6\u8BA1\u7B97:", {
|
|
6584
|
+
altitudeMode: currentAltitudeMode,
|
|
6585
|
+
defaultAltitude: currentDefaultAltitude,
|
|
6586
|
+
finalHeight
|
|
6587
|
+
});
|
|
6588
|
+
} catch (error) {
|
|
6589
|
+
console.warn("[PathEditing] \u8BA1\u7B97\u521D\u59CB\u822A\u70B9\u9AD8\u5EA6\u5931\u8D25:", error);
|
|
6590
|
+
}
|
|
6591
|
+
const totalBefore = positions.length;
|
|
6592
|
+
insertVertex(0, finalPosition, { heading: 0, pitch: -10, roll: 0 });
|
|
6593
|
+
if (options?.onVertexInsertDetail) {
|
|
6594
|
+
try {
|
|
6595
|
+
const totalAfter = positions.length;
|
|
6596
|
+
const newVertex = buildVertexDetailInfo(0);
|
|
6597
|
+
const operationInfo = {
|
|
6598
|
+
type: "insert",
|
|
6599
|
+
index: 0,
|
|
6600
|
+
displayNumber: newVertex.displayNumber,
|
|
6601
|
+
totalVerticesBefore: totalBefore,
|
|
6602
|
+
totalVerticesAfter: totalAfter,
|
|
6603
|
+
newVertex,
|
|
6604
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
6605
|
+
totalDistance: getTotalDistance()
|
|
6606
|
+
};
|
|
6607
|
+
options.onVertexInsertDetail(operationInfo);
|
|
6608
|
+
} catch (error) {
|
|
6609
|
+
console.error("[PathEditing] \u89E6\u53D1 onVertexInsertDetail \u56DE\u8C03\u5931\u8D25:", error);
|
|
6610
|
+
}
|
|
6611
|
+
}
|
|
6612
|
+
}
|
|
6395
6613
|
return {
|
|
6396
6614
|
/** 保存并退出编辑模式 */
|
|
6397
6615
|
saveAndStop: () => {
|
|
@@ -6433,8 +6651,10 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
6433
6651
|
distance: calculatePathDistance(CesiumNS, positions, index),
|
|
6434
6652
|
ellipsoidHeight,
|
|
6435
6653
|
relativeHeight,
|
|
6436
|
-
useGlobalHeight: useGlobalHeightFlags[index] ?? false
|
|
6654
|
+
useGlobalHeight: useGlobalHeightFlags[index] ?? false,
|
|
6437
6655
|
// 🆕 添加 useGlobalHeight
|
|
6656
|
+
waypointId: waypointIds[index]
|
|
6657
|
+
// 🆕 添加 waypointId(原有航点保留ID,新插入航点为 undefined)
|
|
6438
6658
|
};
|
|
6439
6659
|
});
|
|
6440
6660
|
cleanupSession();
|
|
@@ -6817,6 +7037,67 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
|
|
|
6817
7037
|
options2?.onProgress?.("error");
|
|
6818
7038
|
return { success: false, error: String(error) };
|
|
6819
7039
|
}
|
|
7040
|
+
},
|
|
7041
|
+
/**
|
|
7042
|
+
* 🆕 获取当前选中航点索引
|
|
7043
|
+
* @returns 当前选中的航点索引,如果没有选中则返回 undefined
|
|
7044
|
+
*/
|
|
7045
|
+
getActiveIndex: () => {
|
|
7046
|
+
return activeIndex;
|
|
7047
|
+
},
|
|
7048
|
+
/**
|
|
7049
|
+
* 🆕 在选中航点和下一个航点中间插入新航点
|
|
7050
|
+
* @param index 选中航点的索引(如果不传则使用当前选中的航点)
|
|
7051
|
+
* @returns 是否插入成功
|
|
7052
|
+
*/
|
|
7053
|
+
insertMidpoint: (index) => {
|
|
7054
|
+
const targetIndex = index ?? activeIndex;
|
|
7055
|
+
if (targetIndex === void 0) {
|
|
7056
|
+
console.warn("[insertMidpoint] \u6CA1\u6709\u9009\u4E2D\u822A\u70B9");
|
|
7057
|
+
return false;
|
|
7058
|
+
}
|
|
7059
|
+
if (targetIndex >= positions.length - 1) {
|
|
7060
|
+
console.warn("[insertMidpoint] \u9009\u4E2D\u822A\u70B9\u662F\u6700\u540E\u4E00\u4E2A\uFF0C\u65E0\u6CD5\u63D2\u5165\u4E2D\u70B9");
|
|
7061
|
+
return false;
|
|
7062
|
+
}
|
|
7063
|
+
const point1 = positions[targetIndex];
|
|
7064
|
+
const point2 = positions[targetIndex + 1];
|
|
7065
|
+
const midpoint = C.Cartesian3.midpoint(point1, point2, new C.Cartesian3());
|
|
7066
|
+
const carto1 = C.Cartographic.fromCartesian(point1);
|
|
7067
|
+
const carto2 = C.Cartographic.fromCartesian(point2);
|
|
7068
|
+
const deltaLon = carto2.longitude - carto1.longitude;
|
|
7069
|
+
let heading = Math.atan2(
|
|
7070
|
+
Math.sin(deltaLon) * Math.cos(carto2.latitude),
|
|
7071
|
+
Math.cos(carto1.latitude) * Math.sin(carto2.latitude) - Math.sin(carto1.latitude) * Math.cos(carto2.latitude) * Math.cos(deltaLon)
|
|
7072
|
+
);
|
|
7073
|
+
heading = C.Math.toDegrees(heading);
|
|
7074
|
+
if (heading > 180) heading -= 360;
|
|
7075
|
+
if (heading < -180) heading += 360;
|
|
7076
|
+
const pitch = pitches[targetIndex] ?? -10;
|
|
7077
|
+
const roll = rolls[targetIndex] ?? 0;
|
|
7078
|
+
console.log("[insertMidpoint] \u5728\u7D22\u5F15", targetIndex, "\u548C", targetIndex + 1, "\u4E4B\u95F4\u63D2\u5165\u4E2D\u70B9");
|
|
7079
|
+
const totalBefore = positions.length;
|
|
7080
|
+
insertVertex(targetIndex + 1, midpoint, { heading, pitch, roll });
|
|
7081
|
+
if (options?.onVertexInsertDetail) {
|
|
7082
|
+
try {
|
|
7083
|
+
const totalAfter = positions.length;
|
|
7084
|
+
const newVertex = buildVertexDetailInfo(targetIndex + 1);
|
|
7085
|
+
const operationInfo = {
|
|
7086
|
+
type: "insert",
|
|
7087
|
+
index: targetIndex + 1,
|
|
7088
|
+
displayNumber: newVertex.displayNumber,
|
|
7089
|
+
totalVerticesBefore: totalBefore,
|
|
7090
|
+
totalVerticesAfter: totalAfter,
|
|
7091
|
+
newVertex,
|
|
7092
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
7093
|
+
totalDistance: getTotalDistance()
|
|
7094
|
+
};
|
|
7095
|
+
options.onVertexInsertDetail(operationInfo);
|
|
7096
|
+
} catch (error) {
|
|
7097
|
+
console.error("Error in onVertexInsertDetail:", error);
|
|
7098
|
+
}
|
|
7099
|
+
}
|
|
7100
|
+
return true;
|
|
6820
7101
|
}
|
|
6821
7102
|
};
|
|
6822
7103
|
}
|
|
@@ -6898,8 +7179,8 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
|
|
|
6898
7179
|
try {
|
|
6899
7180
|
const auto = options?.autoStartEditing;
|
|
6900
7181
|
const editOptions = {
|
|
6901
|
-
//
|
|
6902
|
-
quickEdit:
|
|
7182
|
+
// 🔧 修复:默认使用快速编辑模式,用户点击地图即可添加航点
|
|
7183
|
+
quickEdit: true
|
|
6903
7184
|
};
|
|
6904
7185
|
if (typeof auto === "object" && auto.preview) {
|
|
6905
7186
|
editOptions.preview = auto.preview;
|
|
@@ -6925,8 +7206,9 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
|
|
|
6925
7206
|
editOptions.altitudeMode = altitudeMode;
|
|
6926
7207
|
editOptions.defaultAltitude = defaultAltitude;
|
|
6927
7208
|
editOptions.climbHeight = climbHeight;
|
|
7209
|
+
editOptions.initialClickPosition = picked;
|
|
6928
7210
|
editSession = startPathEditing(CesiumNS, viewer, created, editOptions);
|
|
6929
|
-
console.log("[startPathDrawing] \u7F16\u8F91\u6A21\u5F0F\u5DF2\u542F\u52A8\uFF0C\
|
|
7211
|
+
console.log("[startPathDrawing] \u7F16\u8F91\u6A21\u5F0F\u5DF2\u542F\u52A8\uFF0C\u5FEB\u901F\u7F16\u8F91\u6A21\u5F0F\uFF0C\u70B9\u51FB\u5730\u56FE\u6DFB\u52A0\u822A\u70B9");
|
|
6930
7212
|
if (editSession && options?.onEditingStarted) {
|
|
6931
7213
|
try {
|
|
6932
7214
|
options.onEditingStarted(editSession);
|