| | |
| | | import { useSimStore } from "@/store/simulation"; |
| | | import { storeToRefs } from "pinia"; |
| | | const simStore = useSimStore(); |
| | | const { selectedScheme } = storeToRefs(simStore); |
| | | const { selectedScheme, currentInfo } = storeToRefs(simStore); |
| | | import { EventBus } from "@/eventBus"; |
| | | |
| | | const pickedPoints = ref([]); |
| | | const handler = ref(null); |
| | |
| | | const schemeInfo = selectedScheme.value; |
| | | serviceInfo = schemeInfo.serviceName; |
| | | |
| | | // 如果已有选中点,则先清除 |
| | | if (pickedPoints.value.length >= 1) { |
| | | endCalculation(); // 清除所有已有点 |
| | | } |
| | | |
| | | // 创建 label 实体 |
| | | const labelEntity = viewer.entities.add({ |
| | | position: point.cartesian, |
| | | label: { |
| | | text: `测量点 ${pickedPoints.value.length + 1}\n水深: 等待启动...\n流速: 等待启动...`, |
| | | text: `测量点\n水深: 等待启动...\n流速: 等待启动...`, |
| | | font: 'bold 14pt monospace', |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | fillColor: Cesium.Color.YELLOW, |
| | |
| | | pixelOffsetScaleByDistance: new Cesium.NearFarScalar(100, 1.0, 5000, 0.3), |
| | | } |
| | | }); |
| | | |
| | | const groundPosition = Cesium.Cartesian3.fromRadians( |
| | | point.longitude * Math.PI / 180, |
| | | point.latitude * Math.PI / 180, |
| | |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000) |
| | | } |
| | | }); |
| | | |
| | | // 存储实体引用之前就更新 currentInfo |
| | | currentInfo.value = { |
| | | longitude: point.longitude, |
| | | latitude: point.latitude, |
| | | serviceInfo: serviceInfo |
| | | }; |
| | | // 请求数据并更新 label |
| | | getFlowRateInfo(point.longitude, point.latitude, displayTime).then(result => { |
| | | updateLabel(pickedPoints.value.length - 1, result.depth, result.velocity); |
| | | updateLabel(pickedPoints.value.length, result.depth, result.velocity); |
| | | }); |
| | | |
| | | // 存储实体引用 |
| | | pickedPoints.value.push({ |
| | | labelEntity, |
| | | cylinderEntity, // 使用圆柱代替 line 和 circle |
| | | cylinderEntity, |
| | | longitude: point.longitude, |
| | | latitude: point.latitude |
| | | }); |
| | |
| | | ); |
| | | |
| | | async function updateAllLabels() { |
| | | for (const pointInfo of pickedPoints.value) { |
| | | for (let i = 0; i < pickedPoints.value.length; i++) { |
| | | const pointInfo = pickedPoints.value[i]; |
| | | if (!pointInfo || !pointInfo.labelEntity) continue; |
| | | |
| | | const result = await getFlowRateInfo(pointInfo.longitude, pointInfo.latitude, currentTime.value); |
| | | updateLabel(pointInfo, result.depth, result.velocity); |
| | | updateLabel(i, result.depth, result.velocity); |
| | | } |
| | | } |
| | | |
| | | function updateLabel(pointInfo, depth, velocity) { |
| | | if (pointInfo.labelEntity && pointInfo.labelEntity.label) { |
| | | function updateLabel(index, depth, velocity) { |
| | | const pointInfo = pickedPoints.value[index]; |
| | | if (pointInfo && pointInfo.labelEntity && pointInfo.labelEntity.label) { |
| | | pointInfo.labelEntity.label.text = ` |
| | | 测量点 ${pickedPoints.value.findIndex(p => p === pointInfo) + 1} |
| | | 测量点 |
| | | 水深: ${depth} m |
| | | 流速: ${velocity} m/s |
| | | `.trim(); |
| | |
| | | if (pointInfo.cylinderEntity) viewer.entities.remove(pointInfo.cylinderEntity); |
| | | }); |
| | | pickedPoints.value = []; |
| | | EventBus.emit("clear-water-depth"); |
| | | EventBus.emit("clear-water-velocity"); |
| | | |
| | | } |
| | | |
| | | defineExpose({ |
| | |
| | | serviceName: serviceInfo |
| | | }; |
| | | return getFlowRate(params).then(data => { |
| | | // console.log('获取到的数据:', data); |
| | | console.log('获取到的数据:', data); |
| | | if (data && data.code === 200) { |
| | | return { |
| | | depth: data.data.depth.toFixed(2), |