Browse Source

盘旋的一种方式

master
ctw 2 months ago
parent
commit
cb769b8cd1
  1. 3
      ruoyi-ui/src/views/cesiumMap/DrawingToolbar.vue
  2. 374
      ruoyi-ui/src/views/cesiumMap/index.vue
  3. 5
      ruoyi-ui/src/views/childRoom/RightPanel.vue
  4. 65
      ruoyi-ui/src/views/childRoom/index.vue

3
ruoyi-ui/src/views/cesiumMap/DrawingToolbar.vue

@ -45,9 +45,6 @@ export default {
{ id: 'polygon', name: '面', icon: 'el-icon-house' },
{ id: 'rectangle', name: '矩形', icon: 'jx' },
{ id: 'circle', name: '圆形', icon: 'circle' },
{ id: 'ellipse', name: '椭圆', icon: 'el-icon-oval' },
{ id: 'hold_circle', name: '圆形盘旋', icon: 'circle' },
{ id: 'hold_ellipse', name: '椭圆盘旋', icon: 'el-icon-oval' },
{ id: 'sector', name: '扇形', icon: 'sx' },
{ id: 'arrow', name: '箭头', icon: 'el-icon-right' },
{ id: 'text', name: '文本', icon: 'el-icon-document' },

374
ruoyi-ui/src/views/cesiumMap/index.vue

@ -132,7 +132,6 @@ export default {
isDrawing: false,
missionHoldParamsByIndex: {},
missionPendingHold: null,
missionInitialHoldParams: null,
tempHoldEntity: null,
activeCursorPosition: null, //
//
@ -160,9 +159,6 @@ export default {
polygon: { color: '#0000FF', opacity: 0.5, width: 2 },
rectangle: { color: '#FFA500', opacity: 0.3, width: 2 },
circle: { color: '#800080', opacity: 0.4, width: 2 },
ellipse: { color: '#008080', opacity: 0.4, width: 2 },
hold_circle: { color: '#00BFFF', width: 2 },
hold_ellipse: { color: '#00BFFF', width: 2 },
sector: { color: '#FF6347', opacity: 0.5, width: 2 },
arrow: { color: '#FF0000', width: 6 },
text: { color: '#000000', font: '48px Microsoft YaHei, PingFang SC, sans-serif', backgroundColor: 'rgba(255, 255, 255, 0.8)' },
@ -384,7 +380,6 @@ export default {
this.drawingPoints = [];
this.missionHoldParamsByIndex = {};
this.missionPendingHold = null;
this.missionInitialHoldParams = null;
let activeCursorPosition = null;
this.isDrawing = true;
this.viewer.canvas.style.cursor = 'crosshair';
@ -402,22 +397,6 @@ export default {
const position = this.getClickPosition(click.position);
if (!position) return;
this.drawingPoints.push(position);
if (this.missionInitialHoldParams && this.drawingPoints.length === 2) {
this.missionPendingHold = {
beforeIndex: 1,
center: Cesium.Cartesian3.clone(this.drawingPoints[0]),
params: this.missionInitialHoldParams
};
this.missionInitialHoldParams = null;
if (this.tempHoldEntity) { try { this.viewer.entities.remove(this.tempHoldEntity); } catch (e) {} this.tempHoldEntity = null; }
this.tempHoldEntity = this.viewer.entities.add({
id: 'temp_hold_preview',
name: 'HOLD',
position: this.missionPendingHold.center,
point: { pixelSize: 10, color: Cesium.Color.ORANGE, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, disableDepthTestDistance: Number.POSITIVE_INFINITY },
label: { text: 'HOLD', font: '12px MicroSoft YaHei', fillColor: Cesium.Color.ORANGE, outlineColor: Cesium.Color.BLACK, outlineWidth: 2 }
});
}
const wpIndex = this.drawingPoints.length;
this.$emit('drawing-points-update', this.drawingPoints.length);
//
@ -552,11 +531,6 @@ export default {
return (this.drawingPoints && this.drawingPoints.length) || 0;
},
/** 方式一:先画盘旋再画航线。在开始航线绘制后、用户点击第一个点作为盘旋中心,第二个点后自动插入该盘旋 */
setInitialHoldParams(holdParams) {
this.missionInitialHoldParams = holdParams;
},
// URL RouteEditDialog / RightPanel
formatPlatformIconUrl(url) {
if (!url) return '';
@ -1569,15 +1543,6 @@ export default {
case 'circle':
this.startCircleDrawing()
break
case 'ellipse':
this.startEllipseDrawing()
break
case 'hold_circle':
this.startHoldCircleDrawing()
break
case 'hold_ellipse':
this.startHoldEllipseDrawing()
break
case 'sector':
this.startSectorDrawing()
break
@ -1619,7 +1584,6 @@ export default {
this.tempHoldEntity = null;
}
this.missionPendingHold = null;
this.missionInitialHoldParams = null;
this.missionHoldParamsByIndex = {};
//
if (this.tempEntity) {
@ -2226,89 +2190,6 @@ export default {
this.drawingPoints = [];
this.activeCursorPosition = null;
},
//
startEllipseDrawing() {
this.drawingPoints = [];
this.activeCursorPosition = null;
if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; }
if (this.tempPreviewEntity) { this.viewer.entities.remove(this.tempPreviewEntity); this.tempPreviewEntity = null; }
this.drawingHandler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
this.drawingHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
this.drawingHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
this.drawingHandler.setInputAction((movement) => {
const newPosition = this.getClickPosition(movement.endPosition);
if (newPosition) this.activeCursorPosition = newPosition;
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
this.drawingHandler.setInputAction((click) => {
const position = this.getClickPosition(click.position);
if (!position) return;
this.drawingPoints.push(position);
if (this.drawingPoints.length === 1) {
this.activeCursorPosition = position;
this.tempEntity = this.viewer.entities.add({
position: position,
ellipse: {
semiMajorAxis: new Cesium.CallbackProperty(() => {
let a = 100;
let b = 50;
if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) {
a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50);
} else if (this.activeCursorPosition && this.drawingPoints.length === 1) {
a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition), 50);
}
if (this.drawingPoints.length >= 3 && this.drawingPoints[0] && this.drawingPoints[1] && this.drawingPoints[2]) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20);
} else if (this.drawingPoints.length >= 2 && this.activeCursorPosition) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20);
}
return Math.max(a, b);
}, false),
semiMinorAxis: new Cesium.CallbackProperty(() => {
let a = 100;
let b = 50;
if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) {
a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50);
} else if (this.activeCursorPosition && this.drawingPoints.length === 1) {
a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition), 50);
}
if (this.drawingPoints.length >= 3 && this.drawingPoints[0] && this.drawingPoints[1] && this.drawingPoints[2]) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20);
} else if (this.drawingPoints.length >= 2 && this.activeCursorPosition) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20);
}
return Math.min(a, b);
}, false),
rotation: new Cesium.CallbackProperty(() => {
if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) {
let heading = this.ellipseHeadingFromCenterAndMajor(this.drawingPoints[0], this.drawingPoints[1]);
let a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50);
let b = 50;
if (this.drawingPoints.length >= 3 && this.drawingPoints[2]) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20);
} else if (this.activeCursorPosition) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20);
}
if (b > a) heading += Math.PI / 2;
return heading;
}
return 0;
}, false),
material: Cesium.Color.fromCssColorString(this.defaultStyles.ellipse.color).withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.ellipse.color),
outlineWidth: 2
}
});
} else if (this.drawingPoints.length === 2) {
this.activeCursorPosition = this.drawingPoints[1];
} else if (this.drawingPoints.length === 3) {
this.activeCursorPosition = null;
if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; }
this.finishEllipseDrawing();
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
this.drawingHandler.setInputAction(() => this.cancelDrawing(), Cesium.ScreenSpaceEventType.RIGHT_CLICK);
},
ellipseHeadingFromCenterAndMajor(center, majorEnd) {
const ellipsoid = this.viewer.scene.globe.ellipsoid;
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(center);
@ -2330,261 +2211,6 @@ export default {
const minorComponent = -e3 * Math.sin(heading) + n3 * Math.cos(heading);
return Math.abs(minorComponent);
},
finishEllipseDrawing() {
const center = this.drawingPoints[0];
const majorEnd = this.drawingPoints[1];
const third = this.drawingPoints[2];
let a = Math.max(Cesium.Cartesian3.distance(center, majorEnd), 50);
let b = Math.max(this.ellipseSemiMinorFromThreePoints(center, majorEnd, third), 20);
let heading = this.ellipseHeadingFromCenterAndMajor(center, majorEnd);
if (b > a) {
[a, b] = [b, a];
heading += Math.PI / 2;
}
const semiMajor = a;
const semiMinor = b;
this.entityCounter++;
const id = `ellipse_${this.entityCounter}`;
const entity = this.viewer.entities.add({
id,
name: `椭圆 ${this.entityCounter}`,
position: center,
ellipse: {
semiMajorAxis: semiMajor,
semiMinorAxis: semiMinor,
rotation: heading,
material: Cesium.Color.fromCssColorString(this.defaultStyles.ellipse.color).withAlpha(this.defaultStyles.ellipse.opacity),
outline: true,
outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.ellipse.color),
outlineWidth: this.defaultStyles.ellipse.width
}
});
const entityData = {
id,
type: 'ellipse',
points: this.drawingPoints.map(p => this.cartesianToLatLng(p)),
positions: [...this.drawingPoints],
entity,
semiMajorAxis: semiMajor,
semiMinorAxis: semiMinor,
headingDeg: (heading * 180 / Math.PI),
color: this.defaultStyles.ellipse.color,
opacity: this.defaultStyles.ellipse.opacity,
width: this.defaultStyles.ellipse.width,
label: `椭圆 ${this.entityCounter}`
};
this.allEntities.push(entityData);
this.measurementResult = { type: 'ellipse', semiMajorAxis: semiMajor, semiMinorAxis: semiMinor, area: Math.PI * semiMajor * semiMinor };
this.drawingPoints = [];
this.activeCursorPosition = null;
},
// +
startHoldCircleDrawing() {
this.drawingPoints = [];
this.activeCursorPosition = null;
if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; }
if (this.tempPreviewEntity) { this.viewer.entities.remove(this.tempPreviewEntity); this.tempPreviewEntity = null; }
const initialRadius = 100;
this.drawingHandler.setInputAction((movement) => {
const newPosition = this.getClickPosition(movement.endPosition);
if (newPosition) this.activeCursorPosition = newPosition;
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
this.drawingHandler.setInputAction((click) => {
const position = this.getClickPosition(click.position);
if (!position) return;
if (this.drawingPoints.length === 0) {
this.drawingPoints.push(position);
this.activeCursorPosition = position;
this.tempEntity = this.viewer.entities.add({
position: position,
ellipse: {
semiMajorAxis: new Cesium.CallbackProperty(() => {
if (this.activeCursorPosition && this.drawingPoints[0]) {
const d = Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition);
return isFinite(d) && d > 0 ? d : initialRadius;
}
return initialRadius;
}, false),
semiMinorAxis: new Cesium.CallbackProperty(() => {
if (this.activeCursorPosition && this.drawingPoints[0]) {
const d = Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition);
return isFinite(d) && d > 0 ? d : initialRadius;
}
return initialRadius;
}, false),
material: Cesium.Color.TRANSPARENT,
outline: true,
outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.hold_circle.color),
outlineWidth: this.defaultStyles.hold_circle.width || 2
}
});
} else if (this.drawingPoints.length === 1) {
this.drawingPoints.push(position);
this.activeCursorPosition = null;
this.finishHoldCircleDrawing(position);
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
this.drawingHandler.setInputAction(() => this.cancelDrawing(), Cesium.ScreenSpaceEventType.RIGHT_CLICK);
},
finishHoldCircleDrawing(edgePosition) {
const centerPoint = this.drawingPoints[0];
const radius = Cesium.Cartesian3.distance(centerPoint, edgePosition);
if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; }
this.entityCounter++;
const id = `hold_circle_${this.entityCounter}`;
const finalEntity = this.viewer.entities.add({
id,
position: centerPoint,
ellipse: {
semiMajorAxis: radius,
semiMinorAxis: radius,
material: Cesium.Color.TRANSPARENT,
outline: true,
outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.hold_circle.color),
outlineWidth: this.defaultStyles.hold_circle.width || 2
}
});
const entityData = {
id,
type: 'hold_circle',
points: [centerPoint, edgePosition].map(p => this.cartesianToLatLng(p)),
positions: [centerPoint, edgePosition],
entity: finalEntity,
color: this.defaultStyles.hold_circle.color,
width: this.defaultStyles.hold_circle.width || 2,
radius,
label: `圆形盘旋 ${this.entityCounter}`
};
this.allEntities.push(entityData);
this.measurementResult = { type: 'hold_circle', radius, area: Math.PI * radius * radius };
this.drawingPoints = [];
this.activeCursorPosition = null;
},
//
startHoldEllipseDrawing() {
this.drawingPoints = [];
this.activeCursorPosition = null;
if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; }
if (this.tempPreviewEntity) { this.viewer.entities.remove(this.tempPreviewEntity); this.tempPreviewEntity = null; }
this.drawingHandler.setInputAction((movement) => {
const newPosition = this.getClickPosition(movement.endPosition);
if (newPosition) this.activeCursorPosition = newPosition;
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
this.drawingHandler.setInputAction((click) => {
const position = this.getClickPosition(click.position);
if (!position) return;
this.drawingPoints.push(position);
if (this.drawingPoints.length === 1) {
this.activeCursorPosition = position;
this.tempEntity = this.viewer.entities.add({
position: position,
ellipse: {
semiMajorAxis: new Cesium.CallbackProperty(() => {
let a = 100, b = 50;
if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) {
a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50);
} else if (this.activeCursorPosition && this.drawingPoints.length === 1) {
a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition), 50);
}
if (this.drawingPoints.length >= 3 && this.drawingPoints[0] && this.drawingPoints[1] && this.drawingPoints[2]) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20);
} else if (this.drawingPoints.length >= 2 && this.activeCursorPosition) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20);
}
return Math.max(a, b);
}, false),
semiMinorAxis: new Cesium.CallbackProperty(() => {
let a = 100, b = 50;
if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) {
a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50);
} else if (this.activeCursorPosition && this.drawingPoints.length === 1) {
a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition), 50);
}
if (this.drawingPoints.length >= 3 && this.drawingPoints[0] && this.drawingPoints[1] && this.drawingPoints[2]) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20);
} else if (this.drawingPoints.length >= 2 && this.activeCursorPosition) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20);
}
return Math.min(a, b);
}, false),
rotation: new Cesium.CallbackProperty(() => {
if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) {
let heading = this.ellipseHeadingFromCenterAndMajor(this.drawingPoints[0], this.drawingPoints[1]);
let a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50);
let b = 50;
if (this.drawingPoints.length >= 3 && this.drawingPoints[2]) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20);
} else if (this.activeCursorPosition) {
b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20);
}
if (b > a) heading += Math.PI / 2;
return heading;
}
return 0;
}, false),
material: Cesium.Color.TRANSPARENT,
outline: true,
outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.hold_ellipse.color),
outlineWidth: this.defaultStyles.hold_ellipse.width || 2
}
});
} else if (this.drawingPoints.length === 2) {
this.activeCursorPosition = this.drawingPoints[1];
} else if (this.drawingPoints.length === 3) {
this.activeCursorPosition = null;
if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; }
this.finishHoldEllipseDrawing();
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
this.drawingHandler.setInputAction(() => this.cancelDrawing(), Cesium.ScreenSpaceEventType.RIGHT_CLICK);
},
finishHoldEllipseDrawing() {
const center = this.drawingPoints[0];
const majorEnd = this.drawingPoints[1];
const third = this.drawingPoints[2];
let a = Math.max(Cesium.Cartesian3.distance(center, majorEnd), 50);
let b = Math.max(this.ellipseSemiMinorFromThreePoints(center, majorEnd, third), 20);
let heading = this.ellipseHeadingFromCenterAndMajor(center, majorEnd);
if (b > a) {
[a, b] = [b, a];
heading += Math.PI / 2;
}
const semiMajor = a;
const semiMinor = b;
this.entityCounter++;
const id = `hold_ellipse_${this.entityCounter}`;
const entity = this.viewer.entities.add({
id,
name: `椭圆盘旋 ${this.entityCounter}`,
position: center,
ellipse: {
semiMajorAxis: semiMajor,
semiMinorAxis: semiMinor,
rotation: heading,
material: Cesium.Color.TRANSPARENT,
outline: true,
outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.hold_ellipse.color),
outlineWidth: this.defaultStyles.hold_ellipse.width || 2
}
});
const entityData = {
id,
type: 'hold_ellipse',
points: this.drawingPoints.map(p => this.cartesianToLatLng(p)),
positions: [...this.drawingPoints],
entity,
semiMajorAxis: semiMajor,
semiMinorAxis: semiMinor,
headingDeg: (heading * 180 / Math.PI),
color: this.defaultStyles.hold_ellipse.color,
width: this.defaultStyles.hold_ellipse.width || 2,
label: `椭圆盘旋 ${this.entityCounter}`
};
this.allEntities.push(entityData);
this.measurementResult = { type: 'hold_ellipse', semiMajorAxis: semiMajor, semiMinorAxis: semiMinor, area: Math.PI * semiMajor * semiMinor };
this.drawingPoints = [];
this.activeCursorPosition = null;
},
//
startSectorDrawing() {
//

5
ruoyi-ui/src/views/childRoom/RightPanel.vue

@ -42,7 +42,6 @@
</div>
<div class="tree-item-actions">
<i class="el-icon-plus" title="新建航线" @click.stop="handleCreateRouteForPlan(plan)"></i>
<i class="el-icon-aim" title="先画盘旋再画航线" @click.stop="handleCreateRouteWithHold(plan)"></i>
<i class="el-icon-edit" title="编辑" @click.stop="handleOpenPlanDialog(plan)"></i>
<i class="el-icon-delete" title="删除" @click.stop="handleDeletePlan(plan)"></i>
</div>
@ -453,10 +452,6 @@ export default {
this.$emit('create-route', plan)
},
handleCreateRouteWithHold(plan) {
this.$emit('create-route-with-hold', plan)
},
handleDeletePlan(plan) {
this.$confirm(`是否确认删除方案 "${plan.name}"?这将同时删除该方案下的所有航线。`, "警告", {
confirmButtonText: "确定",

65
ruoyi-ui/src/views/childRoom/index.vue

@ -160,7 +160,6 @@
@hide="hideRightPanel"
@select-route="selectRoute"
@create-route="createRoute"
@create-route-with-hold="openAddHoldThenCreateRoute"
@delete-route="handleDeleteRoute"
@select-plan="selectPlan"
@create-plan="createPlan"
@ -631,14 +630,12 @@ export default {
addHoldDialogTitle() {
if (!this.addHoldContext) return '添加盘旋';
if (this.addHoldContext.mode === 'drawing') return '在最后两航点之间插入盘旋';
if (this.addHoldContext.mode === 'drawing_first') return '先画盘旋再画航线';
return '在此航段添加盘旋';
},
addHoldDialogTip() {
if (!this.addHoldContext) return '';
if (this.addHoldContext.mode === 'drawing') return '在最后两航点之间插入盘旋,保存航线时生效。';
if (this.addHoldContext.mode === 'drawing_first') return '设置盘旋参数后,将进入航线绘制:第一个点击为盘旋中心,第二个点击为下一航点。';
return `${this.addHoldContext.fromName}${this.addHoldContext.toName} 之间添加盘旋,到计划时间后沿切线飞往下一航点(原「下一格」航点将被移除)。`;
return `将冲突位置「${this.addHoldContext.toName}」替换为盘旋航点,到计划时间后沿切线飞往下一航点,路径顺序不变。`;
}
},
mounted() {
@ -1034,12 +1031,6 @@ export default {
this.showAddHoldDialog = true;
},
openAddHoldThenCreateRoute(plan) {
if (!plan || !plan.id) return;
this.addHoldContext = { mode: 'drawing_first', plan };
this.addHoldForm = { holdType: 'hold_circle', radius: 500, semiMajor: 500, semiMinor: 300, headingDeg: 0, clockwise: true, startTime: '', startTimeMinutes: 60 };
this.showAddHoldDialog = true;
},
/** 弹窗点击“确定”:正式将数据保存到后端数据库 */
async confirmSaveNewRoute() {
// 1.
@ -2230,22 +2221,6 @@ export default {
this.$message.success('已插入盘旋,继续点选航点后右键结束保存');
return;
}
if (this.addHoldContext.mode === 'drawing_first') {
const holdParams = this.addHoldForm.holdType === 'hold_circle'
? { radius: this.addHoldForm.radius, clockwise: this.addHoldForm.clockwise }
: { semiMajor: this.addHoldForm.semiMajor, semiMinor: this.addHoldForm.semiMinor, headingDeg: this.addHoldForm.headingDeg, clockwise: this.addHoldForm.clockwise };
this.showAddHoldDialog = false;
const plan = this.addHoldContext.plan;
this.addHoldContext = null;
this.createRoute(plan);
this.$nextTick(() => {
if (this.$refs.cesiumMap && this.$refs.cesiumMap.setInitialHoldParams) {
this.$refs.cesiumMap.setInitialHoldParams(holdParams);
}
});
this.$message.success('请先点击盘旋中心,再点击下一航点,然后继续绘制或右键结束');
return;
}
const { routeId, legIndex } = this.addHoldContext;
const route = this.routes.find(r => r.id === routeId);
if (!route || !route.waypoints || route.waypoints.length < 2) {
@ -2253,36 +2228,32 @@ export default {
return;
}
const waypoints = route.waypoints;
const prevWp = waypoints[legIndex];
const nextWp = waypoints[legIndex + 1];
const newSeq = (prevWp.seq != null ? Number(prevWp.seq) : legIndex + 1) + 1;
const baseSeq = prevWp.seq != null ? Number(prevWp.seq) : legIndex + 1;
const targetWp = waypoints[legIndex + 1];
if (!targetWp || !targetWp.id) {
this.$message.warning('目标航点无效');
return;
}
const holdParams = this.addHoldForm.holdType === 'hold_circle'
? { radius: this.addHoldForm.radius, clockwise: this.addHoldForm.clockwise }
: { semiMajor: this.addHoldForm.semiMajor, semiMinor: this.addHoldForm.semiMinor, headingDeg: this.addHoldForm.headingDeg, clockwise: this.addHoldForm.clockwise };
const startTime = this.addHoldForm.startTimeMinutes !== '' && this.addHoldForm.startTimeMinutes != null && !Number.isNaN(Number(this.addHoldForm.startTimeMinutes))
? this.minutesToStartTime(Number(this.addHoldForm.startTimeMinutes))
: (nextWp.startTime || 'K+01:00');
: (targetWp.startTime || 'K+01:00');
try {
await addWaypoints({
routeId,
await updateWaypoints({
id: targetWp.id,
routeId: routeId,
name: 'HOLD',
seq: newSeq,
lat: nextWp.lat,
lng: nextWp.lng,
alt: nextWp.alt != null ? nextWp.alt : prevWp.alt,
speed: prevWp.speed || 800,
seq: targetWp.seq,
lat: targetWp.lat,
lng: targetWp.lng,
alt: targetWp.alt,
speed: targetWp.speed != null ? targetWp.speed : 800,
startTime,
turnAngle: targetWp.turnAngle != null ? targetWp.turnAngle : 0,
pointType: this.addHoldForm.holdType,
holdParams: JSON.stringify(holdParams)
});
await delWaypoints(nextWp.id);
for (let i = legIndex + 2; i < waypoints.length; i++) {
const w = waypoints[i];
if (w.id) {
await updateWaypoints({ ...w, seq: baseSeq + (i - legIndex) });
}
}
this.showAddHoldDialog = false;
this.addHoldContext = null;
await this.getList();
@ -2292,9 +2263,9 @@ export default {
this.$refs.cesiumMap.renderRouteWaypoints(updated.waypoints, routeId, updated.platformId, updated.platform, this.parseRouteStyle(updated.attributes));
this.$nextTick(() => this.updateDeductionPositions());
}
this.$message.success('已添加盘旋航点');
this.$message.success('已将冲突位置航点替换为盘旋航点');
} catch (e) {
this.$message.error(e.msg || '添加盘旋失败');
this.$message.error(e.msg || '替换盘旋失败');
console.error(e);
}
},

Loading…
Cancel
Save