guonan
2025-04-18 d0272e6a4e5b68c4e82e7356849f6ceb402a1055
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<template>
  <Left @start="startSimulate" @end="endSimulate" />
  <echartInfo :isDynamicMode="isDynamicMode" :isFinish="isFinish" />
  <TimeLine
    v-if="showWaterSimulate"
    @time-update="timeUpdate"
    @is-playing="isPlaying"
    :waterSimulateParams="waterSimulateParams"
    @playbackFinished="playbackFinished"
    @end="endSimulate"
  />
  <DebuffDetail
    v-if="showDebuffDetail"
    @open="openDetail"
    @close="showDebuffDetail = false"
  />
  <DebuffTable v-if="showDebuffTable" @close="closeDebuffTable" />
</template>
 
<script setup>
import { ref, onMounted, onUnmounted, provide } from "vue";
import TimeLine from "@/components/menu/TimeLine.vue";
import Left from "./left/Left.vue";
import echartInfo from "@/components/monifangzhen/echartInfo.vue";
import DebuffDetail from "@/components/tools/DebuffDetail.vue";
import DebuffTable from "@/components/tools/DebuffTable.vue";
import { getMaxInfluenceArea } from "@/api/index";
 
import { createPoint, geomToGeoJSON } from "@/utils/map.js";
 
import colors from "@/assets/img/left/colors3.png";
import { checkedKeys } from "@/store/index";
const waterSimulateParams = ref({});
const showWaterSimulate = ref(false);
const showDebuffDetail = ref(false);
const showDebuffTable = ref(false);
const isDynamicMode = ref(false);
const isFinish = ref(true);
 
// 提供方法给所有子组件
provide("simulateActions", {
  startSimulate,
  endSimulate,
});
 
function startSimulate(form) {
  // console.log("form", form);
  showWaterSimulate.value = true;
  waterSimulateParams.value = form;
}
function endSimulate() {
  // showDebuffDetail.value = true
  removeDataSources();
  setTimeout(() => {
    showWaterSimulate.value = false;
    isDynamicMode.value = false;
  }, 2000);
}
const MaxInfluenceAreaList = ref([]);
const dataSources = [];
function getTimeMarkers() {
  // 将 list 数据的 geom EPSG:4548 坐标转换为 WGS84 坐标系的 GeoJSON 数据
  const list = MaxInfluenceAreaList.value;
  list.forEach((item, index) => {
    const geojson = geomToGeoJSON(item.geom);
    Cesium.GeoJsonDataSource.load(geojson).then((dataSource) => {
      // 设置样式,将颜色改为红色
      dataSource.entities.values.forEach((entity) => {
        entity.polygon.material = new Cesium.Color(1.0, 0.0, 0.0, 0.6); // 红色,80% 不透明度
        entity.polygon.outlineColor = Cesium.Color.YELLOW; // 设置轮廓颜色为红色(如果需要)
        entity.polygon.outline = true; // 显示轮廓(如果需要)
      });
 
      // 添加数据源到 viewer
      viewer.dataSources.add(dataSource);
      dataSources.push(dataSource);
    });
  });
}
function removeDataSources() {
  dataSources.forEach((dataSource) => {
    viewer.dataSources.remove(dataSource);
  });
}
let TrailLine = [];
async function showLine() {
  const position = [
    {
      x: -2172540.8322597803,
      y: 4339064.62665997,
      z: 4126183.3895281963,
    },
    {
      x: -2172480.18394144,
      y: 4339033.15167176,
      z: 4126240.9529584926,
    },
    {
      x: -2172454.114348403,
      y: 4339020.0398392705,
      z: 4126261.946960697,
    },
    {
      x: -2172377.9670952093,
      y: 4338976.609385458,
      z: 4126333.862357211,
    },
    {
      x: -2172299.4142002705,
      y: 4338951.971578909,
      z: 4126397.5205803993,
    },
    {
      x: -2172245.1703274297,
      y: 4338940.86037857,
      z: 4126436.276389208,
    },
    {
      x: -2172176.7332184147,
      y: 4338930.525741544,
      z: 4126477.629952572,
    },
    {
      x: -2172173.8151051304,
      y: 4338939.043883864,
      z: 4126469.336927342,
    },
    {
      x: -2172173.7151194704,
      y: 4338939.023235937,
      z: 4126469.4107743693,
    },
  ];
  let LineInterpolation = earthCtrl.core.LineInterpolation(earthCtrl.coreMap, {
    positions: position,
    num: 50,
    getHeight: true,
  });
  // console.log(LineInterpolation.height, "A");
 
  let min = LineInterpolation.height;
  let max = min.map((item) => {
    return item + 35;
  });
 
  console.log(min, max);
 
  let _TrailLine = earthCtrl.factory.createTrailLineWall(
    LineInterpolation.positions,
    {
      maximumHeights: max,
      minimumHeights: min,
      color: "#ffffff", //线颜色(可选)
      url: colors,
    }
  );
  TrailLine.push(_TrailLine);
}
// function showLine() {
//   earthCtrl.factory.createSimpleGraphic(
//     "polyline",
//     { clampToGround: true },
//     (entity) => {
//       if (entity) {
//         const position = [
//           {
//             x: -2172540.8322597803,
//             y: 4339064.62665997,
//             z: 4126183.3895281963,
//           },
//           {
//             x: -2172480.18394144,
//             y: 4339033.15167176,
//             z: 4126240.9529584926,
//           },
//           {
//             x: -2172454.114348403,
//             y: 4339020.0398392705,
//             z: 4126261.946960697,
//           },
//           {
//             x: -2172377.9670952093,
//             y: 4338976.609385458,
//             z: 4126333.862357211,
//           },
//           {
//             x: -2172299.4142002705,
//             y: 4338951.971578909,
//             z: 4126397.5205803993,
//           },
//           {
//             x: -2172245.1703274297,
//             y: 4338940.86037857,
//             z: 4126436.276389208,
//           },
//           {
//             x: -2172176.7332184147,
//             y: 4338930.525741544,
//             z: 4126477.629952572,
//           },
//           {
//             x: -2172173.8151051304,
//             y: 4338939.043883864,
//             z: 4126469.336927342,
//           },
//           {
//             x: -2172173.7151194704,
//             y: 4338939.023235937,
//             z: 4126469.4107743693,
//           },
//         ];
//         // console.log("positions", positions);
//         addWall(position, [entity]);
 
//         earthCtrl.factory.SimpleGraphic.remove(entity.id);
//       }
//     }
//   );
// }
function timeUpdate(percentage) {
  if (percentage > 99) {
    if (showDebuffDetail.value) {
      return;
    }
    checkedKeys.value = ["避险点"];
    showDebuffDetail.value = true;
    getTimeMarkers();
    showLine();
  }
}
function openDetail() {
  showDebuffTable.value = true;
}
function closeDebuffTable() {
  showDebuffTable.value = false;
  showDebuffDetail.value = true;
}
function getMaxInfluenceAreaData() {
  getMaxInfluenceArea().then((res) => {
    MaxInfluenceAreaList.value = res.data.items;
  });
}
 
function isPlaying(val) {
  isDynamicMode.value = val;
}
 
function playbackFinished(val) {
  isFinish.value = val;
}
onMounted(() => {
  getMaxInfluenceAreaData();
});
onUnmounted(() => {
  endSimulate();
});
</script>
<style lang="less" scoped>
@import url("../assets/css/home.css");
</style>