Browse Source

转弯半径优化

master
ctw 2 months ago
parent
commit
2b8edb72d2
  1. 97
      ruoyi-ui/src/views/cesiumMap/index.vue

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

@ -899,13 +899,18 @@ export default {
if (existingPlatform) {
this.viewer.entities.remove(existingPlatform);
}
// 线
// 线 entry/exit
waypoints.forEach((wp,index) => {
const waypointEntityId = `wp_${routeId}_${wp.id}`;
const existingWaypoint = this.viewer.entities.getById(waypointEntityId);
if (existingWaypoint) {
this.viewer.entities.remove(existingWaypoint);
}
['_entry', '_exit'].forEach(suffix => {
const entryExitId = `wp_${routeId}_${wp.id}${suffix}`;
const existingEntryExit = this.viewer.entities.getById(entryExitId);
if (existingEntryExit) this.viewer.entities.remove(existingEntryExit);
});
const arcId = `arc-line-${routeId}-${index}`;
const existingArc = this.viewer.entities.getById(arcId);
if (existingArc) {
@ -923,15 +928,46 @@ export default {
const wpColor = wpStyle.color || '#ffffff';
const wpOutline = wpStyle.outlineColor || '#0078FF';
const wpOutlineW = wpStyle.outlineWidth != null ? wpStyle.outlineWidth : 2;
//
// 线线 3线线线
const lineWidth = lineStyle.width != null ? lineStyle.width : 3;
const lineColor = lineStyle.color || '#800080';
const gapColor = lineStyle.gapColor != null ? lineStyle.gapColor : '#000000';
const dashLen = lineStyle.dashLength != null ? lineStyle.dashLength : 20;
const useDash = (lineStyle.style || 'dash') === 'dash';
const lineMaterial = useDash
? new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.fromCssColorString(lineColor),
gapColor: Cesium.Color.fromCssColorString(gapColor),
dashLength: dashLen
})
: Cesium.Color.fromCssColorString(lineColor);
//
const originalPositions = [];
waypoints.forEach((wp, index) => {
waypoints.forEach((wp) => {
const lon = parseFloat(wp.lng);
const lat = parseFloat(wp.lat);
// 使 Number Double
const altValue = Number(wp.alt || 5000);
const pos = Cesium.Cartesian3.fromDegrees(lon, lat, altValue);
originalPositions.push(pos);
originalPositions.push(Cesium.Cartesian3.fromDegrees(lon, lat, altValue));
});
// i 线
const isTurnWaypointWithArc = (i) => {
if (i < 1 || i >= waypoints.length - 1) return false;
const wp = waypoints[i];
if (this.getWaypointRadius(wp) <= 0) return false;
const nextPos = originalPositions[i + 1];
let nextLogical = nextPos;
if (this.isHoldWaypoint(waypoints[i + 1])) {
const holdParams = this.parseHoldParams(waypoints[i + 1]);
nextLogical = holdParams && holdParams.radius != null
? this.getCircleEntryPoint(originalPositions[i + 1], originalPositions[i], holdParams.radius)
: this.getEllipseEntryPoint(originalPositions[i + 1], originalPositions[i], holdParams.semiMajor ?? 500, holdParams.semiMinor ?? 300, ((holdParams.headingDeg || 0) * Math.PI) / 180);
}
return !!nextLogical;
};
// 线
waypoints.forEach((wp, index) => {
if (isTurnWaypointWithArc(index)) return;
const pos = originalPositions[index];
this.viewer.entities.add({
id: `wp_${routeId}_${wp.id}`,
name: wp.name || `WP${index + 1}`,
@ -1047,9 +1083,42 @@ export default {
const arcPoints = this.computeArcPositions(lastPos, currPos, nextLogical, radius);
this.viewer.entities.add({
id: `arc-line-${routeId}-${i}`,
polyline: { positions: arcPoints, width: 8, material: Cesium.Color.RED, clampToGround: true, zIndex: 20 },
polyline: { positions: arcPoints, width: lineWidth, material: lineMaterial, clampToGround: true, zIndex: 20 },
properties: { routeId: routeId }
});
// 线dbId wp.id
const wpName = wp.name || `WP${i + 1}`;
const arcEntry = arcPoints[0];
const arcExit = arcPoints[arcPoints.length - 1];
[arcEntry, arcExit].forEach((pos, idx) => {
const suffix = idx === 0 ? '_entry' : '_exit';
this.viewer.entities.add({
id: `wp_${routeId}_${wp.id}${suffix}`,
name: wpName,
position: pos,
properties: {
isMissionWaypoint: true,
routeId: routeId,
dbId: wp.id,
},
point: {
pixelSize: pixelSize,
color: Cesium.Color.fromCssColorString(wpColor),
outlineColor: Cesium.Color.fromCssColorString(wpOutline),
outlineWidth: wpOutlineW,
disableDepthTestDistance: Number.POSITIVE_INFINITY
},
label: {
text: wpName,
font: `${Math.max(9, pixelSize + 2)}px MicroSoft YaHei`,
pixelOffset: new Cesium.Cartesian2(0, -Math.max(14, pixelSize + 8)),
fillColor: Cesium.Color.WHITE,
outlineColor: Cesium.Color.BLACK,
outlineWidth: 2,
style: Cesium.LabelStyle.FILL_AND_OUTLINE
}
});
});
finalPathPositions.push(...arcPoints);
lastPos = arcPoints[arcPoints.length - 1];
} else {
@ -1058,19 +1127,7 @@ export default {
}
}
}
const lineWidth = lineStyle.width != null ? lineStyle.width : 4;
const lineColor = lineStyle.color || '#ffffff';
const gapColor = lineStyle.gapColor != null ? lineStyle.gapColor : '#000000';
const dashLen = lineStyle.dashLength != null ? lineStyle.dashLength : 20;
const useDash = (lineStyle.style || 'dash') === 'dash';
const lineMaterial = useDash
? new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.fromCssColorString(lineColor),
gapColor: Cesium.Color.fromCssColorString(gapColor),
dashLength: dashLen
})
: Cesium.Color.fromCssColorString(lineColor);
// 线 Polyline
// 线 PolylinelineWidth/lineMaterial 线3
const routeEntity = this.viewer.entities.add({
id: lineId,
polyline: {

Loading…
Cancel
Save