wr1207
2023-07-26 92afa1854f1e650e02a55e2d07e5fb5feafb5cd7
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
(function (window, mars3d) {
  //创建widget类,需要继承BaseWidget
  class MyWidget extends mars3d.widget.BaseWidget {
    //外部资源配置
    get resources() {
      return ["work/Sgmn1Sgfx.js", "work/Sgmn2Clmn.js", "work/Sgmn3Jymn.js"];
    }
 
    //弹窗配置
    get view() {
      return {
        type: "window",
        url: "view.html",
        windowOptions: {
          width: 358,
          position: {
            top: 50,
            bottom: 30,
            right: 10,
          },
        },
      };
    }
 
    //初始化[仅执行1次]
    create() {
      this.sgmn1Sgfx = new Sgmn1Sgfx(this.map);
      this.sgmn2Clmn = new Sgmn2Clmn(this.map);
      this.sgmn3Jymn = new Sgmn3Jymn(this.map);
    }
    //每个窗口创建完成后调用
    winCreateOK(opt, result) {
      this.viewWindow = result;
    }
    //打开激活
    activate() {}
    //关闭释放
    disable() {
      this.viewWindow = null;
      this.clearAll();
    }
    //定位到具体点
    locateById(x, y) {
      if (!x || !y) {
        return;
      }
      this.map.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(x, y, 2500),
        duration: 3,
        orientation: {
          heading: 0,
          pitch: Cesium.Math.toRadians(-90),
          roll: 0,
        },
      });
    }
    //结束模拟
    clearAll() {
      this.sgmn1Sgfx.clearAll();
      this.sgmn3Jymn.clearAll();
      this.sgmn2Clmn.clearAll();
      haoutil.loading.close();
    }
    //======================事故模拟=============================
    //开始 图上选择事故点
    startSelectSgd(callback) {
      this.sgmn1Sgfx.selectSgd(callback);
    }
    //移除事故点
    removeSgd() {
      this.sgmn1Sgfx.removeSgd();
    }
    //是否可以下一步(需要 选择了事故点)
    check1to2() {
      //this.stopDraw();
      //是否选择了点
      if (!this.sgmn1Sgfx.point || this.sgmn1Sgfx.point.length == 0) {
        window.toastr.error("请先选择事故点!");
        return false;
      }
      return true;
    }
    startSgmn(arg) {
      var that = this;
      //如果已有查询结果直接下一步,不用查询
      this.sgmn1Sgfx.start(arg, {
        timelineCallback: function (step) {
          //  同步时间轴
          var dis = that.sgmn1Sgfx.radiusX || 0;
          that.viewWindow.effactArea(dis);
          that.viewWindow.timeProgress(step);
          var comData = that.sgmn1Sgfx.YWpois;
          that.viewWindow.companyInfo(comData);
        },
        bootstrapTableCallback: function (data) {
          //同步bootstraptable表格
          that.viewWindow.affectInfo(data);
        },
      });
    }
    loadMorePOI() {
      var that = this;
      this.sgmn1Sgfx.loadMore(function (data) {
        that.viewWindow.moreTableList(data);
      });
    }
    //是否可以下一步(需要 事故模拟动画结束和查询完毕)
    check2to3() {
      //this.stopDraw();
      if (!this.sgmn1Sgfx.state) {
        window.toastr.error("请等待模拟结束!");
        return this.sgmn1Sgfx.state;
      }
      return this.sgmn1Sgfx.state; //事故模拟过程是否结束
    }
 
    //======================撤离模拟===============================
    startSelectCld(callback) {
      this.sgmn2Clmn.startSelectCld({
        lastEllipseData: this.sgmn1Sgfx.extentData,
        callback: callback,
      });
    }
    //是否可以下一步(需要 存在事故模拟查询到的点和设置了撤离点)
    check3to4() {
      //this.stopDraw();
      if (this.sgmn1Sgfx.point.length == 0) {
        haoutil.msg("没有受影响的点!");
        return false;
      }
      if (!this.sgmn2Clmn.points || this.sgmn2Clmn.points.length == 0) {
        haoutil.msg("请设置撤离点!");
        return false;
      }
      return true;
    }
    cheliDotNum() {
      return this.sgmn2Clmn.points.length;
    }
    //根据id删除对应的撤离点
    removeCLPointById(id) {
      if (!id) {
        return;
      }
      this.sgmn2Clmn.removePointById(id);
      this.sgmn2Clmn.removeLineAboutByPointId(id);
    }
    //计算撤离路线
    startClmn() {
      var that = this;
      var affectedPointArr = this.sgmn1Sgfx.allPois;
      if (affectedPointArr.length > 50) {
        haoutil.msg("当前计算路线过多,仅分析前50个点!");
        affectedPointArr = affectedPointArr.slice(0, 50);
      }
      this.viewWindow.showRes(false);
 
      haoutil.msg("正在计算" + affectedPointArr.length + "个路线……");
 
      haoutil.loading.show();
      this.sgmn2Clmn.start({
        affectedPointArr: affectedPointArr,
        callback: function (dataArr) {
          haoutil.loading.close();
          //所有路线信息
          that.viewWindow.safeLine(dataArr);
          that.viewWindow.showRes(true);
          that.viewWindow.clearLeave();
        },
        noComputeCallback: function () {
          haoutil.loading.close();
          that.viewWindow.showRes(true);
        },
      });
    }
 
    //漫游之前 先读取速度设置
    roamClmnOne(id, speed) {
      if (!id) {
        return;
      }
      //停止救援模拟
      this.sgmn3Jymn.stopAllRoam();
      this.sgmn3Jymn.resetAllLineStyle();
 
      this.closeAllPopup();
      this.sgmn2Clmn.roamOneById(id);
      this.sgmn2Clmn.updatePlaySpeed(speed || 120);
      this.showHidelineByid(id, true);
      this.sgmn2Clmn.hightOneLineById(id); //高亮
    }
    //撤离速度动态变化
    updateCLPlaySpeed(speed) {
      this.sgmn2Clmn.updatePlaySpeed(speed || 120);
    }
    roamClmnArr(ids, speed) {
      if (!ids || ids.length == 0) {
        return;
      }
      //停止救援模拟
      this.sgmn3Jymn.stopAllRoam();
      this.sgmn3Jymn.resetAllLineStyle();
 
      this.closeAllPopup();
      this.sgmn2Clmn.resetAllLineStyle();
      this.sgmn2Clmn.roamArrByIds(ids);
      this.sgmn2Clmn.updatePlaySpeed(speed || 120);
    }
    resetAllLineStyleCL() {
      this.sgmn2Clmn.resetAllLineStyle();
    }
    stopRoamClmnArr(ids) {
      if (!ids || ids.length == 0) {
        return;
      }
      this.closeAllPopup();
      this.sgmn2Clmn.stopRoamArrByIds(ids);
    }
    showHidelineByid(id, isShow) {
      if (!id) {
        return;
      }
      this.sgmn2Clmn.showHideLineById(id, isShow);
    }
    showHideAllLine(isShow) {
      this.sgmn2Clmn.showHideAllLine(isShow);
    }
    getMaxFlylineTime() {
      return this.sgmn2Clmn.getMaxFlylineTime();
    }
    //是否可以下一步(需要 路线全部分析完毕)
    check4to5() {
      //this.stopDraw();
 
      return this.sgmn2Clmn.state;
    }
 
    //===========================救援模拟==================================
    startSelectJyd(callback) {
      this.sgmn3Jymn.startSelectJyd({
        callback: callback,
      });
    }
    //是否可以下一步(需要 存在事故模拟查询到的点 和 设置了撤离点)
    check5to6() {
      //this.stopDraw();
      if (this.sgmn1Sgfx.pois.length == 0) {
        haoutil.msg("没有受影响的点!");
        return false;
      }
      if (!this.sgmn3Jymn.points || this.sgmn3Jymn.points.length == 0) {
        haoutil.msg("请设置救援点!");
        return false;
      }
      return true;
    }
 
    //计算救援路线
    startJymn() {
      var that = this;
      haoutil.loading.show();
      this.viewWindow.showPro(false);
      this.sgmn3Jymn.start({
        incidentLnglat: this.sgmn1Sgfx.point,
        callback: function (dataArr) {
          haoutil.loading.close();
          //所有路线信息
          that.viewWindow.rescueLine(dataArr);
          that.viewWindow.showPro(true);
          that.viewWindow.clearRescue();
        },
        noComputeCallback: function () {
          that.viewWindow.showPro(true);
          haoutil.loading.close();
        },
      });
    }
    //根据id删除对应的救援点
    removeJYPointById(id) {
      if (!id) {
        return;
      }
      this.sgmn3Jymn.removePointById(id);
      this.sgmn3Jymn.removeLineAboutByPointId(id);
    }
    roamJymnOne(id, speed) {
      if (!id) {
        return;
      }
      //停止撤离模拟
      this.sgmn2Clmn.stopAllRoam();
      this.sgmn2Clmn.resetAllLineStyle();
      this.closeAllPopup();
      this.sgmn3Jymn.roamOneById(id);
      this.sgmn3Jymn.updatePlaySpeed(speed || 120);
      this.sgmn3Jymn.hightOneLineById(id); //高亮
      this.showHidelineByid_JY(id, true);
    }
    getOneTimeById(id) {
      if (!id) {
        return;
      }
      var times;
      times = this.sgmn2Clmn.getFlylineById(id).alltimes;
      return times;
    }
    getOtherOneTimeById(id) {
      if (!id) {
        return;
      }
      var times;
      times = this.sgmn3Jymn.getFlylineById(id).alltimes;
      return times;
    }
    roamJymnArr(ids, speed) {
      if (!ids || ids.length == 0) {
        return;
      }
      //停止撤离模拟
      this.sgmn2Clmn.stopAllRoam();
      this.sgmn2Clmn.resetAllLineStyle();
 
      this.closeAllPopup();
      this.sgmn3Jymn.resetAllLineStyle();
      this.sgmn3Jymn.roamArrByIds(ids);
      this.sgmn3Jymn.updatePlaySpeed(speed || 120);
    }
    resetAllLineStyleJY() {
      this.sgmn3Jymn.resetAllLineStyle();
    }
    stopJymnArr(ids) {
      if (!ids || ids.length == 0) {
        return;
      }
      this.closeAllPopup();
      this.sgmn3Jymn.stopRoamArrByIds(ids);
    }
    showHidelineByid_JY(id, isShow) {
      if (!id) {
        return;
      }
      this.sgmn3Jymn.showHideLineById(id, isShow);
    }
    showHideAllLine_JY(isShow) {
      this.sgmn3Jymn.showHideAllLine(isShow);
    }
    getMaxFlylineTime_JY() {
      return this.sgmn3Jymn.getMaxFlylineTime();
    }
    //救援速度动态变化
    updateJYPlaySpeed(speed) {
      this.sgmn3Jymn.updatePlaySpeed(speed || 120);
    }
    stopDraw() {
      this.sgmn2Clmn.stopDraw();
      this.sgmn3Jymn.stopDraw();
      this.sgmn1Sgfx.stopDraw();
    }
    closeAllPopup() {
      this.map.closePopup();
    }
  }
 
  //注册到widget管理器中。
  mars3d.widget.bindClass(MyWidget);
 
  //每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。
})(window, mars3d);