suerprisePlus
2024-10-14 f521ebc2551d468c4c478783a18d4b0714394d61
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
import mapServer from '../../../assets/js/mapSdk/mapServe';
 
const mapWeather = {
    regionWeather: null,
    particle: null,
    closeRegionWeather() {
        if (this.regionWeather) {
            this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_NONE;
            this.regionWeather = null;
        }
        if (this.particle) {
            this.particle.deleteObject();
            this.particle = null;
        }
    },
    setRegionWeatherType(response) {
        this.closeRegionWeather();
        if (!this.regionWeather) {
            this.getRegionWather(response);
        }
        const coord = this.getCoord(response);
        earthCtrl.camera.flyTo(coord[0], coord[1], 1000, 0, -90, 0, 0);
        switch (response.type) {
            case 'rain':
                this.showRain();
                break;
            case 'fire':
                this.showFire(response);
                break;
            case 'snow':
                this.showSnow();
                break;
        }
    },
    showFire(res) {
        const coord = this.getCoord(res);
        const obj = {
            x: coord[0],
            y: coord[1],
            z: 0,
        };
        this.particle = earthCtrl.factory.createParticleEffect(
            'flame',
            obj,
            {
                translation: SmartEarth.Cesium.Cartesian3.fromElements(0, 0, 0), //平移
                particleSize:10
            },
            function (data) {}
        );
    },
 
    showRain() {
        if (this.regionWeather) {
            this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_RAIN;
            this.regionWeather.regionAlpha = 0.6;
            this.regionWeather.regionGradientDistance = 300;
        }
    },
    showSnow() {
        if (this.regionWeather) {
            this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_SNOW;
            this.regionWeather.regionAlpha = 0.9;
            this.regionWeather.regionGradientDistance = 300;
        }
    },
    getCoord(res) {
       const coord = res.point.split(',');
        console.log('测试', coord);
 
        return coord;
    },
    getRegionWather(res) {
        if (res.type == 'fire') return;
        const coord = this.getCoord(res);
        const model = mapServer.layerList.filter((item) => {
            if (item.name == config.baseModel.cnName + '_' + config.baseModel.id) {
                return item;
            }
        });
        if (model.length <= 0) return;
        this.regionWeather = earthCtrl.factory.createRegionWeather({
            primitive: model[0].layer.item,
            position: new SmartEarth.Cesium.Cartesian3.fromDegrees(coord[0], coord[1], 1),
            radius: 1000,
        })
    },
};
 
export default mapWeather;