赣州市洪水风险预警系统三维版本
guoshilong
2023-02-27 4d8c6dd77427e8e581fda17b6b65ba86bfb7a815
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
///////////////////////////////////////////////////////////////////////////
// Copyright © 2019 zhongsong. All Rights Reserved.
// 模块描述: 水文风险区
///////////////////////////////////////////////////////////////////////////
define(['dojo/_base/declare', 'dojo/_base/lang', 'dojo/_base/array', 'dojo/_base/html', "dojo/topic", 'jimu/BaseWidget', 'dojo/on', 'dstore/Memory', 'dstore/Trackable', 'dgrid/Grid', 'dgrid/Keyboard', 'dgrid/Selection', 'dstore/RequestMemory', 'dgrid/test/data/createSyncStore', './CommonPointLayer3D', 'libs/laydate/laydate.js', "./CesiumHeatmap", "libs/jquery.pagination"], function (declare, lang, array, html, topic, BaseWidget, on, Memory, Trackable, Grid, Keyboard, Selection, RequestMemory, createSyncStore, CommonPointLayer3D, laydate) {
 
    return declare([BaseWidget], {
        baseClass: 'jimu-widget-HydrologicalRiskArea',
        name: 'HydrologicalRiskArea',
        fxq_layer: null,
        heatdata: [],
        heatMap: null,
        dataList: [],
        colorList: [],
        startup: function startup() {
            var self = this;
            var flag = true;
 
            // 降水开始与结束时间
            laydate.render({
                elem: '#inpstart', //指定元素
                type: "datetime",
                format: 'yyyy-MM-dd HH:mm',
                btns: ['confirm'],
                done: function done(value) {
                    $($(this)[0].elem[0]).val(value);
                }
            });
            laydate.render({
                elem: '#inpend', //指定元素
                type: "datetime",
                format: 'yyyy-MM-dd HH:mm',
                btns: ['confirm'],
                done: function done(value) {
                    $($(this)[0].elem[0]).val(value);
                }
            });
 
            // this.inherited(arguments);
            /**
    * this 指向重新赋值
    */
            // 定义请求地址
 
            this.fxq_layer = new CommonPointLayer3D({
                id: 'shfxq',
                map: this.map
            });
 
            $('.liclick').on('click', function () {
                document.getElementById('sh_rlt').checked = false;
                document.getElementById('hs_rlt').checked = false;
                if (self.heatMap) {
                    self.heatMap.show(false);
                }
                if (flag == false) return;
                flag = false;
                $('.load-box-list').show();
                // 当前选中添加类名,兄弟移除类名
                $(this).addClass("on").siblings().removeClass("on").addClass("offs");
                // 获取当前选中的文本
                var txt = $(this).text();
                // 调方法,将文本传进去,做判断,是否显示或者隐藏
                self.tab(txt);
                // 做判断,定义请求地址,和请求参数
                if (txt == '山洪风险区') {
                    url = "http://localhost:82/blade-ycreal/mountainrain/listss";
                    data = {};
                } else if (txt == '洪水淹没区') {
                    url = "http://localhost:82/blade-ycreal/floodinundation/listss";
                    data = {};
                } else if (txt == '流域风险区') {
                    url = "http://localhost:82/blade-ycreal/rsvrr/selectRsvrAllList";
                    data = {};
                }
                // 调用方法,发送请求
                self.postUrl(url, data, self, txt);
                flag = true;
            });
            $("#mountainPage .zd_quy").click(function () {
                // 当为山洪风险区的时候的查询点击事件
                $('.load-box-list-query').show();
                // 调方法
                self.shQuery();
            });
            // 当为洪水淹没区的时候的查询点击事件
            $("#floodPage .zd_quy").click(function () {
                $('.load-box-list-query').show();
                // 调方法
                self.hsQuery();
            });
 
            //山洪热力图勾选事件
            $("#sh_rlt").on("change", function () {
                if ($(this)[0].checked) {
                    self.fxq_layer.delEntity();
                    self.addHeatmap();
                } else {
                    self.heatMap.show(false);
                    self.fxq_layer.getData(self.dataList, "山洪风险区", this);
                    self.fxq_layer.updateColor(self.colorList);
                }
            });
 
            //洪水热力图勾选事件
            $("#hs_rlt").on("change", function () {
                if ($(this)[0].checked) {
                    self.fxq_layer.delEntity();
                    self.addHeatmap();
                } else {
                    self.heatMap.show(false);
                    self.fxq_layer.getData(self.dataList, "洪水淹没区", this);
                    self.fxq_layer.updateColor(self.colorList);
                }
            });
        },
 
        onMinimize: function onMinimize() {
            this.resize();
        },
 
        onMaximize: function onMaximize() {
            this.resize();
        },
 
        onOpen: function onOpen() {
            this.map.scene.globe.baseColor = Cesium.Color.BLACK;
            //切换底图
            $($('div.cesium-viewer').find('.cesium-baseLayerPicker-choices')[0]).children('div:eq(0)').trigger('click');
            //面板打开的时候触发 (when open this panel trigger)
            this.fxq_layer ? this.fxq_layer.setVis(true) : '';
            var url = "http://localhost:82/blade-ycreal/mountainrain/listss";
            var data = {};
            $('.load-box-list').show();
            this.postUrl(url, data, this, "山洪风险区");
 
        },
 
        onClose: function onClose() {
            $("#sh_csy").addClass("on").siblings().removeClass("on").addClass("offs");
            document.getElementById('floodPage').style.display = "none";
            document.getElementById('mountainPage').style.display = "block";
            document.getElementById('sh_rlt').checked = false;
            document.getElementById('hs_rlt').checked = false;
            if (this.heatMap) {
                this.heatMap.show(false);
            }
            //面板关闭的时候触发 (when this panel is closed trigger)
            this.fxq_layer ? this.fxq_layer.setVis(false) : '';
},
 
        resize: function resize() {},
 
        destroy: function destroy() {
            this.inherited(arguments);
        },
 
        //http://dgrid.io/tutorials/1.0/hello_dgrid/    创建表格,给表格项添加点击事件,在地图上添加实体
        createList: function createList(dataList, txt) {
 
            $('#Hyd_list .fxq-box-list').empty();
            var column, tab;
            var CustomGrid = declare([Grid, Keyboard, Selection]);
            if (txt == "山洪风险区") {
                column = {
                    xh: '序号',
                    township: '乡镇',
                    village: '行政村',
                    village_group: '村小组'
                };
                tab = 'swfx-tab1-grid';
            } else if (txt == "洪水淹没区") {
                column = {
                    xh: '序号',
                    township: '乡镇',
                    village: '行政村',
                    villagegroup: '村小组'
                };
                tab = 'swfx-tab2-grid';
            } else if (txt == "流域风险区") {
                column = {};
                tab = 'swfx-tab3-grid';
            }
            var grid = new CustomGrid({
                columns: column,
                selectionMode: 'single', // for Selection; only select a single row at a time
                cellNavigation: false // for Keyboard; allow only row-level keyboard navigation
            }, tab);
 
            grid.on('dgrid-select', function (event) {
                topic.publish("gis/map/setCenter", {
                    'lgtd': event.rows[0].data.dj,
                    'lttd': event.rows[0].data.bw
                }); //进行地图定位
            });
            //同时显示到fxq_layer
            grid.renderArray(dataList);
            $('.load-box-list').hide();
 
            //搜索等待动画关闭
            $('.load-box-list-query').hide();
        },
 
        // 控制显示隐藏
        tab: function tab(pid) {
            if (pid == "山洪风险区") {
                document.getElementById('floodPage').style.display = "none";
                document.getElementById('mountainPage').style.display = "block";
            } else if (pid == "洪水淹没区") {
                document.getElementById('mountainPage').style.display = "none";
                document.getElementById('floodPage').style.display = "block";
            } else if (pid == "流域风险区") {}
        },
 
        // 发送请求,获取数据
        postUrl: function postUrl(url, data, self, txt) {
            $.ajax({
                url: url,
                data: data,
                dataType: "json",
                type: "get",
                success: function success(message) {
                    self.heatdata = [];
                    message.data.forEach(function (item, index) {
                        item.xh = index + 1;
                        self.heatdata.push({ x: item.dj, y: item.bw, value: 23 });
                    });
                    self.pageColor(message, txt);
                }
            });
        },
 
        //前端分页变色
        pageColor: function pageColor(message, txt) {
            var self = this;
 
            self.dataList = message.data;
 
            //地图生成实体点
            self.fxq_layer.getData(message.data, txt, this);
 
            var cont = Math.ceil(message.data.length / 25);
            $('.Pagination').pagination({
                mode: 'fixed',
                jump: true,
                coping: false,
                pageCount: cont,
                callback: function callback(index) {
                    var listdata = [];
                    //显示页数
                    var index = (index.getCurrent() - 1) * 25;
                    for (var i = index; i < index + 25; i++) {
                        listdata.push(message.data[i]);
                        if (i == message.data.length - 1) {
                            break;
                        }
                    }
                    self.createList(listdata, txt);
                    self.fxq_layer.updateColor(listdata);
                    self.colorList = listdata;
                }
            });
 
            //首次加载前25条数据
            var data = [];
            if (message.data.length > 25) {
                for (var i = 0; i < 25; i++) {
                    data.push(message.data[i]);
                }
            } else {
                for (var i = 0; i < message.data.length; i++) {
                    data.push(message.data[i]);
                }
            }
 
            self.createList(data, txt);
            self.fxq_layer.updateColor(data);
            self.colorList = data;
        },
 
        // 山洪风险区的查询方法
        shQuery: function shQuery() {
            // 将表格内容清空
            $(".fxq-box-list")[0].innerHTML = '';
            // 将地图上的实体清空
            var self = this;
            // 定义访问地址
            var url_sq;
            // 获取文本框输入的字
            var inp_text = $("#sh_zd").val();
 
            $.ajax({
                url: "http://localhost:82/blade-ycreal/mountainrain/listss",
                data: {
                    query: inp_text
                },
                dataType: "json",
                type: "get",
                success: function success(message) {
                    self.heatdata = [];
                    message.data.forEach(function (item, index) {
                        item.xh = index + 1;
                        self.heatdata.push({ x: item.dj, y: item.bw, value: 23 });
                    });
                    self.pageColor(message, "山洪风险区");
                }
            });
            // 同步
        },
 
        // 和上一个类似,洪水淹没区的查询方法
        hsQuery: function hsQuery() {
            var self = this;
            var inp_text = $('#hs_zd').val();
            $.ajax({
                url: "http://localhost:82/blade-ycreal/floodinundation/listss",
                data: {
                    query: inp_text
                },
                dataType: "json",
                type: "get",
                success: function success(message) {
                    self.heatdata = [];
                    message.data.forEach(function (item, index) {
                        item.xh = index + 1;
                        self.heatdata.push({ x: item.dj, y: item.bw, value: 23 });
                    });
                    self.pageColor(message, "洪水淹没区");
                }
            });
        },
        addHeatmap: function addHeatmap() {
            var bounds = {
                west: 113.91360696000004, south: 24.48625203200004, east: 116.63821188000009, north: 27.143656022000073
            };
            //初始化cesiumheatmap对象,传入相应的参数
            var heatMap = CesiumHeatmap.create(window.viewer, // 视图层
            bounds, // 矩形坐标
            {
                backgroundColor: "rgba(0,0,0,0)",
                radius: 50,
                maxOpacity: .5,
                minOpacity: 0,
                blur: .75
            });
            var valueMin = 0;
            var valueMax = 100;
            // add data to heatmap
            //获取动态数据
            heatMap.setWGS84Data(valueMin, valueMax, this.heatdata);
            this.heatMap = heatMap;
        }
    });
});