燕山石化溯源三维电子沙盘-【前端】-Web
WX
2023-08-01 0d0582cc5352a60e5f7042df81e6153e70a9715e
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
import store from "@/store";
import { getRunAlarm, getRunWarning } from "@/api/api.js";
const menuTool = {
  toolMenu: null,
  toolFlag: null,
  oldLeftMenuId: "f1",
  newLeftMenuId: null,
  colorAll: {},
  squareOjb: [],
  CCpoi: [],
  WRpoi: [],
  SSpoi: [],
  YZZpoi: [],
  BJtext: "0条报警信息",
  YJtext: "0条预警信息",
  BJlist: [],
  YJlist: [],
  YJpoi: [],
  BJpoi: [],
  leftTools(res) {
    // this.closePoi();
    // this.closeSYWG();
 
    this.clearLeftTools({ id: this.oldLeftMenuId });
    this.oldLeftMenuId = res.id;
    switch (res.id) {
      case "a2": //精准溯源
        window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 5100, {
          heading: -90,
        });
        this.createJKpoi();
        break;
      case "a3": //智能报告
        break;
      case "b2": //超标点预测
        window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 7200, {
          heading: -90,
        });
        break;
      case "b3": //污染物扩散趋势
        window.sgworld.Core.postMessage({ TypeG1: "Loop", LG1: "1" });
        window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 7200, {
          heading: -90,
        });
        break;
 
      case "c2": //预警信息
        break;
      case "c3": //报警信息
        break;
 
      case "d2": //风场模拟
        window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 7200, {
          heading: -90,
        });
        this.createFC("fc");
        break;
      case "d3": //污染物模拟
        window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 7200, {
          heading: -90,
        });
        this.createWRW("wrw");
        break;
      case "d4": //监控点位
        window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 5100, {
          heading: -90,
        });
        this.createJKpoi();
        break;
      case "d5": //排放点位
        window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 5100, {
          heading: -90,
        });
        this.createPFpoi();
        break;
      case "d6": //天气特效
        break;
 
      case "e2": //阈值设置
        break;
      case "e3": //系统说明
        break;
    }
  },
 
  clearLeftTools(res) {
    switch (res.id) {
      case "a1": //精准溯源清除
        store.commit("getWGobj", null);
        this.closePoi();
        this.closeSYWG();
        this.delLine();
        this.delFC();
        break;
      case "a2": //精准溯源清除
        store.commit("getWGobj", null);
        this.closePoi();
        this.closeSYWG();
        this.delLine();
        this.delFC();
        break;
      case "a3": //智能报告清除
        break;
      case "b1": //超标点预测清除
        window.sgworld.Core.postMessage({ TypeG1: "Delete" });
        this.delLine();
        store.commit("getWGobj", null);
        break;
      case "b2": //超标点预测清除
        window.sgworld.Core.postMessage({ TypeG1: "Delete" });
        this.delLine();
        store.commit("getWGobj", null);
        break;
      case "b3": //污染物扩散趋势清除
        window.sgworld.Core.postMessage({ TypeG1: "Delete" });
        break;
      case "c1": //预警信息清除报警信息清除
        this.closePoi();
        this.delFC();
        this.delLine();
        this.closeSYWG();
        break;
      case "c2": //预警信息清除
        this.closePoi();
        this.delFC();
        this.delLine();
        this.closeSYWG();
        break;
      case "c3": //报警信息清除
        this.closePoi();
        this.delFC();
        this.delLine();
        break;
      case "d1": //
        this.closePoi();
        this.delFC();
        this.delWRW();
        break;
      case "d2": //风场模拟清除
        this.delFC();
        break;
      case "d3": //污染物模拟清除
        this.delWRW();
        break;
      case "d4": //监控点位清除
        this.closePoi();
        break;
      case "d5": //排放点位清除
        this.closePoi();
        break;
      case "d6": //天气特效清除
        break;
 
      case "e2": //阈值设置清除
        break;
      case "e3": //系统说明清除
        break;
    }
  },
  //监控点位
  createJKpoi() {
    var jkpoiData = JSON.parse(JSON.stringify(store.state.jkList));
    var CCpoiData = JSON.parse(JSON.stringify(store.state.ccList));
    CCpoiData.forEach((e) => {
      let ids = sgworld.Core.createRandomId();
      if (!e.imgurl) {
        e.imgurl = "img/CJJCZ.png";
      }
      this.createPoi(e, e.imgurl, ids, "name", "CJ", -25);
      this.CCpoi.push(ids);
    });
    jkpoiData.forEach((e) => {
      let ids = sgworld.Core.createRandomId();
      if (!e.imgurl) {
        e.imgurl = "img/WYW.png";
      }
      this.createPoi(e, e.imgurl, ids, "name", "WY", -25);
      this.WRpoi.push(ids);
    });
  },
  //排放点位
  createPFpoi() {
    store.state.yzList.forEach((e) => {
      let ids = window.sgworld.Core.createRandomId();
      this.createPoi(e, "img/YZI1.png", ids, "name", "WY", -35);
      this.YZZpoi.push(ids);
    });
 
    // getPOI("有组织排放", "YZ", "YZZpoi", "img/YZI1.png");
    setTimeout(() => {
      // getPOI("实时排放", "SS", "SSpoi", "img/SS.png");
      store.state.ssList.forEach((e) => {
        let ids = window.sgworld.Core.createRandomId();
        this.createPoi(e, "img/SS.png", ids, "name", "CJ", -35);
        this.SSpoi.push(ids);
      });
    }, 500);
  },
  //预警点位
  createYJpoi() {
    this.closePoi();
    this.YJlist.forEach((e) => {
      let ids = window.sgworld.Core.createRandomId();
      this.createPoi(e, "img/yjd.png", ids, "locationName", "WY", -25);
      this.YJpoi.push(ids);
    });
  },
  //报警点位
  createBJpoi() {
    this.closePoi();
    this.BJlist.forEach((e) => {
      let ids = window.sgworld.Core.createRandomId();
      this.createPoi(e, "img/bjd.png", ids, "locationName", "WY", -25);
      this.BJpoi.push(ids);
    });
  },
  //创建poi点
  createPoi(e, img, id, name, type, fontOffsetY) {
    var poi = window.sgworld.Creator.createBillboard({
      id: id,
      lon: e.lon, //经度
      lat: e.lat, //纬度
      height: 150, //高度
      text: e[name], //文本内容
      textLocation: "up", //文本位置
      fontSize: 16, //文本字体大小
      fontColor: "#00D2FF", //字体颜色
      fontOffset: {
        //文本自定义偏移量
        x: 0,
        y: fontOffsetY,
      },
 
      image: `${imgUrl}${img}`, //POI图标地址
      distanceDisplayCondition: {
        near: 0,
        far: 5500,
      },
      data: {
        name: e[name],
        type: type,
      },
      scale: 0.4,
      clickedScale: 0.4,
      POIName: "",
    });
  },
  //关闭poi点
  closePoi() {
    if (this.CCpoi.length != 0) {
      this.CCpoi.forEach((e) => {
        window.sgworld.ProjectTree.deleteItem(e);
      });
      this.CCpoi = [];
    }
    if (this.WRpoi.length != 0) {
      this.WRpoi.forEach((e) => {
        window.sgworld.ProjectTree.deleteItem(e);
      });
      this.WRpoi = [];
    }
    if (this.SSpoi.length != 0) {
      this.SSpoi.forEach((e) => {
        window.sgworld.ProjectTree.deleteItem(e);
      });
      this.SSpoi = [];
    }
    if (this.YZZpoi.length != 0) {
      this.YZZpoi.forEach((e) => {
        window.sgworld.ProjectTree.deleteItem(e);
      });
      this.YZZpoi = [];
    }
    if (this.YJpoi.length != 0) {
      this.YJpoi.forEach((e) => {
        window.sgworld.ProjectTree.deleteItem(e);
      });
      this.YJpoi = [];
    }
    if (this.BJpoi.length != 0) {
      this.BJpoi.forEach((e) => {
        window.sgworld.ProjectTree.deleteItem(e);
      });
      this.BJpoi = [];
    }
  },
  //关闭溯源网格
  closeSYWG() {
    sgworld.Core.postMessage({ type: "delete" });
  },
  //风场模拟
  createFC(type, date) {
    if (type == "fc") {
      sgworld.Core.postMessage(
        `Type=shunxuwinds;Bool=true;Density=${FC.Density};Speed=${FC.Speed};`
      );
    } else if (type == "sj") {
      let arr = date.split(/\s+/);
 
      let day = arr[0].split("-");
 
      let Hour = arr[1];
 
      sgworld.Core.postMessage(
        `Type=customewinds;Bool=true;Year=${day[0]};Mouth=${day[1]};Day=${day[2]};Hour=${Hour};Density=${FC.Density};Speed=${FC.Speed};`
      );
      // console.log(
      //   `Type=customewinds;Bool=true;Year=${day[0]};Mouth=${day[1]};Day=${day[2]};Hour=${Hour[0]};Density=${FC.Density};Speed=${FC.Speed};`
      // );
    } else {
    }
  },
  //风场删除
  delFC() {
    sgworld.Core.postMessage("Type=customewinds;Bool=false;");
    sgworld.Core.postMessage("Type=shunxuwinds;Bool=false;");
  },
  //污染物删除
  delWRW() {
    sgworld.Core.postMessage("Type=wuranwu;Bool=false;");
    sgworld.Core.postMessage("Type=wuranwu;Type2=zidingyi;Bool=false;");
  },
  //污染物
  createWRW(type, date) {
    if (type == "wrw") {
      sgworld.Core.postMessage(
        "Type=wuranwu;Bool=true;Type2=zidong;Alpha=0.03;Speed=2;"
      );
    } else if (type == "sj") {
      let arr = date.split(/\s+/);
 
      let day = arr[0].split("-");
 
      let Hour = arr[1];
      sgworld.Core.postMessage(
        `Type=wuranwu;Bool=true;Type2=zidingyi;Yearstart=${day[0]};Mouthstart=${day[1]};Daystart=${day[2]};Hourend=${Hour};Alpha=0.03;Speed=0.5;`
      );
    }
  },
  async bjthis(time) {
    this.BJlist = [];
 
    const dt = await getRunAlarm(time);
 
    var obj = {};
    this.BJlist = dt.result.reduce(function (item, next) {
      obj[next.locationName]
        ? ""
        : (obj[next.locationName] = true && item.push(next));
      return item;
    }, []);
 
    // this.BJtext = `${this.BJlist.length}条报警信息`;
 
    store.commit("getBJlist", this.BJlist);
    this.createBJpoi();
    return dt.result;
  },
  async yjthis(time) {
    this.YJlist = [];
    const dt1 = await getRunWarning(time);
    // this.YJlist = dt1.result;
    // this.YJlist = this.YJlist.filter((item, index) => {
    //   return item.id !== this.YJlist[index + 1].id;
    // });
    var obj = {};
    this.YJlist = dt1.result.reduce(function (item, next) {
      obj[next.locationName]
        ? ""
        : (obj[next.locationName] = true && item.push(next));
      return item;
    }, []);
 
    // this.YJtext = `${this.YJlist.length}条预警信息`;
    store.commit("getYJtext", this.YJlist);
    this.createYJpoi();
    return dt1.result;
  },
  //删除连线
  delLine() {
    sgworld.Core.postMessage({ func_name: "RemoveGridLines", id: "" });
    //删除边界
    sgworld.Core.postMessage({ func_name: "RemoveGridSide", id: "" });
  },
};
export default menuTool;