From 6cc17bd234d981ef06cf8e888a1d4b8a14f51f41 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期四, 10 七月 2025 11:14:16 +0800
Subject: [PATCH] 断面

---
 src/components/menu/CrossSectionalAnalysis.vue |  247 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 177 insertions(+), 70 deletions(-)

diff --git a/src/components/menu/CrossSectionalAnalysis.vue b/src/components/menu/CrossSectionalAnalysis.vue
index 284efa0..b4478aa 100644
--- a/src/components/menu/CrossSectionalAnalysis.vue
+++ b/src/components/menu/CrossSectionalAnalysis.vue
@@ -1,24 +1,87 @@
 <template>
 	<div style="display: flex; justify-content: space-between;">
-		<div @click="initPickHandler">
-			<img v-if="!isPicking" src="@/assets/img/timeline/鏂潰.png" style="width: 26px;height: 26px;" />
-			<img v-else src="@/assets/img/timeline/宸叉柇闈�.png" style="width: 26px;height: 26px;" />
-		</div>
-		<div @click="confirmPoints">
-			<img v-if="!isUploaded" src="@/assets/img/timeline/涓婁紶.png" style="width: 26px;height: 26px;" />
-			<img v-else src="@/assets/img/timeline/宸蹭笂浼�.png" style="width: 26px;height: 26px;" />
-		</div>
-		<div @click="clearPoints">
-			<img src="@/assets/img/timeline/娓呴櫎.png" style="width: 26px;height: 26px;" />
-		</div>
+		<!-- 绗竴涓寜閽細閫夊彇鏂潰鐐� -->
+		<el-tooltip placement="top" show-after="1000">
+			<template #content>
+				鏂潰鍒嗘瀽鍔熻兘璇存槑锛�
+				<br /><br />
+				馃敼 鐐瑰嚮鎸夐挳鍒囨崲鐘舵�侊細
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;- 鐧借壊锛氬叧闂嬀鍙栧姛鑳斤紙涓嶅彲閫夌偣锛�
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;- 榛勮壊锛氬紑鍚嬀鍙栧姛鑳斤紙鍙偣鍑诲湴鍥鹃�夋嫨2涓柇闈㈢偣锛�
+				<br /><br />
+				馃敼 浣跨敤娴佺▼锛�
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;1. 鐐瑰嚮鎸夐挳鍒囨崲涓洪粍鑹� 鉃� 寮�濮嬫嬀鍙栧潗鏍囩偣
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;2. 鍦ㄥ湴鍥句笂鐐瑰嚮閫夋嫨 2 涓柇闈㈢偣锛堝闇�淇敼锛屽彲閲嶆柊鐐瑰嚮锛�
+				<br /><br />
+				鈿狅笍 娓╅Θ鎻愮ず锛�
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;姣忔鍙兘鍒嗘瀽涓�鏉℃矡娓犵殑鏂潰锛屽涓柇闈㈠彲鑳藉鑷磋绠楀紓甯革紱
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;浣跨敤瀹屾瘯璇峰皢鎸夐挳鍒囧洖鐧借壊锛岄伩鍏嶅奖鍝嶅叾浠栧姛鑳姐��
+			</template>
+			<div @click="initPickHandler" :class="{ active: isPicking }">
+				<img v-if="!isPicking" src="@/assets/img/timeline/鏂潰.png" style="width: 26px;height: 26px;" />
+				<img v-else src="@/assets/img/timeline/宸叉柇闈�.png" style="width: 26px;height: 26px;" />
+			</div>
+		</el-tooltip>
+
+		<!-- 绗簩涓寜閽細涓婁紶骞跺垎鏋愭柇闈� -->
+		<el-tooltip placement="top" show-after="1000">
+			<template #content>
+				涓婁紶骞跺垎鏋愭柇闈㈡暟鎹細
+				<br /><br />
+				馃搶 鏉′欢闄愬埗锛�
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;浠呭綋鎴愬姛閫夋嫨 2 涓柇闈㈢偣鍚庢墠鍙偣鍑�
+				<br /><br />
+				馃攣 鍔熻兘璇存槑锛�
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;鐐瑰嚮鍚庡皢瀵瑰綋鍓嶆柇闈㈣繘琛屽垎鏋愶紝绋嶇瓑鐗囧埢鍗冲彲鍦ㄥ浘琛ㄥ尯鍩熸煡鐪嬬粨鏋�
+				<br /><br />
+				鈿狅笍 娉ㄦ剰浜嬮」锛�
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;璇ュ姛鑳戒粎鏀寔鍗曟潯娌熸笭鍒嗘瀽锛屽涓柇闈㈠彲鑳藉鑷磋绠椾笉绋冲畾鎴栧嚭閿�
+			</template>
+			<div @click="confirmPoints" :class="{ disabled: !isReadyForUpload }">
+				<img v-if="!isUploaded" src="@/assets/img/timeline/涓婁紶.png" style="width: 26px;height: 26px;" />
+				<img v-else src="@/assets/img/timeline/宸蹭笂浼�.png" style="width: 26px;height: 26px;" />
+			</div>
+		</el-tooltip>
+
+		<!-- 绗笁涓寜閽細娓呴櫎鎵�鏈夌偣鍜屽垎鏋愮粨鏋� -->
+		<el-tooltip placement="top" show-after="1000">
+			<template #content>
+				娓呴櫎鎵�鏈夋柇闈㈢偣鍙婂垎鏋愮粨鏋滐細
+				<br /><br />
+				馃攣 鍔熻兘璇存槑锛�
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;鐐瑰嚮鍚庡皢绉婚櫎鍦板浘涓婄殑鎵�鏈夋柇闈㈢偣浠ュ強鐩稿叧鍒嗘瀽鍥捐〃
+				<br /><br />
+				鈿狅笍 娓╅Θ鎻愮ず锛�
+				<br />
+				&nbsp;&nbsp;&nbsp;&nbsp;姝ゆ搷浣滀細娓呯┖褰撳墠鍒嗘瀽杩涘害锛岃纭鍚庡啀鎵ц
+			</template>
+			<div @click="clearPoints">
+				<img src="@/assets/img/timeline/娓呴櫎.png" style="width: 26px;height: 26px;" />
+			</div>
+		</el-tooltip>
 	</div>
 </template>
 
 <script setup>
 import { ElMessage } from 'element-plus';
 import { ref, onMounted, defineExpose } from "vue";
