lixuliang
2024-04-18 b5c4921d0828500379502a916a2ccf2d9d4acc96
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
/**
 * 工具栏-分析
 */
import Bus from "@tools/Bus";
import axios from "axios";
var Cesium = window.Cesium;
//卫星轨迹
var wxgjData = null;
//热力图分析
var HeatMapData = null;
//分析--雷达反射率
var ldfslData = null;
//专题分析--人口迁徙可视化
var rkqxData = null;
//通视
window.ts = [];
//视域
var viewshed;
//视域颜色
var SYFX_visible_color = {
    r: 0.0,
    g: 1.0,
    b: 0.0
},
    SYFX_notVisible_color = {
        r: 1.0,
        g: 0.0,
        b: 0.0
    };
//#endregion
export default {
    methods: {
        addAnalyseToTree(data) {
            Bus.$emit("addOtherData", '分析', data);
        },
        // 分析-卫星轨迹
        SatelliteTrajectorie() {
            if (wxgjData) {
                wxgjData.clear();
                wxgjData = undefined;
            } else {
                //获取卫星轨迹数据
                axios
                    .get(window.SmartEarthRootUrl + "Workers/json/wxgj.json")
                    .then(function (data) {
                        wxgjData = window.sgworld.Creator.createSatelliteTrail({
                            model: window.SmartEarthRootUrl + "Workers/Model/weixin.gltf",
                            path: data.data.data,
                        });
                        //定位
                        window.sgworld.Navigate.flyToPointsInterest({
                            destination: Cesium.Cartesian3.fromDegrees(
                                120.14827238383411,
                                30.269663961027284,
                                20000000
                            ),
                        });
                    });
            }
        },
        // 获取数据
        getData(bounds, length) {
            let data = [];
            let radio = (bounds.east - bounds.west) / 70;
            for (let i = 0; i < length; i++) {
                let x = Math.random() * (bounds.east - bounds.west + 1) + bounds.west;
                let y =
                    Math.random() * (bounds.north - bounds.south + 1) + bounds.south;
                let value = Math.random() * 100;
                data.push({
                    x: x,
                    y: y,
                    value: value,
                    radius: 100 * radio
                });
            }
            return data;
        },
        // 分析-热力图分析
        HeatMap() {
            if (HeatMapData) {
                HeatMapData.deleteObject();
                HeatMapData = undefined;
            } else {
                // 矩形坐标
                let bounds = {
                    west: 118.022502789,
                    south: 29.045434061,
                    east: 123.156157488,
                    north: 32.582515322,
                    // west: 70.0,
                    // south: 10.0,
                    // east: 140.0,
                    // north: 50.0,
                };
 
                let sourceData = this.getData(bounds, 100);
 
                HeatMapData = window.sgworld.Creator.addHeatMap("热力图", {
                    sourceData: sourceData,
                });
                //定位
                window.sgworld.Navigate.flyToPointsInterest({
                    destination: Cesium.Rectangle.fromDegrees(
                        bounds.west,
                        bounds.south,
                        bounds.east,
                        bounds.north
                    ),
                });
            }
        },
        // 分析-雷达反射率
        RadarReflect() {
            if (ldfslData) {
                ldfslData.deleteObject();
                ldfslData = undefined;
            } else {
                let bounds = {
                    west: 73.16895,
                    south: 12.2023,
                    east: 134.86816,
                    north: 54.11485,
                };
                ldfslData = window.sgworld.Creator.createCloudMap(
                    "雷达反射率", {
                    minx: bounds.west,
                    miny: bounds.south,
                    maxx: bounds.east,
                    maxy: bounds.north,
                },
                    [
                        window.SmartEarthRootUrl + "Workers/image/radar/201906211112.png",
                        window.SmartEarthRootUrl + "Workers/image/radar/201906211124.png",
                        window.SmartEarthRootUrl + "Workers/image/radar/201906211130.png",
                        window.SmartEarthRootUrl + "Workers/image/radar/201906211136.png",
                        window.SmartEarthRootUrl + "Workers/image/radar/201906211142.png",
                    ],
                    1
                );
                //定位
                window.sgworld.Navigate.flyToPointsInterest({
                    destination: Cesium.Rectangle.fromDegrees(
                        bounds.west,
                        bounds.south,
                        bounds.east,
                        bounds.north
                    ),
                });
            }
        },
        convertData_rkqx(from, to) {
            let res = [];
            for (let i = 0; i < from.length; i++) {
                let dataItem = from[i];
                let fromCoord = dataItem.position;
                let toCoord = to.position;
                if (fromCoord && toCoord) {
                    res.push([{
                        coord: fromCoord,
                        value: dataItem.value,
                    },
                    {
                        coord: toCoord,
                    },
                    ]);
                }
            }
            return res;
        },
        getSeries_rkqx(from, to) {
            let series = [];
            series.push({
                type: "lines",
                coordinateSystem: "GLMap",
                zlevel: 2,
                effect: {
                    show: true,
                    period: 4, //箭头指向速度,值越小速度越快
                    trailLength: 0.02, //特效尾迹长度[0,1]值越大,尾迹越长重
                    symbol: "arrow", //箭头图标
                    symbolSize: 5, //图标大小
                },
                lineStyle: {
                    normal: {
                        width: 1, //尾迹线条宽度
                        opacity: 1, //尾迹线条透明度
                        color: "#00EAFF", //线的颜色
                        curveness: 0.3, //尾迹线条曲直度
                    },
                },
                data: this.convertData_rkqx(from, to),
            }, {
                type: "effectScatter",
                coordinateSystem: "GLMap",
                zlevel: 2,
                rippleEffect: {
                    //涟漪特效
                    period: 4, //动画时间,值越小速度越快
                    brushType: "stroke", //波纹绘制方式 stroke, fill
                    scale: 4, //波纹圆环最大限制,值越大波纹越大
                },
                label: {
                    normal: {
                        show: true,
                        position: "right", //显示位置
                        offset: [5, 0], //偏移设置
                        formatter: function (params) {
                            //圆环显示文字
                            return params.data.name;
                        },
                        fontSize: 13,
                    },
                    emphasis: {
                        show: true,
                    },
                },
                symbol: "circle",
                symbolSize: function (val) {
                    return 5 + val[2] * 5; //圆环大小
                },
                itemStyle: {
                    normal: {
                        show: false,
                        color: "#32ff9d", //颜色
                    },
                },
                data: from.map(function (dataItem) {
                    return {
                        name: dataItem.name,
                        value: dataItem.position.concat([dataItem.value]),
                    };
                }),
            },
                //被攻击点
                {
                    type: "scatter",
                    coordinateSystem: "GLMap",
                    zlevel: 2,
                    rippleEffect: {
                        period: 4,
                        brushType: "stroke",
                        scale: 4,
                    },
                    itemStyle: {
                        normal: {
                            color: "#ff0617", //颜色
                        },
                    },
                    label: {
                        normal: {
                            show: true,
                            position: "right",
                            //offset:[5, 0],
                            color: "#0f0",
                            formatter: "{b}",
                            textStyle: {
                                color: "#0f0",
                            },
                        },
                        emphasis: {
                            show: true,
                            color: "#f60",
                        },
                    },
                    symbol: "pin",
                    symbolSize: 50,
                    data: [{
                        name: to.name,
                        value: to.position.concat([10]),
                    },],
                }
            );
            return series;
        },
        // 专题分析--人口迁徙可视化
        migrate() {
            if (rkqxData) {
                rkqxData.clear();
                rkqxData = undefined;
            } else {
                //获取人口迁徙数据
                axios
                    .get(window.SmartEarthRootUrl + "Workers/json/rkqx.json")
                    .then((data) => {
                        let fromData = data.data.from;
                        let toData = data.data.to;
                        //echarts参数
                        let option = {
                            animation: !1,
                            GLMap: {},
                            series: this.getSeries_rkqx(fromData, toData),
                        };
                        rkqxData = window.sgworld.Core.CombineEcharts(window.Viewer, option, true);
                        //定位
                        window.sgworld.Navigate.flyToPointsInterest({
                            destination: Cesium.Rectangle.fromDegrees(
                                70.0,
                                10.0,
                                140.0,
                                50.0
                            ),
                        });
                    });
            }
        },
        // 分析-通视 - 下拉框点击事件
        dropDownClick(type, parentName) {
            sgworld = window.sgworld;
            Viewer = window.Viewer;
            tooltip = window.tooltip;
        },
        // 分析-视域
        viewshed() {
            viewshed = window.sgworld.Analysis.create3DViewshed({
                name: "Viewshed On Frederick",
                height: 1.8,
                color: {
                    Back: SYFX_notVisible_color,
                    Fore: SYFX_visible_color,
                },
                isSpherical: false,
            });
        },
        // 分析-日照分析
        sunshineAnalysis() {
            this.$refs.SunshineAnalysis.open();
        },
        //分析-阴影分析
        shadowAnalysis() {
            this.$refs.ShadowAnalysis.open();
        },
        // 分析-天际线
        skyline(btn) {
            btn.checked = !btn.checked;
            // 提示信息
            if (this.message) {
                if (btn.checked) {
                    this.message("success", "天际线已开启");
                } else {
                    this.message("info", "天际线已关闭");
                }
            }
            this.isSkyLine = !this.isSkyLine;
            if (this.isSkyLine) {
                window.sgworld.Analysis.createSkylineAnalysis("#f00");
            } else {
                window.sgworld.Analysis.clearSkylineAnalysis();
            }
        },
        // 关闭所有分析弹窗
        everyPopupClose() {
            this.$refs.slope.close();
            this.$refs.contour.close();
            this.$refs.terrainOutline.close();
            this.$refs.flood.close();
            this.$refs.bufferArea.close();
            this.$refs.terrainDig.close();
            this.$refs.terrainPress.close();
            this.$refs.modelPress.close();
            this.$refs.SunshineAnalysis.close();
            this.$refs.ShadowAnalysis.close();
        },
        // 等高线
        openCountour() {
            this.everyPopupClose();
            this.$refs.contour.open();
        },
        // 坡度图
        slopeMap() {
            this.everyPopupClose();
            this.$refs.slope.open();
        },
        // 地形轮廓
        terrainOutline() {
            this.everyPopupClose();
            this.$refs.terrainOutline.open();
        },
        // 分析-淹没分析
        flood() {
            this.everyPopupClose();
            this.$refs.flood.open();
        },
        // 分析-缓冲区分析
        bufferArea() {
            this.everyPopupClose();
            this.$refs.bufferArea.open();
        },
        // 分析-通视
        lineSight(type) {
            let SightLine = sgworld.Analysis.createSightLine({
                type: type,
            });
            window.ts.push(SightLine);
        },
        // 分析-地形开挖
        terrainDig() {
            this.everyPopupClose();
            this.$refs.terrainDig.open();
        },
        // 分析-地形压平
        terrainPress() {
            this.everyPopupClose();
            this.$refs.terrainPress.open();
        },
        // 分析-模型压平
        modelPress() {
            this.everyPopupClose();
            this.$refs.modelPress.open();
        },
        // 分析-清除
        delete() {
            this.everyPopupClose();
            Bus.$emit("clearFirstParentNode", "分析");
 
            if (window.elevationTool.tf) {
                window.elevationTool.tf = false; //关闭等高线
            }
            if (
                window.elevationTool.type === "elevation" ||
                window.elevationTool.type === "slope"
            ) {
                window.elevationTool.type = "none"; //关闭高程图与坡度图
            }
            window.elevationTool.render();
            // 关闭地形轮廓
            if (window.AnalysisDXPM) {
                window.AnalysisDXPM && window.AnalysisDXPM.deleteObject();
                layer.closeAll();
            }
            // 关闭淹没
            if (window.AnalysisFlood) {
                window.AnalysisFlood && window.AnalysisFlood.deleteObject();
            }
            // 关闭缓冲区
            if (window.buff) {
                window.buff.clearBuff();
            }
            // 关闭地形开挖
            if (window.Excavation) {
                window.Excavation.clear();
            }
            // 关闭卫星轨迹
            if (wxgjData) {
                wxgjData.clear();
                wxgjData = undefined;
            }
            // 关闭热力图分析
            if (HeatMapData) {
                HeatMapData.deleteObject();
                HeatMapData = undefined;
            }
            // 关闭雷达反射率
            if (ldfslData) {
                ldfslData.deleteObject();
                ldfslData = undefined;
            }
            // 关闭人口迁徙可视化
            if (rkqxData) {
                rkqxData.clear();
                rkqxData = undefined;
            }
            // 关闭通视
            if (window.ts) {
                window.ts.forEach(element => {
                    element.deleteObject();
                });
            }
            // 关闭视域
            if (viewshed) {
                viewshed.close();
                viewshed = null;
            }
            // 关闭日照分析结果
            window._AnalysisSunshine && window._AnalysisSunshine.remove();
            window._AnalysisSunshine = undefined
 
            // 关闭阴影分析结果
            window.Viewer.clockViewModel.currentTime = new Date().getTime();
 
            window.Viewer.clock.multiplier = 1;
            this.$refs.ShadowAnalysis.form.isPlay = false;
            this.$refs.ShadowAnalysis.form.isStop = true;
            window.Viewer.shadows = false;
            // 关闭天际线
            window.sgworld.Analysis.clearSkylineAnalysis();
            this.$message.info("分析结果已全部清除");
        },
    }
}