北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
AdaKing88
2023-10-20 eae888a841f55514f6e507ea5ae5c45effdc92e8
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
//视域分析
var viewshed = null;
var isFirstAddViewshed = true;
var SYFX_visible_color, SYFX_notVisible_color;
 
function addViewshed(height) {
    if (isFirstAddViewshed) {
        isFirstAddViewshed = false;
    } else {
        clearnViewshed();
    }
    setShadows('open');
    viewshed = sgworld.Analysis.create3DViewshed({
        name: 'Viewshed On Frederick',
        height: height === undefined ? 0 : height,
        color: {
            Back: SYFX_notVisible_color,
            Fore: SYFX_visible_color,
            default: window.shadowMap_color
        }
    });
}
 
//删除视域分析
function clearnViewshed() {
    if (viewshed) {
        viewshed.close();
        viewshed = null;
    } else if (window.parent.viewshed) {
        window.parent.viewshed.close();
        window.parent.viewshed = null;
    }
    setShadows('close');
}
 
var default_shadows_value;
 
function setShadows(type) {
    switch (type) {
        case 'open':
            default_shadows_value = sgworld._Viewer.shadows;
            if (!default_shadows_value) {
                window.shadows = true;
            }
            break;
        case 'close':
            if (default_shadows_value !== undefined && sgworld._Viewer.shadows !== default_shadows_value) {
                sgworld._Viewer.shadows = !!default_shadows_value;
                window.shadows = !!default_shadows_value;
            }
            default_shadows_value = undefined;
            break;
    }
}
 
 
var default_depthTestAgainstTerrain_value;
 
function setDepthTest(type) {
    switch (type) {
        case 'open':
            default_depthTestAgainstTerrain_value = Viewer.scene.globe.depthTestAgainstTerrain;
            if (!default_depthTestAgainstTerrain_value) {
                Viewer.scene.globe.depthTestAgainstTerrain = true;
                window.depth = true;
            }
            break;
        case 'close':
            if (Viewer.scene.globe.depthTestAgainstTerrain !== default_depthTestAgainstTerrain_value) {
                Viewer.scene.globe.depthTestAgainstTerrain = default_depthTestAgainstTerrain_value;
                window.depth = default_depthTestAgainstTerrain_value;
            }
            default_depthTestAgainstTerrain_value = undefined;
            break;
    }
}
 
function fnLayerHauto(type, h) {
    //判断该类型弹出来是否存在
    autoH = true;
    var $layer = $('#layui-layer' + type, document.parent);
    if (!type || $layer.length == 0) return;
 
    $layer.css({
        'height': h + 'px','top': 'unset','bottom': '0px','border-radius': '13px 13px 0px 0px'
    });
    $layer.find('iframe').css({'height': h - 40 + 'px'});
    $layer.find('iframe').contents().find('body').css({
        'height': h - 40 + 'px',
        'overflow': 'hidden',
    });
    $layer.find('iframe')[0].contentWindow.scrollStart ? $layer.find('iframe')[0].contentWindow.scrollStart() : '';
}
 
function getElevationTool() {
    !window._ElevationTool && (window._ElevationTool = new ElevationTool());
    return window._ElevationTool;
}
 
//等高线和坡度图工具
let ElevationTool = function () {
    function _() {
        this.contourUniforms = undefined;
        this.shadingUniforms = undefined;
        this.min = {
            'elevation': 10,
            'slope': 10
        };
        this.max = {
            'elevation': 5000,
            'slope': 90
        };
        this.width = 2;
        this.spacing = 150;
        this.tf = false;
        this.contourColor = undefined;
        this.type = 'none';
        this.Contour = undefined;
        this.colorArr = ['#0b0b88', '#2747E0', '#D33B7D', '#D33038', '#FF9742', '#ffd700', '#bbff00'];
        this.startColor = '#0b0b88';
        this.endColor = '#bbff00';
    }
 
    _.prototype.render = function () {
        this.Contour = sgworld.Analysis.createElevationContour(this.tf, this.type, {
            colorArr: this.colorArr,
            min: this.min[this.type],
            max: this.max[this.type],
            width: this.width,
            spacing: this.spacing,
            lineColor: this.contourColor
        });
        this.shadingUniforms = this.Contour.item.shadingUniforms;
        this.contourUniforms = this.Contour.item.contourUniforms;
    };
 
    _.prototype.setContourColor = function (color) {
        this.contourColor = color;
        this.Contour && this.Contour.setMaterialColor(this.contourColor);
    };
 
    //等高线宽
    _.prototype.setWidth = function (num) {
        this.width = num;
        this.Contour && this.Contour.setWidth(this.width);
    };
 
    //等高线间距
    _.prototype.setSpacing = function (num) {
        this.spacing = num;
        this.Contour && this.Contour.setSpacing(this.spacing);
    };
 
    //起始颜色
    _.prototype.setStartColor = function (color) {
        this.startColor = color;
        this.colorArr = sgworld.Core.gradientColor(this.startColor, this.endColor, 7);
        this.render();
    };
 
    //终止颜色
    _.prototype.setEndColor = function (color) {
        this.endColor = color;
        this.colorArr = sgworld.Core.gradientColor(this.startColor, this.endColor, 7);
        this.render();
    };
 
    //最小值
    _.prototype.setMin = function (num) {
        this.min[this.type] = num;
        if (this.type === 'elevation') {
            this.shadingUniforms.minimumHeight = this.min[this.type];
        } else {
            this.render();
        }
    };
 
    //最大值
    _.prototype.setMax = function (num) {
        this.max[this.type] = num;
        if (this.type === 'elevation') {
            this.shadingUniforms.maximumHeight = this.max[this.type];
        } else {
            this.render();
        }
    };
 
    //最大值
    _.prototype.reset = function () {
        this.colorArr = ['#0b0b88', '#2747E0', '#D33B7D', '#D33038', '#FF9742', '#ffd700', '#bbff00'];
        this.render();
    };
 
    return _;
}();