-
+import { getCrossSection } from '@/api/trApi.js'; // 鍋囪浣犳湁鐪熷疄鎺ュ彛
+import { useSimStore } from '@/store/simulation';
+import { storeToRefs } from 'pinia';
+const simStore = useSimStore();
+const { selectedScheme } = storeToRefs(simStore);
 const viewer = window.viewer;
+let selectedSchemeId = selectedScheme.value.id
 
 let pickedPointsCross = ref([]);
 let pickHandlerCross = null;
@@ -52,7 +115,13 @@
 // 閫夊彇涓や釜鏂潰鐐瑰潗鏍囧苟缁樺埗鏂潰鎴潰
 function addPointToViewer(point) {
 	if (pickedPointsCross.value.length >= 2) {
-		clearPoints();
+		for (const id of pickedEntitiesIds.value) {
+			viewer.entities.remove(viewer.entities.getById(id));
+		}
+		pickedPointsCross.value = [];
+		pickedEntitiesIds.value = [];
+		isWallCreated.value = false;
+		isUploaded.value = false;
 	}
 	pickedPointsCross.value.push(point);
 	drawPointOnMap(point);
@@ -72,7 +141,9 @@
 			color: Cesium.Color.RED,
 			outlineColor: Cesium.Color.YELLOW,
 			outlineWidth: 2,
-			pixelSize: 8 // 鍦嗙偣鍗婂緞澶у皬
+			pixelSize: 8,// 鍦嗙偣鍗婂緞澶у皬
+			distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000),
+
 		}
 	});
 	pickedEntitiesIds.value.push(entity.id); // 璁板綍瀹炰綋ID
@@ -85,6 +156,8 @@
 			positions: [startPoint.cartesian, endPoint.cartesian],
 			material: Cesium.Color.YELLOW,
 			heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
+			distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000),
+
 		}
 	});
 	pickedEntitiesIds.value.push(entity.id); // 璁板綍瀹炰綋ID
@@ -94,59 +167,59 @@
 
 // 鏂板锛氱粯鍒舵ā鎷熺偣锛堝渾鏌� + label锛�
 function drawSimulationPoint(start, end) {
-// 璁$畻涓偣锛堢粡绾害骞冲潎鍊硷級
-const midLon = (start.longitude + end.longitude) / 2;
-const midLat = (start.latitude + end.latitude) / 2;
-const terrainHeight = viewer.scene.globe.getHeight(
-	Cesium.Cartographic.fromDegrees(midLon, midLat)
-);
+	// 璁$畻涓偣锛堢粡绾害骞冲潎鍊硷級
+	const midLon = (start.longitude + end.longitude) / 2;
+	const midLat = (start.latitude + end.latitude) / 2;
+	const terrainHeight = viewer.scene.globe.getHeight(
+		Cesium.Cartographic.fromDegrees(midLon, midLat)
+	);
 
-const cylinderBottomHeight = 0;
-const cylinderTopHeight = terrainHeight + 190;
-const cartesianBottom = viewer.scene.globe.ellipsoid.cartographicToCartesian(
-	Cesium.Cartographic.fromDegrees(midLon, midLat, cylinderBottomHeight)
-);
-const CrosscylinderEntity = viewer.entities.add({
-	position: cartesianBottom,
-	cylinder: {
-		length: 190.0,
-		topRadius: 1.0,
-		bottomRadius: 1.0,
-		material: Cesium.Color.YELLOW,
-		outline: true,
-		outlineColor: Cesium.Color.YELLOW,
-		slices: 64,
-		heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
-		distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000)
-	}
-});
-const labelHeight = cylinderTopHeight + 10;
-const cartesianLabel = viewer.scene.globe.ellipsoid.cartographicToCartesian(
-	Cesium.Cartographic.fromDegrees(midLon, midLat, labelHeight)
-);
+	const cylinderBottomHeight = 0;
+	const cylinderTopHeight = terrainHeight + 100;
+	const cartesianBottom = viewer.scene.globe.ellipsoid.cartographicToCartesian(
+		Cesium.Cartographic.fromDegrees(midLon, midLat, cylinderBottomHeight)
+	);
+	const CrosscylinderEntity = viewer.entities.add({
+		position: cartesianBottom,
+		cylinder: {
+			length: 100.0,
+			topRadius: 1.0,
+			bottomRadius: 1.0,
+			material: Cesium.Color.YELLOW,
+			outline: true,
+			outlineColor: Cesium.Color.YELLOW,
+			slices: 64,
+			heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
+			distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000)
+		}
+	});
+	const labelHeight = cylinderTopHeight + 10;
+	const cartesianLabel = viewer.scene.globe.ellipsoid.cartographicToCartesian(
+		Cesium.Cartographic.fromDegrees(midLon, midLat, labelHeight)
+	);
 
-const CrosslabelEntity = viewer.entities.add({
-	position: cartesianLabel,
-	label: {
-		text: '鏂潰鎴潰妯℃嫙鐐�',
-		font: 'bold 14pt monospace',
-		style: Cesium.LabelStyle.FILL_AND_OUTLINE,
-		fillColor: Cesium.Color.YELLOW,
-		outlineColor: Cesium.Color.BLACK,
-		outlineWidth: 2,
-		verticalOrigin: Cesium.VerticalOrigin.CENTER,
-		horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
-		backgroundColor: Cesium.Color.fromCssColorString('rgba(0,0,0,0.7)'),
-		backgroundPadding: new Cesium.Cartesian2(10, 10),
-		showBackground: true,
-		scale: 1,
-		distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000),
-		pixelOffsetScaleByDistance: new Cesium.NearFarScalar(100, 1.0, 5000, 0.3),
-		heightReference: Cesium.HeightReference.NONE // 浣跨敤缁濆楂樺害
-	}
-});
-pickedEntitiesIds.value.push(CrosscylinderEntity.id);
-pickedEntitiesIds.value.push(CrosslabelEntity.id);
+	const CrosslabelEntity = viewer.entities.add({
+		position: cartesianLabel,
+		label: {
+			text: '鏂潰鎴潰妯℃嫙鐐�',
+			font: 'bold 14pt monospace',
+			style: Cesium.LabelStyle.FILL_AND_OUTLINE,
+			fillColor: Cesium.Color.YELLOW,
+			outlineColor: Cesium.Color.BLACK,
+			outlineWidth: 2,
+			verticalOrigin: Cesium.VerticalOrigin.CENTER,
+			horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
+			backgroundColor: Cesium.Color.fromCssColorString('rgba(0,0,0,0.7)'),
+			backgroundPadding: new Cesium.Cartesian2(10, 10),
+			showBackground: true,
+			scale: 1,
+			distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000),
+			pixelOffsetScaleByDistance: new Cesium.NearFarScalar(100, 1.0, 5000, 0.3),
+			heightReference: Cesium.HeightReference.NONE // 浣跨敤缁濆楂樺害
+		}
+	});
+	pickedEntitiesIds.value.push(CrosscylinderEntity.id);
+	pickedEntitiesIds.value.push(CrosslabelEntity.id);
 }
 function clearPoints() {
 	for (const id of pickedEntitiesIds.value) {
@@ -156,6 +229,13 @@
 	pickedEntitiesIds.value = [];
 	isWallCreated.value = false;
 	isUploaded.value = false;
+	if (pickHandlerCross) {
+		pickHandlerCross.destroy();
+		pickHandlerCross = null;
+	}
+	isPicking.value = false;
+	console.log('杩欓噷鍙戦�佽姹傦紝娓呯┖閮鐨別charts2');
+	
 }
 function initPickHandler() {
 	if (isPicking.value) {
@@ -165,7 +245,7 @@
 		}
 		isPicking.value = false;
 		// isUploaded.value = false;
-		
+
 		ElMessage.info('宸插叧闂�--鏂潰鎴潰--鎷惧彇鐐瑰潗鏍囧姛鑳斤紒');
 		return;
 	}
@@ -187,7 +267,9 @@
 
 	pickHandlerCross.setInputAction(clickAction, Cesium.ScreenSpaceEventType.LEFT_CLICK);
 }
-function confirmPoints() {
+async function confirmPoints() {
+	console.log(selectedSchemeId,'杩欓噷鎷跨殑鏄柟妗堢殑鏁版嵁');
+	
 	if (pickedPointsCross.value.length < 2) {
 		ElMessage.warning('璇峰厛閫夋嫨涓や釜鐐瑰悗鍐嶈繘琛岀‘璁わ紒');
 		return;
@@ -195,6 +277,7 @@
 
 	const point1 = pickedPointsCross.value[0];
 	const point2 = pickedPointsCross.value[1];
+console.log(point1,point2);
 
 	console.log('绗竴涓偣淇℃伅锛�', {
 		longitude: point1.longitude,
@@ -207,11 +290,35 @@
 		latitude: point2.latitude,
 		cartesian: point2.cartesian
 	});
-
-	isUploaded.value = true; 
+	const startPoint = `${point1.longitude},${point1.latitude}`;
+	const endPoint = `${point2.longitude},${point2.latitude}`;
+	const result = await getCrossSectionInfo(startPoint, endPoint);
+	simStore.crossSection = result
+	console.log(result,'杩欓噷鏄儹妤犻渶瑕佺殑鏂潰鏁版嵁');
+	
+	isUploaded.value = true;
 	ElMessage.success('姝e湪杩涜--鏂潰鎴潰--鏁版嵁鍒嗘瀽涓婁紶锛岃绋嶇瓑...');
+	
 }
-
+  // 鑾峰彇鐪熷疄鏁版嵁
+function getCrossSectionInfo(a, b) {
+  const params = {
+    startPoint: a,
+    endPoint: b,
+    id: selectedSchemeId
+  };
+  return getCrossSection(params).then(data => {
+    if (data && data.code === 200) {
+      return data.data; // 杩斿洖鍘熷鏁版嵁鏁扮粍
+    } else {
+      return [];
+    }
+  }).catch(error => {
+    console.error('鑾峰彇鏁版嵁鏃跺彂鐢熼敊璇�:', error);
+    ElMessage.warning('鏁版嵁鏈夎锛岃鑱旂郴绠$悊鍛樻垨閲嶆柊杩涜妯℃嫙锛�');
+    return [];
+  });
+}
 defineExpose({
 	clearPoints
 });

--
Gitblit v1.9.3